Open aiuto opened 5 years ago
Any suggestions on this?
A partial solution (hits about half the bullets under "Scope"): https://github.com/bcsgh/bazel_rules/tree/master/cc_embed_data
I've only tested that on the limited environments I've needed it in (Linux/ELF) so YMMV. If anyone wants to add Win/COFF I'd accept pull requests.
It is often extremely useful to embed a generated (or static) binary object directly in a C++ library. For example, the ICU library build compiles text files describing character attributes into compressed binary structures that can be evaluated at run time. The canonical technique is to
Typically, the object file defines at least 2 symbols unit8_t _DATA_OBJECT_NAME_start[] unit32_t _DATA_OBJECT_NAME_size Those are declared in a generated .h file and provided by the object module.
Problem scope
There is an interesting overview of issues and techniques here: https://www.devever.net/~hl/incbin