Request for Narrower Module Including (to improve build times and avoid whole-project recompilations)


#1

I posted this at the end of this thread but it may have been lost in there and I think it deserves a request in its own right: How to Include an Entire Source Tree

I’m a big fan of the module format, apart from it being a really easy way to include code across projects, it quietly promotes a much better coding style of separating components and programming in a more generic, library orientated way.

However, the whole project re-builds can be annoying when you’re simply modifying some inlined methods or do a git-pull etc.

I’ve been wondering if there is way modules can be included on a more opt-in basis and I don’t think this would be too hard to do.
• In the Projucer you’d just have a box next to the module that you could tick to “Generate separate header”
• If this is ticked it wouldn’t get added to JuceHeader.h but it’s own file would be created that looked like below:

module_name.h

#pragma once
#include "AppConfig.h"
#include <module_name/module_name.h>

• Then, in your app code you could simply include the module where required, like you would boost or the STL. E.g. #include <module_name.h>
• The search path would already be included because it’s within /JuceLibraryCode/
• The JUCE_MODULE_AVAILABLE_module_name is still defined in AppConfig.h
• An eventually we could ditch this an use C++17’s __has_include (<module_name.h>)

I think this should work but I’ve not fully tested it yet. Can anyone spot any obvious holes?


#2

Yes - sounds like a nice idea!

(Am really looking forward to __has_include, that could be used for some really cool compile tricks)