This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.ninja
161 lines (133 loc) · 4.72 KB
/
build.ninja
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
ninja_required_version = 1.3
builddir = out
base_dir = ../../backends/base
wgpu_dir = ../../backends/wgpu
wgpu_lib_dir = $wgpu_dir/out/debug
# --------------------------------------------------------------
# flags
cflags = $
-std=c11 $
-g $
-fcolor-diagnostics $
-Wall $
-Wextra $
-Wvla $
-Wimplicit-fallthrough $
-Wno-missing-field-initializers $
-Wno-unused-parameter $
-Werror=implicit-function-declaration $
-Wcovered-switch-default $
-Wunused $
-DSYS_DEBUG=1 $
-I../../include $
-I$wgpu_dir/include
ldflags =
cflags_wasm = $
--no-standard-libraries $
-fvisibility=hidden $
-Ofast $
--target=wasm32
# cflags_host = $
# -O3 $
# -march=native
cflags_host = -O0
ldflags_macos = $
-platform_version macos 10.15 10.15 $
-ObjC $
-lSystem.B $
-framework CoreFoundation $
-framework Cocoa $
-framework Metal $
-framework IOKit $
-framework IOSurface $
-framework QuartzCore
ldflags_wasm = $
-allow-undefined-file ../../etc/playsys-wasm.syms $
--no-entry $
--no-gc-sections $
--export-dynamic $
--import-memory
# --------------------------------------------------------------
# rules
rule c2obj_host
command = clang -MMD -MF $out.d $cflags $cflags_host -c -o $out $in
depfile = $out.d
rule c2obj_wasm
command = clang -MMD -MF $out.d $cflags $cflags_wasm -c -o $out $in
depfile = $out.d
rule c2bc_wasm
command = clang -MMD -MF $out.d $cflags $cflags_wasm -emit-llvm -c -o $out $in
depfile = $out.d
rule wasm_compile_and_link
command = clang $cflags $cflags_wasm $
-Wno-override-module $
-Wl,--no-entry $
-Wl,--no-gc-sections $
-Wl,--export-dynamic $
-Wl,--import-memory $
-Wl,-allow-undefined-file ../../etc/playsys-wasm.syms $
-o $out $in
rule ld_macos_x64
command = ld64.lld $ldflags $ldflags_macos -arch x86_64 $in -o $out
rule ld_wasm
command = wasm-ld $ldflags $ldflags_wasm -error-limit=0 $in -o $out
rule wasm2wast
command = wasm2wat $in -o $out
rule wasm_asyncify
command = wasm-opt --asyncify -O $in -o $out
# --------------------------------------------------------------
# targets
build $builddir/hello_mac_x64_d: ld_macos_x64 $
$builddir/mac_x64/hello.o $
$builddir/mac_x64/hello_triangle.o $
$builddir/mac_x64/hello_ioring.o $
$builddir/mac_x64/syslib.o $
$builddir/mac_x64/ioring.o $
$builddir/mac_x64/vfile.o $
$builddir/mac_x64/syscall.o
ldflags = $ldflags -L$wgpu_lib_dir -rpath $wgpu_lib_dir -lplaywgpu_d -lc++
build $builddir/hello_mac_x64: ld_macos_x64 $
$builddir/mac_x64/hello.o $
$builddir/mac_x64/hello_triangle.o $
$builddir/mac_x64/hello_ioring.o $
$builddir/mac_x64/syslib.o $
$builddir/mac_x64/ioring.o $
$builddir/mac_x64/vfile.o $
$builddir/mac_x64/syscall.o $
$wgpu_lib_dir/libplaywgpu_all.a
# build $builddir/hello.wasm: wasm_asyncify $builddir/hello1.wasm
build $builddir/hello.wasm: wasm_asyncify $builddir/hello2.wasm
# build $builddir/hello1.wasm: wasm_compile_and_link $
# $builddir/wasm32/hello.bc $
# $builddir/wasm32/hello_triangle.bc $
# $builddir/wasm32/syslib.bc $
# $builddir/wasm32/syscall.bc $
# $builddir/wasm32/pwgpu_ctx_wasm.bc
build $builddir/hello2.wasm: ld_wasm $
$builddir/wasm32/hello.o $
$builddir/wasm32/hello_triangle.o $
$builddir/wasm32/hello_ioring.o $
$builddir/wasm32/syslib.o $
$builddir/wasm32/syscall.o $
$builddir/wasm32/pwgpu_ctx_wasm.o
build $builddir/mac_x64/hello.o: c2obj_host hello.c
build $builddir/mac_x64/hello_triangle.o: c2obj_host hello_triangle.c
build $builddir/mac_x64/hello_ioring.o: c2obj_host hello_ioring.c
build $builddir/mac_x64/syslib.o: c2obj_host syslib.c
build $builddir/mac_x64/syscall.o: c2obj_host $base_dir/syscall.c
build $builddir/mac_x64/vfile.o: c2obj_host $base_dir/vfile.c
build $builddir/mac_x64/ioring.o: c2obj_host $base_dir/ioring.c
build $builddir/wasm32/hello.o: c2obj_wasm hello.c
build $builddir/wasm32/hello_triangle.o: c2obj_wasm hello_triangle.c
build $builddir/wasm32/syslib.o: c2obj_wasm syslib.c
build $builddir/wasm32/syscall.o: c2obj_wasm $base_dir/syscall.c
build $builddir/wasm32/vfile.o: c2obj_wasm $base_dir/vfile.c
build $builddir/wasm32/ioring.o: c2obj_wasm $base_dir/ioring.c
build $builddir/wasm32/pwgpu_ctx_wasm.o: c2obj_wasm $wgpu_dir/src/ctx_wasm.c
# build $builddir/wasm32/hello.bc: c2bc_wasm hello.c
# build $builddir/wasm32/hello_triangle.bc: c2bc_wasm hello_triangle.c
# build $builddir/wasm32/syslib.bc: c2bc_wasm syslib.c
# build $builddir/wasm32/syscall.bc: c2bc_wasm $base_dir/syscall.c
# build $builddir/wasm32/pwgpu_ctx_wasm.bc: c2bc_wasm $wgpu_dir/src/ctx_wasm.c
# --------------------------------------------------------------
default $builddir/hello_mac_x64 $builddir/hello.wasm