Use prebuilt Mono binaries. Remove asm.js fallback (Mono doesn't distribute asm.js builds).

This commit is contained in:
Steve Sanderson 2018-11-07 09:43:27 +00:00
parent 54f78ca34d
commit 0857483a42
6 changed files with 8 additions and 28 deletions

View File

@ -175,21 +175,13 @@ function findMethod(assemblyName: string, namespace: string, className: string,
}
function addScriptTagsToDocument() {
// Load either the wasm or asm.js version of the Mono runtime
const browserSupportsNativeWebAssembly = typeof WebAssembly !== 'undefined' && WebAssembly.validate;
const monoRuntimeUrlBase = '_framework/' + (browserSupportsNativeWebAssembly ? 'wasm' : 'asmjs');
const monoRuntimeScriptUrl = `${monoRuntimeUrlBase}/mono.js`;
if (!browserSupportsNativeWebAssembly) {
// In the asmjs case, the initial memory structure is in a separate file we need to download
const meminitXHR = Module['memoryInitializerRequest'] = new XMLHttpRequest();
meminitXHR.open('GET', `${monoRuntimeUrlBase}/mono.js.mem`);
meminitXHR.responseType = 'arraybuffer';
meminitXHR.send(undefined);
throw new Error('This browser does not support WebAssembly.');
}
const scriptElem = document.createElement('script');
scriptElem.src = monoRuntimeScriptUrl;
scriptElem.src = '_framework/wasm/mono.js';
scriptElem.defer = true;
document.body.appendChild(scriptElem);
}
@ -197,7 +189,6 @@ function addScriptTagsToDocument() {
function createEmscriptenModuleInstance(loadAssemblyUrls: string[], onReady: () => void, onError: (reason?: any) => void) {
const module = {} as typeof Module;
const wasmBinaryFile = '_framework/wasm/mono.wasm';
const asmjsCodeFile = '_framework/asmjs/mono.asm.js';
const suppressMessages = ['DEBUGGING ENABLED'];
module.print = line => (suppressMessages.indexOf(line) < 0 && console.log(`WASM: ${line}`));
@ -209,7 +200,6 @@ function createEmscriptenModuleInstance(loadAssemblyUrls: string[], onReady: ()
module.locateFile = fileName => {
switch (fileName) {
case 'mono.wasm': return wasmBinaryFile;
case 'mono.asm.js': return asmjsCodeFile;
default: return fileName;
}
};

View File

@ -18,7 +18,7 @@
<file src="build\**" target="build" />
<file src="targets\**" target="targets" />
<file src="$publishdir$netcoreapp2.1\**\*" target="tools/" />
<file src="..\mono\dist\optimized\**\*" target="tools\mono" />
<file src="..\mono\dist\**\*" target="tools\mono" />
<file src="..\mono\tools\binaries\illink\**\*.*" target="tools\illink" />
<file src="..\Microsoft.AspNetCore.Blazor.Browser.JS\dist\blazor.*.js" target="tools\blazor" />
</files>

View File

@ -12,10 +12,9 @@
<BlazorBuildReferenceFromSource>true</BlazorBuildReferenceFromSource>
<BlazorMonoRuntimeBasePath>$(MSBuildThisFileDirectory)../mono/</BlazorMonoRuntimeBasePath>
<MonoLinkerPath>$(BlazorMonoRuntimeBasePath)tools/binaries/illink/illink.dll</MonoLinkerPath>
<MonoBaseClassLibraryPath>$(BlazorMonoRuntimeBasePath)dist/optimized/bcl/</MonoBaseClassLibraryPath>
<MonoBaseClassLibraryFacadesPath>$(BlazorMonoRuntimeBasePath)dist/optimized/bcl/Facades/</MonoBaseClassLibraryFacadesPath>
<MonoAsmjsRuntimePath>$(BlazorMonoRuntimeBasePath)dist/optimized/asmjs/</MonoAsmjsRuntimePath>
<MonoWasmRuntimePath>$(BlazorMonoRuntimeBasePath)dist/optimized/wasm/</MonoWasmRuntimePath>
<MonoBaseClassLibraryPath>$(BlazorMonoRuntimeBasePath)dist/bcl/</MonoBaseClassLibraryPath>
<MonoBaseClassLibraryFacadesPath>$(BlazorMonoRuntimeBasePath)dist/bcl/Facades/</MonoBaseClassLibraryFacadesPath>
<MonoWasmRuntimePath>$(BlazorMonoRuntimeBasePath)dist/wasm/</MonoWasmRuntimePath>
<BlazorJsPath>$(MSBuildThisFileDirectory)../Microsoft.AspNetCore.Blazor.Browser.JS/dist/blazor.*.js</BlazorJsPath>
</PropertyGroup>

View File

@ -4,7 +4,6 @@
<MonoLinkerPath>$(BlazorMonoRuntimeBasePath)tools/illink/illink.dll</MonoLinkerPath>
<MonoBaseClassLibraryPath>$(BlazorMonoRuntimeBasePath)tools/mono/bcl/</MonoBaseClassLibraryPath>
<MonoBaseClassLibraryFacadesPath>$(BlazorMonoRuntimeBasePath)tools/mono/bcl/Facades/</MonoBaseClassLibraryFacadesPath>
<MonoAsmjsRuntimePath>$(BlazorMonoRuntimeBasePath)tools/mono/asmjs/</MonoAsmjsRuntimePath>
<MonoWasmRuntimePath>$(BlazorMonoRuntimeBasePath)tools/mono/wasm/</MonoWasmRuntimePath>
<BlazorJsPath>$(BlazorMonoRuntimeBasePath)tools/blazor/blazor.*.js</BlazorJsPath>
</PropertyGroup>
@ -16,7 +15,6 @@
<BaseBlazorPackageContentOutputPath>$(BaseBlazorDistPath)_content/</BaseBlazorPackageContentOutputPath>
<BaseBlazorRuntimeOutputPath>$(BaseBlazorDistPath)_framework/</BaseBlazorRuntimeOutputPath>
<BaseBlazorRuntimeBinOutputPath>$(BaseBlazorRuntimeOutputPath)_bin/</BaseBlazorRuntimeBinOutputPath>
<BaseBlazorRuntimeAsmjsOutputPath>$(BaseBlazorRuntimeOutputPath)asmjs/</BaseBlazorRuntimeAsmjsOutputPath>
<BaseBlazorRuntimeWasmOutputPath>$(BaseBlazorRuntimeOutputPath)wasm/</BaseBlazorRuntimeWasmOutputPath>
<BaseBlazorJsOutputPath>$(BaseBlazorRuntimeOutputPath)</BaseBlazorJsOutputPath>
<BaseBlazorIntermediateOutputPath>blazor/</BaseBlazorIntermediateOutputPath>

View File

@ -122,7 +122,6 @@
The final folder is something like bin/<<Configuration>>/<<TargetFramework>>/dist
/_framework/_bin <- This will contain either the BCL + app assemblies or the result of linking the app.
/_framework/asmjs <- This will contain the asmjs runtime copied from the nuget package.
/_framework/wasm <- This will contain the wsm runtime copied from the nuget package.
/_framework/blazor.js <- This is the blazor.js file copied from the nuget package.
/_framework/blazor.boot.json <- This is the boot json file
@ -157,14 +156,8 @@
</PropertyGroup>
<ItemGroup Label="Static content to copy to the output folder">
<MonoAsmjsFile Include="$(MonoAsmjsRuntimePath)**/*.*" />
<MonoWasmFile Include="$(MonoWasmRuntimePath)**/*.*" />
<BlazorJsFile Include="$(BlazorJsPath)" />
<BlazorItemOutput Include="@(MonoAsmjsFile)">
<TargetOutputPath>$(TargetDir)$(BaseBlazorRuntimeAsmjsOutputPath)%(FileName)%(Extension)</TargetOutputPath>
<Type>AsmJs</Type>
<IsStatic>true</IsStatic>
</BlazorItemOutput>
<BlazorItemOutput Include="@(MonoWasmFile)">
<TargetOutputPath>$(TargetDir)$(BaseBlazorRuntimeWasmOutputPath)%(FileName)%(Extension)</TargetOutputPath>
<Type>WebAssembly</Type>

View File

@ -35,8 +35,8 @@ namespace Microsoft.AspNetCore.Blazor.Build.Test
var basePath = Path.GetDirectoryName(typeof(RuntimeDependenciesResolverTest).Assembly.Location);
var bclLocations = new []
{
Path.Combine(basePath, "../../../../../src/mono/dist/optimized/bcl/"),
Path.Combine(basePath, "../../../../../src/mono/dist/optimized/bcl/Facades/"),
Path.Combine(basePath, "../../../../../src/mono/dist/bcl/"),
Path.Combine(basePath, "../../../../../src/mono/dist/bcl/Facades/"),
};
var expectedContents = new[]