From 0842c591c0c237195650e4ddb5f7b07fb54f4922 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 22 Jun 2017 18:55:10 -0700 Subject: [PATCH] Improvements for WebAssembly/Emscripten --- lime/project/HXProject.hx | 9 +++++- lime/tools/platforms/EmscriptenPlatform.hx | 35 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/lime/project/HXProject.hx b/lime/project/HXProject.hx index 7c14e398f..0a5920f47 100644 --- a/lime/project/HXProject.hx +++ b/lime/project/HXProject.hx @@ -141,7 +141,7 @@ class HXProject { platformType = PlatformType.WEB; architectures = []; - case HTML5, FIREFOX, EMSCRIPTEN: + case HTML5, FIREFOX: platformType = PlatformType.WEB; architectures = []; @@ -149,7 +149,14 @@ class HXProject { defaultWindow.width = 0; defaultWindow.height = 0; defaultWindow.fps = 60; + defaultWindow.allowHighDPI = false; + + case EMSCRIPTEN: + platformType = PlatformType.WEB; + architectures = []; + + defaultWindow.fps = 60; defaultWindow.allowHighDPI = false; case ANDROID, BLACKBERRY, IOS, TIZEN, WEBOS, TVOS: diff --git a/lime/tools/platforms/EmscriptenPlatform.hx b/lime/tools/platforms/EmscriptenPlatform.hx index 944e94443..13d4fef6a 100644 --- a/lime/tools/platforms/EmscriptenPlatform.hx +++ b/lime/tools/platforms/EmscriptenPlatform.hx @@ -74,9 +74,32 @@ class EmscriptenPlatform extends PlatformTarget { args = args.concat ([ prefix + "ApplicationMain" + (project.debug ? "-debug" : "") + ".a", "-o", "ApplicationMain.o" ]); ProcessHelper.runCommand (targetDirectory + "/obj", "emcc", args, true, false, true); - args = [ "ApplicationMain.o", "-s", "ASM_JS=1", "-s", "NO_EXIT_RUNTIME=1", "-s", "USE_SDL=2" ]; + args = [ "ApplicationMain.o" ]; - if (!project.debug) { + if (project.targetFlags.exists ("webassembly") || project.targetFlags.exists ("wasm")) { + + args.push ("-s"); + args.push ("WASM=1"); + + } else { + + args.push ("-s"); + args.push ("ASM_JS=1"); + + } + + args.push ("-s"); + args.push ("NO_EXIT_RUNTIME=1"); + args.push ("-s"); + args.push ("USE_SDL=2"); + + if (project.targetFlags.exists ("final")) { + + args.push ("-s"); + args.push ("DISABLE_EXCEPTION_CATCHING=0"); + args.push ("-O3"); + + } else if (!project.debug) { args.push ("-s"); args.push ("DISABLE_EXCEPTION_CATCHING=0"); @@ -99,6 +122,8 @@ class EmscriptenPlatform extends PlatformTarget { if (project.targetFlags.exists ("minify")) { + // 02 enables minification + //args.push ("--minify"); //args.push ("1"); //args.push ("--closure"); @@ -118,7 +143,11 @@ class EmscriptenPlatform extends PlatformTarget { } - if (LogHelper.verbose) args.push ("-v"); + if (LogHelper.verbose) { + + args.push ("-v"); + + } //if (project.targetFlags.exists ("compress")) { //