From f39606589e16c7f2f1dd5647964230a89e760f45 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 19 Sep 2022 23:31:58 +0200 Subject: [PATCH 1/7] build: harden ccpp.yml permissions Signed-off-by: Alex --- .github/workflows/ccpp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index bf346dd63..00f923f05 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [ master ] +permissions: + contents: read # to fetch code (actions/checkout) + jobs: job: name: ${{ matrix.name }}-build-and-test From 79c9c820260b86586dc26c547a9efc08b40f7ada Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 19 Sep 2022 23:32:11 +0200 Subject: [PATCH 2/7] build: harden sanitizer.yml permissions Signed-off-by: Alex --- .github/workflows/sanitizer.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 750c17005..57d6e78f1 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -6,6 +6,9 @@ on: pull_request: branches: [ master ] +permissions: + contents: read # to fetch code (actions/checkout) + jobs: job1: name: adress-sanitizer From 22494bde1724fa1b71b9f159b24f0a7deb913e51 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 23 Sep 2022 04:08:20 +0300 Subject: [PATCH 3/7] Don't include stm_image implementation if using stb library from Hunter Hunter compiles its own stb library binaries. Currently a second copy is compiled by defining STB_IMAGE_IMPLEMENTATION in Assimp.cpp. This may cause hard to understand bugs if this compiled copy ever becomes different from what Hunter supplies. --- code/Common/Assimp.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/Common/Assimp.cpp b/code/Common/Assimp.cpp index ee798238e..57ecb953c 100644 --- a/code/Common/Assimp.cpp +++ b/code/Common/Assimp.cpp @@ -1273,11 +1273,13 @@ ASSIMP_API void aiQuaternionInterpolate( #define ASSIMP_HAS_PBRT_EXPORT (!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_PBRT_EXPORTER) #define ASSIMP_HAS_M3D ((!ASSIMP_BUILD_NO_EXPORT && !ASSIMP_BUILD_NO_M3D_EXPORTER) || !ASSIMP_BUILD_NO_M3D_IMPORTER) -#if ASSIMP_HAS_PBRT_EXPORT -# define ASSIMP_NEEDS_STB_IMAGE 1 -#elif ASSIMP_HAS_M3D -# define ASSIMP_NEEDS_STB_IMAGE 1 -# define STBI_ONLY_PNG +#ifndef STB_USE_HUNTER +# if ASSIMP_HAS_PBRT_EXPORT +# define ASSIMP_NEEDS_STB_IMAGE 1 +# elif ASSIMP_HAS_M3D +# define ASSIMP_NEEDS_STB_IMAGE 1 +# define STBI_ONLY_PNG +# endif #endif // Ensure all symbols are linked correctly From f6a590065c5df9ea2cdb7779843511f3605aeeb3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 23 Sep 2022 04:08:21 +0300 Subject: [PATCH 4/7] Prefix symbols from stb_image.h This makes it possible to link assimp statically into an executable with another static library that includes stb_image.h without hiding its symbols. --- code/Common/StbCommon.h | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/code/Common/StbCommon.h b/code/Common/StbCommon.h index 1265d25da..573c98ac7 100644 --- a/code/Common/StbCommon.h +++ b/code/Common/StbCommon.h @@ -48,6 +48,64 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma GCC diagnostic ignored "-Wunused-function" #endif +#ifndef STB_USE_HUNTER +/* Use prefixed names for the symbols from stb_image as it is a very commonly embedded library. + Including vanilla stb_image symbols causes duplicate symbol problems if assimp is linked + statically together with another library or executable that also embeds stb_image. + + Symbols are not prefixed if using Hunter because in such case there exists a single true + stb_image library on the system that is used by assimp and can be used by all the other + libraries and executables. + + The list can be regenerated using the following: + + cat | fgrep STBIDEF | fgrep '(' | sed -E 's/\*|\(.+//g' | \ + awk '{print "#define " $(NF) " assimp_" $(NF) }' | sort | uniq" +*/ +#define stbi_convert_iphone_png_to_rgb assimp_stbi_convert_iphone_png_to_rgb +#define stbi_convert_wchar_to_utf8 assimp_stbi_convert_wchar_to_utf8 +#define stbi_failure_reason assimp_stbi_failure_reason +#define stbi_hdr_to_ldr_gamma assimp_stbi_hdr_to_ldr_gamma +#define stbi_hdr_to_ldr_scale assimp_stbi_hdr_to_ldr_scale +#define stbi_image_free assimp_stbi_image_free +#define stbi_info assimp_stbi_info +#define stbi_info_from_callbacks assimp_stbi_info_from_callbacks +#define stbi_info_from_file assimp_stbi_info_from_file +#define stbi_info_from_memory assimp_stbi_info_from_memory +#define stbi_is_16_bit assimp_stbi_is_16_bit +#define stbi_is_16_bit_from_callbacks assimp_stbi_is_16_bit_from_callbacks +#define stbi_is_16_bit_from_file assimp_stbi_is_16_bit_from_file +#define stbi_is_16_bit_from_memory assimp_stbi_is_16_bit_from_memory +#define stbi_is_hdr assimp_stbi_is_hdr +#define stbi_is_hdr_from_callbacks assimp_stbi_is_hdr_from_callbacks +#define stbi_is_hdr_from_file assimp_stbi_is_hdr_from_file +#define stbi_is_hdr_from_memory assimp_stbi_is_hdr_from_memory +#define stbi_ldr_to_hdr_gamma assimp_stbi_ldr_to_hdr_gamma +#define stbi_ldr_to_hdr_scale assimp_stbi_ldr_to_hdr_scale +#define stbi_load_16 assimp_stbi_load_16 +#define stbi_load_16_from_callbacks assimp_stbi_load_16_from_callbacks +#define stbi_load_16_from_memory assimp_stbi_load_16_from_memory +#define stbi_load assimp_stbi_load +#define stbi_loadf assimp_stbi_loadf +#define stbi_loadf_from_callbacks assimp_stbi_loadf_from_callbacks +#define stbi_loadf_from_file assimp_stbi_loadf_from_file +#define stbi_loadf_from_memory assimp_stbi_loadf_from_memory +#define stbi_load_from_callbacks assimp_stbi_load_from_callbacks +#define stbi_load_from_file_16 assimp_stbi_load_from_file_16 +#define stbi_load_from_file assimp_stbi_load_from_file +#define stbi_load_from_memory assimp_stbi_load_from_memory +#define stbi_load_gif_from_memory assimp_stbi_load_gif_from_memory +#define stbi_set_flip_vertically_on_load assimp_stbi_set_flip_vertically_on_load +#define stbi_set_flip_vertically_on_load_thread assimp_stbi_set_flip_vertically_on_load_thread +#define stbi_set_unpremultiply_on_load assimp_stbi_set_unpremultiply_on_load +#define stbi_zlib_decode_buffer assimp_stbi_zlib_decode_buffer +#define stbi_zlib_decode_malloc assimp_stbi_zlib_decode_malloc +#define stbi_zlib_decode_malloc_guesssize assimp_stbi_zlib_decode_malloc_guesssize +#define stbi_zlib_decode_malloc_guesssize_headerflag assimp_stbi_zlib_decode_malloc_guesssize_headerflag +#define stbi_zlib_decode_noheader_buffer assimp_stbi_zlib_decode_noheader_buffer +#define stbi_zlib_decode_noheader_malloc assimp_stbi_zlib_decode_noheader_malloc +#endif + #include "stb/stb_image.h" #if _MSC_VER From 789168ba310125bb6f7e3d7eda68845dad48e688 Mon Sep 17 00:00:00 2001 From: feishengfei Date: Tue, 27 Sep 2022 20:23:28 +0800 Subject: [PATCH 5/7] FIX: C++ std::tuple constexpr initial list on old compiler --- test/unit/utglTF2ImportExport.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 00f76aa47..203b69efd 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -753,12 +753,21 @@ TEST_F(utglTF2ImportExport, wrongTypes) { // Deliberately broken version of the BoxTextured.gltf asset. using tup_T = std::tuple; std::vector wrongTypes = { +#ifdef __cpp_lib_constexpr_tuple { "/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]" }, { "/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]" }, { "/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]" }, { "/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]" }, { "/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]" }, { "/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]" } +#else + tup_T( "/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]" ), + tup_T( "/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]" ), + tup_T( "/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]" ), + tup_T( "/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]" ), + tup_T( "/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]" ), + tup_T( "/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]" ) +#endif }; for (const auto& tuple : wrongTypes) { From 816b8e6156e9acab89125b1a56aae44923e5dd3b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 29 Sep 2022 16:48:15 +0200 Subject: [PATCH 6/7] Update utglTF2ImportExport.cpp Needed some change of scenery and optimized this a little bit. --- test/unit/utglTF2ImportExport.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 203b69efd..399bbdc4f 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -754,20 +754,17 @@ TEST_F(utglTF2ImportExport, wrongTypes) { using tup_T = std::tuple; std::vector wrongTypes = { #ifdef __cpp_lib_constexpr_tuple - { "/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]" }, - { "/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]" }, - { "/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]" }, - { "/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]" }, - { "/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]" }, - { "/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]" } + #define TUPLE(x) {x} #else - tup_T( "/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]" ), - tup_T( "/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]" ), - tup_T( "/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]" ), - tup_T( "/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]" ), - tup_T( "/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]" ), - tup_T( "/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]" ) + #define TUPLE(x) tup_T(x) #endif + TUPLE("/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]"), + TUPLE("/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]"), + TUPLE("/glTF2/wrongTypes/badUint.gltf", "uint", "index", "materials[0]"), + TUPLE("/glTF2/wrongTypes/badNumber.gltf", "number", "scale", "materials[0]"), + TUPLE("/glTF2/wrongTypes/badObject.gltf", "object", "pbrMetallicRoughness", "materials[0]"), + TUPLE("/glTF2/wrongTypes/badExtension.gltf", "object", "KHR_texture_transform", "materials[0]") +#undef TUPLE }; for (const auto& tuple : wrongTypes) { From 0be5c567c9b3aaa970c487bcc32e0c12654f48cb Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 29 Sep 2022 23:32:44 +0800 Subject: [PATCH 7/7] FIX: C++ std::tuple constexpr initial list on old compiler [cont 1] --- test/unit/utglTF2ImportExport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index 399bbdc4f..ef3fc4137 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -754,9 +754,9 @@ TEST_F(utglTF2ImportExport, wrongTypes) { using tup_T = std::tuple; std::vector wrongTypes = { #ifdef __cpp_lib_constexpr_tuple - #define TUPLE(x) {x} + #define TUPLE(x, y, z, w) {x, y, z, w} #else - #define TUPLE(x) tup_T(x) + #define TUPLE(x, y, z, w) tup_T(x, y, z, w) #endif TUPLE("/glTF2/wrongTypes/badArray.gltf", "array", "primitives", "meshes[0]"), TUPLE("/glTF2/wrongTypes/badString.gltf", "string", "name", "scenes[0]"),