From 3dd8145d5a6e402ca90482b2b5794f9fea843460 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Fri, 27 Sep 2024 11:06:08 -0700 Subject: [PATCH 1/5] Adding a combined version define in MaterialX C++ Signed-off-by: Rui Yang --- source/MaterialXCore/Library.h | 5 +++++ source/MaterialXTest/MaterialXCore/Library.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 source/MaterialXTest/MaterialXCore/Library.cpp diff --git a/source/MaterialXCore/Library.h b/source/MaterialXCore/Library.h index 1a92c634a7..4105c37324 100644 --- a/source/MaterialXCore/Library.h +++ b/source/MaterialXCore/Library.h @@ -6,6 +6,11 @@ #ifndef MATERIALX_LIBRARY_H #define MATERIALX_LIBRARY_H +#define MATERIALX_GENERATE_INDEX(major, minor, build) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build))) +#define MATERIALX_VERSION_INDEX \ + MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION) + /// @file /// Library-wide includes and types. This file should be the first include for /// any public header in the MaterialX library. diff --git a/source/MaterialXTest/MaterialXCore/Library.cpp b/source/MaterialXTest/MaterialXCore/Library.cpp new file mode 100644 index 0000000000..f3bc54c0aa --- /dev/null +++ b/source/MaterialXTest/MaterialXCore/Library.cpp @@ -0,0 +1,16 @@ +// +// Copyright Contributors to the MaterialX Project +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include + +namespace mx = MaterialX; + +TEST_CASE("Version comparison", "[library]") +{ + // Test for version comparison + REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); +} From b1f824869246d420178ee0088e75958143c59213 Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Wed, 23 Oct 2024 17:40:23 -0700 Subject: [PATCH 2/5] Move the Version comparison test to CoreUtil.cpp Signed-off-by: Rui Yang --- source/MaterialXTest/MaterialXCore/CoreUtil.cpp | 7 +++++++ source/MaterialXTest/MaterialXCore/Library.cpp | 16 ---------------- 2 files changed, 7 insertions(+), 16 deletions(-) delete mode 100644 source/MaterialXTest/MaterialXCore/Library.cpp diff --git a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp index 11aa826d4f..48dae7b698 100644 --- a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp +++ b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp @@ -7,6 +7,7 @@ #include #include +#include namespace mx = MaterialX; @@ -111,3 +112,9 @@ TEST_CASE("Print utilities", "[coreutil]") REQUIRE(nodeGraph->asStringDot() == blessed); } + +TEST_CASE("Version comparison", "[coreutil]") +{ + // Test for version comparison + REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); +} \ No newline at end of file diff --git a/source/MaterialXTest/MaterialXCore/Library.cpp b/source/MaterialXTest/MaterialXCore/Library.cpp deleted file mode 100644 index f3bc54c0aa..0000000000 --- a/source/MaterialXTest/MaterialXCore/Library.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright Contributors to the MaterialX Project -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -#include - -namespace mx = MaterialX; - -TEST_CASE("Version comparison", "[library]") -{ - // Test for version comparison - REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); -} From 8541564f2e9a97cbd3b4ccb8857605f962e7b89c Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Wed, 23 Oct 2024 18:51:29 -0700 Subject: [PATCH 3/5] Add newline Signed-off-by: Jonathan Stone --- source/MaterialXTest/MaterialXCore/CoreUtil.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp index 48dae7b698..c229694976 100644 --- a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp +++ b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp @@ -117,4 +117,4 @@ TEST_CASE("Version comparison", "[coreutil]") { // Test for version comparison REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); -} \ No newline at end of file +} From 8744ae9e54b1c5655b85a4903d9a975194b15bcd Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Wed, 23 Oct 2024 19:02:29 -0700 Subject: [PATCH 4/5] Remove extra include Signed-off-by: Jonathan Stone --- source/MaterialXTest/MaterialXCore/CoreUtil.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp index c229694976..4bc174a690 100644 --- a/source/MaterialXTest/MaterialXCore/CoreUtil.cpp +++ b/source/MaterialXTest/MaterialXCore/CoreUtil.cpp @@ -7,10 +7,15 @@ #include #include -#include namespace mx = MaterialX; +TEST_CASE("Version comparison", "[coreutil]") +{ + // Test for version comparison + REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); +} + TEST_CASE("String utilities", "[coreutil]") { std::string invalidName("test.name"); @@ -112,9 +117,3 @@ TEST_CASE("Print utilities", "[coreutil]") REQUIRE(nodeGraph->asStringDot() == blessed); } - -TEST_CASE("Version comparison", "[coreutil]") -{ - // Test for version comparison - REQUIRE(MATERIALX_VERSION_INDEX > MATERIALX_GENERATE_INDEX(1, 38, 8)); -} From e3fe0e3d940d1a23c0d451f7682af70f7b2ce320 Mon Sep 17 00:00:00 2001 From: Jonathan Stone Date: Wed, 23 Oct 2024 19:04:45 -0700 Subject: [PATCH 5/5] Group macros together Signed-off-by: Jonathan Stone --- source/MaterialXCore/Library.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/MaterialXCore/Library.h b/source/MaterialXCore/Library.h index 4105c37324..571644c098 100644 --- a/source/MaterialXCore/Library.h +++ b/source/MaterialXCore/Library.h @@ -6,11 +6,6 @@ #ifndef MATERIALX_LIBRARY_H #define MATERIALX_LIBRARY_H -#define MATERIALX_GENERATE_INDEX(major, minor, build) \ - ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build))) -#define MATERIALX_VERSION_INDEX \ - MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION) - /// @file /// Library-wide includes and types. This file should be the first include for /// any public header in the MaterialX library. @@ -26,6 +21,11 @@ #include +#define MATERIALX_GENERATE_INDEX(major, minor, build) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(build))) +#define MATERIALX_VERSION_INDEX \ + MATERIALX_GENERATE_INDEX(MATERIALX_MAJOR_VERSION, MATERIALX_MINOR_VERSION, MATERIALX_BUILD_VERSION) + /// Platform-specific macros for declaring imported and exported symbols. #if defined(MATERIALX_BUILD_SHARED_LIBS) #if defined(_WIN32)