From eac54460a59ca65e6ed1dd101205ffb0b9474b0b Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 2 Oct 2018 07:28:55 +0300 Subject: [PATCH] Add preliminary ON_RUNTIME_LINUX support. * [make] add missing files to get compile going - opennurbs_glyph_outline.cpp - opennurbs_unicode_cpsb.cpp - commented out version of LINKFLAGS with -luuid - commented out entries for Clang usage --- makefile | 9 +++++++++ opennurbs_3dm_settings.cpp | 2 +- opennurbs_font.cpp | 4 ++-- opennurbs_locale.cpp | 12 ++++++------ opennurbs_mesh_ngon.cpp | 2 +- opennurbs_sort.cpp | 2 +- opennurbs_string_format.cpp | 4 ++-- opennurbs_string_scan.cpp | 8 ++++---- opennurbs_system_compiler.h | 2 +- opennurbs_system_runtime.h | 24 ++++++++++++++++++++++++ 10 files changed, 51 insertions(+), 18 deletions(-) diff --git a/makefile b/makefile index c7496d1d..d090eec4 100644 --- a/makefile +++ b/makefile @@ -48,14 +48,20 @@ ON_GNU_COMMON_FLAGS = $(ON_GNU_OPTIMIZER_FLAGS) $(ON_GNU_WARNING_FLAGS) -D_GNU_S # C compiler and flags CC = gcc +# clang c +#CC = clang CFLAGS = $(ON_GNU_COMMON_FLAGS) # C++ compiler and flags CCC = g++ +# clang++ +#CCC = c++ CCFLAGS = $(ON_GNU_COMMON_FLAGS) -std=c++14 LINK = $(CCC) LINKFLAGS = +# Linux link flag needed for libuuid +#LINKFLAGS = -luuid ############################################################### @@ -378,6 +384,7 @@ ON_SRC = opennurbs_3dm_attributes.cpp \ opennurbs_topology.cpp \ opennurbs_torus.cpp \ opennurbs_unicode.cpp \ + opennurbs_unicode_cpsb.cpp \ opennurbs_units.cpp \ opennurbs_userdata.cpp \ opennurbs_userdata_obsolete.cpp \ @@ -444,6 +451,7 @@ ON_OBJ = opennurbs_3dm_attributes.o \ opennurbs_fsp.o \ opennurbs_function_list.o \ opennurbs_geometry.o \ + opennurbs_glyph_outline.o \ opennurbs_group.o \ opennurbs_hash_table.o \ opennurbs_hatch.o \ @@ -550,6 +558,7 @@ ON_OBJ = opennurbs_3dm_attributes.o \ opennurbs_topology.o \ opennurbs_torus.o \ opennurbs_unicode.o \ + opennurbs_unicode_cpsb.o \ opennurbs_units.o \ opennurbs_userdata.o \ opennurbs_userdata_obsolete.o \ diff --git a/opennurbs_3dm_settings.cpp b/opennurbs_3dm_settings.cpp index 263053db..d8cdce74 100644 --- a/opennurbs_3dm_settings.cpp +++ b/opennurbs_3dm_settings.cpp @@ -5370,7 +5370,7 @@ void ON_3dmSettings::Dump( ON_TextLog& dump ) const // ON_3dmAnimationProperties // -const ON_3dmAnimationProperties ON_3dmAnimationProperties::Default; +const ON_3dmAnimationProperties ON_3dmAnimationProperties::Default ON_CLANG_CONSTRUCTOR_BUG_INIT(ON_3dmAnimationProperties); bool ON_3dmAnimationProperties::Read(ON_BinaryArchive& archive) { diff --git a/opennurbs_font.cpp b/opennurbs_font.cpp index 277554ca..6598be9c 100644 --- a/opennurbs_font.cpp +++ b/opennurbs_font.cpp @@ -6779,7 +6779,7 @@ const ON_wString ON_Font::FamilyNameFromDirtyName( const wchar_t* prev_clean_family_name = nullptr; for (size_t i = 0; i < installed_count; i++) { -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) const ON_Font* font = installed_fonts[(int)i]; #else const ON_Font* font = installed_fonts[i]; @@ -6842,7 +6842,7 @@ const ON_wString ON_Font::FamilyNameFromDirtyName( InternalHashToName candidate; for (size_t i = 0; i < count0; i++) { -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) InternalHashToName e = a[(int)i]; #else InternalHashToName e = a[i]; diff --git a/opennurbs_locale.cpp b/opennurbs_locale.cpp index ec6b4596..effb512b 100644 --- a/opennurbs_locale.cpp +++ b/opennurbs_locale.cpp @@ -35,7 +35,7 @@ static ON_CRT_locale_t ON_CRT_C_locale() ON_C_locale = _create_locale(LC_ALL, "C"); #elif defined(ON_RUNTIME_APPLE) ON_C_locale = _c_locale; -#elif defined(ON_RUNTIME_ANDROID) +#elif defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) ON_C_locale = 0; #else ON_C_locale = _create_locale(category, locale); @@ -104,7 +104,7 @@ static ON_CRT_locale_t ON_CRT_create_locale_ALL( const char * locale ) } } return newlocale(LC_ALL_MASK, apple_name, ON_CRT_C_locale() ); -#elif defined(ON_RUNTIME_ANDROID) +#elif defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) return 0; #else return _create_locale(category, locale); @@ -1344,7 +1344,7 @@ public: static bool Validate_sprintf_l() { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted printing char buffer[64] = { 0 }; // Testing C-runtime - do not using ON_String::FormatIntoBuffer @@ -1369,7 +1369,7 @@ public: static bool Validate_sprintf_s_l() { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted printing char buffer[64] = { 0 }; size_t buffer_capacity = (sizeof(buffer) / sizeof(buffer[0])) - 1; @@ -1423,7 +1423,7 @@ public: static bool Validate_sscanf_l() { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted scanning double a = ON_UNSET_VALUE; // Testing C-runtime - do not using ON_String::Scan @@ -1448,7 +1448,7 @@ public: static bool Validate_sscanf_s_l() { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) // Test formatted scanning double a = ON_UNSET_VALUE; // Testing C-runtime - do not using ON_String::Scan diff --git a/opennurbs_mesh_ngon.cpp b/opennurbs_mesh_ngon.cpp index 5df77950..d9279494 100644 --- a/opennurbs_mesh_ngon.cpp +++ b/opennurbs_mesh_ngon.cpp @@ -4774,7 +4774,7 @@ ON_Plane ON_Plane::FromPointList( -const ON_MeshNgonIterator ON_MeshNgonIterator::EmptyMeshNgonIterator; +const ON_MeshNgonIterator ON_MeshNgonIterator::EmptyMeshNgonIterator ON_CLANG_CONSTRUCTOR_BUG_INIT(ON_MeshNgonIterator); ON_MeshNgonIterator::ON_MeshNgonIterator( const class ON_Mesh* mesh diff --git a/opennurbs_sort.cpp b/opennurbs_sort.cpp index f1f0b3c2..9431fd85 100644 --- a/opennurbs_sort.cpp +++ b/opennurbs_sort.cpp @@ -63,7 +63,7 @@ ON_qsort( void *base, size_t nel, size_t width, int (*compar)(void*,const void * // find pivots, that calculation must be thread safe. #if defined(ON_COMPILER_MSC) qsort_s(base,nel,width,compar,context); -#elif defined(ON_RUNTIME_ANDROID) +#elif defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) ON_hsort(base, nel, width, compar, context); #elif defined(ON_COMPILER_CLANG) qsort_r(base,nel,width,context,compar); diff --git a/opennurbs_string_format.cpp b/opennurbs_string_format.cpp index 5355b2ff..bac30138 100644 --- a/opennurbs_string_format.cpp +++ b/opennurbs_string_format.cpp @@ -807,7 +807,7 @@ int ON_String::FormatVargsIntoBuffer( // CLang modifies args so a copy is required va_list args_copy; va_copy (args_copy, args); -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) int len = vsnprintf(buffer, buffer_capacity, format, args_copy); #else int len = vsnprintf_l(buffer, buffer_capacity, ON_Locale::Ordinal.NumericLocalePtr(), format, args_copy); @@ -859,7 +859,7 @@ int ON_String::FormatVargsOutputCount( va_list args_copy; va_copy (args_copy, args); -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) int len = vsnprintf(nullptr, 0, format, args_copy); #else int len = vsnprintf_l(nullptr, 0, ON_Locale::Ordinal.NumericLocalePtr(), format, args_copy); diff --git a/opennurbs_string_scan.cpp b/opennurbs_string_scan.cpp index 177f6020..652120de 100644 --- a/opennurbs_string_scan.cpp +++ b/opennurbs_string_scan.cpp @@ -86,7 +86,7 @@ int ON_String::ScanBufferVargs( ) { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (nullptr == buffer || nullptr == format) return -1; return vsscanf(buffer, format, args); @@ -149,7 +149,7 @@ int ON_wString::ScanBufferVargs( ) { #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (nullptr == buffer || nullptr == format) return -1; return swscanf(buffer, format, args); @@ -398,7 +398,7 @@ const char* ON_String::ToNumber( double x = value_on_failure; #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (1 == sscanf(local_buffer, "%lg", &x)) { *value = x; @@ -640,7 +640,7 @@ const wchar_t* ON_wString::ToNumber( double x = value_on_failure; #if defined(ON_COMPILER_CLANG) -#if defined(ON_RUNTIME_ANDROID) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) if (1 == sscanf(local_buffer, "%lg", &x)) { *value = x; diff --git a/opennurbs_system_compiler.h b/opennurbs_system_compiler.h index 654fc0d4..c03e7694 100644 --- a/opennurbs_system_compiler.h +++ b/opennurbs_system_compiler.h @@ -247,7 +247,7 @@ #define ON_SIZEOF_WCHAR_T 2 -#elif defined(__clang__) | defined(ON_COMPILER_CLANG) +#elif defined(__clang__) | defined(__clang) | defined(ON_COMPILER_CLANG) /* //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// diff --git a/opennurbs_system_runtime.h b/opennurbs_system_runtime.h index 70819ddf..83d1b87b 100644 --- a/opennurbs_system_runtime.h +++ b/opennurbs_system_runtime.h @@ -55,6 +55,11 @@ #define ON_RUNTIME_ANDROID #endif +#elif defined(__linux__) +#if !defined(ON_RUNTIME_LINUX) +#define ON_RUNTIME_LINUX +#endif + #endif /* // @@ -150,6 +155,25 @@ #define ON_SIZEOF_WCHAR_T 4 #endif +#elif defined(ON_RUNTIME_LINUX) + +#if defined(__x86_64__) +#define ON_64BIT_RUNTIME +#else +#define ON_32BIT_RUNTIME +#endif + + +#if !defined(ON_SIZEOF_WCHAR_T) +#define ON_SIZEOF_WCHAR_T 4 +#endif + +#if !defined(ON_LITTLE_ENDIAN) +#if defined( __x86_64__ ) +#define ON_LITTLE_ENDIAN +#endif +#endif + #endif #if !defined(ON_64BIT_RUNTIME) && !defined(ON_32BIT_RUNTIME)