forked from shader-slang/slang-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mk
100 lines (79 loc) · 4.14 KB
/
build.mk
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
# Helper to ensure all required variables are defined
define ensure_defined
ifndef $1
$$(error "$1 is not defined")
endif
endef
OS_NAME :=
ifeq ($(OS),Windows_NT)
OS_NAME = Windows
else
OS_NAME = $(shell uname -s)
endif
COPY:=
ifeq ($(OS_NAME),Windows)
COPY = copy /b /y
else
COPY = cp -rf
endif
# Helper to ensure a directory exists
ensure_dir = if not exist $(dir $1) mkdir $(dir $1)
# Check that all required variables are defined
required_variables =
## The output directory where to output target (non-source) files
required_variables += TRY_SLANG_TARGET_DIRECTORY_PATH
## Path to the hello-emscripten source tree
required_variables += TRY_SLANG_SOURCE_DIRECTORY_PATH
## Slang source directory
required_variables += TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH
$(eval $(foreach var,$(required_variables),\
$(call ensure_defined,$(var))))
.PHONY: website_runtime
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/index.html
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.wasm
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/try-slang.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/util.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/pass_through.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/compute.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/water_demo.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/ui.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/styles
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/compiler.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/language-server.js
website_runtime: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/playgroundShader.js
.PHONY: $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.js
$(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.js $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.wasm &:
cd $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH) && \
cmake --build --preset emscripten --target slang-wasm
.PHONY: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.js
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.js: $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.js
$(COPY) $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.js $@
.PHONY: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.wasm
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/slang-wasm.wasm: $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.wasm
$(COPY) $(TRY_SLANG_SLANG_SOURCE_DIRECTORY_PATH)/build.em/Release/bin/slang-wasm.wasm $@
.PHONY: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/index.html
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/index.html: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/index.html
$(COPY) $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/index.html $@
.PHONY: $(TRY_SLANG_TARGET_DIRECTORY_PATH)/try-slang.js
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/try-slang.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/try-slang.js
$(COPY) $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/try-slang.js $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/util.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/util.js
$(COPY) $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/util.js $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/pass_through.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/pass_through.js
$(COPY) $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/pass_through.js $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/compute.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/compute.js
$(COPY) $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/compute.js $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/water_demo.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/water_demo.js
$(COPY) $^ $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/ui.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/ui.js
$(COPY) $^ $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/styles: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/styles/styles.css
mkdir -p $(TRY_SLANG_TARGET_DIRECTORY_PATH)/styles
$(COPY) $^ $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/compiler.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/compiler.js
$(COPY) $^ $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/language-server.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/language-server.js
$(COPY) $^ $@
$(TRY_SLANG_TARGET_DIRECTORY_PATH)/playgroundShader.js: $(TRY_SLANG_SOURCE_DIRECTORY_PATH)/playgroundShader.js
$(COPY) $^ $@