Replace CMake generated version files with checked-in versions#1993
Replace CMake generated version files with checked-in versions#1993darbyjohnston wants to merge 1 commit intoAcademySoftwareFoundation:mainfrom
Conversation
Signed-off-by: Darby Johnston <darbyjohnston@yahoo.com>
meshula
left a comment
There was a problem hiding this comment.
looking good, minor request
| #define OPENTIME_VERSION_MINOR 19 | ||
| #define OPENTIME_VERSION_PATCH 0 | ||
| #define OPENTIME_VERSION v0_19_0 | ||
| #define OPENTIME_VERSION_NS v0_19 |
There was a problem hiding this comment.
Here's a variant that leaves no room for human forgetfulness
#define OPENTIME_VERSION_MAJOR 0
#define OPENTIME_VERSION_MINOR 19
#define OPENTIME_VERSION_PATCH 0
#define OPENTIME_VERSION
v##OPENTIME_VERSION_MAJOR####OPENTIME_VERSION_MINOR####OPENTIME_VERSION_PATCH
#define OPENTIME_VERSION_NS
v##OPENTIME_VERSION_MAJOR##_##OPENTIME_VERSION_MINOR
There was a problem hiding this comment.
Maybe I'm missing something, but that doesn't seem to be working for me using VS2022. I get: vOPENTIME_VERSION_MAJOR_OPENTIME_VERSION_MINOR_OPENTIME_VERSION_PATCH.
There was a problem hiding this comment.
That looks like too many ## in a row, or missing some _ between?. Here's how that's supposed to work:
https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html
There was a problem hiding this comment.
Right, but I don't think the macros are expanding like expected. Running this simple example through cpp on Linux:
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_NS v##VERSION_MAJOR##_##VERSION_MINOR
namespace VERSION_NS {}
Results in this output:
namespace vVERSION_MAJOR_VERSION_MINOR {}
I can get it to work by using macro arguments, but I don't think the added complexity is worth it:
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_NS v##VERSION_MAJOR##_##VERSION_MINOR
#define VERSION_NS2(MAJOR, MINOR) v##MAJOR##_##MINOR
#define VERSION_NS3(MAJOR, MINOR) VERSION_NS2(MAJOR, MINOR)
namespace VERSION_NS {}
namespace VERSION_NS2(VERSION_MAJOR, VERSION_MINOR) {}
namespace VERSION_NS3(VERSION_MAJOR, VERSION_MINOR) {}
Results in this output:
namespace vVERSION_MAJOR_VERSION_MINOR {}
namespace vVERSION_MAJOR_VERSION_MINOR {}
namespace v1_2 {}
| #define OPENTIMELINEIO_VERSION_MAJOR 0 | ||
| #define OPENTIMELINEIO_VERSION_MINOR 19 | ||
| #define OPENTIMELINEIO_VERSION_PATCH 0 | ||
| #define OPENTIMELINEIO_VERSION v0_19_0 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1993 +/- ##
=======================================
Coverage 85.15% 85.15%
=======================================
Files 181 181
Lines 12783 12783
Branches 1206 1206
=======================================
Hits 10885 10885
Misses 1715 1715
Partials 183 183
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
Sorry, I don't know how I typed 4 #'s in a row. I'm still in favor of concatenation even with a helpy macro! |
That requires updating every source file with the new macro. That seems like a lot of work to not duplicate a number, plus it also adds complexity which I think undermines the benefits of DRY. |
In PR #1907 we added version headers so applications could identify which OpenTimelineIO they were using. However this also introduced a dependency on CMake to generate the headers, which can cause issues for other projects that use OTIO without CMake (for example the OTIO Swift bindings).
This PR replaces the CMake file generation with checked-in files, and instead has CMake parse the version from the checked-in header files. This is similar to what OpenEXR does for their version handling.