Embedding Resources into Binary (Resource Compiler)
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
Hi wonderful Bazel folks, this one's a **feature request**.
It'd be awesome to be able to embed resource files in native binaries (across platforms). This would be great for having resources (like images, model/data files, etc) easily portable within binaries without always needing to do platform specific resource handling.
It strikes me that Bazel is uniquely suited to solve this, with its easy ability to generate code to be compiled into the dependency graph. It seems like the easiest way to do it would be to generate some source files (or an object file directly) containing the bytes of the resource file and then link that in, accessible at a given symbol. [Here's an article](https://caiorss.github.io/C-Cpp-Notes/resources-executable.html) that sketches that kind of thing out, including how it's done for cmake--though you probably want to be careful to use `extern` here to keep from blowing up the build artifacts.
Thanks for your consideration,
Chris
(ex-Googler)
P.S. Related: There's an older Windows-specific issue here https://github.com/bazelbuild/bazel/issues/8273--windows tooling also referred to in that article I linked.
Contributor guide
Research direction
The request names no Bazel files, tests, or entry points. Start by reviewing the linked C/C++ resource-embedding article and related Windows issue #8273, then define the cross-platform build behavior needed to embed resource bytes in native binaries and expose them through a symbol.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100