-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
49 lines (40 loc) · 1.04 KB
/
makefile
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
# Makefile
# 使用 `make n` 命令编译并运行 Scripts/n.cc 文件
# 默认目标
.PHONY: all
all:
# 查找 Scripts 目录中的所有 .cc 文件并编译它们
FILES := $(shell find Scripts -name "*.cc")
# 将文件名转换为相应的可执行文件路径
OUTPUTS := $(patsubst Scripts/%.cc, Debug/%.out, $(FILES))
# 编译所有找到的 .cc 文件
all: $(OUTPUTS)
# 编译特定编号的文件
%:
@file=$(shell find . -name "$*.cc"); \
if [ -f "$$file" ]; then \
outfile="Debug/$*.out"; \
mkdir -p $$(dirname $$outfile); \
g++ -std=c++20 $$file -o $$outfile; \
echo "[+] g++ -std=c++20 $$file -o $$outfile"; \
echo "[+] Running $$outfile"; \
./$$outfile; \
else \
echo "No source file found for target $*"; \
exit 1; \
fi
# Git push 目标
.PHONY: push
push:
@git add .
@echo "[+] git add ."
@git commit -m "$(m)"
@echo "[+] git commit -m '$(m)'"
@git push -u origin main
@echo "[+] git push -u origin main"
# clean 目标
.PHONY: clean
clean:
@rm -rf ./Debug/*.out
@echo "[+] rm -rf ./Debug/*.out"
@echo "[+] Successed"