From 2e259e946d125d9cf53702ee4605c3e01a29457c Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Wed, 24 Apr 2024 20:03:18 +0200 Subject: [PATCH] improve make preprocess fun story - I had this exact piece of code without a single changed not work the prior 2 times, then I changed a bit, a part started working so I changed it back to this and the 3rd time it somehow works --- Makefile | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index e430c2f..ccb260c 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,6 @@ PREPROCESSED = preprocessed _PROG = HitObjectDrawable.cpp main.cpp osuparser.cpp TextureManager.cpp PROG = $(addprefix $(SRC)/, $(_PROG)) -PP_HXX = osuparser.hpp config.hpp -PP_CXX = osuparser.cpp -PP = $(PP_HXX) $(PP_CXX) - OBJ = $(_PROG:.cpp=.o) .PHONY: all clean @@ -42,9 +38,21 @@ clean: TMP = temp -preprocess: dirs +tmp: mkdir -p $(TMP) - $(foreach file, $(PP_HXX), $(CXX) $(CXXFLAGS) -E $(INCLUDE)/$(file) > $(TMP)/$(file);) - $(foreach file, $(PP_CXX), $(CXX) $(CXXFLAGS) -E $(SRC)/$(file) > $(TMP)/$(file);) - $(foreach file, $(PP), clang-format $(TMP)/$(file) > $(PREPROCESSED)/$(file);) + +_PP_HXX = osuparser.hpp config.hpp +_PP_CXX = osuparser.cpp +_PP = $(_PP_HXX) $(_PP_CXX) +PP = $(addprefix $(PREPROCESSED)/, $(_PP)) + +preprocess: dirs tmp $(PP) rm -rf $(TMP) + +$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp + $(CXX) $(CXXFLAGS) -E $< > $(TMP)/$(@:$(PREPROCESSED)/%=%) + clang-format $(TMP)/$(@:$(PREPROCESSED)/%=%) > $@ + +$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp + $(CXX) $(CXXFLAGS) -E $< > $(TMP)/$(@:$(PREPROCESSED)/%=%) + clang-format $(TMP)/$(@:$(PREPROCESSED)/%=%) > $@