From e1dbdf5228e7ee456652ab4d7239179193ee4592 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 24 Apr 2024 23:25:15 +0200 Subject: [PATCH] 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) --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6ff16c5..b94f3a1 100644 --- a/Makefile +++ b/Makefile @@ -41,12 +41,19 @@ _PP_CXX = osuparser.cpp _PP = $(_PP_HXX) $(_PP_CXX) PP = $(addprefix $(PREPROCESSED)/, $(_PP)) +# TODO work out how to keep my own headers in the awk somehow pp: dirs $(PP) $(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 $@ + rm -rf $(TMP) $(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 $@ + rm -rf $(TMP)