Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
50 lines (40 loc) · 2.44 KB
/
Copy pathMakefile
File metadata and controls
50 lines (40 loc) · 2.44 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
.SILENT:
.PHONY: run build
BUILD_DIR ?= ./build
run: build
@output_file=$$(mktemp) || { printf "Failed to create temporary output file\n" >&2; exit 1; }; \
$(BUILD_DIR)/Project > "$$output_file"; \
EXIT_CODE=$$?; \
if [ -s "$$output_file" ]; then \
echo "—————————————————————— Program's Output ——————————————————————"; \
echo; \
cat "$$output_file"; \
fi; \
rm -f "$$output_file"; \
if [ $$EXIT_CODE -ne 0 ]; then \
echo; \
printf "\033[1;31mProgram exited with code $$EXIT_CODE\033[0m\n"; \
exit $$EXIT_CODE; \
fi
build:
echo "————————————————————————— Build Logs —————————————————————————"
@printf "\nClearing existing build... \033[1;33m[\033[39m1/3\033[33m]\033[0m\n"
cmake -S . -B $(BUILD_DIR) -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release > /tmp/adan_build.log 2>&1 \
|| { printf "\n\033[1;31mProgram build failed!\033[0m\n"; \
echo ; echo "————————————————————————— Error Logs —————————————————————————"; \
cat /tmp/project_build.log; \
echo "———————————————————————————————————————————————————————————————"; \
exit 1; }
@printf "Re-compiling project... \033[1;33m[\033[39m2/3\033[33m]\033[0m\n"
@cmake --build $(BUILD_DIR) > /tmp/project_build.log 2>&1 \
|| { printf "\n\033[1;31mProgram build failed!\033[0m\n"; \
echo; \
echo "————————————————————————— Error Logs —————————————————————————"; \
echo; \
cat /tmp/project_build.log; \
echo; \
echo "———————————————————————————————————————————————————————————————"; \
echo; \
exit 1; }
@printf "Finishing project build... \033[1;33m[\033[39m3/3\033[33m]\033[0m\n"
@printf "\n\033[1;32mProgram build success!\033[0m\n\n"