-
Notifications
You must be signed in to change notification settings - Fork 189
/
DotNetJsApi.targets
124 lines (115 loc) · 7.44 KB
/
DotNetJsApi.targets
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
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- Defaults for user-visible settings. -->
<WasmEmitSourceMap Condition="'$(WasmEmitSourceMap)' == '' and '$(NativeDebugSymbols)' == 'true'">true</WasmEmitSourceMap>
</PropertyGroup>
<PropertyGroup>
<LinkNativeDependsOn>$(LinkNativeDependsOn);PrepareDotNetJsApiForLinking</LinkNativeDependsOn>
<NativeBinary>$(NativeOutputPath)dotnet.native.js</NativeBinary>
<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints><!-- For JSExports -->
<!-- The async entry point JSExport will be our "Main", so we don't want the IL entrypoint
to be exported. Additionally, the hosted application model is essentially a "library"
one, expected to be reentrant (e. g. there is no shutdown handling by the entry point). -->
<IlcIsLibLikeApp>true</IlcIsLibLikeApp>
</PropertyGroup>
<ItemGroup Condition="'$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe'">
<IlcArg Condition="'$(NativeLib)' == ''" Include="--nativelib" />
<Compile Include="$(MSBuildThisFileDirectory)AsyncEntryPointThunkClass.cs" Visible="false" />
</ItemGroup>
<ItemGroup>
<!-- Emscripten methods used by the JS runtime. Keep in loose sync with the same list in "src/mono/browser/browser.proj". -->
<!-- TODO-LLVM: unify the lists. -->
<EmccExportedFunction Include="_free" />
<EmccExportedFunction Include="_htons" />
<EmccExportedFunction Include="_malloc" />
<EmccExportedFunction Include="_memalign" />
<EmccExportedFunction Include="_memset" />
<EmccExportedFunction Include="_ntohs" />
<EmccExportedFunction Include="stackAlloc" />
<EmccExportedFunction Include="stackRestore" />
<EmccExportedFunction Include="stackSave" />
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="out" />
<EmccExportedRuntimeMethod Include="err" />
<EmccExportedRuntimeMethod Include="ccall" />
<EmccExportedRuntimeMethod Include="cwrap" />
<EmccExportedRuntimeMethod Include="setValue" />
<EmccExportedRuntimeMethod Include="getValue" />
<EmccExportedRuntimeMethod Include="addRunDependency" />
<EmccExportedRuntimeMethod Include="addFunction" />
<EmccExportedRuntimeMethod Include="UTF8ToString" />
<EmccExportedRuntimeMethod Include="UTF8ArrayToString" />
<EmccExportedRuntimeMethod Include="lengthBytesUTF8" />
<EmccExportedRuntimeMethod Include="stringToUTF8Array" />
<EmccExportedRuntimeMethod Include="FS_createPath" />
<EmccExportedRuntimeMethod Include="FS_createDataFile" />
<EmccExportedRuntimeMethod Include="removeRunDependency" />
<EmccExportedRuntimeMethod Include="safeSetTimeout" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePush" />
<EmccExportedRuntimeMethod Include="runtimeKeepalivePop" />
<!-- Pseudo-namespace for the JS interop symbols. -->
<DirectPInvoke Include="System.Runtime.InteropServices.JavaScript" />
<UnmanagedEntryPointsAssembly Include="System.Runtime.InteropServices.JavaScript" />
</ItemGroup>
<Target Name="PrepareDotNetJsApiForLinking">
<PropertyGroup>
<_EmccExportedLibraryFunction>"[@(EmccExportedLibraryFunction -> '%27%(Identity)%27', ',')]"</_EmccExportedLibraryFunction>
<_EmccExportedRuntimeMethods>"[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]"</_EmccExportedRuntimeMethods>
</PropertyGroup>
<ItemGroup>
<!-- Default values for flags passed from emscripten to dotnet/runtime.js. Left here only to minimize changes to typescript -->
<EmscriptenEnvVars Include="DISABLE_LEGACY_JS_INTEROP=1" />
<EmscriptenEnvVars Include="WASM_ENABLE_SIMD=0" />
<EmscriptenEnvVars Include="WASM_ENABLE_EH=1" />
<EmscriptenEnvVars Include="ENABLE_AOT_PROFILER=0" />
<EmscriptenEnvVars Include="ENABLE_BROWSER_PROFILER=0" />
<EmscriptenEnvVars Include="RUN_AOT_COMPILATION=0" />
<_DotNetJsLinkerFlag Include="-s EXPORT_ES6=1" /><!-- Produce ES6 module as expented by hosting API -->
<_DotNetJsLinkerFlag Include="-s MODULARIZE=1" /><!-- Produce ES6 module as expented by hosting API -->
<_DotNetJsLinkerFlag Include="-s EXPORT_NAME="'createDotnetRuntime'"" /><!-- Export emscripten factory as 'createDotnetRuntime', as expented by hosting API -->
<_DotNetJsLinkerFlag Include="-s ENVIRONMENT="'web,webview,worker,node,shell'"" /><!-- Add support for all enviroments (default list is smaller) -->
<_DotNetJsLinkerFlag Condition="'$(EmccEnvironment)' != ''" Include="-s ENVIRONMENT="$(EmccEnvironment)"" />
<_DotNetJsLinkerFlag Include="-s FORCE_FILESYSTEM=1" /><!-- We are using JS API for accessing FS -->
<_DotNetJsLinkerFlag Include="--emit-symbol-map" Condition="'$(WasmEmitSymbolMap)' == 'true'" />
<!-- JavaScript modifications to javascript produced by emscripten -->
<JSFileType Include="extpre.js" Kind="extern-pre-js" />
<JSFileType Include="iffe.js" Kind="extern-pre-js" />
<JSFileType Include="pre.js" Kind="pre-js" />
<JSFileType Include="lib.js" Kind="js-library" />
<JSFileType Include="post.js" Kind="post-js" />
<JSFileType Include="extpost.js" Kind="extern-post-js" />
<_WasmExtraJSFile Include="$(IlcSdkPath)dotnetjs\src\es6\*.%(JSFileType.Identity)" Kind="%(JSFileType.Kind)" />
<_DotNetJsLinkerFlag Include="--%(_WasmExtraJSFile.Kind) "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' != ''" />
<!-- Exported functions required by user or runtime API -->
<_DotNetJsLinkerFlag Include="-s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$(_EmccExportedLibraryFunction)" Condition="'$(_EmccExportedLibraryFunction)' != ''" />
<_DotNetJsLinkerFlag Include="-s EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)" />
<_DotNetJsLinkerFlag Include="$(EmccExtraLDFlags)" />
</ItemGroup>
<ItemGroup>
<CustomLinkerArg Include="@(_DotNetJsLinkerFlag)" />
</ItemGroup>
<ReadLinesFromFile File="$(ExportsFile)">
<Output TaskParameter="Lines" ItemName="_ExistingExports" />
</ReadLinesFromFile>
<ItemGroup>
<_ExportsToAddToExportsFile Include="@(EmccExportedFunction)" />
<_ExportsToAddToExportsFile Remove="@(_ExistingExports)" />
</ItemGroup>
<WriteLinesToFile File="$(ExportsFile)" Lines="@(_ExportsToAddToExportsFile)" Overwrite="false" Condition="'@(_ExportsToAddToExportsFile->Count())' != '0'" />
</Target>
<Target Name="CopyDotnetJsAfterLinking" AfterTargets="LinkNativeLlvm">
<ItemGroup>
<_FilesToCopyToNative Include="$(IlcSdkPath)dotnetjs\dotnet*.js" />
<_FilesToCopyToNative Include="$(IlcSdkPath)dotnetjs\dotnet*.map" Condition="'$(WasmEmitSourceMap)' == 'true'" />
<_FilesToCopyToNative Include="@(WasmExtraFilesToDeploy)" /><!-- User defined extra files to be included in the build output -->
</ItemGroup>
<Copy SourceFiles="@(_FilesToCopyToNative)" DestinationFolder="$(NativeOutputPath)" />
</Target>
<!-- TODO-LLVM-Upstream: https://github.com/dotnet/runtimelab/issues/2576 -->
<Target Name="ReplaceJSImportGenerator" AfterTargets="ResolveTargetingPackAssets">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="'%(Analyzer.AssemblyName)' == 'Microsoft.Interop.JavaScript.JSImportGenerator' or '%(Analyzer.AssemblyName)' == 'Microsoft.Interop.SourceGeneration'" />
<Analyzer Include="$(MSBuildThisFileDirectory)..\analyzers\**\*.dll" />
</ItemGroup>
</Target>
</Project>