From 3cd245682e1a3a3c74f990595a18aa70a00acee4 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 23 Jun 2017 16:30:15 -0700 Subject: [PATCH] Fix Emscripten asset support, fix Log.verbose on Emscripten builds --- lime/system/ThreadPool.hx | 4 ++++ lime/tools/helpers/AssetHelper.hx | 6 ++++++ lime/tools/platforms/EmscriptenPlatform.hx | 12 ++++++++++-- templates/haxe/ManifestResources.hx | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lime/system/ThreadPool.hx b/lime/system/ThreadPool.hx index 1d1c2d6cb..1ac0c5605 100644 --- a/lime/system/ThreadPool.hx +++ b/lime/system/ThreadPool.hx @@ -50,6 +50,10 @@ class ThreadPool { __workCompleted = 0; #end + #if emscripten + __synchronous = true; + #end + } diff --git a/lime/tools/helpers/AssetHelper.hx b/lime/tools/helpers/AssetHelper.hx index 8c305d7b6..94fd6b641 100644 --- a/lime/tools/helpers/AssetHelper.hx +++ b/lime/tools/helpers/AssetHelper.hx @@ -111,6 +111,12 @@ class AssetHelper { } else { + if (project.target == EMSCRIPTEN && (asset.embed != false || (asset.library != null && libraries.exists (asset.library) && libraries[asset.library].preload))) { + + assetData.preload = true; + + } + if (asset.embed == true || asset.type == FONT) { assetData.className = "__ASSET__" + asset.flatName; diff --git a/lime/tools/platforms/EmscriptenPlatform.hx b/lime/tools/platforms/EmscriptenPlatform.hx index 1ed8aafab..0328d0acd 100644 --- a/lime/tools/platforms/EmscriptenPlatform.hx +++ b/lime/tools/platforms/EmscriptenPlatform.hx @@ -38,8 +38,16 @@ class EmscriptenPlatform extends PlatformTarget { public override function build ():Void { var hxml = targetDirectory + "/haxe/" + buildType + ".hxml"; + var args = [ hxml, "-D", "emscripten", "-D", "webgl", "-D", "static_link"]; - ProcessHelper.runCommand ("", "haxe", [ hxml, "-D", "emscripten", "-D", "webgl", "-D", "static_link" ] ); + if (LogHelper.verbose) { + + args.push ("-D"); + args.push ("verbose"); + + } + + ProcessHelper.runCommand ("", "haxe", args); if (noOutput) return; @@ -53,7 +61,7 @@ class EmscriptenPlatform extends PlatformTarget { ProcessHelper.runCommand ("", "emcc", [ targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o" ], true, false, true); - var args = [ "Main.o" ]; + args = [ "Main.o" ]; for (ndll in project.ndlls) { diff --git a/templates/haxe/ManifestResources.hx b/templates/haxe/ManifestResources.hx index f8763f69d..cc07f4b15 100644 --- a/templates/haxe/ManifestResources.hx +++ b/templates/haxe/ManifestResources.hx @@ -35,7 +35,7 @@ import sys.FileSystem; if (rootPath == null) { - #if (ios || tvos) + #if (ios || tvos || emscripten) rootPath = "assets/"; #elseif (windows && !cs) rootPath = FileSystem.absolutePath (haxe.io.Path.directory (#if (haxe_ver >= 3.3) Sys.programPath () #else Sys.executablePath () #end)) + "/";