Add support for embedded JS dependencies (embed Lime dependencies by default)
This commit is contained in:
10
include.xml
10
include.xml
@@ -81,11 +81,11 @@
|
|||||||
<ndll name="lime" if="native" unless="lime-console static_link || lime-switch static_link" />
|
<ndll name="lime" if="native" unless="lime-console static_link || lime-switch static_link" />
|
||||||
|
|
||||||
<dependency name="extension-api" path="dependencies/extension-api" if="android" />
|
<dependency name="extension-api" path="dependencies/extension-api" if="android" />
|
||||||
<dependency path="dependencies/howler.min.js" if="html5 howlerjs" />
|
<dependency path="dependencies/howler.min.js" if="html5 howlerjs" embed="true" />
|
||||||
<dependency path="dependencies/pako.min.js" if="html5" />
|
<dependency path="dependencies/pako.min.js" if="html5" embed="true" />
|
||||||
<dependency path="dependencies/FileSaver.min.js" if="html5" />
|
<dependency path="dependencies/FileSaver.min.js" if="html5" embed="true" />
|
||||||
<dependency path="dependencies/webgl-debug.js" if="html5 webgl-debug" />
|
<dependency path="dependencies/webgl-debug.js" if="html5 webgl-debug" embed="true" />
|
||||||
<dependency path="dependencies/stats.min.js" if="html5 stats" />
|
<dependency path="dependencies/stats.min.js" if="html5 stats" embed="true" />
|
||||||
<dependency path="dependencies/angle/d3dcompiler_47.dll" if="windows angle" unless="static_link" />
|
<dependency path="dependencies/angle/d3dcompiler_47.dll" if="windows angle" unless="static_link" />
|
||||||
<dependency path="dependencies/angle/libegl.dll" if="windows angle" unless="static_link" />
|
<dependency path="dependencies/angle/libegl.dll" if="windows angle" unless="static_link" />
|
||||||
<dependency path="dependencies/angle/libglesv2.dll" if="windows angle" unless="static_link" />
|
<dependency path="dependencies/angle/libglesv2.dll" if="windows angle" unless="static_link" />
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class Dependency {
|
|||||||
|
|
||||||
// TODO: Is "forceLoad" the best name? Implement "whole-archive" on GCC
|
// TODO: Is "forceLoad" the best name? Implement "whole-archive" on GCC
|
||||||
|
|
||||||
|
public var embed:Bool;
|
||||||
public var forceLoad:Bool;
|
public var forceLoad:Bool;
|
||||||
public var name:String;
|
public var name:String;
|
||||||
public var path:String;
|
public var path:String;
|
||||||
@@ -22,6 +23,7 @@ class Dependency {
|
|||||||
public function clone ():Dependency {
|
public function clone ():Dependency {
|
||||||
|
|
||||||
var dependency = new Dependency (name, path);
|
var dependency = new Dependency (name, path);
|
||||||
|
dependency.embed = embed;
|
||||||
dependency.forceLoad = forceLoad;
|
dependency.forceLoad = forceLoad;
|
||||||
return dependency;
|
return dependency;
|
||||||
|
|
||||||
|
|||||||
@@ -1916,9 +1916,15 @@ class ProjectXMLParser extends HXProject {
|
|||||||
|
|
||||||
var dependency = new Dependency (name, path);
|
var dependency = new Dependency (name, path);
|
||||||
|
|
||||||
|
if (element.has.embed) {
|
||||||
|
|
||||||
|
dependency.embed = parseBool (element.att.embed);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (element.has.resolve ("force-load")) {
|
if (element.has.resolve ("force-load")) {
|
||||||
|
|
||||||
dependency.forceLoad = (substitute (element.att.resolve ("force-load")) == "true");
|
dependency.forceLoad = parseBool (element.att.resolve ("force-load"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
::if embeddedLibraries::::foreach (embeddedLibraries)::
|
||||||
|
::__current__::::end::::end::
|
||||||
// lime.embed namespace wrapper
|
// lime.embed namespace wrapper
|
||||||
(function ($hx_exports, $global) { "use strict";
|
(function ($hx_exports, $global) { "use strict";
|
||||||
$hx_exports.lime = $hx_exports.lime || {};
|
$hx_exports.lime = $hx_exports.lime || {};
|
||||||
|
|||||||
@@ -83,6 +83,19 @@ class HTML5Platform extends PlatformTarget {
|
|||||||
|
|
||||||
var context = project.templateContext;
|
var context = project.templateContext;
|
||||||
context.SOURCE_FILE = File.getContent (outputFile);
|
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, "html5/output.js", outputFile, context);
|
System.copyFileTemplate (project.templatePaths, "html5/output.js", outputFile, context);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -341,16 +354,20 @@ class HTML5Platform extends PlatformTarget {
|
|||||||
|
|
||||||
for (dependency in project.dependencies) {
|
for (dependency in project.dependencies) {
|
||||||
|
|
||||||
if (StringTools.endsWith (dependency.name, ".js")) {
|
if (!dependency.embed) {
|
||||||
|
|
||||||
context.linkedLibraries.push (dependency.name);
|
if (StringTools.endsWith (dependency.name, ".js")) {
|
||||||
|
|
||||||
} else if (StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
|
context.linkedLibraries.push (dependency.name);
|
||||||
|
|
||||||
var name = Path.withoutDirectory (dependency.path);
|
} else if (StringTools.endsWith (dependency.path, ".js") && FileSystem.exists (dependency.path)) {
|
||||||
|
|
||||||
context.linkedLibraries.push ("./" + dependencyPath + "/" + name);
|
var name = Path.withoutDirectory (dependency.path);
|
||||||
System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
|
|
||||||
|
context.linkedLibraries.push ("./" + dependencyPath + "/" + name);
|
||||||
|
System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user