Rename wasm dlls to bins

This is to help them get through corporate networks.

Fixes #92
This commit is contained in:
Frank A. Krueger 2018-04-25 18:12:37 -07:00
parent 3c6c1ecf66
commit a04b511461
No known key found for this signature in database
GPG Key ID: 0471C67474FFE664
2 changed files with 29 additions and 6 deletions

View File

@ -18,6 +18,8 @@ namespace Ooui.Wasm.Build.Tasks
{ {
const string SdkUrl = "https://xamjenkinsartifact.azureedge.net/test-mono-mainline-webassembly/108/highsierra/sdks/wasm/mono-wasm-a14f41ca260.zip"; const string SdkUrl = "https://xamjenkinsartifact.azureedge.net/test-mono-mainline-webassembly/108/highsierra/sdks/wasm/mono-wasm-a14f41ca260.zip";
const string AssemblyExtension = ".bin";
[Required] [Required]
public string Assembly { get; set; } public string Assembly { get; set; }
[Required] [Required]
@ -33,8 +35,10 @@ namespace Ooui.Wasm.Build.Tasks
InstallSdk (); InstallSdk ();
GetBcl (); GetBcl ();
CreateDist (); CreateDist ();
DeleteOldAssemblies ();
CopyRuntime (); CopyRuntime ();
LinkAssemblies (); LinkAssemblies ();
RenameAssemblies ();
ExtractClientJs (); ExtractClientJs ();
DiscoverEntryPoint (); DiscoverEntryPoint ();
GenerateHtml (); GenerateHtml ();
@ -98,6 +102,16 @@ namespace Ooui.Wasm.Build.Tasks
Directory.CreateDirectory (managedPath); Directory.CreateDirectory (managedPath);
} }
void DeleteOldAssemblies ()
{
foreach (var dll in Directory.GetFiles (managedPath, "*.dll")) {
File.Delete (dll);
}
foreach (var dll in Directory.GetFiles (managedPath, "*" + AssemblyExtension)) {
File.Delete (dll);
}
}
void CopyRuntime () void CopyRuntime ()
{ {
var rtPath = Path.Combine (sdkPath, "release"); var rtPath = Path.Combine (sdkPath, "release");
@ -154,10 +168,7 @@ namespace Ooui.Wasm.Build.Tasks
} }
pipeline.AddStepAfter (typeof (LoadReferencesStep), new LoadI18nAssemblies (I18nAssemblies.None)); pipeline.AddStepAfter (typeof (LoadReferencesStep), new LoadI18nAssemblies (I18nAssemblies.None));
DeleteOldAssemblies ();
foreach (var dll in Directory.GetFiles (managedPath, "*.dll")) {
File.Delete (dll);
}
pipeline.Process (context); pipeline.Process (context);
} }
@ -318,6 +329,16 @@ namespace Ooui.Wasm.Build.Tasks
} }
} }
void RenameAssemblies ()
{
for (int i = 0; i < linkedAsmPaths.Count; i++) {
var path = linkedAsmPaths[i];
var newPath = Path.ChangeExtension(path, AssemblyExtension);
File.Move (path, newPath);
linkedAsmPaths[i] = newPath;
}
}
void ExtractClientJs () void ExtractClientJs ()
{ {
var oouiPath = refpaths.FirstOrDefault (x => Path.GetFileName (x).Equals ("Ooui.dll", StringComparison.InvariantCultureIgnoreCase)); var oouiPath = refpaths.FirstOrDefault (x => Path.GetFileName (x).Equals ("Ooui.dll", StringComparison.InvariantCultureIgnoreCase));

View File

@ -335,10 +335,12 @@ var Module = {
Module.FS_createPath ("/", "managed", true, true); Module.FS_createPath ("/", "managed", true, true);
var pending = 0; var pending = 0;
this.assemblies.forEach (function(asm_name) { var mangled_ext_re = new RegExp("\\.bin$");
this.assemblies.forEach (function(asm_mangled_name) {
var asm_name = asm_mangled_name.replace (mangled_ext_re, ".dll");
if (debug) console.log ("Loading", asm_name); if (debug) console.log ("Loading", asm_name);
++pending; ++pending;
fetch ("managed/" + asm_name, { credentials: 'same-origin' }).then (function (response) { fetch ("managed/" + asm_mangled_name, { credentials: 'same-origin' }).then (function (response) {
if (!response.ok) if (!response.ok)
throw "failed to load Assembly '" + asm_name + "'"; throw "failed to load Assembly '" + asm_name + "'";
return response['arrayBuffer'](); return response['arrayBuffer']();