Add target support for Electron (#1157)
* add initial support for Electron
This commit is contained in:
committed by
Joshua Granick
parent
dccc2da7cb
commit
e45f0dd51d
@@ -264,7 +264,6 @@ class CommandLineTools {
|
||||
}
|
||||
|
||||
for (targetName in targets) {
|
||||
|
||||
var target = null;
|
||||
|
||||
switch (targetName) {
|
||||
@@ -284,6 +283,10 @@ class CommandLineTools {
|
||||
target = PlatformHelper.hostPlatform;
|
||||
targetFlags.set ("nodejs", "");
|
||||
|
||||
case "electron":
|
||||
target = Platform.HTML5;
|
||||
targetFlags.set ("electron", "");
|
||||
|
||||
case "cs":
|
||||
|
||||
target = PlatformHelper.hostPlatform;
|
||||
@@ -717,7 +720,12 @@ class CommandLineTools {
|
||||
|
||||
case HTML5:
|
||||
|
||||
platform = new HTML5Platform (command, project, targetFlags);
|
||||
if (targetFlags.exists("electron")) {
|
||||
platform = new ElectronPlatform (command, project, targetFlags);
|
||||
}
|
||||
else {
|
||||
platform = new HTML5Platform (command, project, targetFlags);
|
||||
}
|
||||
|
||||
case FIREFOX:
|
||||
|
||||
@@ -1040,6 +1048,7 @@ class CommandLineTools {
|
||||
LogHelper.println (" \x1b[1mnodejs\x1b[0m -- Alias for host platform (using \x1b[1m-nodejs\x1b[0m)");
|
||||
LogHelper.println (" \x1b[1mjava\x1b[0m -- Alias for host platform (using \x1b[1m-java\x1b[0m)");
|
||||
LogHelper.println (" \x1b[1mcs\x1b[0m -- Alias for host platform (using \x1b[1m-cs\x1b[0m)");
|
||||
LogHelper.println (" \x1b[1melectron\x1b[0m -- Alias for \x1b[1mhtml5 -electron\x1b[0m");
|
||||
LogHelper.println (" \x1b[1muwp\x1b[0;3m/\x1b[0m\x1b[1mwinjs\x1b[0m -- Alias for \x1b[1mwindows -uwp\x1b[0m");
|
||||
// LogHelper.println (" \x1b[1miphone\x1b[0;3m/\x1b[0m\x1b[1miphoneos\x1b[0m -- \x1b[1mios\x1b[0m");
|
||||
// LogHelper.println (" \x1b[1miphonesim\x1b[0m -- Alias for \x1b[1mios -simulator\x1b[0m");
|
||||
@@ -1146,6 +1155,7 @@ class CommandLineTools {
|
||||
|
||||
if (command != "run" && command != "trace") {
|
||||
|
||||
LogHelper.println (" \x1b[3m(html5)\x1b[0m \x1b[1m-electron\x1b[0m -- Target Electron instead of the browser");
|
||||
LogHelper.println (" \x1b[3m(emscripten)\x1b[0m \x1b[1m-webassembly\x1b[0m -- Compile for WebAssembly instead of asm.js");
|
||||
|
||||
}
|
||||
@@ -1680,6 +1690,11 @@ class CommandLineTools {
|
||||
target = PlatformHelper.hostPlatform;
|
||||
targetFlags.set ("nodejs", "");
|
||||
|
||||
case "electron":
|
||||
|
||||
target = Platform.HTML5;
|
||||
targetFlags.set ("electron", "");
|
||||
|
||||
case "cs":
|
||||
|
||||
target = PlatformHelper.hostPlatform;
|
||||
|
||||
@@ -515,6 +515,11 @@ class PlatformSetup {
|
||||
|
||||
// setupWebOS ();
|
||||
|
||||
case "electron":
|
||||
|
||||
setupElectron();
|
||||
|
||||
|
||||
case "windows":
|
||||
|
||||
if (PlatformHelper.hostPlatform == Platform.WINDOWS) {
|
||||
@@ -1277,6 +1282,65 @@ class PlatformSetup {
|
||||
}
|
||||
|
||||
|
||||
public static function setupElectron ():Void {
|
||||
|
||||
if (PlatformHelper.hostPlatform != Platform.WINDOWS) return;
|
||||
|
||||
var setElectronToPath = false;
|
||||
var defines = getDefines ();
|
||||
var answer = CLIHelper.ask ("Download and install Electron?");
|
||||
var electronPath:String = "";
|
||||
|
||||
if (answer == YES || answer == ALWAYS) {
|
||||
|
||||
var downloadPath:String = electronWin;
|
||||
var defaultInstallPath:String = "C:\\_sdks\\electron";
|
||||
|
||||
var localPath:String = "";
|
||||
|
||||
downloadFile (downloadPath);
|
||||
|
||||
localPath = unescapePath (CLIHelper.param ("Output directory [" + defaultInstallPath + "]"));
|
||||
localPath = createPath (localPath, defaultInstallPath);
|
||||
|
||||
extractFile (Path.withoutDirectory (downloadPath), localPath, "");
|
||||
|
||||
defines.set ("ELECTRON", localPath);
|
||||
writeConfig (defines.get ("LIME_CONFIG"), defines);
|
||||
LogHelper.println ("");
|
||||
|
||||
|
||||
setElectronToPath = true;
|
||||
|
||||
}
|
||||
|
||||
var requiredVariables = new Array<String> ();
|
||||
var requiredVariableDescriptions = new Array<String> ();
|
||||
|
||||
if (!setElectronToPath) {
|
||||
|
||||
requiredVariables.push ("Electron");
|
||||
requiredVariableDescriptions.push ("Path to Electron");
|
||||
|
||||
}
|
||||
|
||||
if (!setElectronToPath) {
|
||||
|
||||
LogHelper.println ("");
|
||||
|
||||
}
|
||||
|
||||
var defines = getDefines (requiredVariables, requiredVariableDescriptions, null);
|
||||
|
||||
if (defines != null) {
|
||||
|
||||
writeConfig (defines.get ("LIME_CONFIG"), defines);
|
||||
|
||||
}
|
||||
|
||||
HaxelibHelper.runCommand ("", [ "install", "electron" ], true, true);
|
||||
}
|
||||
|
||||
public static function setupWindows ():Void {
|
||||
|
||||
LogHelper.println ("\x1b[1mIn order to build native executables for Windows, you must have a");
|
||||
|
||||
Reference in New Issue
Block a user