awk marker comments to save necessary macros
I restructured the beginnings of the preprocessed files for debugging to make the awks in the makefile not eat headers which are needed for debugging (e.g. the FOR_EACH macro) it's done by putting awk marker comments: // awk stop marker (check make pp) after the macros to be eaten by awk and before the ones we wanna keep I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this I hate this
This commit is contained in:
parent
e1dbdf5228
commit
c967207520
3 changed files with 23 additions and 6 deletions
13
Makefile
13
Makefile
|
@ -41,19 +41,26 @@ _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
|
# the awks below will remove all includes, pragmas and blank lines from the top of the file
|
||||||
|
# until they hit something else
|
||||||
|
#
|
||||||
|
# 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: dirs $(PP)
|
pp: dirs $(PP)
|
||||||
|
|
||||||
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
|
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.hpp
|
||||||
$(eval TMP := $(shell mktemp).hpp)
|
$(eval TMP := $(shell mktemp).hpp)
|
||||||
awk '/^#include/ || /^#pragma/ || /^namespace/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
||||||
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
||||||
clang-format -i $@
|
clang-format -i $@
|
||||||
rm -rf $(TMP)
|
rm -rf $(TMP)
|
||||||
|
|
||||||
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
|
$(PREPROCESSED)/%.cpp: $(SRC)/%.cpp
|
||||||
$(eval TMP := $(shell mktemp).cpp)
|
$(eval TMP := $(shell mktemp).cpp)
|
||||||
awk '/^#include/ || /^#pragma/ || /^namespace/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
awk '/^#include/ || /^#pragma/ || /^[[:space:]]*$$/ {if(!f)next} // {f=1;print}' $< > $(TMP)
|
||||||
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
$(CXX) $(CXXFLAGS) -E $(TMP) > $@
|
||||||
clang-format -i $@
|
clang-format -i $@
|
||||||
rm -rf $(TMP)
|
rm -rf $(TMP)
|
||||||
|
|
|
@ -5,9 +5,15 @@
|
||||||
|
|
||||||
#include <SFML/Graphics/Color.hpp>
|
#include <SFML/Graphics/Color.hpp>
|
||||||
|
|
||||||
#include <foreach.hpp>
|
|
||||||
#include <util_stream_ops.hpp>
|
#include <util_stream_ops.hpp>
|
||||||
|
|
||||||
|
// awk stop marker (check make pp)
|
||||||
|
// <util_stream_ops.hpp> only brings in operator<< definitions
|
||||||
|
// for sf::Color and std::vector<T>
|
||||||
|
// doesn't change output, we only need the FOR_EACH macro
|
||||||
|
|
||||||
|
#include <foreach.hpp>
|
||||||
|
|
||||||
#define CONFIG(name, ...) \
|
#define CONFIG(name, ...) \
|
||||||
struct name {\
|
struct name {\
|
||||||
__VA_ARGS__\
|
__VA_ARGS__\
|
||||||
|
|
|
@ -2,10 +2,14 @@
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
#include <config.hpp>
|
#include <config.hpp>
|
||||||
|
|
||||||
|
// 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);
|
#define CONFIG(name, ...) name parse##name(fs::path configPath);
|
||||||
#define SECTION(name, ...)
|
#define SECTION(name, ...)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue