Revert WebAssembly improvements (moved to 8.1.0-Dev branch)
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<set name="tvos" value="1" if="appletv" />
|
||||
|
||||
<set name="LIME_CAIRO" value="1" />
|
||||
<set name="LIME_CURL" value="1" unless="winrt" />
|
||||
<set name="LIME_CURL" value="1" unless="emscripten || winrt" />
|
||||
<set name="LIME_EFSW" value="1" if="windows || mac || linux" unless="winrt" />
|
||||
<set name="LIME_JPEG" value="1" />
|
||||
<!-- <set name="LIME_FAUDIO" value="1" /> -->
|
||||
@@ -22,7 +22,7 @@
|
||||
<!-- <set name="LIME_NEKO" value="1" if="linux" /> -->
|
||||
<set name="LIME_OGG" value="1" />
|
||||
<set name="LIME_OPENALSOFT" value="1" if="windows || linux || mac || android" unless="static_link" />
|
||||
<set name="LIME_OPENAL" value="1" if="iphone || webassembly || tvos" />
|
||||
<set name="LIME_OPENAL" value="1" if="iphone || emscripten || tvos" />
|
||||
<set name="LIME_MOJOAL" value="1" if="switch || static_link || winrt || mojoal" unless="LIME_OPENAL" />
|
||||
<unset name="LIME_OPENALSOFT" if="LIME_MOJOAL" />
|
||||
<set name="LIME_OPENAL" value="1" if="LIME_OPENALSOFT" />
|
||||
|
||||
@@ -28,8 +28,6 @@ namespace lime {
|
||||
|
||||
static void GCEnterBlocking ();
|
||||
static void GCExitBlocking ();
|
||||
static void GCTryEnterBlocking ();
|
||||
static void GCTryExitBlocking ();
|
||||
static bool GetAllowScreenTimeout ();
|
||||
static std::wstring* GetDeviceModel ();
|
||||
static std::wstring* GetDeviceVendor ();
|
||||
|
||||
Submodule project/lib/cairo updated: 0d9ea82797...70d5bd67f3
Submodule project/lib/curl updated: c1b5625eda...3237f26170
@@ -42,6 +42,12 @@ namespace lime {
|
||||
|
||||
framePeriod = 1000.0 / 60.0;
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
emscripten_cancel_main_loop ();
|
||||
emscripten_set_main_loop (UpdateFrame, 0, 0);
|
||||
emscripten_set_main_loop_timing (EM_TIMING_RAF, 1);
|
||||
#endif
|
||||
|
||||
currentUpdate = 0;
|
||||
lastUpdate = 0;
|
||||
nextUpdate = 0;
|
||||
@@ -89,12 +95,6 @@ namespace lime {
|
||||
|
||||
Init ();
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
emscripten_cancel_main_loop ();
|
||||
emscripten_set_main_loop (UpdateFrame, 0, 0);
|
||||
emscripten_set_main_loop_timing (EM_TIMING_RAF, 1);
|
||||
#endif
|
||||
|
||||
#if defined(IPHONE) || defined(EMSCRIPTEN)
|
||||
|
||||
return 0;
|
||||
@@ -891,7 +891,7 @@ namespace lime {
|
||||
|
||||
currentUpdate = SDL_GetTicks ();
|
||||
|
||||
#if defined (IPHONE) || defined (EMSCRIPTEN)
|
||||
#if defined (IPHONE)
|
||||
|
||||
if (currentUpdate >= nextUpdate) {
|
||||
|
||||
@@ -901,6 +901,12 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
#elif defined (EMSCRIPTEN)
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
HandleEvent (&event);
|
||||
event.type = -1;
|
||||
|
||||
#else
|
||||
|
||||
if (currentUpdate >= nextUpdate) {
|
||||
@@ -926,16 +932,8 @@ namespace lime {
|
||||
|
||||
void SDLApplication::UpdateFrame () {
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
System::GCTryExitBlocking ();
|
||||
#endif
|
||||
|
||||
currentApplication->Update ();
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
System::GCTryEnterBlocking ();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -201,9 +201,7 @@ namespace lime {
|
||||
|
||||
// if (window->flags & WINDOW_FLAG_VSYNC) {
|
||||
|
||||
#ifdef EMSCRIPTEN
|
||||
sdlRendererFlags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
#endif
|
||||
// sdlRendererFlags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
#elif defined (EMSCRIPTEN)
|
||||
|
||||
#define LIME_GLES
|
||||
// #define LIME_GLES3_API
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#define LIME_GLES3_API
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl2ext.h>
|
||||
|
||||
#elif defined (TIZEN)
|
||||
|
||||
|
||||
@@ -42,28 +42,6 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void System::GCTryEnterBlocking () {
|
||||
|
||||
if (!_isHL) {
|
||||
|
||||
gc_try_blocking ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void System::GCTryExitBlocking () {
|
||||
|
||||
if (!_isHL) {
|
||||
|
||||
gc_try_unblocking ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#if defined (HX_WINDOWS) && !defined (HX_WINRT)
|
||||
std::wstring* GetWMIValue (BSTR query, BSTR field) {
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class Bytes
|
||||
return untyped $sget(b, pos);
|
||||
#elseif flash
|
||||
return b[pos];
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
return untyped b[pos];
|
||||
#elseif java
|
||||
return untyped b[pos] & 0xFF;
|
||||
@@ -72,7 +72,7 @@ class Bytes
|
||||
untyped $sset(b, pos, v);
|
||||
#elseif flash
|
||||
b[pos] = v;
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
untyped b[pos] = v;
|
||||
#elseif java
|
||||
b[pos] = cast v;
|
||||
@@ -104,7 +104,7 @@ class Bytes
|
||||
cs.system.Array.Copy(src.b, srcpos, b, pos, len);
|
||||
#elseif python
|
||||
python.Syntax.code("self.b[{0}:{0}+{1}] = src.b[srcpos:srcpos+{1}]", pos, len);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
b.blit(pos, src.b, srcpos, len);
|
||||
#else
|
||||
var b1 = b;
|
||||
@@ -136,7 +136,7 @@ class Bytes
|
||||
pos += len & ~3;
|
||||
for (i in 0...len & 3)
|
||||
set(pos++, value);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
untyped __global__.__hxcpp_memory_memset(b, pos, len, value);
|
||||
#else
|
||||
for (i in 0...len)
|
||||
@@ -206,7 +206,7 @@ class Bytes
|
||||
return length - other.length;
|
||||
// #elseif cs
|
||||
// TODO: memcmp if unsafe flag is on
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
return b.memcmp(other.b);
|
||||
#else
|
||||
var b1 = b;
|
||||
@@ -232,7 +232,7 @@ class Bytes
|
||||
#elseif flash
|
||||
b.position = pos;
|
||||
return b.readDouble();
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
if (pos < 0 || pos + 8 > length) throw Error.OutsideBounds;
|
||||
return untyped __global__.__hxcpp_memory_get_double(b, pos);
|
||||
#else
|
||||
@@ -254,7 +254,7 @@ class Bytes
|
||||
#elseif flash
|
||||
b.position = pos;
|
||||
return b.readFloat();
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
if (pos < 0 || pos + 4 > length) throw Error.OutsideBounds;
|
||||
return untyped __global__.__hxcpp_memory_get_float(b, pos);
|
||||
#else
|
||||
@@ -278,7 +278,7 @@ class Bytes
|
||||
#elseif flash
|
||||
b.position = pos;
|
||||
b.writeDouble(v);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
if (pos < 0 || pos + 8 > length) throw Error.OutsideBounds;
|
||||
untyped __global__.__hxcpp_memory_set_double(b, pos, v);
|
||||
#else
|
||||
@@ -304,7 +304,7 @@ class Bytes
|
||||
#elseif flash
|
||||
b.position = pos;
|
||||
b.writeFloat(v);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
if (pos < 0 || pos + 4 > length) throw Error.OutsideBounds;
|
||||
untyped __global__.__hxcpp_memory_set_float(b, pos, v);
|
||||
#else
|
||||
@@ -398,7 +398,7 @@ class Bytes
|
||||
#elseif flash
|
||||
b.position = pos;
|
||||
return b.readUTFBytes(len);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
var result:String = "";
|
||||
untyped __global__.__hxcpp_string_of_bytes(b, result, pos, len);
|
||||
return result;
|
||||
@@ -510,7 +510,7 @@ class Bytes
|
||||
var b = new flash.utils.ByteArray();
|
||||
b.length = length;
|
||||
return new Bytes(length, b);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
var a = new BytesData();
|
||||
if (length > 0) cpp.NativeArray.setSize(a, length);
|
||||
return new Bytes(length, a);
|
||||
@@ -540,7 +540,7 @@ class Bytes
|
||||
var b = new flash.utils.ByteArray();
|
||||
b.writeUTFBytes(s);
|
||||
return new Bytes(b.length, b);
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
var a = new BytesData();
|
||||
untyped __global__.__hxcpp_bytes_of_string(a, s);
|
||||
return new Bytes(a.length, a);
|
||||
@@ -638,7 +638,7 @@ class Bytes
|
||||
return untyped __dollar__sget(b, pos);
|
||||
#elseif flash
|
||||
return b[pos];
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
return untyped b.unsafeGet(pos);
|
||||
#elseif java
|
||||
return untyped b[pos] & 0xFF;
|
||||
|
||||
@@ -145,7 +145,7 @@ class NativeApplication
|
||||
#elseif lime_cffi
|
||||
var result = NativeCFFI.lime_application_exec(handle);
|
||||
|
||||
#if (!webassembly && !ios && !nodejs)
|
||||
#if (!emscripten && !ios && !nodejs)
|
||||
parent.onExit.dispatch(result);
|
||||
#end
|
||||
|
||||
|
||||
@@ -562,7 +562,7 @@ class NativeAudioSource
|
||||
{
|
||||
if (handle != null)
|
||||
{
|
||||
#if !webassembly
|
||||
#if !emscripten
|
||||
var value = AL.getSource3f(handle, AL.POSITION);
|
||||
position.x = value[0];
|
||||
position.y = value[1];
|
||||
|
||||
@@ -49,11 +49,8 @@ class DefineMacro
|
||||
Compiler.define("mobile");
|
||||
if (cffi) Compiler.define("lime-opengles");
|
||||
}
|
||||
else if (Context.defined("webassembly") || Context.defined("wasm") || Context.defined("emscripten"))
|
||||
else if (Context.defined("emscripten"))
|
||||
{
|
||||
Compiler.define("webassembly");
|
||||
Compiler.define("wasm");
|
||||
Compiler.define("emscripten");
|
||||
Compiler.define("web");
|
||||
if (cffi) Compiler.define("lime-opengles");
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class CFFI
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (cpp && (iphone || webassembly || android || static_link || tvos))
|
||||
#if (cpp && (iphone || emscripten || android || static_link || tvos))
|
||||
return cpp.Lib.load(library, method, args);
|
||||
#end
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lime.app.Event;
|
||||
#if haxe4
|
||||
import sys.thread.Deque;
|
||||
import sys.thread.Thread;
|
||||
#elseif (cpp || webassembly)
|
||||
#elseif cpp
|
||||
import cpp.vm.Deque;
|
||||
import cpp.vm.Thread;
|
||||
#elseif neko
|
||||
@@ -30,7 +30,7 @@ class ThreadPool
|
||||
public var onProgress = new Event<Dynamic->Void>();
|
||||
public var onRun = new Event<Dynamic->Void>();
|
||||
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
@:noCompletion private var __synchronous:Bool;
|
||||
@:noCompletion private var __workCompleted:Int;
|
||||
@:noCompletion private var __workIncoming = new Deque<ThreadPoolMessage>();
|
||||
@@ -45,12 +45,12 @@ class ThreadPool
|
||||
|
||||
currentThreads = 0;
|
||||
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
__workQueued = 0;
|
||||
__workCompleted = 0;
|
||||
#end
|
||||
|
||||
#if (webassembly || force_synchronous)
|
||||
#if (emscripten || force_synchronous)
|
||||
__synchronous = true;
|
||||
#end
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class ThreadPool
|
||||
// }
|
||||
public function queue(state:Dynamic = null):Void
|
||||
{
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
// TODO: Better way to handle this?
|
||||
|
||||
if (Application.current != null && Application.current.window != null && !__synchronous)
|
||||
@@ -98,7 +98,7 @@ class ThreadPool
|
||||
|
||||
public function sendComplete(state:Dynamic = null):Void
|
||||
{
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
if (!__synchronous)
|
||||
{
|
||||
__workResult.add(new ThreadPoolMessage(COMPLETE, state));
|
||||
@@ -111,7 +111,7 @@ class ThreadPool
|
||||
|
||||
public function sendError(state:Dynamic = null):Void
|
||||
{
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
if (!__synchronous)
|
||||
{
|
||||
__workResult.add(new ThreadPoolMessage(ERROR, state));
|
||||
@@ -124,7 +124,7 @@ class ThreadPool
|
||||
|
||||
public function sendProgress(state:Dynamic = null):Void
|
||||
{
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
if (!__synchronous)
|
||||
{
|
||||
__workResult.add(new ThreadPoolMessage(PROGRESS, state));
|
||||
@@ -137,7 +137,7 @@ class ThreadPool
|
||||
|
||||
@:noCompletion private function runWork(state:Dynamic = null):Void
|
||||
{
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
if (!__synchronous)
|
||||
{
|
||||
__workResult.add(new ThreadPoolMessage(WORK, state));
|
||||
@@ -150,7 +150,7 @@ class ThreadPool
|
||||
doWork.dispatch(state);
|
||||
}
|
||||
|
||||
#if (cpp || neko || webassembly)
|
||||
#if (cpp || neko)
|
||||
@:noCompletion private function __doWork():Void
|
||||
{
|
||||
while (true)
|
||||
|
||||
@@ -264,7 +264,7 @@ class AssetHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
if (project.target == WEB_ASSEMBLY
|
||||
if (project.target == EMSCRIPTEN
|
||||
&& (asset.embed != false
|
||||
|| (asset.library != null && libraries.exists(asset.library) && libraries[asset.library].preload)))
|
||||
{
|
||||
|
||||
@@ -85,7 +85,7 @@ class HTML5Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static function launch(project:HXProject, path:String, port:Int = 0):Void
|
||||
public static function launch(project:HXProject, path:String, port:Int = 3000):Void
|
||||
{
|
||||
if (project.app.url != null && project.app.url != "")
|
||||
{
|
||||
@@ -124,25 +124,27 @@ class HTML5Helper
|
||||
Sys.command("chmod", ["+x", node]);
|
||||
}
|
||||
|
||||
var args = [server, path, "-c-1", "--cors"];
|
||||
|
||||
if (project.targetFlags.exists("port"))
|
||||
{
|
||||
port = Std.parseInt(project.targetFlags.get("port"));
|
||||
}
|
||||
|
||||
if (port != 0)
|
||||
Log.info("", " - \x1b[1mStarting local web server:\x1b[0m http://localhost:" + port);
|
||||
|
||||
/*Thread.create (function () {
|
||||
|
||||
Sys.sleep (0.5);
|
||||
System.openURL ("http://localhost:" + port);
|
||||
|
||||
});*/
|
||||
|
||||
var args = [server, path, "-p", Std.string(port), "-c-1", "--cors"];
|
||||
|
||||
if (project.targetFlags.exists("nolaunch"))
|
||||
{
|
||||
args.push("-p");
|
||||
args.push(Std.string(port));
|
||||
Log.info("", "\x1b[1mStarting local web server:\x1b[0m http://localhost:" + port);
|
||||
Log.info("\x1b[1mStarting local web server:\x1b[0m http://localhost:" + port);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.info("", "\x1b[1mStarting local web server:\x1b[0m http://localhost:[3000*]");
|
||||
}
|
||||
|
||||
if (!project.targetFlags.exists("nolaunch"))
|
||||
{
|
||||
args.push("-o");
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ class HXProject extends Script
|
||||
case AIR if (targetFlags.exists("ios") || targetFlags.exists("android")):
|
||||
PlatformType.MOBILE;
|
||||
|
||||
case FLASH, HTML5, FIREFOX, WEB_ASSEMBLY:
|
||||
case FLASH, HTML5, FIREFOX, EMSCRIPTEN:
|
||||
PlatformType.WEB;
|
||||
|
||||
case ANDROID, BLACKBERRY, IOS, TIZEN, WEBOS, TVOS:
|
||||
|
||||
@@ -16,7 +16,6 @@ package lime.tools;
|
||||
var PS4 = "ps4";
|
||||
var TIZEN = "tizen";
|
||||
var VITA = "vita";
|
||||
var WEB_ASSEMBLY = "webassembly";
|
||||
var WINDOWS = "windows";
|
||||
var WEBOS = "webos";
|
||||
var WIIU = "wiiu";
|
||||
|
||||
@@ -140,17 +140,9 @@ class ProjectXMLParser extends HXProject
|
||||
defines.set("neko", "1");
|
||||
}
|
||||
}
|
||||
else if (target == Platform.WEB_ASSEMBLY)
|
||||
{
|
||||
defines.set("webassembly", "1");
|
||||
defines.set("wasm", "1");
|
||||
defines.set("emscripten", "1");
|
||||
defines.set("targetType", "cpp");
|
||||
defines.set("native", "1");
|
||||
defines.set("cpp", "1");
|
||||
}
|
||||
else if (targetFlags.exists("cpp")
|
||||
|| ((platformType != PlatformType.WEB) && !targetFlags.exists("html5")))
|
||||
|| ((platformType != PlatformType.WEB) && !targetFlags.exists("html5"))
|
||||
|| target == Platform.EMSCRIPTEN)
|
||||
{
|
||||
defines.set("targetType", "cpp");
|
||||
defines.set("native", "1");
|
||||
|
||||
@@ -31,9 +31,6 @@ class Log
|
||||
|
||||
if (throwErrors)
|
||||
{
|
||||
#if webassembly
|
||||
println(message);
|
||||
#end
|
||||
throw message;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -80,13 +80,8 @@ else if (colors) {
|
||||
};
|
||||
}
|
||||
|
||||
// CHANGE: Always show logger info
|
||||
if (!logger) logger = {};
|
||||
logger.info = console.log;
|
||||
|
||||
if (!port) {
|
||||
// CHANGE: Start finding ports beginning at port 3000
|
||||
portfinder.basePort = 3000;
|
||||
portfinder.basePort = 8080;
|
||||
portfinder.getPort(function (err, port) {
|
||||
if (err) { throw err; }
|
||||
listen(port);
|
||||
|
||||
2
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic.js
generated
vendored
2
templates/bin/node/http-server/node_modules/ecstatic/lib/ecstatic.js
generated
vendored
@@ -198,7 +198,7 @@ var ecstatic = module.exports = function (dir, options) {
|
||||
charSet;
|
||||
|
||||
if (contentType) {
|
||||
charSet = mime.charsets.lookup(contentType);
|
||||
charSet = mime.charsets.lookup(contentType, 'utf-8');
|
||||
if (charSet) {
|
||||
contentType += '; charset=' + charSet;
|
||||
}
|
||||
|
||||
2
templates/bin/node/http-server/node_modules/mime/types.json
generated
vendored
2
templates/bin/node/http-server/node_modules/mime/types.json
generated
vendored
File diff suppressed because one or more lines are too long
40
templates/emscripten/cpp/Main.cpp
Normal file
40
templates/emscripten/cpp/Main.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Main.mm
|
||||
*
|
||||
* Boot code for lime.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" const char *hxRunLibrary ();
|
||||
extern "C" void hxcpp_set_top_of_stack ();
|
||||
|
||||
extern "C" int zlib_register_prims ();
|
||||
extern "C" int lime_register_prims ();
|
||||
::foreach ndlls::::if (registerStatics)::extern "C" int ::nameSafe::_register_prims ();::end::
|
||||
::end::
|
||||
|
||||
|
||||
extern "C" int main (int argc, char *argv[]) {
|
||||
|
||||
hxcpp_set_top_of_stack ();
|
||||
|
||||
zlib_register_prims ();
|
||||
lime_register_prims ();
|
||||
::foreach ndlls::::if (registerStatics)::::nameSafe::_register_prims ();::end::
|
||||
::end::
|
||||
|
||||
const char *err = NULL;
|
||||
err = hxRunLibrary ();
|
||||
|
||||
if (err) {
|
||||
|
||||
printf (" Error %s\n", err);
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
-cp ::OUTPUT_DIR::/haxe
|
||||
-cpp ::CPP_DIR::
|
||||
--macro keep("::APP_MAIN::")
|
||||
-D webassembly
|
||||
-D wasm
|
||||
-D emscripten
|
||||
-D webgl
|
||||
-debug
|
||||
@@ -2,8 +2,6 @@
|
||||
-cp ::OUTPUT_DIR::/haxe
|
||||
-cpp ::CPP_DIR::
|
||||
--macro keep("::APP_MAIN::")
|
||||
-D webassembly
|
||||
-D wasm
|
||||
-D emscripten
|
||||
-D webgl
|
||||
-D final
|
||||
@@ -2,7 +2,5 @@
|
||||
-cp ::OUTPUT_DIR::/haxe
|
||||
-cpp ::CPP_DIR::
|
||||
--macro keep("::APP_MAIN::")
|
||||
-D webassembly
|
||||
-D wasm
|
||||
-D emscripten
|
||||
-D webgl
|
||||
@@ -9,9 +9,6 @@
|
||||
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
::if favicons::::foreach (favicons)::
|
||||
<link rel="::__current__.rel::" type="::__current__.type::" href="::__current__.href::">::end::::end::
|
||||
|
||||
::if linkedLibraries::::foreach (linkedLibraries)::
|
||||
<script type="text/javascript" src="::__current__::"></script>::end::::end::
|
||||
|
||||
@@ -49,6 +46,7 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var Module = {};
|
||||
Module.canvas = document.getElementById ("canvas");
|
||||
//::if DEBUG::Module.setStatus = function (msg) { console.log (msg); };::else::Module.setStatus = function(_) {};::end::
|
||||
@@ -58,13 +56,17 @@
|
||||
Module.canvas.width = container.clientWidth;
|
||||
Module.canvas.height = container.clientHeight;
|
||||
|
||||
window.addEventListener ("resize", function (e)
|
||||
{
|
||||
window.addEventListener ("resize", function (e) {
|
||||
|
||||
Module.canvas.width = container.clientWidth;
|
||||
Module.canvas.height = container.clientHeight;
|
||||
|
||||
}, true);::end::::end::
|
||||
|
||||
</script>
|
||||
|
||||
::if DEBUG::<script type="text/javascript" src="./webgl-debug.js"></script>::end::
|
||||
|
||||
<script type="text/javascript" src="./::APP_FILE::.js"></script>
|
||||
|
||||
</body>
|
||||
@@ -125,7 +125,7 @@ import ::APP_MAIN::;
|
||||
|
||||
var result = app.exec();
|
||||
|
||||
#if (sys && !ios && !nodejs && !webassembly)
|
||||
#if (sys && !ios && !nodejs && !emscripten)
|
||||
lime.system.System.exit(result);
|
||||
#end
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ import sys.FileSystem;
|
||||
|
||||
if (rootPath == null) {
|
||||
|
||||
#if (ios || tvos || webassembly)
|
||||
#if (ios || tvos || emscripten)
|
||||
rootPath = "assets/";
|
||||
#elseif android
|
||||
rootPath = "";
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
::SOURCE_FILE::
|
||||
::if embeddedLibraries::::foreach (embeddedLibraries)::
|
||||
::__current__::::end::::end::
|
||||
@@ -287,8 +287,8 @@ class CommandLineTools
|
||||
target = Platform.LINUX;
|
||||
targetFlags.set("rpi", "");
|
||||
|
||||
case "webassembly", "wasm", "emscripten":
|
||||
target = Platform.WEB_ASSEMBLY;
|
||||
case "webassembly", "wasm":
|
||||
target = Platform.EMSCRIPTEN;
|
||||
targetFlags.set("webassembly", "");
|
||||
|
||||
default:
|
||||
@@ -622,8 +622,8 @@ class CommandLineTools
|
||||
|
||||
// platform = new FirefoxPlatform (command, project, targetFlags);
|
||||
|
||||
case WEB_ASSEMBLY:
|
||||
platform = new WebAssemblyPlatform(command, project, targetFlags);
|
||||
case EMSCRIPTEN:
|
||||
platform = new EmscriptenPlatform(command, project, targetFlags);
|
||||
|
||||
case TVOS:
|
||||
platform = new TVOSPlatform(command, project, targetFlags);
|
||||
@@ -916,6 +916,7 @@ class CommandLineTools
|
||||
Log.println(" \x1b[1mair\x1b[0m -- Create an AIR application");
|
||||
Log.println(" \x1b[1mandroid\x1b[0m -- Create an Android application");
|
||||
// Log.println (" \x1b[1mblackberry\x1b[0m -- Create a BlackBerry application");
|
||||
Log.println(" \x1b[1memscripten\x1b[0m -- Create an Emscripten application");
|
||||
Log.println(" \x1b[1mflash\x1b[0m -- Create a Flash SWF application");
|
||||
Log.println(" \x1b[1mhtml5\x1b[0m -- Create an HTML5 application");
|
||||
Log.println(" \x1b[1mios\x1b[0m -- Create an iOS application");
|
||||
@@ -924,7 +925,6 @@ class CommandLineTools
|
||||
// Log.println (" \x1b[1mtizen\x1b[0m -- Create a Tizen application");
|
||||
Log.println(" \x1b[1mtvos\x1b[0m -- Create a tvOS application");
|
||||
// Log.println (" \x1b[1mwebos\x1b[0m -- Create a webOS application");
|
||||
Log.println(" \x1b[1mwebassembly\x1b[0m -- Create a WebAssembly application");
|
||||
Log.println(" \x1b[1mwindows\x1b[0m -- Create a Windows application");
|
||||
|
||||
Log.println("");
|
||||
@@ -947,7 +947,7 @@ class CommandLineTools
|
||||
// Log.println (" \x1b[1mappletvsim\x1b[0m -- Alias for \x1b[1mtvos -simulator\x1b[0m");
|
||||
Log.println(" \x1b[1mrpi\x1b[0;3m/\x1b[0m\x1b[1mraspberrypi\x1b[0m -- Alias for \x1b[1mlinux -rpi\x1b[0m");
|
||||
Log.println(" \x1b[1melectron\x1b[0m -- Alias for \x1b[1mhtml5 -electron\x1b[0m");
|
||||
Log.println(" \x1b[1mwasm/emscripten\x1b[0m -- Alias for \x1b[1mwebassembly\x1b[0m");
|
||||
Log.println(" \x1b[1mwebassembly\x1b[0;3m/\x1b[0m\x1b[1mwasm\x1b[0m -- Alias for \x1b[1memscripten -webassembly\x1b[0m");
|
||||
}
|
||||
|
||||
Log.println("");
|
||||
@@ -1030,15 +1030,16 @@ class CommandLineTools
|
||||
|
||||
if (command != "run" && command != "trace")
|
||||
{
|
||||
Log.println(" \x1b[3m(html5|webassembly)\x1b[0m \x1b[1m-minify\x1b[0m -- Minify application file");
|
||||
Log.println(" \x1b[3m(emscripten)\x1b[0m \x1b[1m-webassembly\x1b[0m -- Compile for WebAssembly instead of asm.js");
|
||||
Log.println(" \x1b[3m(emscripten|html5)\x1b[0m \x1b[1m-minify\x1b[0m -- Minify application file");
|
||||
}
|
||||
|
||||
if (command == "run" || command == "test")
|
||||
{
|
||||
Log.println(" \x1b[3m(html5|flash|webassembly)\x1b[0m \x1b[1m-nolaunch\x1b[0m -- Begin test server without launching");
|
||||
Log.println(" \x1b[3m(emscripten|html5|flash)\x1b[0m \x1b[1m-nolaunch\x1b[0m -- Begin test server without launching");
|
||||
// Log.println (" \x1b[3m(html5)\x1b[0m \x1b[1m-minify\x1b[0m -- Minify output using the Google Closure compiler");
|
||||
// Log.println (" \x1b[3m(html5)\x1b[0m \x1b[1m-minify -yui\x1b[0m -- Minify output using the YUI compressor");
|
||||
Log.println(" \x1b[3m(html5|flash|webassembly)\x1b[0m \x1b[1m--port=\x1b[0;3mvalue\x1b[0m -- Set port for test server");
|
||||
Log.println(" \x1b[3m(emscripten|html5|flash)\x1b[0m \x1b[1m--port=\x1b[0;3mvalue\x1b[0m -- Set port for test server");
|
||||
}
|
||||
|
||||
Log.println("");
|
||||
@@ -1561,8 +1562,8 @@ class CommandLineTools
|
||||
target = Platform.LINUX;
|
||||
targetFlags.set("rpi", "");
|
||||
|
||||
case "webassembly", "wasm", "emscripten":
|
||||
target = Platform.WEB_ASSEMBLY;
|
||||
case "webassembly", "wasm":
|
||||
target = Platform.EMSCRIPTEN;
|
||||
targetFlags.set("webassembly", "");
|
||||
|
||||
case "winjs", "uwp":
|
||||
|
||||
@@ -13,17 +13,14 @@ import lime.tools.CPPHelper;
|
||||
import lime.tools.DeploymentHelper;
|
||||
import lime.tools.HTML5Helper;
|
||||
import lime.tools.HXProject;
|
||||
import lime.tools.Icon;
|
||||
import lime.tools.IconHelper;
|
||||
import lime.tools.Orientation;
|
||||
import lime.tools.PlatformTarget;
|
||||
import lime.tools.ProjectHelper;
|
||||
import sys.io.File;
|
||||
import sys.FileSystem;
|
||||
|
||||
class WebAssemblyPlatform extends PlatformTarget
|
||||
class EmscriptenPlatform extends PlatformTarget
|
||||
{
|
||||
private var dependencyPath:String;
|
||||
private var outputFile:String;
|
||||
|
||||
public function new(command:String, _project:HXProject, targetFlags:Map<String, String>)
|
||||
@@ -94,8 +91,7 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
defaults.merge(project);
|
||||
project = defaults;
|
||||
|
||||
targetDirectory = Path.combine(project.app.path, project.config.getString("webassembly.output-directory", "webassembly"));
|
||||
dependencyPath = project.config.getString("webassembly.dependency-path", "lib");
|
||||
targetDirectory = Path.combine(project.app.path, project.config.getString("emscripten.output-directory", "emscripten"));
|
||||
outputFile = targetDirectory + "/bin/" + project.app.file + ".js";
|
||||
}
|
||||
|
||||
@@ -114,11 +110,11 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
|
||||
if (sdkPath == null)
|
||||
{
|
||||
Log.error("You must define EMSCRIPTEN_SDK with the path to your Emscripten SDK.");
|
||||
Log.error("You must define EMSCRIPTEN_SDK with the path to your Emscripten SDK");
|
||||
}
|
||||
|
||||
var hxml = targetDirectory + "/haxe/" + buildType + ".hxml";
|
||||
var args = [hxml, "-D", "webassembly", "-D", "wasm", "-D", "emscripten", "-D", "webgl", "-D", "static_link"];
|
||||
var args = [hxml, "-D", "emscripten", "-D", "webgl", "-D", "static_link"];
|
||||
|
||||
if (Log.verbose)
|
||||
{
|
||||
@@ -130,12 +126,11 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
|
||||
if (noOutput) return;
|
||||
|
||||
CPPHelper.compile(project, targetDirectory + "/obj", ["-Dwebassembly", "-Dwasm", "-Demscripten", "-Dwebgl", "-Dstatic_link"]);
|
||||
// CPPHelper.compile(project, targetDirectory + "/obj", ["-Demscripten", "-Dwebgl", "-Dstatic_link"], "BuildMain.xml");
|
||||
CPPHelper.compile(project, targetDirectory + "/obj", ["-Demscripten", "-Dwebgl", "-Dstatic_link"]);
|
||||
|
||||
project.path(sdkPath);
|
||||
|
||||
System.runCommand("", "emcc", ["-c", targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o"], true, false, true);
|
||||
System.runCommand("", "emcc", [targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o"], true, false, true);
|
||||
|
||||
args = ["Main.o"];
|
||||
|
||||
@@ -164,8 +159,11 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
"-o",
|
||||
"ApplicationMain.o"
|
||||
]);
|
||||
System.runCommand(targetDirectory + "/obj", "emcc", args, true, false, true);
|
||||
|
||||
if (!project.targetFlags.exists("asmjs"))
|
||||
args = ["ApplicationMain.o"];
|
||||
|
||||
if (project.targetFlags.exists("webassembly") || project.targetFlags.exists("wasm"))
|
||||
{
|
||||
args.push("-s");
|
||||
args.push("WASM=1");
|
||||
@@ -190,56 +188,29 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
}
|
||||
}
|
||||
|
||||
if (project.targetFlags.exists("final") || project.defines.exists("disable-exception-catching") || project.targetFlags.exists("disable-exception-catching"))
|
||||
if (project.targetFlags.exists("final"))
|
||||
{
|
||||
args.push("-s");
|
||||
args.push("DISABLE_EXCEPTION_CATCHING=1");
|
||||
args.push("DISABLE_EXCEPTION_CATCHING=0");
|
||||
args.push("-O3");
|
||||
}
|
||||
else if (!project.debug)
|
||||
{
|
||||
args.push("-s");
|
||||
args.push("DISABLE_EXCEPTION_CATCHING=0");
|
||||
// args.push ("-s");
|
||||
// args.push ("OUTLINING_LIMIT=70000");
|
||||
args.push("-O2");
|
||||
}
|
||||
else
|
||||
{
|
||||
args.push("-gsource-map");
|
||||
args.push("-s");
|
||||
args.push("DISABLE_EXCEPTION_CATCHING=0");
|
||||
args.push("-s");
|
||||
args.push("NO_DISABLE_EXCEPTION_CATCHING=1");
|
||||
args.push("DISABLE_EXCEPTION_CATCHING=2");
|
||||
args.push("-s");
|
||||
args.push("ASSERTIONS=1");
|
||||
// args.push("-s");
|
||||
// args.push("ASSERTIONS=2");
|
||||
// args.push("-s");
|
||||
// args.push("STACK_OVERFLOW_CHECK=2");
|
||||
// args.push("-s");
|
||||
// args.push("DEMANGLE_SUPPORT=1");
|
||||
args.push("-O1");
|
||||
}
|
||||
|
||||
// set initial size
|
||||
// args.push("-s");
|
||||
// args.push("INITIAL_MEMORY=32MB");
|
||||
|
||||
args.push("-s");
|
||||
args.push("STACK_SIZE=1MB");
|
||||
|
||||
// args.push("-s");
|
||||
// args.push("SAFE_HEAP=1");
|
||||
|
||||
// if (project.targetFlags.exists("final"))
|
||||
// {
|
||||
// args.push("-O3");
|
||||
// }
|
||||
// else if (!project.debug)
|
||||
// {
|
||||
// // args.push ("-s");
|
||||
// // args.push ("OUTLINING_LIMIT=70000");
|
||||
// args.push("-O2");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// args.push("-O1");
|
||||
// }
|
||||
|
||||
// https://github.com/HaxeFoundation/hxcpp/issues/987
|
||||
args.push("-O0");
|
||||
|
||||
args.push("-s");
|
||||
args.push("ALLOW_MEMORY_GROWTH=1");
|
||||
|
||||
@@ -288,24 +259,6 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
|
||||
System.runCommand(targetDirectory + "/obj", "emcc", args, true, false, true);
|
||||
|
||||
if (FileSystem.exists(outputFile))
|
||||
{
|
||||
var context = project.templateContext;
|
||||
context.SOURCE_FILE = File.getContent(outputFile);
|
||||
context.embeddedLibraries = [];
|
||||
|
||||
for (dependency in project.dependencies)
|
||||
{
|
||||
if (dependency.embed && StringTools.endsWith(dependency.path, ".js") && FileSystem.exists(dependency.path))
|
||||
{
|
||||
var script = File.getContent(dependency.path);
|
||||
context.embeddedLibraries.push(script);
|
||||
}
|
||||
}
|
||||
|
||||
System.copyFileTemplate(project.templatePaths, "webassembly/output.js", outputFile, context);
|
||||
}
|
||||
|
||||
if (project.targetFlags.exists("minify"))
|
||||
{
|
||||
HTML5Helper.minify(project, targetDirectory + "/bin/" + project.app.file + ".js");
|
||||
@@ -340,7 +293,7 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
|
||||
public override function deploy():Void
|
||||
{
|
||||
DeploymentHelper.deploy(project, targetFlags, targetDirectory, "WebAssembly");
|
||||
DeploymentHelper.deploy(project, targetFlags, targetDirectory, "Emscripten");
|
||||
}
|
||||
|
||||
public override function display():Void
|
||||
@@ -377,7 +330,7 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
|
||||
public override function rebuild():Void
|
||||
{
|
||||
CPPHelper.rebuild(project, [["-Dwebassembly", "-Dwasm", "-Demscripten", "-Dstatic_link"]]);
|
||||
CPPHelper.rebuild(project, [["-Demscripten", "-Dstatic_link"]]);
|
||||
}
|
||||
|
||||
public override function run():Void
|
||||
@@ -402,10 +355,10 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
}
|
||||
}
|
||||
|
||||
// for (asset in project.assets)
|
||||
// {
|
||||
// asset.resourceName = "assets/" + asset.resourceName;
|
||||
// }
|
||||
for (asset in project.assets)
|
||||
{
|
||||
asset.resourceName = "assets/" + asset.resourceName;
|
||||
}
|
||||
|
||||
var destination = targetDirectory + "/bin/";
|
||||
System.mkdir(destination);
|
||||
@@ -433,44 +386,6 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
context.CPP_DIR = targetDirectory + "/obj";
|
||||
context.USE_COMPRESSION = project.targetFlags.exists("compress");
|
||||
|
||||
context.favicons = [];
|
||||
|
||||
var icons = project.icons;
|
||||
|
||||
if (icons.length == 0)
|
||||
{
|
||||
icons = [new Icon(System.findTemplate(project.templatePaths, "default/icon.svg"))];
|
||||
}
|
||||
|
||||
// if (IconHelper.createWindowsIcon (icons, Path.combine (destination, "favicon.ico"))) {
|
||||
//
|
||||
// context.favicons.push ({ rel: "icon", type: "image/x-icon", href: "./favicon.ico" });
|
||||
//
|
||||
// }
|
||||
|
||||
if (IconHelper.createIcon(icons, 192, 192, Path.combine(destination, "favicon.png")))
|
||||
{
|
||||
context.favicons.push({rel: "shortcut icon", type: "image/png", href: "./favicon.png"});
|
||||
}
|
||||
|
||||
for (dependency in project.dependencies)
|
||||
{
|
||||
if (!dependency.embed)
|
||||
{
|
||||
if (StringTools.endsWith(dependency.name, ".js"))
|
||||
{
|
||||
context.linkedLibraries.push(dependency.name);
|
||||
}
|
||||
else if (StringTools.endsWith(dependency.path, ".js") && FileSystem.exists(dependency.path))
|
||||
{
|
||||
var name = Path.withoutDirectory(dependency.path);
|
||||
|
||||
context.linkedLibraries.push("./" + dependencyPath + "/" + name);
|
||||
System.copyIfNewer(dependency.path, Path.combine(destination, Path.combine(dependencyPath, name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (asset in project.assets)
|
||||
{
|
||||
var path = Path.combine(targetDirectory + "/obj/assets", asset.targetPath);
|
||||
@@ -486,11 +401,10 @@ class WebAssemblyPlatform extends PlatformTarget
|
||||
}
|
||||
}
|
||||
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "webassembly/template", destination, context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/template", destination, context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "haxe", targetDirectory + "/haxe", context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "webassembly/hxml", targetDirectory + "/haxe", context);
|
||||
// ProjectHelper.recursiveSmartCopyTemplate(project, "webassembly/cpp", targetDirectory + "/obj", context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "cpp/static", targetDirectory + "/obj", context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/hxml", targetDirectory + "/haxe", context);
|
||||
ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/cpp", targetDirectory + "/obj", context);
|
||||
|
||||
for (asset in project.assets)
|
||||
{
|
||||
@@ -369,6 +369,9 @@ class PlatformSetup
|
||||
|
||||
// setupBlackBerry ();
|
||||
|
||||
case "emscripten", "webassembly", "wasm":
|
||||
setupEmscripten();
|
||||
|
||||
case "html5":
|
||||
Log.println("\x1b[0;3mNo additional configuration is required.\x1b[0m");
|
||||
// setupHTML5 ();
|
||||
@@ -395,9 +398,6 @@ class PlatformSetup
|
||||
|
||||
// setupTizen ();
|
||||
|
||||
case "webassembly", "wasm", "emscripten":
|
||||
setupWebAssembly();
|
||||
|
||||
case "webos":
|
||||
|
||||
// setupWebOS ();
|
||||
@@ -625,6 +625,18 @@ class PlatformSetup
|
||||
Log.println("Setup complete.");
|
||||
}
|
||||
|
||||
public static function setupEmscripten():Void
|
||||
{
|
||||
Log.println("\x1b[1mIn order to build for WebAssembly or asm.js, you must download");
|
||||
Log.println("and install the Emscripten SDK.");
|
||||
Log.println("");
|
||||
|
||||
getDefineValue("EMSCRIPTEN_SDK", "Path to Emscripten SDK");
|
||||
|
||||
Log.println("");
|
||||
Log.println("Setup complete.");
|
||||
}
|
||||
|
||||
public static function setupHaxelib(haxelib:Haxelib, dependency:Bool = false):Void
|
||||
{
|
||||
setupHaxelibs.set(haxelib.name, true);
|
||||
@@ -1153,20 +1165,6 @@ class PlatformSetup
|
||||
}
|
||||
}
|
||||
|
||||
public static function setupWebAssembly():Void
|
||||
{
|
||||
Log.println("\x1b[1mIn order to build for WebAssembly or asm.js, you must download");
|
||||
Log.println("and install the Emscripten SDK.");
|
||||
Log.println("");
|
||||
Log.println("After install, the SDK path may be at \"emsdk/upstream/emscripten\"");
|
||||
Log.println("");
|
||||
|
||||
getDefineValue("EMSCRIPTEN_SDK", "Path to Emscripten SDK");
|
||||
|
||||
Log.println("");
|
||||
Log.println("Setup complete.");
|
||||
}
|
||||
|
||||
public static function setupWindows():Void
|
||||
{
|
||||
Log.println("\x1b[1mIn order to build native executables for Windows, you must have a");
|
||||
|
||||
Reference in New Issue
Block a user