FR: binary resources in JUCE module spec

There currently doesn’t seem to be a way within the JUCE module specification to declare binary resources that the module depends on.

In a CMake project, it’s trivial to work around this – just create another binary data target with juce_add_binary_data and specify a custom header name and namespace, then link your module target to it.

However, if you’re writing a module that has to support Projucer projects, then currently you have basically two options:

  1. Run the binary builder manually to generate the source files containing the binary data, then commit these files into the module. Re-run the binary builder manually every time you need to add a resource file or one of them changes.

  2. Don’t directly declare your module’s resources, but just write some docs for the user that say “your Projucer project must include these files as binary data”. The module code include’s BinaryData.h and references its data in the BinaryData namespace, failing to compile if the user didn’t manually add all the resources to their Projucer project.

Neither of these solutions is a good one. I would like to propose adding to the JUCE module specification the ability to declare resource files the module depends on. This would basically mean introducing two new keys to the juce module declaration block: binaryDataHeaderName and binaryDataNamespace. There could also be a key for the directory the resource files are in, or it could default to something like resources/, like the libs/ directory does. I would suggest that explicitly providing binaryDataHeaderName and binaryDataNamespace should be required to use resource files in a module, and that it should be an error if either of them are the default BinaryData (that should be reserved for use by projects).

Ooh love the idea to improve this, as there’s currently a fair amount of friction using images, etc in modules. I currently do method 1 to help out the Projucers.

+1 for there being a directory convention! Would
be great if the namespace was also default set by convention — ideally module devs could just dump assets into /resources and not have to setup much else!

1 Like