diff --git a/include.xml b/include.xml
index e3a3e8f1d..6080c706d 100644
--- a/include.xml
+++ b/include.xml
@@ -81,11 +81,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/src/lime/tools/Dependency.hx b/src/lime/tools/Dependency.hx
index 871aace97..64c3d6f50 100644
--- a/src/lime/tools/Dependency.hx
+++ b/src/lime/tools/Dependency.hx
@@ -6,6 +6,7 @@ class Dependency {
// TODO: Is "forceLoad" the best name? Implement "whole-archive" on GCC
+ public var embed:Bool;
public var forceLoad:Bool;
public var name:String;
public var path:String;
@@ -22,6 +23,7 @@ class Dependency {
public function clone ():Dependency {
var dependency = new Dependency (name, path);
+ dependency.embed = embed;
dependency.forceLoad = forceLoad;
return dependency;
diff --git a/src/lime/tools/ProjectXMLParser.hx b/src/lime/tools/ProjectXMLParser.hx
index 79fe6fc6d..a912b0c99 100644
--- a/src/lime/tools/ProjectXMLParser.hx
+++ b/src/lime/tools/ProjectXMLParser.hx
@@ -1916,9 +1916,15 @@ class ProjectXMLParser extends HXProject {
var dependency = new Dependency (name, path);
+ if (element.has.embed) {
+
+ dependency.embed = parseBool (element.att.embed);
+
+ }
+
if (element.has.resolve ("force-load")) {
- dependency.forceLoad = (substitute (element.att.resolve ("force-load")) == "true");
+ dependency.forceLoad = parseBool (element.att.resolve ("force-load"));
}
diff --git a/templates/html5/output.js b/templates/html5/output.js
index f1be029cc..96da95a74 100644
--- a/templates/html5/output.js
+++ b/templates/html5/output.js
@@ -1,3 +1,5 @@
+::if embeddedLibraries::::foreach (embeddedLibraries)::
+::__current__::::end::::end::
// lime.embed namespace wrapper
(function ($hx_exports, $global) { "use strict";
$hx_exports.lime = $hx_exports.lime || {};
diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx
index 908b7f2ac..a8feb141f 100644
--- a/tools/platforms/HTML5Platform.hx
+++ b/tools/platforms/HTML5Platform.hx
@@ -83,6 +83,19 @@ class HTML5Platform extends PlatformTarget {
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, "html5/output.js", outputFile, context);
}
@@ -341,16 +354,20 @@ class HTML5Platform extends PlatformTarget {
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);
- System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
+ var name = Path.withoutDirectory (dependency.path);
+
+ context.linkedLibraries.push ("./" + dependencyPath + "/" + name);
+ System.copyIfNewer (dependency.path, Path.combine (destination, Path.combine (dependencyPath, name)));
+
+ }
}