-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (69 loc) · 2.22 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
UNAME := $(shell uname -s)
ifeq ($(UNAME),Linux)
OS := linux
DEBUG := gdb
endif
ifeq ($(UNAME),Darwin)
OS := darwin
DEBUG := lldb
SHADERC := ./3rdparty/bgfx/bin/osx_x64/shadercRelease
SHADERC_OS_ARGS := --platform osx
# SHADERC_OS_ARGS := --platform osx -p metal
endif
CONFIGURATION := debug
PREMAKE := ./tools/$(OS)/premake5
PROJECT_DIR := ./.build/projects/$(OS)
TARGET_DIR := ./.build/bin/$(OS)/$(CONFIGURATION)
PROJECT := $(PROJECT_DIR)/Makefile
EXECUTABLE := $(TARGET_DIR)/entry
SHADERS := $(wildcard src/shaders/*.shader)
SHADER_INCLUDES := "3rdparty/bgfx/include"
# APP
$(EXECUTABLE): $(PROJECT) touch completion
@ cd $(PROJECT_DIR) && make
$(PROJECT): shaders assets
$(PREMAKE) gmake
completion:
$(PREMAKE) clang-complete
# TODO: remove it.
xcode:
$(PREMAKE) xcode4
touch:
@ touch -c $(PROJECT)
clean:
rm -rf .build
rm -f .clang_complete
rm -f src/shaders/*.h
rm -rf src/generated
build: $(EXECUTABLE)
run: $(EXECUTABLE)
@ $(EXECUTABLE)
debug: $(EXECUTABLE)
@ $(DEBUG) $(EXECUTABLE)
# ASSETS
assets:
@ mkdir -p src/generated
./scripts/sprites.py assets src/generated
# SHADERS
BUILT_SHADERS_VS := $(addsuffix _vs.h, $(basename $(SHADERS)))
BUILT_SHADERS_FS := $(addsuffix _fs.h, $(basename $(SHADERS)))
src/shaders/%_vs.h: src/shaders/%.shader
@ echo "Compiling vertex $<..."
@ $(SHADERC) $(SHADERC_OS_ARGS) \
-i $(SHADER_INCLUDES) \
--varyingdef $(patsubst %.shader, %.varying, $<) \
--define VERTEX_SHADER --type vertex \
-f $< -o $@ \
--bin2c $(addsuffix _vs, $(notdir $(basename $<)))
src/shaders/%_fs.h: src/shaders/%.shader
@ echo "Compiling fragment $<..."
@ $(SHADERC) $(SHADERC_OS_ARGS) \
-i $(SHADER_INCLUDES) \
--varyingdef $(patsubst %.shader, %.varying, $<) \
--define FRAGMENT_SHADER --type fragment \
-f $< -o $@ \
--bin2c $(addsuffix _fs, $(notdir $(basename $<)))
shaders: $(BUILT_SHADERS_VS) $(BUILT_SHADERS_FS)
# ETC
print-% : ; @echo $* = $($*)
.PHONY: completion touch clean build run debug shaders assets xcode