-
Notifications
You must be signed in to change notification settings - Fork 105
/
Makefile
193 lines (152 loc) · 6.57 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
WILDCARD_SOURCE:=$(wildcard src/*.rs)
GIT_TAG=$(shell git describe --abbrev=0 --tags)
GIT_TAG_FULL=$(shell git describe --tags)
OS_NAME=
EXTRA_BUILD_ARGS=
TARGET_DIR=target
ifdef TARGET
EXTRA_BUILD_ARGS=--target $(TARGET)
TARGET_DIR=target/$(TARGET)
endif
ifndef ARCHIVE_NAME
ARCHIVE_NAME=wgpu-$(TARGET)
endif
ifeq ($(OS),Windows_NT)
OS_NAME=windows
else
UNAME_S:=$(shell uname -s)
ifeq ($(UNAME_S),Linux)
OS_NAME=linux
endif
ifeq ($(UNAME_S),Darwin)
OS_NAME=macos
endif
endif
MKDIR_CMD:=mkdir -p
ifeq ($(origin MSYSTEM),undefined) # MSYSTEM env var is defined on msys2
ifeq ($(OS),Windows_NT)
SHELL:=cmd
MKDIR_CMD=powershell -Command md -Force
endif
endif
.PHONY: check test doc clear \
lib-native lib-native-release \
example-capture example-compute example-triangle \
example-push_constants example-push_constants-release \
run-example-push_constants run-example-push_constants-release \
example-capture-release example-compute-release example-triangle-release \
run-example-capture run-example-compute run-example-triangle \
run-example-capture-release run-example-compute-release run-example-triangle-release
package: lib-native lib-native-release
mkdir -p dist
echo "Zipping the binaries ..."
echo "$(GIT_TAG_FULL)" > dist/wgpu-native-git-tag
for RELEASE in debug release; do \
ARCHIVEDIR=toarchive; \
ARCHIVEFILE=$(ARCHIVE_NAME)-$$RELEASE.zip; \
LIBDIR=$(TARGET_DIR)/$$RELEASE; \
rm -r -f dist/$$ARCHIVEDIR; \
rm -f dist/$$ARCHIVEFILE; \
mkdir -p dist/$$ARCHIVEDIR/wgpu-native-meta; \
mkdir -p dist/$$ARCHIVEDIR/include/webgpu; \
mkdir -p dist/$$ARCHIVEDIR/lib; \
cp ./dist/wgpu-native-git-tag dist/$$ARCHIVEDIR/wgpu-native-meta; \
cp ./ffi/webgpu-headers/webgpu.yml dist/$$ARCHIVEDIR/wgpu-native-meta; \
cp ./ffi/webgpu-headers/webgpu.h dist/$$ARCHIVEDIR/include/webgpu; \
cp ./ffi/wgpu.h dist/$$ARCHIVEDIR/include/webgpu; \
if [ $(OS_NAME) = linux ]; then \
cp ./$$LIBDIR/libwgpu_native.so dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/libwgpu_native.a dist/$$ARCHIVEDIR/lib; \
fi; \
if [ $(OS_NAME) = macos ]; then \
cp ./$$LIBDIR/libwgpu_native.dylib dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/libwgpu_native.a dist/$$ARCHIVEDIR/lib; \
fi; \
if [ $(OS_NAME) = windows ]; then \
if [[ "$(TARGET)" == *"gnu"* ]]; then \
cp ./$$LIBDIR/wgpu_native.dll dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/libwgpu_native.a dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/libwgpu_native.dll.a dist/$$ARCHIVEDIR/lib; \
else \
cp ./$$LIBDIR/wgpu_native.dll dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/wgpu_native.lib dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/wgpu_native.dll.lib dist/$$ARCHIVEDIR/lib; \
cp ./$$LIBDIR/wgpu_native.pdb dist/$$ARCHIVEDIR/lib; \
fi;\
fi; \
cd dist/$$ARCHIVEDIR; \
if [ $(OS_NAME) = windows ]; then \
7z a -tzip ../$$ARCHIVEFILE *; \
else \
zip -r ../$$ARCHIVEFILE *; \
fi; \
cd ../..; \
rm -r -f dist/$$ARCHIVEDIR; \
done
clean:
cargo clean
rm -Rf examples/build
check:
cargo check --all
test:
cargo test --all
doc:
cargo doc --all
clear:
cargo clean
lib-native: Cargo.lock Cargo.toml Makefile $(WILDCARD_SOURCE)
cargo build $(EXTRA_BUILD_ARGS)
lib-native-release: Cargo.lock Cargo.toml Makefile $(WILDCARD_SOURCE)
cargo build --release $(EXTRA_BUILD_ARGS)
examples-debug: lib-native
cd examples && $(MKDIR_CMD) "build/Debug" && cd build/Debug && cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ../..
examples-release: lib-native-release
cd examples && $(MKDIR_CMD) "build/RelWithDebInfo" && cd build/RelWithDebInfo && cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ../..
example-push_constants: examples-debug
cd examples/build/Debug && cmake --build . --target push_constants
run-example-push_constants: example-push_constants
cd examples/push_constants && "../build/Debug/push_constants/push_constants"
example-push_constants-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target push_constants
run-example-push_constants-release: example-push_constants-release
cd examples/push_constants && "../build/RelWithDebInfo/push_constants/push_constants"
example-capture: examples-debug
cd examples/build/Debug && cmake --build . --target capture
run-example-capture: example-capture
cd examples/capture && "../build/Debug/capture/capture"
example-capture-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target capture
run-example-capture-release: example-capture-release
cd examples/capture && "../build/RelWithDebInfo/capture/capture"
example-compute: examples-debug
cd examples/build/Debug && cmake --build . --target compute
run-example-compute: example-compute
cd examples/compute && "../build/Debug/compute/compute"
example-compute-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target compute
run-example-compute-release: example-compute-release
cd examples/compute && "../build/RelWithDebInfo/compute/compute"
example-enumerate_adapters: examples-debug
cd examples/build/Debug && cmake --build . --target enumerate_adapters
run-example-enumerate_adapters: example-enumerate_adapters
cd examples/enumerate_adapters && "../build/Debug/enumerate_adapters/enumerate_adapters"
example-enumerate_adapters-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target enumerate_adapters
run-example-enumerate_adapters-release: example-enumerate_adapters-release
cd examples/triangle && "../build/RelWithDebInfo/enumerate_adapters/enumerate_adapters"
example-texture_arrays: examples-debug
cd examples/build/Debug && cmake --build . --target texture_arrays
run-example-texture_arrays: example-texture_arrays
cd examples/texture_arrays && "../build/Debug/texture_arrays/texture_arrays"
example-texture_arrays-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target texture_arrays
run-example-texture_arrays-release: example-texture_arrays-release
cd examples/texture_arrays && "../build/RelWithDebInfo/texture_arrays/texture_arrays"
example-triangle: examples-debug
cd examples/build/Debug && cmake --build . --target triangle
run-example-triangle: example-triangle
cd examples/triangle && "../build/Debug/triangle/triangle"
example-triangle-release: examples-release
cd examples/build/RelWithDebInfo && cmake --build . --target triangle
run-example-triangle-release: example-triangle-release
cd examples/triangle && "../build/RelWithDebInfo/triangle/triangle"