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
This commit is contained in:
jacekpoz 2024-04-24 20:03:18 +02:00
parent d2342cad28
commit 2e259e946d
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -14,10 +14,6 @@ PREPROCESSED = preprocessed
_PROG = HitObjectDrawable.cpp main.cpp osuparser.cpp TextureManager.cpp _PROG = HitObjectDrawable.cpp main.cpp osuparser.cpp TextureManager.cpp
PROG = $(addprefix $(SRC)/, $(_PROG)) PROG = $(addprefix $(SRC)/, $(_PROG))
PP_HXX = osuparser.hpp config.hpp
PP_CXX = osuparser.cpp
PP = $(PP_HXX) $(PP_CXX)
OBJ = $(_PROG:.cpp=.o) OBJ = $(_PROG:.cpp=.o)
.PHONY: all clean .PHONY: all clean
@ -42,9 +38,21 @@ clean:
TMP = temp TMP = temp
preprocess: dirs tmp:
mkdir -p $(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);) _PP_HXX = osuparser.hpp config.hpp
$(foreach file, $(PP), clang-format $(TMP)/$(file) > $(PREPROCESSED)/$(file);) _PP_CXX = osuparser.cpp
_PP = $(_PP_HXX) $(_PP_CXX)
PP = $(addprefix $(PREPROCESSED)/, $(_PP))
preprocess: dirs tmp $(PP)
rm -rf $(TMP) 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)/%=%) > $@