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 = $(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)
|
||||
|
||||
$(PREPROCESSED)/%.hpp: $(INCLUDE)/%.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) > $@
|
||||
clang-format -i $@
|
||||
rm -rf $(TMP)
|
||||
|
||||
$(PREPROCESSED)/%.cpp: $(SRC)/%.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) > $@
|
||||
clang-format -i $@
|
||||
rm -rf $(TMP)
|
||||
|
|
|
@ -5,9 +5,15 @@
|
|||
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
|
||||
#include <foreach.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, ...) \
|
||||
struct name {\
|
||||
__VA_ARGS__\
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
|
||||
#include <filesystem>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#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 SECTION(name, ...)
|
||||
|
||||
|
|
Loading…
Reference in a new issue