add make preprocess

This commit is contained in:
jacekpoz 2024-04-24 19:30:34 +02:00
parent 29d00653eb
commit cf110103ad
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8
2 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
target/ target/
preprocessed/
result result
.ccls-cache/ .ccls-cache/
.direnv/ .direnv/

View file

@ -1,16 +1,23 @@
CXX = g++ CXX = g++
CXXFLAGS = -std=c++20 -O3 -Wall -Wextra -Wpedantic CXXFLAGS = -std=c++20 -O3 -Wall -Wextra -Wpedantic
CXXFLAGS += -Iinclude
LDFLAGS = -lsfml-graphics -lsfml-window -lsfml-system LDFLAGS = -lsfml-graphics -lsfml-window -lsfml-system
NAME = osu++ NAME = osu++
INCLUDE = include
CXXFLAGS += -I$(INCLUDE)
SRC = src SRC = src
BIN = target BIN = target
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
@ -19,6 +26,7 @@ all: dirs $(NAME)
dirs: dirs:
mkdir -p $(BIN) mkdir -p $(BIN)
mkdir -p $(PREPROCESSED)
$(NAME): $(OBJ) $(NAME): $(OBJ)
$(CXX) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@ $(CXX) $(addprefix $(BIN)/, $^) $(LDFLAGS) -o $(BIN)/$@
@ -29,3 +37,14 @@ $(NAME): $(OBJ)
clean: clean:
rm -rf $(addprefix $(BIN)/, $(OBJ)) rm -rf $(addprefix $(BIN)/, $(OBJ))
rm -rf $(BIN)/$(NAME) rm -rf $(BIN)/$(NAME)
rm -rf $(BIN)
rm -rf $(PREPROCESSED)
TMP = temp
preprocess: dirs
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);)
rm -rf $(TMP)