未验证 提交 8eb41381 编写于 作者: P Pavel Savara 提交者: GitHub

[wasm] EmccExportedRuntimeMethod MSBuild item (#76455)

Co-authored-by: NAnkit Jain <radical@gmail.com>
上级 01cc5733
......@@ -4,8 +4,12 @@
<_SampleProject>Wasm.Advanced.Sample.csproj</_SampleProject>
<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
<PublishTrimmed>true</PublishTrimmed>
<!-- add OpenGL emulation -->
<EmccExtraLDFlags> -s USE_CLOSURE_COMPILER=1 -s LEGACY_GL_EMULATION=1 -lGL -lSDL</EmccExtraLDFlags>
</PropertyGroup>
<ItemGroup>
<!-- add export GL object from Module -->
<EmccExportedRuntimeMethod Include="GL" />
<NativeFileReference Include="fibonacci.c" />
<TrimmerRootDescriptor Include="$(MSBuildThisFileDirectory)ILLink.Descriptors.xml" />
</ItemGroup>
......
......@@ -8,7 +8,7 @@ function add(a, b) {
}
try {
const { runtimeBuildInfo, setModuleImports, getAssemblyExports, runMain, getConfig } = await dotnet
const { runtimeBuildInfo, setModuleImports, getAssemblyExports, runMain, getConfig, Module } = await dotnet
.withElementOnExit()
// 'withModuleConfig' is internal lower level API
// here we show how emscripten could be further configured
......@@ -49,6 +49,9 @@ try {
const config = getConfig();
const exports = await getAssemblyExports(config.mainAssemblyName);
const meaning = exports.Sample.Test.TestMeaning();
if (typeof Module.GL !== "object") {
exit(-10, "Can't find GL");
}
console.debug(`meaning: ${meaning}`);
if (!exports.Sample.Test.IsPrime(meaning)) {
document.getElementById("out").innerHTML = `${meaning} as computed on dotnet ver ${runtimeBuildInfo.productVersion}`;
......
......@@ -368,13 +368,15 @@
</ItemGroup>
</Target>
<Target Name="_WasmWriteRspFilesForLinking">
<PropertyGroup>
<Target Name="_WasmWriteRspFilesForLinking" DependsOnTargets="_CheckEmccIsExpectedVersion">
<PropertyGroup>
<_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' == 'true'">libmono-wasm-eh-wasm.a</_WasmEHLib>
<_WasmEHLib Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-js.a</_WasmEHLib>
<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' == 'true'">libmono-wasm-eh-js.a</_WasmEHLibToExclude>
<_WasmEHLibToExclude Condition="'$(WasmEnableExceptionHandling)' != 'true'">libmono-wasm-eh-wasm.a</_WasmEHLibToExclude>
</PropertyGroup>
<_EmccExportedRuntimeMethods>&quot;[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]&quot;</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
</PropertyGroup>
<ItemGroup>
<!-- order matters -->
<_WasmNativeFileForLinking Include="%(_BitcodeFile.ObjectFile)" />
......@@ -401,6 +403,9 @@
<_EmccLinkStepArgs Include="-o &quot;$(_WasmIntermediateOutputPath)dotnet.js&quot;" />
<_WasmLinkDependencies Include="$(_EmccLinkRsp)" />
<_EmccLinkStepArgs Include="-s EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)" />
<_EmccLinkStepArgs Include="-s EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)" />
<_EmccLinkStepArgs Include="$(EmccExtraLDFlags)" />
</ItemGroup>
......@@ -457,6 +462,8 @@
<ReadEmccProps JsonFilePath="$(_WasmRuntimePackSrcDir)emcc-props.json">
<Output TaskParameter="EmccProperties" ItemName="_EmccPropItems" />
<Output TaskParameter="WasmOptConfigurationFlags" ItemName= "_WasmOptConfigurationFlagsItems" />
<Output TaskParameter="EmccDefaultExportedFunctions" ItemName= "EmccExportedFunction" />
<Output TaskParameter="EmccDefaultExportedRuntimeMethods" ItemName= "EmccExportedRuntimeMethod" />
</ReadEmccProps>
<CreateProperty Value="%(_EmccPropItems.Value)">
......@@ -641,6 +648,8 @@
<ParameterGroup>
<EmccProperties ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" />
<WasmOptConfigurationFlags ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" />
<EmccDefaultExportedFunctions ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" />
<EmccDefaultExportedRuntimeMethods ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" />
</ParameterGroup>
</UsingTask>
</Project>
......@@ -82,6 +82,8 @@
<WasmExtraConfig Include="json" Value="{ &quot;abc&quot;: 4 }" />
<WasmExtraConfig Include="string_val" Value="&quot;abc&quot;" />
<WasmExtraConfig Include="string_with_json" Value="&quot;{ &quot;abc&quot;: 4 }&quot;" />
- @(EmccExportedRuntimeMethod) - Extra method for emcc flag EXPORTED_RUNTIME_METHODS
- @(EmccExportedFunction) - Extra function for emcc flag EXPORTED_FUNCTIONS
-->
<PropertyGroup>
......
......@@ -108,17 +108,48 @@
<Error Text="Failed to parse emcc version, and hash from the full version string: '$(_EmccVersionRaw)'"
Condition="'$(_EmccVersion)' == '' or '$(_EmccVersionHash)' == ''" />
<ItemGroup>
<EmccExportedRuntimeMethod Include="FS" />
<EmccExportedRuntimeMethod Include="print" />
<EmccExportedRuntimeMethod Include="ccall" />
<EmccExportedRuntimeMethod Include="cwrap" />
<EmccExportedRuntimeMethod Include="setValue" />
<EmccExportedRuntimeMethod Include="getValue" />
<EmccExportedRuntimeMethod Include="UTF8ToString" />
<EmccExportedRuntimeMethod Include="UTF8ArrayToString" />
<EmccExportedRuntimeMethod Include="FS_createPath" />
<EmccExportedRuntimeMethod Include="FS_createDataFile" />
<EmccExportedRuntimeMethod Include="removeRunDependency" />
<EmccExportedRuntimeMethod Include="addRunDependency" />
<EmccExportedRuntimeMethod Include="FS_readFile" />
<EmccExportedFunction Include="_malloc" />
<EmccExportedFunction Include="_memalign" />
<EmccExportedFunction Include="_htons" />
<EmccExportedFunction Include="_ntohs" />
</ItemGroup>
<!-- after 3.0 -->
<ItemGroup Condition="$([MSBuild]::VersionGreaterThan('$(_EmccVersion)', '3.0'))">
<EmccExportedFunction Include="_memset" />
</ItemGroup>
<!-- before 3.1.7 see https://github.com/dotnet/runtime/issues/64724 -->
<ItemGroup Condition="$([MSBuild]::VersionLessThan('$(_EmccVersion)', '3.1.7'))">
<EmccExportedFunction Include="__get_daylight" />
<EmccExportedFunction Include="__get_timezone" />
<EmccExportedFunction Include="__get_tzname" />
<EmccExportedFunction Include="g_free" />
</ItemGroup>
<!-- after 3.1.7 -->
<ItemGroup Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(_EmccVersion)', '3.1.7'))">
<EmccExportedFunction Include="stackSave" />
<EmccExportedFunction Include="stackRestore" />
<EmccExportedFunction Include="stackAlloc" />
<EmccExportedFunction Include="_free" />
</ItemGroup>
<PropertyGroup>
<_DefaultExportedFunctions Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(_EmccVersion)', '3.1.7'))"
>_malloc,stackSave,stackRestore,stackAlloc,_memalign,_memset,_htons,_ntohs,_free</_DefaultExportedFunctions>
<!-- _htons,_ntohs,__get_daylight,__get_timezone,__get_tzname are exported temporarily, until the issue is fixed in emscripten, https://github.com/dotnet/runtime/issues/64724 -->
<_DefaultExportedFunctions Condition="'$(_DefaultExportedFunctions)' == '' and $([MSBuild]::VersionGreaterThan('$(_EmccVersion)', '3.0'))"
>g_free,_malloc,_memalign,_memset,_htons,_ntohs,__get_daylight,__get_timezone,__get_tzname</_DefaultExportedFunctions>
<_DefaultExportedFunctions Condition="'$(_DefaultExportedFunctions)' == '' and $([MSBuild]::VersionLessThan('$(_EmccVersion)', '3.0'))"
>g_free,_malloc,_htons,_ntohs,__get_daylight,__get_timezone,__get_tzname,_memalign</_DefaultExportedFunctions>
<_EmccExportedRuntimeMethods>&quot;[@(EmccExportedRuntimeMethod -> '%27%(Identity)%27', ',')]&quot;</_EmccExportedRuntimeMethods>
<_EmccExportedFunctions>@(EmccExportedFunction -> '%(Identity)',',')</_EmccExportedFunctions>
</PropertyGroup>
<ItemGroup>
<_EmccCommonFlags Condition="'$(WasmEnableSIMD)' == 'true'" Include="-msimd128" />
<_EmccCommonFlags Condition="'$(MonoWasmThreads)' == 'true'" Include="-s USE_PTHREADS=1" />
......@@ -128,8 +159,8 @@
<_EmccLinkFlags Include="-s ALLOW_MEMORY_GROWTH=1" />
<_EmccLinkFlags Include="-s NO_EXIT_RUNTIME=1" />
<_EmccLinkFlags Include="-s FORCE_FILESYSTEM=1" />
<_EmccLinkFlags Include="-s EXPORTED_RUNTIME_METHODS=&quot;['FS','print','ccall','cwrap','setValue','getValue','UTF8ToString','UTF8ArrayToString','FS_createPath','FS_createDataFile','removeRunDependency','addRunDependency', 'FS_readFile']&quot;" />
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=$(_DefaultExportedFunctions)" Condition="'$(_DefaultExportedFunctions)' != ''" />
<_EmccLinkFlags Include="-s EXPORTED_RUNTIME_METHODS=$(_EmccExportedRuntimeMethods)" />
<_EmccLinkFlags Include="-s EXPORTED_FUNCTIONS=$(_EmccExportedFunctions)" />
<_EmccLinkFlags Include="--source-map-base http://example.com" />
<_EmccLinkFlags Include="-s STRICT_JS=1" />
<_EmccLinkFlags Include="-s EXPORT_NAME=&quot;'createDotnetRuntime'&quot;" />
......@@ -167,7 +198,9 @@
],
"WasmOptConfigurationFlags": [
{ "identity": "WasmOptConfigurationFlags", "value": "$(_WasmOptConfigurationFlags)" }
]
],
"EmccDefaultExportedFunctions": [@(EmccExportedFunction -> '%22%(Identity)%22', ',')],
"EmccDefaultExportedRuntimeMethods": [@(EmccExportedRuntimeMethod -> '%22%(Identity)%22', ',')]
}
}
]]>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册