-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (54 loc) · 1.66 KB
/
Makefile
File metadata and controls
71 lines (54 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
.DEFAULT_GOAL := help
CXX := g++
PYTHON := uv run python
OPTION := -std=c++2b -O2 -D DEBUG -I /ac-library -Wall -Wextra -Wshadow -Wconversion -Wno-sign-conversion
SRC ?= main.cpp
SRC_CORRECT ?= main_correct.cpp
SRC_TESTCASES ?= main_testcases.cpp
BUILD_DIR := Bin/
SRC_FLAT = $(subst /,_,$(SRC))
SRC_COPY_FLAT = $(BUILD_DIR)/$(SRC_FLAT:.cpp=_copy.cpp)
BIN_RUN = $(BUILD_DIR)/$(SRC_FLAT:.cpp=.out)
BIN_TEST := $(BUILD_DIR)/test.out
DEPENDS = $(BIN_RUN:.out=.d) $(BIN_TEST:.out=.d)
HEADERS = $(shell find ./ -name "*.hpp")
$(SRC_COPY_FLAT): $(SRC) $(HEADERS)
@$(PYTHON) Command/inline_includes.py $< | tee $@ | xsel -bi
$(BIN_RUN): $(SRC) $(HEADERS)
@$(CXX) $(OPTION) $< -MMD -MP -o $@
$(BIN_TEST): $(SRC) $(HEADERS)
@$(CXX) $(OPTION) $< -D TEST -MMD -MP -o $@
.PHONY: i
i: ## reset
@cp Library/Main/$(SRC) ./$(SRC)
@cp Library/Main/$(SRC) ./$(SRC_CORRECT)
@cp Library/Main/$(SRC) ./$(SRC_TESTCASES)
@rm -f *.o
.PHONY: y
y: $(SRC_COPY_FLAT) ## yank
@$(CXX) $(OPTION) $(SRC_COPY_FLAT) -o tmp && rm -r tmp
.PHONY: r
r: $(BIN_RUN) ## run
@./$^ < i
.PHONY: ri
ri: $(BIN_RUN) ## run without input
@./$^
.PHONY: t
t: ## test
@$(PYTHON) Command/debug_compare.py $(SRC) $(SRC_CORRECT) $(SRC_TESTCASES) | tee i
.PHONY: ti
ti: ## interactive test
@$(PYTHON) Command/debug_interactive.py $(SRC) $(SRC_TESTCASES) | tee i
.PHONY: c
c: $(BIN_RUN) ## compile
.PHONY: clean
clean: ## clean
@rm -f $(BUILD_DIR)/*
@rm -f *.o
-include $(DEPENDS)
.PHONY: help
help: ## show this help
@echo 'Usage: make [Targets]'
@echo ''
@echo 'Targets:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'