-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a combined version define in MaterialX C++ #1609
Comments
This is a good suggestion, @pablode, though I wonder if we can do better than the combined integer approach for preprocessor comparisons. For context, here is the pattern we currently use to compare MaterialX versions in Python:
And here is the equivalent comparison in C++:
Could there potentially be an equivalent approach for preprocessor comparisons, or are combined integers truly our best bet? |
Indeed, the combined integer could be constructed with a macro; see f.i. Vulkan’s VK_MAKE_VERSION. A MaterialX equivalent would then look like this: #if MATERIALX_VERSION > MATERIALX_MAKE_VERSION(1, 38, 8) |
Hi can I try solving this one for Dev Days 2024? |
Definitely, and welcome @ruiyang2021! |
Hi folks, I take a closer look today. I'm still a beginner learning from the code repo, may have some shallow understanding. I see that tuples are compared position by position, it is great we can use ">" and "<" operators to compare the versions. Then here's a doubt:
with something maybe like this in Util.h (or the Vulkan way of combining)
It requires changes at a number of places. To be thorough, there is also a |
This is a great question, @ruiyang2021, and fortunately I think the request in this GitHub Issue is simpler than the full change you're considering. For this issue, I believe the only new features that we would need are the following two features in the
Then, when a developer needs to compare versions in their C++ code, they should be able to add a call like the following:
Let me know if that helps to clarify things, and feel free to ask additional questions! |
Thanks for breaking it down for me @jstone-lucasfilm ! Sending a pr #2031 |
PR for #1609 Also added a simple test in source/MaterialXTest/MaterialXCore
Thanks for this original report, @pablode, as well as to @ruiyang2021 for the implementation in #2031! |
Currently, checking against the MaterialX version in C++ code can be code-heavy:
I propose that a define such as
MATERIALX_VERSION
should be added, just like it's done in USD:https://github.com/PixarAnimationStudios/OpenUSD/blob/0b18ad3f840c24eb25e16b795a5b0821cf05126e/cmake/defaults/Version.cmake#L29
The above check can then be simplified to
The text was updated successfully, but these errors were encountered: