speed up make pp from 23 seconds to almost instant
this is done by removing all headers from the top of the file using that awk written by the amazing Jappie3 from the hyprland discord g++ -E itself was pretty fast but clang-format took a while to format a 52k line file (wonder why), removing std makes the files considerably smaller and makes the whole operation almost instant one small issue is currently the script removes every single header unless it hits something else - not ideal since my own headers will get wiped too and in the preprocessed output not all macros will be evaluated (e.g. FOR_EACH from for_each.hpp in config.hpp)
This commit is contained in:
parent
3c4f5ababa
commit
e1dbdf5228
1 changed files with 9 additions and 2 deletions
11
Makefile
11
Makefile
|
@ -41,12 +41,19 @@ _PP_CXX = osuparser.cpp
|
||||||
_PP = $(_PP_HXX) $(_PP_CXX)
|
_PP = $(_PP_HXX) $(_PP_CXX)
|
||||||
PP = $(addprefix $(PREPROCESSED)/, $(_PP))
|
PP = $(addprefix $(PREPROCESSED)/, $(_PP))
|
||||||
|
|
||||||
|
# TODO work out how to keep my own headers in the awk somehow
|
||||||
pp: dirs $(PP)
|
pp: dirs $(PP)
|
||||||
|
|
||||||
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
|
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
|
||||||
$(CXX) $(CXXFLAGS) -E $< > $@
|
$(eval TMP := $(shell mktemp).hpp)
|
||||||
|
awk '/^#include/ || /^#pragma/ || /^namespace/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
||||||
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
||||||
clang-format -i $@
|
clang-format -i $@
|
||||||
|
rm -rf $(TMP)
|
||||||
|
|
||||||
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
|
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
|
||||||
$(CXX) $(CXXFLAGS) -E $< > $@
|
$(eval TMP := $(shell mktemp).cpp)
|
||||||
|
awk '/^#include/ || /^#pragma/ || /^namespace/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
||||||
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
||||||
clang-format -i $@
|
clang-format -i $@
|
||||||
|
rm -rf $(TMP)
|
||||||
|
|
Loading…
Reference in a new issue