-
Notifications
You must be signed in to change notification settings - Fork 95
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
Simplify data embedding #270
Simplify data embedding #270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Now that you've simplified the codgen, I wonder how hard it would be to generate the file using CMake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remembered that I saw some minor style issues after I approved.
This is an internal-only refactoring that changes the mechanics of how the sdf/** file data is embedded into the library. For one, it solves the "static initialization order fiasco" for the embedded data. The data is only loaded into memory upon first use, instead of as the library is being loaded. It also simplifies the ruby embedding code, making it more concise. I hope this is easier to maintain, but it also helps me when sharing Drake with consumers that always build from source, but will not install ruby as a compile-time prerequisite The EmbeddedSdf codegen now emits the cc file with the data; the header is stored in git. This provides an easier way to use a function to retrieve the embedded strings as static locals. The embedded SDF data is now combined into a single map. Embedding files should be boring, ala the WIP std::embed specification. It should not include application-layer logic encoding upgrade paths. This will also make it easier to avoid the "static destruction fiasco" in future commits, due to fewer functions to repair. Signed-off-by: Jeremy Nimmer <jeremy.nimmer@tri.global>
FYI I've locally squashed and force-pushed as part of placating the DCO bot
Probably possible, but there's a more complicated use of ruby still in tools/, so we wouldn't be able to drop the ruby dependency yet. That could be future work. For now, this is enough to make my users happier. |
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
=======================================
Coverage 86.45% 86.46%
=======================================
Files 59 59
Lines 9051 9065 +14
=======================================
+ Hits 7825 7838 +13
- Misses 1226 1227 +1
Continue to review full report at Codecov.
|
/// directory such as "1.8/root.sdf", and the values are the contents of | ||
/// that source file. | ||
const std::map<std::string, std::string> &GetEmbeddedSdf(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit Mismatched indentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we usually close the internal namespace on the same line that it was created (Converter.hh) but not always (SDFImplPrivate.hh), so I'm not worried about it
This is an internal-only refactoring that changes the mechanics of how the sdf/** file data is embedded into the library. For one, it solves the "static initialization order fiasco" for the embedded data. The data is only loaded into memory upon first use, instead of as the library is being loaded. It also simplifies the ruby embedding code, making it more concise. I hope this is easier to maintain, but it also helps me when sharing Drake with consumers that always build from source, but will not install ruby as a compile-time prerequisite The EmbeddedSdf codegen now emits the cc file with the data; the header is stored in git. This provides an easier way to use a function to retrieve the embedded strings as static locals. The embedded SDF data is now combined into a single map. Embedding files should be boring, ala the WIP std::embed specification. It should not include application-layer logic encoding upgrade paths. This will also make it easier to avoid the "static destruction fiasco" in future commits, due to fewer functions to repair. Signed-off-by: Jeremy Nimmer <jeremy.nimmer@tri.global>
This is an internal-only refactoring that changes the mechanics of how the
sdf/**
file data is embedded into the library.For one, it solves the https://isocpp.org/wiki/faq/ctors#static-init-order fiasco for the embedded data. The data is only loaded into memory upon first use, instead of as the library is being loaded. This is the magic of function-local statics.
It also simplifies the ruby embedding code, making it more concise. I hope this is easier to maintain, but it also helps me when sharing Drake with consumers that always build from source, but will not install ruby as a compile-time prerequisite (RobotLocomotion/drake#13231).
I am happy to take feedback. Is this the correct branch to PR into? Should I be adding a changelog entry? You are welcome to push fixes to my branch -- it looks like by convention I should not be rebasing nor squashing it?