From a04b511461b1d0f55255eb244fc386b5fcf8252b Mon Sep 17 00:00:00 2001 From: "Frank A. Krueger" Date: Wed, 25 Apr 2018 18:12:37 -0700 Subject: [PATCH] Rename wasm dlls to bins This is to help them get through corporate networks. Fixes #92 --- Ooui.Wasm.Build.Tasks/BuildDistTask.cs | 29 ++++++++++++++++++++++---- Ooui/Client.js | 6 ++++-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Ooui.Wasm.Build.Tasks/BuildDistTask.cs b/Ooui.Wasm.Build.Tasks/BuildDistTask.cs index c889e0a..3cc2ec0 100644 --- a/Ooui.Wasm.Build.Tasks/BuildDistTask.cs +++ b/Ooui.Wasm.Build.Tasks/BuildDistTask.cs @@ -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 AssemblyExtension = ".bin"; + [Required] public string Assembly { get; set; } [Required] @@ -33,8 +35,10 @@ namespace Ooui.Wasm.Build.Tasks InstallSdk (); GetBcl (); CreateDist (); + DeleteOldAssemblies (); CopyRuntime (); LinkAssemblies (); + RenameAssemblies (); ExtractClientJs (); DiscoverEntryPoint (); GenerateHtml (); @@ -98,6 +102,16 @@ namespace Ooui.Wasm.Build.Tasks 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 () { var rtPath = Path.Combine (sdkPath, "release"); @@ -154,10 +168,7 @@ namespace Ooui.Wasm.Build.Tasks } pipeline.AddStepAfter (typeof (LoadReferencesStep), new LoadI18nAssemblies (I18nAssemblies.None)); - - foreach (var dll in Directory.GetFiles (managedPath, "*.dll")) { - File.Delete (dll); - } + DeleteOldAssemblies (); 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 () { var oouiPath = refpaths.FirstOrDefault (x => Path.GetFileName (x).Equals ("Ooui.dll", StringComparison.InvariantCultureIgnoreCase)); diff --git a/Ooui/Client.js b/Ooui/Client.js index 7a271ef..2534b79 100644 --- a/Ooui/Client.js +++ b/Ooui/Client.js @@ -335,10 +335,12 @@ var Module = { Module.FS_createPath ("/", "managed", true, true); 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); ++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) throw "failed to load Assembly '" + asm_name + "'"; return response['arrayBuffer']();