I am trying to get my various projects (C++) set up with Bazel and have had no issues so far in getting the bits of my code that don't rely on any third party libraries to build. However, quite a lot of my code is dependent on the
Juce libraries, which aren't built in Bazel. I will be using Juce for multiple different projects, call them FirstProject and SecondProject. My directory structure looks like this:
root
|--WORKSPACE
|--FirstProject
| |--BUILD
| |--AppConfig.h
| |--More Code...
|
|--SecondProject
| |--BUILD
| |--AppConfig.h
| |--More Code...
|
|--ThirdPartyCode
|--Juce
|--BUILD
What I would like is to have one target for Juce and have the targets in FirstProject and SecondProject depend on it.
cc_library (
name = "MyJuceTarget",
...
deps = [ /* Lots of Juce library submodules */]
)
The complication is that each project that uses Juce has a header called AppConfig.h with a bunch of #defines in it. Juce needs AppConfig.h at compile time to do some project specific configuration, so there's this awkward backwards dependency. MyJuceTarget has lots of dependencies, and I would like to reduce the redundancy in the BUILD files as much as possible such that for each project, all I have to do is depend on MyJuceTarget (without re-listing all of Juce's deps) and tell it once where that header is.
I believe I can see a way to make this work by making a FirstProjectJuce and SecondProjectJuce target in the projects that list all of MyJuceTarget's deps as their own deps, and include AppConfig.h in the hdrs, which is messy. Any suggestions on a clean way to do this? Can we tell MyJuceTarget that it still is waiting on a header file and depend on it directly provided we supply the header?
Thanks,
Chet