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
9 MAKEFLAGS
+= --no-builtin-rules
10 #emcc has lots of bash'isms
13 #Use either 'release' or 'debug' dependending on what you need
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
47 BINDING_TEST_SOURCES
= \
50 MINI_TEST_SOURCES
= $(patsubst %,$(MINI_PATH
)/%,$(MINI_TEST_FILES
))
52 UNAME
:= $(shell uname
-s
)
56 ifeq ($(UNAME
),Darwin
)
62 node node_modules
/jsvu
/cli.js
--os
=$(JSVU_OS
) --engines
=all
66 node node_modules
/jsvu
/cli.js
--os
=$(JSVU_OS
) --engines
=all
70 toolchain
: .stamp-jsvu
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
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']"
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']"
91 $(WASM_BCL_DIR
)/monolinker.exe
: $(TOP
)/mcs
/class
/lib
/build
/monolinker.exe
94 $(WASM_BCL_DIR
)/Mono.Cecil.dll
: $(TOP
)/mcs
/class
/lib
/build
/Mono.Cecil.dll
97 build-native
: debug
/.stamp-build release
/.stamp-build
100 make
-j4
-C ..
/builds package-wasm-runtime
101 make
-j4
-C ..
/builds package-wasm-bcl
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
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
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
)
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)
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))
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
190 $(MAKE
) $(patsubst %,build-aot-
%,$(AOT_TEST_SUITES
))
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
202 dotnet build ProxyDriver
204 build-framework-nuget
:
205 nuget pack WebAssembly.Framework.nuspec
207 build
: build-native build-managed
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
235 package
: build build-dbg-proxy build-framework-nuget
239 cp
-r
$(TOP
)/sdks
/out
/wasm-bcl
/wasm
/* tmp
/bcl
/
241 rm -rf tmp
/bcl
/secxml
243 rm -rf tmp
/bcl
/corlib.unsafe.dll.tmp
246 cp library_mono.js tmp
/
247 cp binding_support.js tmp
/
248 cp dotnet_support.js tmp
/
251 rm tmp
/debug
/.stamp-build
252 rm tmp
/release
/.stamp-build
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
265 cp Mono.Cecil.dll 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
/
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 .
)
279 /Applications
/Google\ Chrome\ Canary.app
/Contents
/MacOS
/Google\ Chrome\ Canary
--remote-debugging-port
=9222
281 check-aot
: do-aot-sample