diff --git a/Makefile b/Makefile index 46184e6..383383e 100644 --- a/Makefile +++ b/Makefile @@ -41,29 +41,14 @@ _PP_CXX = osuparser.cpp _PP = $(_PP_HXX) $(_PP_CXX) PP = $(addprefix $(PREPROCESSED)/, $(_PP)) -# the awks below will remove all includes, pragmas and blank lines from the top of the file -# until they hit something else -# -# that something else could be an awk marker comment which saves part of the includes -# from being eaten by awk - ones useful when debugging the output of these godforsaken macros -# -# doing that makes clang-format considerably faster (c++ std moment) -# but also removes my own headers which makes some of the macros not evaluate -# -# that issue is fixed by adding a comment that'll stop the awk before my macros -# and after all the others +# PP_DEBUG gets rid of all the macros we don't need +# when debugging the preprocessed output pp: dirs $(PP) $(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp - $(eval TMP := $(shell mktemp).hpp) - awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP) - $(CXX) $(CXXFLAGS) -E $(TMP) > $@ + $(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@ clang-format -i $@ - rm -rf $(TMP) $(PREPROCESSED)/%.cpp: $(SRC)/%.cpp - $(eval TMP := $(shell mktemp).cpp) - awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP) - $(CXX) $(CXXFLAGS) -E $(TMP) > $@ + $(CXX) -DPP_DEBUG $(CXXFLAGS) -E $< > $@ clang-format -i $@ - rm -rf $(TMP) diff --git a/include/config.hpp b/include/config.hpp index 0c6b0be..18ff0b5 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -1,17 +1,14 @@ #pragma once +#ifndef PP_DEBUG #include #include #include +#endif #include -// awk stop marker (check make pp) -// only brings in operator<< definitions -// for sf::Color and std::vector -// doesn't change output, we only need the FOR_EACH macro - #include #define CONFIG(name, ...) \ diff --git a/include/osuparser.hpp b/include/osuparser.hpp index 7a7be8e..6768948 100644 --- a/include/osuparser.hpp +++ b/include/osuparser.hpp @@ -1,13 +1,11 @@ #pragma once +#ifndef PP_DEBUG #include +#endif #include -// no marker here since config.hpp is only included to bring -// the generated struct into scope -// the output will be the same regardless - namespace fs = std::filesystem; #define CONFIG(name, ...) name parse##name(fs::path configPath); diff --git a/include/util_stream_ops.hpp b/include/util_stream_ops.hpp index ee66b59..506645a 100644 --- a/include/util_stream_ops.hpp +++ b/include/util_stream_ops.hpp @@ -1,10 +1,12 @@ #pragma once +#ifndef PP_DEBUG #include #include #include #include +#endif inline std::ostream &operator<<(std::ostream &stream, const sf::Color &color) { stream << "Color(" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ")"; diff --git a/src/osuparser.cpp b/src/osuparser.cpp index 4ebce09..25a06c2 100644 --- a/src/osuparser.cpp +++ b/src/osuparser.cpp @@ -1,9 +1,11 @@ #include +#ifndef PP_DEBUG #include #include #include #include +#endif inline std::string trimString(const std::string &str) { std::string ret(str);