-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
72 lines (49 loc) · 1.61 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
CXX = clang++
LIBS = -lvulkan -lglfw -ldl
CXXFLAGS = -Wall -std=c++20 -stdlib=libstdc++ $(LIBS)
debug: CXXFLAGS += -g
release: CXXFLAGS += -O3
GLSLC = glslc
BEAR_CMD = bear
MAKE_CMD = make
SRC_DIR = src
SRC_CPP_DIR = $(SRC_DIR)/main
SRC_ASSET_DIR = $(SRC_DIR)/assets
SRC_SHADER_DIR = $(SRC_DIR)/shaders
SRCS = $(SRC_CPP_DIR)/main.cpp $(SRC_CPP_DIR)/xdvk.cpp $(SRC_CPP_DIR)/vertex.cpp
BUILD_DIR = build
ASSET_DIR = $(BUILD_DIR)/assets
SHADER_DIR = $(BUILD_DIR)/shaders
PROGRAM_NAME = main
PROGRAM_FULL = $(BUILD_DIR)/$(PROGRAM_NAME)
VERT_SHADER = $(SHADER_DIR)/shader.vert.spv
FRAG_SHADER = $(SHADER_DIR)/shader.frag.spv
PROFILER_ENV = VK_INSTANCE_LAYERS=VK_LAYER_MESA_overlay VK_LAYER_MESA_OVERLAY_CONFIG=vertices=1,fps_sampling_period=10000
COMPILATION_DB = compile_commands.json
CACHE = .cache
ALL = all
$(ALL): $(BUILD_DIR) assets shaders $(PROGRAM_FULL)
debug: $(ALL)
release: $(ALL)
run: $(ALL)
cd $(BUILD_DIR) && ./$(PROGRAM_NAME)
profile: release
cd $(BUILD_DIR) && $(PROFILER_ENV) ./$(PROGRAM_NAME)
assets: $(ASSET_DIR) asset_files
asset_files: $(wildcard $(SRC_ASSET_DIR)/*)
cp -t $(ASSET_DIR)/ $^
shaders: $(SHADER_DIR) $(VERT_SHADER) $(FRAG_SHADER)
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
$(ASSET_DIR): $(BUILD_DIR)
mkdir -p $(ASSET_DIR)
$(SHADER_DIR): $(BUILD_DIR)
mkdir -p $(SHADER_DIR)
$(PROGRAM_FULL): $(wildcard $(SRC_CPP_DIR)/*.cpp) $(wildcard $(SRC_CPP_DIR)/*.hpp)
$(CXX) $(CXXFLAGS) $(SRCS) -o $@
$(SHADER_DIR)/shader.%.spv: $(SRC_SHADER_DIR)/shader.%
$(GLSLC) $^ -o $@
$(COMPILATION_DB): clean
$(BEAR_CMD) -- $(MAKE_CMD) $(ALL)
clean:
rm -rf $(BUILD_DIR) $(COMPILATION_DB) $(CACHE)