|
18 | 18 | </_WasmBuildNativeCoreDependsOn> |
19 | 19 |
|
20 | 20 | <WasmBuildNativeOnlyDependsOn> |
| 21 | + _InitializeCommonProperties; |
21 | 22 | _PrepareForWasmBuildNativeOnly; |
22 | 23 | _WasmBuildNativeCore; |
23 | 24 | </WasmBuildNativeOnlyDependsOn> |
|
38 | 39 | <Target Name="WasmBuildNativeOnly" DependsOnTargets="$(WasmBuildNativeOnlyDependsOn)" Condition="'$(WasmBuildNative)' == 'true'" /> |
39 | 40 |
|
40 | 41 | <Target Name="_PrepareForWasmBuildNativeOnly"> |
| 42 | + <MakeDir Directories="$(_WasmIntermediateOutputPath)" /> |
| 43 | + |
41 | 44 | <ItemGroup> |
42 | 45 | <_WasmAssembliesInternal Remove="@(_WasmAssembliesInternal)" /> |
43 | 46 | <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> |
44 | 47 | </ItemGroup> |
45 | 48 | </Target> |
46 | 49 |
|
47 | | - |
48 | 50 | <Target Name="_SetupEmscripten"> |
49 | 51 | <PropertyGroup> |
50 | 52 | <_EMSDKMissingPaths Condition="'$(_EMSDKMissingPaths)' == '' and ('$(EmscriptenSdkToolsPath)' == '' or !Exists('$(EmscriptenSdkToolsPath)'))">%24(EmscriptenSdkToolsPath)=$(EmscriptenSdkToolsPath) </_EMSDKMissingPaths> |
|
115 | 117 |
|
116 | 118 | <PropertyGroup> |
117 | 119 | <WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true'">true</WasmBuildNative> |
118 | | - <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative> |
119 | | - <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release'">true</WasmBuildNative> |
| 120 | + <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative> |
| 121 | + <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'" >false</WasmBuildNative> |
| 122 | + <WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(Configuration)' == 'Release'" >true</WasmBuildNative> |
120 | 123 | <WasmBuildNative Condition="'$(WasmBuildNative)' == ''">false</WasmBuildNative> |
121 | 124 | </PropertyGroup> |
122 | 125 |
|
|
153 | 156 |
|
154 | 157 | <EmccCompileOptimizationFlag Condition="'$(EmccCompileOptimizationFlag)' == ''">$(_EmccOptimizationFlagDefault)</EmccCompileOptimizationFlag> |
155 | 158 | <EmccLinkOptimizationFlag Condition="'$(EmccLinkOptimizationFlag)' == ''" >-O0 -s ASSERTIONS=$(_EmccAssertionLevelDefault)</EmccLinkOptimizationFlag> |
| 159 | + |
| 160 | + <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp</_EmccCompileRsp> |
156 | 161 | </PropertyGroup> |
157 | 162 |
|
158 | 163 | <ItemGroup> |
|
161 | 166 | <_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" /> |
162 | 167 | <_EmccCommonFlags Include="-g" Condition="'$(WasmNativeStrip)' == 'false'" /> |
163 | 168 | <_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" /> |
| 169 | + |
| 170 | + <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" /> |
| 171 | + <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" /> |
| 172 | + <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" /> |
| 173 | + |
| 174 | + <!-- Adding optimization flag at the top, so it gets precedence --> |
| 175 | + <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" /> |
| 176 | + <_EmccCFlags Include="@(_EmccCommonFlags)" /> |
| 177 | + |
| 178 | + <_EmccCFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" /> |
| 179 | + <_EmccCFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" /> |
| 180 | + <_EmccCFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" /> |
| 181 | + <_EmccCFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" /> |
| 182 | + <_EmccCFlags Include="-DCORE_BINDINGS" /> |
| 183 | + <_EmccCFlags Include="-DGEN_PINVOKE=1" /> |
| 184 | + |
| 185 | + <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" /> |
| 186 | + <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> |
| 187 | + |
| 188 | + <_EmccCFlags Include="$(EmccExtraCFlags)" /> |
| 189 | + |
| 190 | + <_WasmRuntimePackSrcFile Include="$(_WasmRuntimePackSrcDir)*.c" /> |
| 191 | + <_WasmRuntimePackSrcFile ObjectFile="$(_WasmIntermediateOutputPath)%(FileName).o" /> |
| 192 | + |
| 193 | + <_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)\*.js" /> |
| 194 | + <_WasmNativeFileForLinking Include="@(NativeFileReference)" /> |
164 | 195 | </ItemGroup> |
165 | 196 |
|
166 | | - <ItemGroup> |
167 | | - <_DotnetJSSrcFile Include="$(_WasmRuntimePackSrcDir)\*.js" /> |
168 | | - </ItemGroup> |
| 197 | + <Error Text="Could not find NativeFileReference %(NativeFileReference.Identity)" Condition="'%(NativeFileReference.Identity)' != '' and !Exists(%(NativeFileReference.Identity))" /> |
169 | 198 | </Target> |
170 | 199 |
|
171 | 200 | <Target Name="_GeneratePInvokeTable"> |
172 | 201 | <ItemGroup> |
| 202 | + <_WasmPInvokeModules Include="%(_WasmNativeFileForLinking.FileName)" Condition="'%(_WasmNativeFileForLinking.ScanForPInvokes)' != 'false'" /> |
| 203 | + |
173 | 204 | <_WasmPInvokeModules Include="libSystem.Native" /> |
174 | 205 | <_WasmPInvokeModules Include="libSystem.IO.Compression.Native" /> |
175 | 206 | <_WasmPInvokeModules Include="libSystem.Globalization.Native" /> |
|
194 | 225 |
|
195 | 226 | <Target Name="_WasmCompileNativeFiles"> |
196 | 227 | <ItemGroup> |
197 | | - <_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" /> |
198 | | - <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" /> |
199 | | - <_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)wasm" /> |
200 | | - |
201 | | - <!-- Adding optimization flag at the top, so it gets precedence --> |
202 | | - <_EmccCFlags Include="$(EmccCompileOptimizationFlag)" /> |
203 | | - <_EmccCFlags Include="@(_EmccCommonFlags)" /> |
204 | | - |
205 | | - <_EmccCFlags Include="-DENABLE_AOT=1" Condition="'$(RunAOTCompilation)' == 'true'" /> |
206 | | - <_EmccCFlags Include="-DDRIVER_GEN=1" Condition="'$(RunAOTCompilation)' == 'true'" /> |
207 | | - <_EmccCFlags Include="-DINVARIANT_GLOBALIZATION=1" Condition="'$(InvariantGlobalization)' == 'true'" /> |
208 | | - <_EmccCFlags Include="-DLINK_ICALLS=1" Condition="'$(WasmLinkIcalls)' == 'true'" /> |
209 | | - <_EmccCFlags Include="-DCORE_BINDINGS" /> |
210 | | - <_EmccCFlags Include="-DGEN_PINVOKE=1" /> |
211 | | - <_EmccCFlags Include="-emit-llvm" /> |
212 | | - |
213 | | - <_EmccCFlags Include=""-I%(_EmccIncludePaths.Identity)"" /> |
214 | | - <_EmccCFlags Include="-g" Condition="'$(WasmNativeDebugSymbols)' == 'true'" /> |
215 | | - <_EmccCFlags Include="-s EXPORTED_FUNCTIONS='[@(_ExportedFunctions->'"%(Identity)"', ',')]'" Condition="@(_ExportedFunctions->Count()) > 0" /> |
216 | | - |
217 | | - <_EmccCFlags Include="$(EmccExtraCFlags)" /> |
218 | | - |
219 | | - <_WasmRuntimePackSrcFile Remove="@(_WasmRuntimePackSrcFile)" /> |
220 | | - <_WasmRuntimePackSrcFile Include="$(_WasmRuntimePackSrcDir)\*.c" /> |
221 | | - <_WasmRuntimePackSrcFile ObjectFile="$(_WasmIntermediateOutputPath)%(FileName).o" /> |
| 228 | + <_WasmSourceFileToCompile Remove="@(_WasmSourceFileToCompile)" /> |
222 | 229 | <_WasmSourceFileToCompile Include="@(_WasmRuntimePackSrcFile)" /> |
223 | 230 | </ItemGroup> |
224 | 231 |
|
225 | 232 | <PropertyGroup> |
226 | 233 | <_EmBuilder Condition="$([MSBuild]::IsOSPlatform('WINDOWS'))">embuilder.bat</_EmBuilder> |
227 | 234 | <_EmBuilder Condition="!$([MSBuild]::IsOSPlatform('WINDOWS'))">embuilder.py</_EmBuilder> |
228 | | - <_EmccCompileRsp>$(_WasmIntermediateOutputPath)emcc-compile.rsp</_EmccCompileRsp> |
229 | 235 | </PropertyGroup> |
230 | 236 |
|
231 | 237 | <WriteLinesToFile Lines="@(_EmccCFlags)" File="$(_EmccCompileRsp)" Overwrite="true" WriteOnlyWhenDifferent="true" /> |
|
235 | 241 |
|
236 | 242 | <Message Text="Compiling native assets with emcc. This may take a while ..." Importance="High" /> |
237 | 243 | <EmccCompile SourceFiles="@(_WasmSourceFileToCompile)" Arguments='"@$(_EmccDefaultFlagsRsp)" "@$(_EmccCompileRsp)"' EnvironmentVariables="@(EmscriptenEnvVars)" /> |
| 244 | + |
| 245 | + <ItemGroup> |
| 246 | + <WasmNativeAsset Include="%(_WasmSourceFileToCompile.ObjectFile)" /> |
| 247 | + </ItemGroup> |
238 | 248 | </Target> |
239 | 249 |
|
240 | 250 | <ItemGroup Condition="'$(Configuration)' == 'Debug' and '@(_MonoComponent->Count())' == 0"> |
|
271 | 281 | Include="$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\*.a" |
272 | 282 | Exclude="@(_MonoRuntimeComponentDontLink->'$(MicrosoftNetCoreAppRuntimePackRidNativeDir)\%(Identity)')" /> |
273 | 283 |
|
| 284 | + <_WasmExtraJSFile Include="@(Content)" Condition="'%(Content.Extension)' == '.js'" /> |
| 285 | + |
274 | 286 | <_EmccLinkStepArgs Include="@(_EmccLDFlags)" /> |
275 | 287 | <_EmccLinkStepArgs Include="--js-library "%(_DotnetJSSrcFile.Identity)"" /> |
276 | 288 | <_EmccLinkStepArgs Include="--js-library "%(_WasmExtraJSFile.Identity)"" Condition="'%(_WasmExtraJSFile.Kind)' == 'js-library'" /> |
@@ -483,6 +495,5 @@ EMSCRIPTEN_KEEPALIVE void mono_wasm_load_profiler_aot (const char *desc) { mono_ |
483 | 495 | <ParameterGroup> |
484 | 496 | <EmccProperties ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> |
485 | 497 | </ParameterGroup> |
486 | | - </UsingTask> |
487 | | - |
| 498 | + </UsingTask> |
488 | 499 | </Project> |
0 commit comments