Fix recently introduced warning. (#11257)
[mono-project.git] / sdks / wasm / Makefile
blob9a01c374ac767ab11ec90df7c44988a30c3a9f39
1 TOP=$(realpath $(CURDIR)/../..)
2 -include $(TOP)/sdks/Make.config
3 -include $(TOP)/mcs/build/config.make
4 include $(TOP)/sdks/versions.mk
5 include $(TOP)/sdks/paths.mk
7 all: build
9 MAKEFLAGS += --no-builtin-rules
10 #emcc has lots of bash'isms
11 SHELL:=/bin/bash
13 #Use either 'release' or 'debug' dependending on what you need
14 DRIVER_CONF=release
17 EMSCRIPTEN_SDKDIR=$(TOP)/sdks/builds/toolchains/emsdk
18 EMCC=source $(TOP)/sdks/builds/toolchains/emsdk/emsdk_env.sh && emcc
19 WASM_BCL_DIR=$(TOP)/sdks/out/wasm-bcl/wasm
20 WASM_RUNTIME_DIR=$(TOP)/sdks/out/wasm-runtime-release
21 MINI_PATH=$(TOP)/mono/mini
22 CSC= MONO_PATH=$(TOP)/mcs/class/lib/build $(TOP)/sdks/builds/bcl/runtime/mono-wrapper $(CSC_LOCATION)
23 CSC_FLAGS := /debug:portable /noconfig /nostdlib /nologo /langversion:latest
25 MINI_TEST_FILES= \
26 TestDriver.cs \
27 aot-tests.cs \
28 arrays.cs \
29 basic-calls.cs \
30 basic-float.cs \
31 basic-long.cs \
32 basic-math.cs \
33 basic.cs \
34 exceptions.cs \
35 generics.cs \
36 gshared.cs \
37 objects.cs \
38 builtin-types.cs \
39 devirtualization.cs \
40 mixed.cs \
41 gc-test.cs
43 APP_SOURCES = \
44 main.cs \
45 incrementalrunner.cs
47 BINDING_TEST_SOURCES = \
48 bindings-test.cs
50 MINI_TEST_SOURCES = $(patsubst %,$(MINI_PATH)/%,$(MINI_TEST_FILES))
52 UNAME := $(shell uname -s)
53 ifeq ($(UNAME),Linux)
54 JSVU_OS=linux64
55 endif
56 ifeq ($(UNAME),Darwin)
57 JSVU_OS=mac64
58 endif
59 .PHONY: jsup
61 jsup:
62 node node_modules/jsvu/cli.js --os=$(JSVU_OS) --engines=all
64 .stamp-jsvu:
65 npm install
66 node node_modules/jsvu/cli.js --os=$(JSVU_OS) --engines=all
67 touch $@
69 .PHONY: toolchain
70 toolchain: .stamp-jsvu
72 driver.o: driver.c
73 $(EMCC) -g -Os -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s ALIASING_FUNCTION_POINTERS=0 -I$(WASM_RUNTIME_DIR)/include/mono-2.0 driver.c -c -o driver.o
75 debug/:
76 mkdir -p $@
77 release/:
78 mkdir -p $@
80 MONO_LIBS = $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-ee-interp.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-ilgen.a $(TOP)/sdks/out/wasm-runtime-release/lib/libmono-icall-table.a
82 debug/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a | debug/
83 $(EMCC) -g4 -Os -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s ALIASING_FUNCTION_POINTERS=0 -s ASSERTIONS=1 --js-library library_mono.js --js-library binding_support.js --js-library dotnet_support.js driver.o $(MONO_LIBS) -o debug/mono.js -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString']"
84 touch $@
86 # Notice that release/.stamp-build depends on debug/.stamp-build. This is the case as emcc is believed to not work well with parallel builds.
87 release/.stamp-build: driver.o library_mono.js binding_support.js dotnet_support.js $(TOP)/sdks/out/wasm-runtime-release/lib/libmonosgen-2.0.a debug/.stamp-build | release/
88 $(EMCC) -Oz --llvm-opts 2 --llvm-lto 1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s BINARYEN=1 -s "BINARYEN_TRAP_MODE='clamp'" -s ALIASING_FUNCTION_POINTERS=0 --js-library library_mono.js --js-library binding_support.js --js-library dotnet_support.js driver.o $(MONO_LIBS) -o release/mono.js -s NO_EXIT_RUNTIME=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['ccall', 'FS_createPath', 'FS_createDataFile', 'cwrap', 'setValue', 'getValue', 'UTF8ToString']"
89 touch $@
91 $(WASM_BCL_DIR)/monolinker.exe: $(TOP)/mcs/class/lib/build/monolinker.exe
92 cp $< $@
94 $(WASM_BCL_DIR)/Mono.Cecil.dll: $(TOP)/mcs/class/lib/build/Mono.Cecil.dll
95 cp $< $@
97 build-native: debug/.stamp-build release/.stamp-build
99 do-runtime:
100 make -j4 -C ../builds package-wasm-runtime
101 make -j4 -C ../builds package-wasm-bcl
102 make build-native
104 BCL_DEPS=/r:$(WASM_BCL_DIR)/mscorlib.dll /r:$(WASM_BCL_DIR)/System.Core.dll /r:$(WASM_BCL_DIR)/System.dll /r:$(WASM_BCL_DIR)/System.Net.Http.dll
106 main.exe: $(APP_SOURCES)
107 $(CSC) $(CSC_FLAGS) /unsafe -out:$@ $(BCL_DEPS) /r:$(WASM_BCL_DIR)/nunitlite.dll $(APP_SOURCES)
109 mini_tests.dll: $(MINI_TEST_SOURCES) mini-test-runner.cs
110 $(CSC) $(CSC_FLAGS) /unsafe -target:library -out:$@ -define:__MOBILE__,ARCH_32 $(BCL_DEPS) /r:$(WASM_BCL_DIR)/nunitlite.dll $(MINI_TEST_SOURCES) mini-test-runner.cs
112 binding_tests.dll: WebAssembly.Bindings.dll $(BINDING_TEST_SOURCES)
113 $(CSC) $(CSC_FLAGS) /unsafe -target:library -out:$@ /r:WebAssembly.Bindings.dll $(BCL_DEPS) /r:$(WASM_BCL_DIR)/nunitlite.dll $(BINDING_TEST_SOURCES)
115 WebAssembly.Bindings.dll: bindings.cs
116 $(CSC) $(CSC_FLAGS) /target:library -out:$@ /r:$(WASM_BCL_DIR)/mscorlib.dll bindings.cs
118 WebAssembly.Net.Http.dll: WebAssembly.Bindings.dll WasmHttpMessageHandler.cs
119 $(CSC) $(CSC_FLAGS) /target:library -out:$@ /r:WebAssembly.Bindings.dll /r:$(WASM_BCL_DIR)/mscorlib.dll /r:$(WASM_BCL_DIR)/System.dll /r:$(WASM_BCL_DIR)/System.Core.dll /r:$(WASM_BCL_DIR)/System.Net.dll /r:$(WASM_BCL_DIR)/System.Net.Http.dll WasmHttpMessageHandler.cs
121 Simple.Dependency.dll: dependency.cs
122 $(CSC) $(CSC_FLAGS) /target:library -out:$@ /r:$(WASM_BCL_DIR)/mscorlib.dll /r:$(WASM_BCL_DIR)/System.Core.dll dependency.cs
124 sample.dll: Simple.Dependency.dll sample.cs WebAssembly.Bindings.dll WebAssembly.Net.Http.dll
125 $(CSC) $(CSC_FLAGS) /target:library -out:$@ /r:Simple.Dependency.dll /r:$(WASM_BCL_DIR)/mscorlib.dll /r:$(WASM_BCL_DIR)/System.dll /r:$(WASM_BCL_DIR)/System.Core.dll /r:$(WASM_BCL_DIR)/System.Net.Http.dll /r:WebAssembly.Bindings.dll /r:WebAssembly.Net.Http.dll sample.cs
127 OPTIONS_CS = $(TOP)/mcs/class/Mono.Options/Mono.Options/Options.cs
129 Mono.Cecil.dll: Makefile
130 nuget install -version 0.10.0 Mono.Cecil
131 cp Mono.Cecil.0.10.0/lib/net40/Mono.Cecil.dll $@
133 # We use system csc as this is a desktop program
134 packager.exe: packager.cs Mono.Cecil.dll $(OPTIONS_CS)
135 csc /debug:portable /out:$@ /r:Mono.Cecil.dll packager.cs $(OPTIONS_CS)
137 .stamp-build-debug-sample: $(DRIVER_CONF)/.stamp-build packager.exe WebAssembly.Bindings.dll WebAssembly.Net.Http.dll sample.dll debug.html runtime.js
138 mono packager.exe -debug -out=debug_sample sample.dll
139 cp debug.html debug_sample
140 touch $@
142 TEST_ASSEMBLIES = $(WASM_BCL_DIR)/nunitlite.dll $(WASM_BCL_DIR)/tests/wasm_corlib_test.dll $(WASM_BCL_DIR)/tests/wasm_System_test.dll $(WASM_BCL_DIR)/tests/wasm_System.Core_test.dll
144 .stamp-build-test-suite: $(DRIVER_CONF)/.stamp-build packager.exe WebAssembly.Bindings.dll binding_tests.dll WebAssembly.Net.Http.dll mini_tests.dll main.exe runtime-tests.js
145 mono --debug packager.exe --template=runtime-tests.js --appdir=bin/test-suite --builddir=obj/test-suite binding_tests.dll WebAssembly.Net.Http.dll mini_tests.dll main.exe $(TEST_ASSEMBLIES)
146 ninja -v -C obj/test-suite
147 touch $@
149 # For development
150 aot-sample: packager.exe mini_tests.dll main.exe runtime.js
151 mono packager.exe --emscripten-sdkdir=$(EMSCRIPTEN_SDKDIR) --mono-sdkdir=$(TOP)/sdks/out -appdir=bin/aot-sample --nobinding --builddir=obj/aot-sample --aot --template=runtime-tests.js mini_tests.dll
152 ninja -v -C obj/aot-sample
154 do-aot-sample: aot-sample
155 (cd bin/aot-sample && $(SM) runtime.js --regression mini_tests.dll)
157 build-aot-mini: packager.exe mini_tests.dll main.exe runtime.js
158 mono packager.exe --emscripten-sdkdir=$(EMSCRIPTEN_SDKDIR) --mono-sdkdir=$(TOP)/sdks/out -appdir=bin/aot-mini --nobinding --builddir=obj/aot-mini --aot --template=runtime-tests.js mini_tests.dll
159 ninja -v -C obj/aot-mini
161 check-aot-mini run-aot-mini: build-aot-mini
162 (cd bin/aot-mini && $(SM) runtime.js --regression mini_tests.dll)
165 # Parameters:
166 # $(1) - make target suffix
167 # $(2) - test assembly filename
168 # $(3) - main.exe argument
169 define AotTestTemplate
171 build-aot-$(1): packager.exe runtime-tests.js main.exe WebAssembly.Bindings.dll binding_tests.dll $$(WASM_BCL_DIR)/nunitlite.dll $$(WASM_BCL_DIR)/tests/$(2)
172 mono packager.exe --emscripten-sdkdir=$$(EMSCRIPTEN_SDKDIR) --mono-sdkdir=$$(TOP)/sdks/out -appdir=bin/aot-$(1) --nobinding --builddir=obj/aot-$(1) --aot --template=runtime-tests.js main.exe WebAssembly.Bindings.dll binding_tests.dll $$(WASM_BCL_DIR)/tests/$(2)
173 ninja -v -C obj/aot-$(1)
175 clean-aot-$(1):
176 $(RM) -r obj/aot-$(1) bin/aot-$(1)
178 check-aot-$(1) run-aot-$(1): build-aot-$(1)
179 (cd bin/aot-$(1) && $$(SM) runtime.js $(3))
181 endef
183 $(eval $(call AotTestTemplate,corlib,wasm_corlib_test.dll,corlib))
184 $(eval $(call AotTestTemplate,System.Core,wasm_System.Core_test.dll,system-core))
185 $(eval $(call AotTestTemplate,System,wasm_System_test.dll,system))
187 AOT_TEST_SUITES=corlib System.Core
189 build-aot-all:
190 $(MAKE) $(patsubst %,build-aot-%,$(AOT_TEST_SUITES))
192 run-aot-all:
193 for suite in System.Core; do make run-aot-$$suite || exit 1; done
195 build-debug-sample: .stamp-build-debug-sample
197 build-test-suite: .stamp-build-test-suite
199 build-managed: build-debug-sample build-test-suite $(WASM_BCL_DIR)/monolinker.exe $(WASM_BCL_DIR)/Mono.Cecil.dll
201 build-dbg-proxy:
202 dotnet build ProxyDriver
204 build-framework-nuget:
205 nuget pack WebAssembly.Framework.nuspec
207 build: build-native build-managed
209 CHAKRA=~/.jsvu/ch
210 D8=~/.jsvu/v8
211 JSC=~/.jsvu/jsc
212 SM=~/.jsvu/sm
214 run-ch-%: toolchain build-test-suite
215 (cd bin/test-suite && $(CHAKRA) runtime.js -args $*)
217 run-v8-%: toolchain build-test-suite
218 (cd bin/test-suite && $(D8) --expose_wasm runtime.js -- $*)
220 run-jsc-%: toolchain build-test-suite
221 (cd bin/test-suite && $(JSC) runtime.js -- $*)
223 run-sm-%: toolchain build-test-suite
224 (cd bin/test-suite && $(SM) runtime.js $*)
226 # Leaving JSC for now cuz it aborts when it encounters wasm
227 run-all-%:
228 make -C . run-ch-$*
229 make -C . run-v8-$*
230 make -C . run-sm-$*
231 make -C . run-jsc-$*
233 clean:
235 package: build build-dbg-proxy build-framework-nuget
236 rm -rf tmp
237 mkdir tmp
238 mkdir tmp/bcl
239 cp -r $(TOP)/sdks/out/wasm-bcl/wasm/* tmp/bcl/
240 rm -rf tmp/bcl/bare
241 rm -rf tmp/bcl/secxml
242 rm -rf tmp/bcl/tests
243 rm -rf tmp/bcl/corlib.unsafe.dll.tmp
244 cp driver.c tmp/
245 cp $(MONO_LIBS) tmp/
246 cp library_mono.js tmp/
247 cp binding_support.js tmp/
248 cp dotnet_support.js tmp/
249 cp -r debug tmp/
250 cp -r release tmp/
251 rm tmp/debug/.stamp-build
252 rm tmp/release/.stamp-build
253 cp sample.html tmp/
254 mkdir tmp/framework
255 cp bindings.cs tmp
256 cp WebAssembly.Bindings.dll tmp/framework
257 cp WebAssembly.Bindings.pdb tmp/framework
258 cp WasmHttpMessageHandler.cs tmp
259 cp WebAssembly.Net.Http.dll tmp/framework
260 cp WebAssembly.Net.Http.pdb tmp/framework
261 cp WebAssembly.Framework.0.1.0-alpha.nupkg tmp/framework
262 cp sample.cs tmp/
263 cp README.md tmp/
264 cp server.py tmp/
265 cp Mono.Cecil.dll tmp/
266 cp packager.exe tmp/
267 cp runtime.js tmp/
268 cp Mono.WebAssembly.DebuggerProxy/bin/Debug/netstandard2.0/Mono.WebAssembly.DebuggerProxy.dll tmp/
269 cp Mono.WebAssembly.DebuggerProxy/bin/Debug/netstandard2.0/Mono.WebAssembly.DebuggerProxy.pdb tmp/
270 mkdir tmp/dbg-proxy
271 cp -r ProxyDriver/bin/Debug/netcoreapp2.1/ tmp/dbg-proxy/
272 (cd tmp; zip -r9 ../mono-wasm-$(shell git rev-parse --short HEAD).zip .)
273 rm -rf tmp
275 serve:
276 python server.py
278 canary:
279 /Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --remote-debugging-port=9222
281 check-aot: do-aot-sample