-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
135 lines (109 loc) · 3.97 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Check for required dependencies
REQUIRED_CMDS := conan cmake ninja
$(foreach cmd,$(REQUIRED_CMDS),\
$(if $(shell command -v $(cmd) 2> /dev/null),,\
$(error Please install '$(cmd)'. \
conan: pip install conan, \
cmake: https://cmake.org/download/, \
ninja: pip install ninja)))
# Directory markers for dependency tracking
MARKER_DIR := ./build/.markers
$(shell mkdir -p $(MARKER_DIR))
# Source file tracking
SRCS := $(shell find src -name '*.cpp' -o -name '*.h' -o -name '*.hpp')
CMAKE_FILES := $(shell find . -name 'CMakeLists.txt')
# Dependency markers
DEPS_DEBUG_MARKER := $(MARKER_DIR)/deps-relwithdebinfo
DEPS_RELEASE_MARKER := $(MARKER_DIR)/deps-release
CMAKE_DEBUG_MARKER := $(MARKER_DIR)/cmake-debug
CMAKE_RELEASE_MARKER := $(MARKER_DIR)/cmake-release
# Executables
DEBUG_EXE := build/RelWithDebInfo/src/game/stabby
RELEASE_EXE := build/Release/src/game/stabby
DEBUG_EDITOR := build/RelWithDebInfo/src/editor/editor
RELEASE_EDITOR := build/Release/src/editor/editor
# Chose the correct profile based on the OS
ifeq ($(OS),Windows_NT)
PROFILE := profiles/windows.profile
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PROFILE := profiles/linux.profile
endif
ifeq ($(UNAME_S),Darwin)
PROFILE := profiles/macos.profile
endif
endif
# Dependencies targets
$(DEPS_DEBUG_MARKER): conanfile.txt
conan install . --build=missing --profile=$(PROFILE) -s build_type=RelWithDebInfo
@mkdir -p $(MARKER_DIR)
@touch $@
$(DEPS_RELEASE_MARKER): conanfile.txt
conan install . --build=missing --profile=$(PROFILE) -s build_type=Release
@mkdir -p $(MARKER_DIR)
@touch $@
deps-debug: $(DEPS_DEBUG_MARKER)
deps-release: $(DEPS_RELEASE_MARKER)
deps: deps-debug
# CMake configuration markers
$(CMAKE_DEBUG_MARKER): $(DEPS_DEBUG_MARKER) $(CMAKE_FILES)
cmake --preset conan-relwithdebinfo -S . -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
@mkdir -p $(MARKER_DIR)
@touch $@
$(CMAKE_RELEASE_MARKER): $(DEPS_RELEASE_MARKER) $(CMAKE_FILES)
cmake --preset conan-release -S . -G Ninja -DCMAKE_BUILD_TYPE=Release
@mkdir -p $(MARKER_DIR)
@touch $@
# Build targets
$(DEBUG_EXE): $(CMAKE_DEBUG_MARKER) $(SRCS)
cmake --build build/RelWithDebInfo --target stabby
$(RELEASE_EXE): $(CMAKE_RELEASE_MARKER) $(SRCS)
cmake --build build/Release --target stabby
$(DEBUG_EDITOR): $(CMAKE_DEBUG_MARKER) $(SRCS)
cmake --build build/RelWithDebInfo --target editor
$(RELEASE_EDITOR): $(CMAKE_RELEASE_MARKER) $(SRCS)
cmake --build build/Release --target editor
build-dev: $(DEBUG_EXE) $(DEBUG_EDITOR)
build-release: $(RELEASE_EXE) $(RELEASE_EDITOR)
build: build-dev
# Run targets
run-debug: $(DEBUG_EXE)
./$(DEBUG_EXE)
run-release: $(RELEASE_EXE)
./$(RELEASE_EXE)
run: run-debug
run-editor-debug: $(DEBUG_EDITOR)
./$(DEBUG_EDITOR)
run-editor-release: $(RELEASE_EDITOR)
./$(RELEASE_EDITOR)
run-editor: run-editor-debug
# Clean target
clean:
rm -rf build $(MARKER_DIR)
play: run
.PHONY: deps-debug deps-release deps build-dev build-release build \
run-debug run-release run run-editor-debug run-editor-release \
run-editor play clean help
help:
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " deps-debug - Install debug dependencies using Conan"
@echo " deps-release - Install release dependencies using Conan"
@echo " deps - Install debug dependencies (default)"
@echo " build-dev - Build debug version of game and editor"
@echo " build-release- Build release version of game and editor"
@echo " build - Build debug version (default)"
@echo " run - Build and run the game"
@echo " run-editor - Build and run the editor"
@echo " clean - Remove build directory"
@echo ""
@echo "Examples:"
@echo " make deps - Install dependencies"
@echo " make build - Build debug version"
@echo " make run - Build and run the game"
@echo " make run-editor - Build and run the editor"
@echo " make play - Build and run the game"
@echo " make clean - Remove build directory"
.DEFAULT_GOAL := help