From 1dadbb725c3de1076b726bd3aa7bb76e09800cb8 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 26 Apr 2018 11:27:50 -0700 Subject: [PATCH] Initial support for HL target in tools (for testing) --- lime/project/ProjectXMLParser.hx | 6 ++++++ lime/tools/platforms/LinuxPlatform.hx | 13 +++++++++++++ lime/tools/platforms/MacPlatform.hx | 13 +++++++++++++ lime/tools/platforms/WindowsPlatform.hx | 13 +++++++++++++ templates/hl/hxml/debug.hxml | 5 +++++ templates/hl/hxml/final.hxml | 5 +++++ templates/hl/hxml/release.hxml | 4 ++++ tools/CommandLineTools.hx | 17 +++++++++++++++++ tools/utils/PlatformSetup.hx | 2 +- 9 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 templates/hl/hxml/debug.hxml create mode 100644 templates/hl/hxml/final.hxml create mode 100644 templates/hl/hxml/release.hxml diff --git a/lime/project/ProjectXMLParser.hx b/lime/project/ProjectXMLParser.hx index 1fb8683d3..c10728ae3 100644 --- a/lime/project/ProjectXMLParser.hx +++ b/lime/project/ProjectXMLParser.hx @@ -94,6 +94,12 @@ class ProjectXMLParser extends HXProject { defines.set ("native", "1"); defines.set ("neko", "1"); + } else if (targetFlags.exists ("hl")) { + + defines.set ("targetType", "hl"); + defines.set ("native", "1"); + defines.set ("hl", "1"); + } else if (targetFlags.exists ("java")) { defines.set ("targetType", "java"); diff --git a/lime/tools/platforms/LinuxPlatform.hx b/lime/tools/platforms/LinuxPlatform.hx index 8db1f546f..c95fb9120 100644 --- a/lime/tools/platforms/LinuxPlatform.hx +++ b/lime/tools/platforms/LinuxPlatform.hx @@ -64,6 +64,10 @@ class LinuxPlatform extends PlatformTarget { targetType = "neko"; + } else if (project.targetFlags.exists ("hl")) { + + targetType = "hl"; + } else if (project.targetFlags.exists ("nodejs")) { targetType = "nodejs"; @@ -128,6 +132,14 @@ class LinuxPlatform extends PlatformTarget { } + } else if (targetType == "hl") { + + ProcessHelper.runCommand ("", "haxe", [ hxml ]); + + if (noOutput) return; + + NekoHelper.copyLibraries (project.templatePaths, "linux" + (is64 ? "64" : ""), applicationDirectory); + } else if (targetType == "nodejs") { ProcessHelper.runCommand ("", "haxe", [ hxml ]); @@ -249,6 +261,7 @@ class LinuxPlatform extends PlatformTarget { context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n"; context.NODE_FILE = targetDirectory + "/bin/ApplicationMain.js"; + context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl"; context.CPP_DIR = targetDirectory + "/obj/"; context.BUILD_DIR = project.app.path + "/linux" + (is64 ? "64" : "") + (isRaspberryPi ? "-rpi" : ""); context.WIN_ALLOW_SHADERS = false; diff --git a/lime/tools/platforms/MacPlatform.hx b/lime/tools/platforms/MacPlatform.hx index 6ebe9cae9..92bedd5b3 100644 --- a/lime/tools/platforms/MacPlatform.hx +++ b/lime/tools/platforms/MacPlatform.hx @@ -58,6 +58,10 @@ class MacPlatform extends PlatformTarget { targetType = "neko"; + } else if (project.targetFlags.exists ("hl")) { + + targetType = "hl"; + } else if (project.targetFlags.exists ("java")) { targetType = "java"; @@ -111,6 +115,14 @@ class MacPlatform extends PlatformTarget { NekoHelper.createExecutable (project.templatePaths, "mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath); NekoHelper.copyLibraries (project.templatePaths, "mac" + (is64 ? "64" : ""), executableDirectory); + } else if (targetType == "hl") { + + ProcessHelper.runCommand ("", "haxe", [ hxml ]); + + if (noOutput) return; + + NekoHelper.copyLibraries (project.templatePaths, "mac" + (is64 ? "64" : ""), executableDirectory); + } else if (targetType == "java") { var libPath = PathHelper.combine (PathHelper.getHaxelib (new Haxelib ("lime")), "templates/java/lib/"); @@ -224,6 +236,7 @@ class MacPlatform extends PlatformTarget { var context = project.templateContext; context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n"; context.NODE_FILE = executableDirectory + "/ApplicationMain.js"; + context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl"; context.CPP_DIR = targetDirectory + "/obj/"; context.BUILD_DIR = project.app.path + "/mac" + (is64 ? "64" : ""); diff --git a/lime/tools/platforms/WindowsPlatform.hx b/lime/tools/platforms/WindowsPlatform.hx index d95b5ddc5..15ea304f0 100644 --- a/lime/tools/platforms/WindowsPlatform.hx +++ b/lime/tools/platforms/WindowsPlatform.hx @@ -63,6 +63,10 @@ class WindowsPlatform extends PlatformTarget { targetType = "neko"; + } else if (project.targetFlags.exists ("hl")) { + + targetType = "hl"; + } else if (project.targetFlags.exists ("nodejs")) { targetType = "nodejs"; @@ -188,6 +192,14 @@ class WindowsPlatform extends PlatformTarget { NekoHelper.createWindowsExecutable (project.templatePaths, targetDirectory + "/obj/ApplicationMain.n", executablePath, iconPath); NekoHelper.copyLibraries (project.templatePaths, "windows" + (is64 ? "64" : ""), applicationDirectory); + } else if (targetType == "hl") { + + ProcessHelper.runCommand ("", "haxe", [ hxml ]); + + if (noOutput) return; + + NekoHelper.copyLibraries (project.templatePaths, "windows" + (is64 ? "64" : ""), applicationDirectory); + } else if (targetType == "nodejs") { ProcessHelper.runCommand ("", "haxe", [ hxml ]); @@ -352,6 +364,7 @@ class WindowsPlatform extends PlatformTarget { context.NEKO_FILE = targetDirectory + "/obj/ApplicationMain.n"; context.NODE_FILE = targetDirectory + "/bin/ApplicationMain.js"; + context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl"; context.CPP_DIR = targetDirectory + "/obj"; context.BUILD_DIR = project.app.path + "/windows" + (is64 ? "64" : ""); diff --git a/templates/hl/hxml/debug.hxml b/templates/hl/hxml/debug.hxml new file mode 100644 index 000000000..6d06cf72b --- /dev/null +++ b/templates/hl/hxml/debug.hxml @@ -0,0 +1,5 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-hl ::HL_FILE:: +--macro keep("::APP_MAIN::") +-debug \ No newline at end of file diff --git a/templates/hl/hxml/final.hxml b/templates/hl/hxml/final.hxml new file mode 100644 index 000000000..3255f914e --- /dev/null +++ b/templates/hl/hxml/final.hxml @@ -0,0 +1,5 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-hl ::HL_FILE:: +--macro keep("::APP_MAIN::") +-D final \ No newline at end of file diff --git a/templates/hl/hxml/release.hxml b/templates/hl/hxml/release.hxml new file mode 100644 index 000000000..c6d6863c8 --- /dev/null +++ b/templates/hl/hxml/release.hxml @@ -0,0 +1,4 @@ +-main ApplicationMain ::HAXE_FLAGS:: +-cp ::OUTPUT_DIR::/haxe +-hl ::HL_FILE:: +--macro keep("::APP_MAIN::") \ No newline at end of file diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index bc4fc8ec6..e4543f5bb 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -279,6 +279,16 @@ class CommandLineTools { target = PlatformHelper.hostPlatform; targetFlags.set ("neko", ""); + case "hl": + + target = PlatformHelper.hostPlatform; + targetFlags.set ("hl", ""); + + case "java": + + target = PlatformHelper.hostPlatform; + targetFlags.set ("java", ""); + case "nodejs": target = PlatformHelper.hostPlatform; @@ -1034,6 +1044,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[1mhl\x1b[0m -- Alias for host platform (using \x1b[1m-hl\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"); @@ -1151,6 +1162,7 @@ class CommandLineTools { LogHelper.println (" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-java\x1b[0m -- Build for Java instead of C++"); LogHelper.println (" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-nodejs\x1b[0m -- Build for Node.js instead of C++"); LogHelper.println (" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-cs\x1b[0m -- Build for C# instead of C++"); + LogHelper.println (" \x1b[3m(windows|mac|linux)\x1b[0m \x1b[1m-hl\x1b[0m -- Build for HashLink instead of C++"); LogHelper.println (" \x1b[3m(windows)\x1b[0m \x1b[1m-winjs\x1b[0m -- Build for WinJS instead of C++ (implies UWP)"); LogHelper.println (" \x1b[3m(windows)\x1b[0m \x1b[1m-uwp\x1b[0m -- Build for Universal Windows Platform"); @@ -1663,6 +1675,11 @@ class CommandLineTools { target = PlatformHelper.hostPlatform; targetFlags.set ("neko", ""); + case "hl": + + target = PlatformHelper.hostPlatform; + targetFlags.set ("hl", ""); + case "java": target = PlatformHelper.hostPlatform; diff --git a/tools/utils/PlatformSetup.hx b/tools/utils/PlatformSetup.hx index 3a97e2345..c8cb207da 100644 --- a/tools/utils/PlatformSetup.hx +++ b/tools/utils/PlatformSetup.hx @@ -523,7 +523,7 @@ class PlatformSetup { } - case "neko", "cs", "uwp", "winjs", "nodejs", "java": + case "neko", "hl", "cs", "uwp", "winjs", "nodejs", "java": LogHelper.println ("\x1b[0;3mNo additional configuration is required.\x1b[0m");