Description
Motivation: To speed up build times even more.
Input: a list of source files.
Could be easily specified with the ones we already specify in CMakeLists.txt, and passed to add_custom_target, named remove_superfluous_includes.
Approach: brute-force. I propose this algorithm:
For every input cpp file, comment out the n-th found include directive by prepending //.
Just match against ^#include.
Build the project as usual - the script can just call ninja all on a build directory passed as input.
Parse the error log to know which sources failed to build.
In the ones that failed, uncomment the just commented out include directive (literally just remove the first two characters).
(Optional) - build the project once again to ensure that everything is alright.
If not, halt and spout a beautiful error.
If no file has an (n+1)-th include directive, halt with success.
Otherwise repeat the algorithm with n = n + 1.
While we could simply anaylze each file one-by-one, we would then have to parallelize it by hand.
Instead we take advantage of the regular parallelism of builds.
As a bonus we actually get to know if the whole project builds.
Additionally, if we parallelized on file-level, we would have more i/o overhead due to necessary temporary file copies.
Problem: with #ifdef-ed code, shit may hit the fan when the defines change.
We'll just run it with all defines enabled.
We'll just remove platform-specific code and run it specifically on the game code - these should be alright.
Reactions are currently unavailable
You can鈥檛 perform that action at this time.
CMakeLists.txt, and passed toadd_custom_target, namedremove_superfluous_includes.//.^#include.ninja allon a build directory passed as input.n = n + 1.#ifdef-ed code, shit may hit the fan when the defines change.