From 54ed3c435f8b8af841f345a61cc7d16d2c545744 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sat, 28 Mar 2026 12:58:24 -0700 Subject: [PATCH 01/14] Make NPM workfow more distinct with additional lifecycle scripts. package.json and node_modules out-last multiple builds. Optional preupdate, update, prebuild, build scripts. Required run and test scripts (which replace default lime run and lime build+run behavior) --- templates/html5/npm/package.json | 29 ++----- templates/html5/npm/webpack.common.js | 20 ----- templates/html5/npm/webpack.dev.js | 10 --- templates/html5/npm/webpack.prod.js | 17 ---- tools/platforms/HTML5Platform.hx | 117 +++++++++++++++++++------- 5 files changed, 95 insertions(+), 98 deletions(-) delete mode 100755 templates/html5/npm/webpack.common.js delete mode 100755 templates/html5/npm/webpack.dev.js delete mode 100755 templates/html5/npm/webpack.prod.js diff --git a/templates/html5/npm/package.json b/templates/html5/npm/package.json index 2c7d7d9920..c9fc0e365d 100755 --- a/templates/html5/npm/package.json +++ b/templates/html5/npm/package.json @@ -2,25 +2,12 @@ "name": "::META_PACKAGE::", "version": "::META_VERSION::", "private": true, - "devDependencies": { - "haxe": "^5.0.10", - "haxe-loader": "^0.10.0", - "uglifyjs-webpack-plugin": "^1.3.0", - "webpack": "^4.20.2", - "webpack-cli": "^3.1.2", - "webpack-dev-server": "^3.1.9", - "webpack-merge": "^4.1.4" - }, - "haxeDependencies": { - "haxe": "3.4.7" - }, "scripts": { - "build": "npm run build:prod", - "build:dev": "webpack --config webpack.dev.js", - "build:prod": "webpack --config webpack.prod.js", - "start": "npm run start:dev", - "start:dev": "webpack-dev-server --open --config webpack.dev.js", - "start:prod": "webpack-dev-server --open --config webpack.prod.js" - }, - "dependencies": {} -} + "lime:preupdate": "node -e \"/* (Optional) preupdate: Run tasks before Lime tools update (prepare environment, sync assets, etc) */\"", + "lime:update": "node -e \"/* (Optional) update: Run tasks after Lime tools update (verify updates, log info, etc) */\"", + "lime:prebuild": "node -e \"/* (Optional) prebuild: Run tasks before Lime tools build (codegen, preprocess assets, etc) */\"", + "lime:build": "node -e \"/* (Optional) build: Run tasks after Lime tools build (optimize artifacts, copy files, etc) */\"", + "lime:run": "node -e \"/* (Required) run: Run build output (vite preview, npx serve, npx http-server) */\"", + "lime:test": "node -e \"/* (Required) test: Start dev server/watch mode for non-final builds; replaces build and run lifecycle */\"" + } +} \ No newline at end of file diff --git a/templates/html5/npm/webpack.common.js b/templates/html5/npm/webpack.common.js deleted file mode 100755 index 04152203fb..0000000000 --- a/templates/html5/npm/webpack.common.js +++ /dev/null @@ -1,20 +0,0 @@ -const path = require ('path'); - -module.exports = { - entry: "./../haxe/::if DEBUG::debug.hxml::else::::if FINAL::final.hxml::else::release.hxml::end::::end::", - output: { - path: path.resolve (__dirname, "dist"), - filename: "::OUTPUT_FILE::", - library: "lime", - libraryTarget: 'window', - libraryExport: 'lime' - }, - module: { - rules: [ - { - test: /\.hxml$/, - loader: 'haxe-loader', - } - ] - } -}; \ No newline at end of file diff --git a/templates/html5/npm/webpack.dev.js b/templates/html5/npm/webpack.dev.js deleted file mode 100755 index a770e2b88c..0000000000 --- a/templates/html5/npm/webpack.dev.js +++ /dev/null @@ -1,10 +0,0 @@ -const merge = require ('webpack-merge'); -const common = require ('./webpack.common.js'); - -module.exports = merge (common, { - mode: 'development', - devServer: { - contentBase: './dist' - }, - devtool: "inline-source-map", -}); \ No newline at end of file diff --git a/templates/html5/npm/webpack.prod.js b/templates/html5/npm/webpack.prod.js deleted file mode 100755 index 317b40fb2a..0000000000 --- a/templates/html5/npm/webpack.prod.js +++ /dev/null @@ -1,17 +0,0 @@ -const webpack = require ('webpack'); -const merge = require ('webpack-merge'); -const UglifyJSPlugin = require ('uglifyjs-webpack-plugin'); -const common = require ('./webpack.common.js'); - -module.exports = merge (common, { - mode: 'production', - devtool: "source-map", - plugins: [ - new UglifyJSPlugin ({ - sourceMap: true - }), - new webpack.DefinePlugin ({ - 'process.env.NODE_ENV': JSON.stringify ('production') - }) - ] -}); \ No newline at end of file diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index a9fef8cb6b..18052422c7 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -1,5 +1,7 @@ package; +import haxe.Json; +import sys.io.Process; import hxp.HXML; import hxp.Log; import hxp.Path; @@ -103,6 +105,11 @@ class HTML5Platform extends PlatformTarget public override function build():Void { + if (npm) + { + runNPMCommand(["run", "lime:prebuild", "--if-present"]); + } + ModuleHelper.buildModules(project, targetDirectory + "/obj", targetDirectory + "/bin"); if (project.app.main != null) @@ -157,23 +164,16 @@ class HTML5Platform extends PlatformTarget System.copyFileTemplate(project.templatePaths, "html5/output.js", outputFile, context); } - if (project.targetFlags.exists("minify") || type == "final") + if (project.targetFlags.exists("minify") || (type == "final" && !npm)) { HTML5Helper.minify(project, targetDirectory + "/bin/" + project.app.file + ".js"); } } - if (npm) + var finalRelease = (!project.debug && project.targetFlags.exists("final")); + if (npm && (command == "build" || (command == "test" && finalRelease))) { - if (command == "build") - { - var buildCommand = "build:" + (project.targetFlags.exists("final") ? "prod" : "dev"); - System.runCommand(targetDirectory + "/bin", "npm", ["run", buildCommand, "-s"]); - } - else - { - return; - } + runNPMCommand(["run", "lime:build", "--if-present"]); } } @@ -254,35 +254,96 @@ class HTML5Platform extends PlatformTarget try { - if (project.defines.exists("npm") || targetFlags.exists("npm") || (FileSystem.exists(targetDirectory + "/bin/package.json") && !targetFlags.exists("electron"))) - { + if (targetFlags.exists("npm") || project.defines.exists("npm") || (FileSystem.exists(targetDirectory + "/bin/package.json") && !targetFlags.exists("electron"))) { npm = true; - // outputFile = project.app.file + ".js"; } } catch (e:Dynamic) {} } + private function ensureNPM():Void + { + var destination = targetDirectory + "/bin/"; + System.mkdir(destination); + + // Log.info("", Log.accentColor + "Using NPM project: " + Path.combine(Path.tryFullPath(destination), "project.json") + Log.resetColor); + + // Copy template if not present (allows package.json and node_modules to be preserved) + if (!FileSystem.exists(targetDirectory + "/bin/package.json")) + { + var context = project.templateContext; + ProjectHelper.recursiveSmartCopyTemplate(project, "html5/npm", destination, context); + } + + // Check if dependencies are okay + var needsInstall = true; + try + { + var output = System.runProcess(destination, "npm", ["ls", "--depth=0", "--json"], true, true, true); + if (output != null) + { + var json = Json.parse(output); + if (json.problems == null || json.problems.length == 0) + { + needsInstall = false; + } + } + } + catch (e:Dynamic) {} + + if (needsInstall) + { + runNPMCommand(["install"]); + } + } + public override function run():Void { if (npm) { - var runCommand = "start:" + (project.targetFlags.exists("final") ? "prod" : "dev"); - System.runCommand(targetDirectory + "/bin", "npm", ["run", runCommand, "-s"]); + // If "lime test" and not final, rely on "lime:test" script to start a dev server + var finalRelease = (!project.debug && project.targetFlags.exists("final")); + if (!finalRelease && command == "test") + { + runNPMCommand(["run", "lime:test"]); + } + else + { + runNPMCommand(["run", "lime:run", "--if-present"]); + } } - else if (targetFlags.exists("electron")) + else { - var npx = targetFlags.exists("npx"); - ElectronHelper.launch(project, targetDirectory + "/bin", npx); + if (targetFlags.exists("electron")) + { + var npx = targetFlags.exists("npx"); + ElectronHelper.launch(project, targetDirectory + "/bin", npx); + } + else + { + HTML5Helper.launch(project, targetDirectory + "/bin"); + } } - else + } + + private function runNPMCommand(args:Array, safeExecute:Bool = true, ignoreErrors:Bool = false):Int + { + var destination = targetDirectory + "/bin/"; + if (!project.targetFlags.exists("verbose")) { - HTML5Helper.launch(project, targetDirectory + "/bin"); + args.push("--silent"); } + return System.runCommand(destination, "npm", args, safeExecute, ignoreErrors); } public override function update():Void { + if (npm) + { + ensureNPM(); + runNPMCommand(["run", "lime:preupdate", "--if-present"]); + } + AssetHelper.processLibraries(project, targetDirectory); // project = project.clone (); @@ -546,15 +607,6 @@ class HTML5Platform extends PlatformTarget ProjectHelper.recursiveSmartCopyTemplate(project, "html5/hxml", targetDirectory + "/haxe", context); } - if (npm) - { - ProjectHelper.recursiveSmartCopyTemplate(project, "html5/npm", targetDirectory + "/bin", context); - if (!FileSystem.exists(targetDirectory + "/bin/node_modules")) - { - System.runCommand(targetDirectory + "/bin", "npm", ["install", "-s"]); - } - } - if (targetFlags.exists("electron")) { ProjectHelper.recursiveSmartCopyTemplate(project, "electron/template", destination, context); @@ -576,6 +628,11 @@ class HTML5Platform extends PlatformTarget AssetHelper.copyAsset(asset, path, context); } } + + if (npm) + { + runNPMCommand(["run", "lime:update", "--if-present"]); + } } public override function watch():Void From 2173a60a9d5da5ba77a81c6ca6ea4e27f208a434 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sat, 28 Mar 2026 22:06:47 -0700 Subject: [PATCH 02/14] Move NPM package.json to targetDirectory, divide Haxe JS output to /build and other assets/templates to /public --- tools/platforms/HTML5Platform.hx | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 18052422c7..1eabad4364 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -27,8 +27,11 @@ import sys.FileSystem; class HTML5Platform extends PlatformTarget { + private var assetsDirectory:String; private var dependencyPath:String; + private var finalRelease:Bool; private var npm:Bool; + private var outputDirectory:String; private var outputFile:String; public function new(command:String, _project:HXProject, targetFlags:Map) @@ -110,7 +113,7 @@ class HTML5Platform extends PlatformTarget runNPMCommand(["run", "lime:prebuild", "--if-present"]); } - ModuleHelper.buildModules(project, targetDirectory + "/obj", targetDirectory + "/bin"); + ModuleHelper.buildModules(project, targetDirectory + "/obj", outputDirectory); if (project.app.main != null) { @@ -130,7 +133,7 @@ class HTML5Platform extends PlatformTarget if (noOutput) return; - HTML5Helper.encodeSourceMappingURL(targetDirectory + "/bin/" + project.app.file + ".js"); + HTML5Helper.encodeSourceMappingURL(outputFile); if (project.targetFlags.exists("webgl")) { @@ -166,11 +169,10 @@ class HTML5Platform extends PlatformTarget if (project.targetFlags.exists("minify") || (type == "final" && !npm)) { - HTML5Helper.minify(project, targetDirectory + "/bin/" + project.app.file + ".js"); + HTML5Helper.minify(project, outputFile); } } - var finalRelease = (!project.debug && project.targetFlags.exists("final")); if (npm && (command == "build" || (command == "test" && finalRelease))) { runNPMCommand(["run", "lime:build", "--if-present"]); @@ -250,36 +252,39 @@ class HTML5Platform extends PlatformTarget } dependencyPath = project.config.getString("html5.dependency-path", "lib"); - outputFile = targetDirectory + "/bin/" + project.app.file + ".js"; try { - if (targetFlags.exists("npm") || project.defines.exists("npm") || (FileSystem.exists(targetDirectory + "/bin/package.json") && !targetFlags.exists("electron"))) { + if (targetFlags.exists("npm") || project.defines.exists("npm") || (FileSystem.exists(targetDirectory + "/package.json") && !targetFlags.exists("electron"))) { npm = true; } } catch (e:Dynamic) {} + + finalRelease = (!project.debug && project.targetFlags.exists("final")); + assetsDirectory = targetDirectory + (npm ? "/public" : "/bin"); + outputDirectory = targetDirectory + (npm ? "/build" : "/bin"); + outputFile = outputDirectory + "/" + project.app.file + ".js"; } private function ensureNPM():Void { - var destination = targetDirectory + "/bin/"; - System.mkdir(destination); + System.mkdir(targetDirectory); // Log.info("", Log.accentColor + "Using NPM project: " + Path.combine(Path.tryFullPath(destination), "project.json") + Log.resetColor); // Copy template if not present (allows package.json and node_modules to be preserved) - if (!FileSystem.exists(targetDirectory + "/bin/package.json")) + if (!FileSystem.exists(targetDirectory + "/package.json")) { var context = project.templateContext; - ProjectHelper.recursiveSmartCopyTemplate(project, "html5/npm", destination, context); + ProjectHelper.recursiveSmartCopyTemplate(project, "html5/npm", targetDirectory, context); } // Check if dependencies are okay var needsInstall = true; try { - var output = System.runProcess(destination, "npm", ["ls", "--depth=0", "--json"], true, true, true); + var output = System.runProcess(targetDirectory, "npm", ["ls", "--depth=0", "--json"], true, true, true); if (output != null) { var json = Json.parse(output); @@ -302,14 +307,13 @@ class HTML5Platform extends PlatformTarget if (npm) { // If "lime test" and not final, rely on "lime:test" script to start a dev server - var finalRelease = (!project.debug && project.targetFlags.exists("final")); if (!finalRelease && command == "test") { runNPMCommand(["run", "lime:test"]); } else { - runNPMCommand(["run", "lime:run", "--if-present"]); + runNPMCommand(["run", "lime:run"]); } } else @@ -317,23 +321,22 @@ class HTML5Platform extends PlatformTarget if (targetFlags.exists("electron")) { var npx = targetFlags.exists("npx"); - ElectronHelper.launch(project, targetDirectory + "/bin", npx); + ElectronHelper.launch(project, outputDirectory, npx); } else { - HTML5Helper.launch(project, targetDirectory + "/bin"); + HTML5Helper.launch(project, outputDirectory); } } } private function runNPMCommand(args:Array, safeExecute:Bool = true, ignoreErrors:Bool = false):Int { - var destination = targetDirectory + "/bin/"; if (!project.targetFlags.exists("verbose")) { args.push("--silent"); } - return System.runCommand(destination, "npm", args, safeExecute, ignoreErrors); + return System.runCommand(targetDirectory, "npm", args, safeExecute, ignoreErrors); } public override function update():Void @@ -348,8 +351,8 @@ class HTML5Platform extends PlatformTarget // project = project.clone (); - var destination = targetDirectory + "/bin/"; - System.mkdir(destination); + var destination = assetsDirectory + "/"; + System.mkdir(assetsDirectory); var webfontDirectory = targetDirectory + "/obj/webfont"; var useWebfonts = true; From 2b45365350f5bfca75caa0d33c6db91ae83ee73e Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 17:19:07 -0700 Subject: [PATCH 03/14] Allow target flags which start with two dashes --- tools/CommandLineTools.hx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index 0d3e63f448..bfbe8b0847 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -2244,17 +2244,21 @@ class CommandLineTools { targetFlags.set("help", ""); } - else if (argument == "--output-file") - { - targetFlags.set("output-file", ""); - } else if (argument.substr(0, 1) == "-") { - if (argument == "-dce" || argument.substr(1, 1) == "-") + if (argument == "-dce") + { + overrides.haxeflags.push(argument); + catchHaxeFlag = true; + } + else if (argument.length > 2 && argument.substr(1, 1) == "-") { + targetFlags.set(argument.substr(2), ""); + + // TODO: Should this be more selective? overrides.haxeflags.push(argument); - if (argument == "--remap" || argument == "--connect" || argument == "-dce") + if (argument == "--remap" || argument == "--connect") { catchHaxeFlag = true; } From 7d1319bf0c95deaed4d03c95b02331662f4a2b56 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:08:44 -0700 Subject: [PATCH 04/14] Add 'lime display --template-context' and 'lime display --template-context --json --- src/lime/tools/ObjectHelper.hx | 90 +++++++++++++ tools/CommandLineTools.hx | 44 ++++--- tools/platforms/AIRPlatform.hx | 97 +++++++------- tools/platforms/AndroidPlatform.hx | 160 ++++++++++++---------- tools/platforms/FlashPlatform.hx | 140 +++++++++++--------- tools/platforms/HTML5Platform.hx | 117 ++++++++-------- tools/platforms/IOSPlatform.hx | 154 +++++++++++----------- tools/platforms/LinuxPlatform.hx | 158 ++++++++++++---------- tools/platforms/MacPlatform.hx | 148 ++++++++++++--------- tools/platforms/TVOSPlatform.hx | 112 +++++++++------- tools/platforms/TizenPlatform.hx | 97 +++++++------- tools/platforms/WebAssemblyPlatform.hx | 130 ++++++++++-------- tools/platforms/WindowsPlatform.hx | 176 ++++++++++++++++--------- 13 files changed, 955 insertions(+), 668 deletions(-) create mode 100644 src/lime/tools/ObjectHelper.hx diff --git a/src/lime/tools/ObjectHelper.hx b/src/lime/tools/ObjectHelper.hx new file mode 100644 index 0000000000..2ea8aa56b7 --- /dev/null +++ b/src/lime/tools/ObjectHelper.hx @@ -0,0 +1,90 @@ +package lime.tools; + +class ObjectHelper +{ + public static function formatForDisplay(object:Dynamic):String + { + var keys = Reflect.fields(object); + keys.sort(Reflect.compare); + var lines = []; + for (key in keys) + { + lines.push('${key}: ${Reflect.field(object, key)}'); + } + return lines.join("\n"); + } + + public static function formatJson(obj:Dynamic, indent:Int = 2):String + { + return prettyJson(obj, 0, indent); + } + + private static function objectToString(value:Dynamic):String + { + if (value == null) return "null"; + if (Std.isOfType(value, Bool) || Std.isOfType(value, Int) || Std.isOfType(value, Float)) return Std.string(value); + if (Std.isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"'; + + // Handle enums + var e = Type.getEnum(value); + if (e != null) return Type.enumConstructor(value); + + // Handle arrays + if (Std.isOfType(value, Array)) + { + var arr:Array = cast value; + return "[" + arr.map(objectToString).join(", ") + "]"; + } + + // Handle objects/maps recursively + var fields = Reflect.fields(value); + if (fields.length > 0) + { + var pairs = fields.map(function(f) + { + return f + ": " + objectToString(Reflect.field(value, f)); + }); + return "{" + pairs.join(", ") + "}"; + } + + return ""; + } + + private static function prettyJson(value:Dynamic, level:Int, indent:Int):String + { + var pad = StringTools.lpad("", " ", level * indent); + var nextPad = StringTools.lpad("", " ", (level + 1) * indent); + + // Primitive types + if (value == null) return "null"; + if (Std.isOfType(value, Bool) || Std.isOfType(value, Int) || Std.isOfType(value, Float)) return Std.string(value); + if (Std.isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"'; + + // Enums + var e = Type.getEnum(value); + if (e != null) return '"' + Type.enumConstructor(value) + '"'; + + // Arrays + if (Std.isOfType(value, Array)) + { + var arr:Array = cast value; + var items = arr.map(function(v) return prettyJson(v, level + 1, indent)); + return "[\n" + nextPad + items.join(",\n" + nextPad) + "\n" + pad + "]"; + } + + // Objects + var fields = Reflect.fields(value); + fields.sort(Reflect.compare); + if (fields.length > 0) + { + var pairs = fields.map(function(f) + { + var v = Reflect.field(value, f); + return '"' + f + '": ' + prettyJson(v, level + 1, indent); + }); + return "{\n" + nextPad + pairs.join(",\n" + nextPad) + "\n" + pad + "}"; + } + + return '""'; + } +} diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index bfbe8b0847..4966c4c055 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -420,8 +420,7 @@ class CommandLineTools publishProject(); case "installer", "copy-if-newer": - - // deprecated? + // deprecated? default: Log.error("'" + command + "' is not a valid command"); @@ -511,7 +510,7 @@ class CommandLineTools case LINUX: var arguments = Sys.args(); - if (System.hostArchitecture == ARMV7 ) + if (System.hostArchitecture == ARMV7) { untyped $loader.path = $array(path + "LinuxArm/", $loader.path); } @@ -600,19 +599,16 @@ class CommandLineTools platform = new AndroidPlatform(command, project, targetFlags); case BLACKBERRY: - - // platform = new BlackBerryPlatform (command, project, targetFlags); + // platform = new BlackBerryPlatform (command, project, targetFlags); case IOS: platform = new IOSPlatform(command, project, targetFlags); case TIZEN: - - // platform = new TizenPlatform (command, project, targetFlags); + // platform = new TizenPlatform (command, project, targetFlags); case WEBOS: - - // platform = new WebOSPlatform (command, project, targetFlags); + // platform = new WebOSPlatform (command, project, targetFlags); case WINDOWS: platform = new WindowsPlatform(command, project, targetFlags); @@ -788,14 +784,22 @@ class CommandLineTools { var commands = [ - "config" => "Display or set command-line configuration values", "create" => "Create a new project or extension using templates", - "clean" => "Clean the specified project and target", "update" => "Copy assets for the specified project and target", - "build" => "Compile and package for the specified project and target", "run" => "Install and run for the specified project and target", - "test" => "Update, build and run in one command", "help" => "Show this information", - "trace" => "Trace output for the specifed project and target", "deploy" => "Archive and upload builds", - "display" => "Display information for the specified project and target", "rebuild" => "Recompile native binaries for libraries", - "install" => "Install a library from haxelib, plus dependencies", "remove" => "Remove a library from haxelib", - "upgrade" => "Upgrade a library from haxelib", "setup" => "Setup " + defaultLibraryName + " or a specific platform" + "config" => "Display or set command-line configuration values", + "create" => "Create a new project or extension using templates", + "clean" => "Clean the specified project and target", + "update" => "Copy assets for the specified project and target", + "build" => "Compile and package for the specified project and target", + "run" => "Install and run for the specified project and target", + "test" => "Update, build and run in one command", + "help" => "Show this information", + "trace" => "Trace output for the specifed project and target", + "deploy" => "Archive and upload builds", + "display" => "Display information for the specified project and target", + "rebuild" => "Recompile native binaries for libraries", + "install" => "Install a library from haxelib, plus dependencies", + "remove" => "Remove a library from haxelib", + "upgrade" => "Upgrade a library from haxelib", + "setup" => "Setup " + defaultLibraryName + " or a specific platform" ]; @@ -1102,6 +1106,8 @@ class CommandLineTools Log.println(""); Log.println(" \x1b[3m(no option)\x1b[0m -- Display HXML build arguments"); Log.println(" \x1b[1m--output-file\x1b[0m -- Display the output file for the project"); + Log.println(" \x1b[1m--template-context\x1b[0m -- Display variables in the current template context"); + Log.println(" \x1b[1m--template-context --json\x1b[0m -- Display variables in the current template context in JSON format"); } } } @@ -1841,7 +1847,9 @@ class CommandLineTools var projectDirectory = Path.directory(projectFile); var localRepository = Path.combine(projectDirectory, ".haxelib"); - if (FileSystem.exists(localRepository) && FileSystem.isDirectory(localRepository) && StringTools.startsWith(path, localRepository)) + if (FileSystem.exists(localRepository) + && FileSystem.isDirectory(localRepository) + && StringTools.startsWith(path, localRepository)) { args.push("-nolocalrepocheck"); } diff --git a/tools/platforms/AIRPlatform.hx b/tools/platforms/AIRPlatform.hx index 2fa394bb36..9e65ca5bd8 100644 --- a/tools/platforms/AIRPlatform.hx +++ b/tools/platforms/AIRPlatform.hx @@ -31,56 +31,53 @@ class AIRPlatform extends FlashPlatform var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; if (project.targetFlags.exists("ios") || project.targetFlags.exists("android")) { diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 47095c2280..633138b788 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import hxp.ArrayTools; import hxp.Haxelib; import hxp.HXML; @@ -31,56 +32,53 @@ class AndroidPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; if (project.targetFlags.exists("simulator") || project.targetFlags.exists("emulator")) { @@ -162,8 +160,16 @@ class AndroidPlatform extends PlatformTarget for (architecture in architectures) { var minSDKVer = project.config.getInt("android.minimum-sdk-version", 21); - //PLATFORM define needed for older ndk and gcc toolchain - var haxeParams = [hxml, "-D", "android", "-D", 'PLATFORM_NUMBER=$minSDKVer', "-D", 'PLATFORM=android-$minSDKVer']; + // PLATFORM define needed for older ndk and gcc toolchain + var haxeParams = [ + hxml, + "-D", + "android", + "-D", + 'PLATFORM_NUMBER=$minSDKVer', + "-D", + 'PLATFORM=android-$minSDKVer' + ]; var cppParams = ["-Dandroid", '-DPLATFORM_NUMBER=$minSDKVer', '-DPLATFORM=android-$minSDKVer']; var path = sourceSet + "/jniLibs/armeabi"; var suffix = ".so"; @@ -295,6 +301,17 @@ class AndroidPlatform extends PlatformTarget Sys.println(Path.combine(outputDirectory, project.app.file + build + ".apk")); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -309,7 +326,8 @@ class AndroidPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -365,8 +383,7 @@ class AndroidPlatform extends PlatformTarget public override function rebuild():Void { - var armv5 = (/*command == "rebuild" ||*/ - ArrayTools.containsValue(project.architectures, Architecture.ARMV5) + var armv5 = (/*command == "rebuild" ||*/ ArrayTools.containsValue(project.architectures, Architecture.ARMV5) || ArrayTools.containsValue(project.architectures, Architecture.ARMV6)); var armv7 = (command == "rebuild" || ArrayTools.containsValue(project.architectures, Architecture.ARMV7)); var arm64 = (command == "rebuild" || ArrayTools.containsValue(project.architectures, Architecture.ARM64)); @@ -504,8 +521,18 @@ class AndroidPlatform extends PlatformTarget "android:launchMode": "singleTask", "android:label": project.meta.title, "android:configChanges": project.config.getArrayString("android.configChanges", - ["layoutDirection", "locale", "orientation", "uiMode", "screenLayout", "screenSize", "smallestScreenSize", "keyboard", "keyboardHidden", "navigation"]) - .join("|"), + [ + "layoutDirection", + "locale", + "orientation", + "uiMode", + "screenLayout", + "screenSize", + "smallestScreenSize", + "keyboard", + "keyboardHidden", + "navigation" + ]).join("|"), "android:screenOrientation": project.window.orientation == PORTRAIT ? "sensorPortrait" : (project.window.orientation == LANDSCAPE ? "sensorLandscape" : null) }); context.ANDROID_ACCEPT_FILE_INTENT = project.config.getArrayString("android.accept-file-intent", []); @@ -580,9 +607,7 @@ class AndroidPlatform extends PlatformTarget } } } - catch (e:Dynamic) - { - } + catch (e:Dynamic) {} } if (Reflect.hasField(context, "KEY_STORE")) context.KEY_STORE = StringTools.replace(context.KEY_STORE, "\\", "\\\\"); @@ -605,13 +630,12 @@ class AndroidPlatform extends PlatformTarget var name = dependency.name; if (name == "") name = "project" + index; - context.ANDROID_LIBRARY_PROJECTS.push( - { - name: name, - index: index, - path: "deps/" + name, - source: dependency.path - }); + context.ANDROID_LIBRARY_PROJECTS.push({ + name: name, + index: index, + path: "deps/" + name, + source: dependency.path + }); index++; } } @@ -642,7 +666,7 @@ class AndroidPlatform extends PlatformTarget && !context.HAS_ICON) { context.HAS_ICON = true; - context.ANDROID_APPLICATION.push({ key: "android:icon", value: "@drawable/icon" }); + context.ANDROID_APPLICATION.push({key: "android:icon", value: "@drawable/icon"}); } } diff --git a/tools/platforms/FlashPlatform.hx b/tools/platforms/FlashPlatform.hx index 8e157cf26e..f5012a4a63 100644 --- a/tools/platforms/FlashPlatform.hx +++ b/tools/platforms/FlashPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.Json; import hxp.Haxelib; import hxp.HXML; @@ -36,56 +37,53 @@ class FlashPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; for (i in 1...project.windows.length) { @@ -124,6 +122,17 @@ class FlashPlatform extends PlatformTarget { Sys.println(Path.combine(targetDirectory, "bin/" + project.app.file + ".swf")); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -183,7 +192,8 @@ class FlashPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -322,20 +332,20 @@ class FlashPlatform extends PlatformTarget } /*private function getIcon (size:Int, targetPath:String):Void { - - var icon = icons.findIcon (size, size); - - if (icon != "") { - - System.copyIfNewer (icon, targetPath); - - } else { - - icons.updateIcon (size, size, targetPath); - - } - - }*/ + + var icon = icons.findIcon (size, size); + + if (icon != "") { + + System.copyIfNewer (icon, targetPath); + + } else { + + icons.updateIcon (size, size, targetPath); + + } + + }*/ public override function watch():Void { var hxml = getDisplayHXML(); diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 1eabad4364..4163882c1a 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.Json; import sys.io.Process; import hxp.HXML; @@ -40,56 +41,53 @@ class HTML5Platform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.window.width = 0; defaults.window.height = 0; @@ -205,6 +203,17 @@ class HTML5Platform extends PlatformTarget { Sys.println(outputFile); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -219,7 +228,8 @@ class HTML5Platform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -255,7 +265,10 @@ class HTML5Platform extends PlatformTarget try { - if (targetFlags.exists("npm") || project.defines.exists("npm") || (FileSystem.exists(targetDirectory + "/package.json") && !targetFlags.exists("electron"))) { + if (targetFlags.exists("npm") + || project.defines.exists("npm") + || (FileSystem.exists(targetDirectory + "/package.json") && !targetFlags.exists("electron"))) + { npm = true; } } diff --git a/tools/platforms/IOSPlatform.hx b/tools/platforms/IOSPlatform.hx index 30f76b342e..1edbeb9e97 100644 --- a/tools/platforms/IOSPlatform.hx +++ b/tools/platforms/IOSPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.Json; import hxp.ArrayTools; import hxp.Haxelib; @@ -40,56 +41,53 @@ class IOSPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.architectures = [Architecture.ARM64]; defaults.window.width = 0; @@ -151,6 +149,17 @@ class IOSPlatform extends PlatformTarget { Sys.println(Path.combine(targetDirectory, project.app.file + ".xcodeproj")); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -417,7 +426,7 @@ class IOSPlatform extends PlatformTarget if (allowInsecureHTTP != "*" && allowInsecureHTTP != "true") { - var sites:Array<{domain: String}> = []; + var sites:Array<{domain:String}> = []; if (allowInsecureHTTP != "false") { @@ -454,7 +463,8 @@ class IOSPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -636,15 +646,13 @@ class IOSPlatform extends PlatformTarget } } - var contents = - { - images: images, - info: - { - version: "1", - author: "xcode" - } - }; + var contents = { + images: images, + info: { + version: "1", + author: "xcode" + } + }; File.saveContent(Path.combine(imagesetPath, "Contents.json"), Json.stringify(contents)); @@ -658,12 +666,11 @@ class IOSPlatform extends PlatformTarget for (imageset in imagesets) { - sb.templateContext.imagesets.push( - { - name: imageset.name, - width: imageset.width, - height: imageset.height, - }); + sb.templateContext.imagesets.push({ + name: imageset.name, + width: imageset.width, + height: imageset.height, + }); } var deployment:String = context.DEPLOYMENT; @@ -672,13 +679,12 @@ class IOSPlatform extends PlatformTarget var minor = parts.length >= 2 ? Std.parseInt(parts[1]) : 0; var patch = parts.length >= 3 ? Std.parseInt(parts[2]) : 0; - Reflect.setField(sb.templateContext, "deploymentVersion", - { - major: major, - minor: minor, - patch: patch, - code: Std.parseInt("0x" + major + minor + patch) - }); + Reflect.setField(sb.templateContext, "deploymentVersion", { + major: major, + minor: minor, + patch: patch, + code: Std.parseInt("0x" + major + minor + patch) + }); System.copyFileTemplate(project.templatePaths, "ios/storyboards/" + sb.template, projectDirectory + sb.template, sb.templateContext, true, true); diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index f886c90cb2..f8f9a1de1e 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import lime.tools.HashlinkHelper; import hxp.Haxelib; import hxp.HXML; @@ -38,56 +39,53 @@ class LinuxPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; switch (System.hostArchitecture) { @@ -122,7 +120,9 @@ class LinuxPlatform extends PlatformTarget for (architecture in project.architectures) { - if (!targetFlags.exists("32") && !targetFlags.exists("x86_32") && (architecture == Architecture.X64 || architecture == Architecture.ARM64)) + if (!targetFlags.exists("32") + && !targetFlags.exists("x86_32") + && (architecture == Architecture.X64 || architecture == Architecture.ARM64)) { is64 = true; } @@ -198,7 +198,8 @@ class LinuxPlatform extends PlatformTarget } else { - ProjectHelper.copyLibrary(project, ndll, "Linux" + (( System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64)?"Arm":"") + (is64 ? "64" : ""), "", + ProjectHelper.copyLibrary(project, ndll, + "Linux" + ((System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64) ? "Arm" : "") + (is64 ? "64" : ""), "", (ndll.haxelib != null && (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", applicationDirectory, project.debug, targetSuffix); @@ -212,9 +213,13 @@ class LinuxPlatform extends PlatformTarget if (noOutput) return; - NekoHelper.createExecutable(project.templatePaths, "linux" + (( System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64)?"Arm":"") + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath); + NekoHelper.createExecutable(project.templatePaths, + "linux" + + ((System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64) ? "Arm" : "") + + (is64 ? "64" : ""), + targetDirectory + + "/obj/ApplicationMain.n", executablePath); NekoHelper.copyLibraries(project.templatePaths, "linux" + (is64 ? "64" : ""), applicationDirectory); - } else if (targetType == "hl") { @@ -227,7 +232,19 @@ class LinuxPlatform extends PlatformTarget if (project.targetFlags.exists("hlc")) { var compiler = project.targetFlags.exists("clang") ? "clang" : "gcc"; - var command = [compiler, "-O3", "-o", executablePath, "-std=c11", "-Wl,-rpath,$ORIGIN", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c"), "-L", applicationDirectory]; + var command = [ + compiler, + "-O3", + "-o", + executablePath, + "-std=c11", + "-Wl,-rpath,$ORIGIN", + "-I", + Path.combine(targetDirectory, "obj"), + Path.combine(targetDirectory, "obj/ApplicationMain.c"), + "-L", + applicationDirectory + ]; for (file in System.readDirectory(applicationDirectory)) { switch Path.extension(file) @@ -401,6 +418,17 @@ class LinuxPlatform extends PlatformTarget { Sys.println(executablePath); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -411,7 +439,7 @@ class LinuxPlatform extends PlatformTarget { // var project = project.clone (); - if(targetFlags.exists('rpi')) + if (targetFlags.exists('rpi')) { project.haxedefs.set("rpi", 1); } @@ -436,7 +464,8 @@ class LinuxPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -468,7 +497,7 @@ class LinuxPlatform extends PlatformTarget { var commands:Array> = []; - if (targetFlags.exists('rpi') && System.hostArchitecture == ARM64 ) + if (targetFlags.exists('rpi') && System.hostArchitecture == ARM64) { commands.push([ "-Dlinux", @@ -501,14 +530,9 @@ class LinuxPlatform extends PlatformTarget // TODO: Support single binary commands.push(["-Dlinux", "-DHXCPP_M64", "-Dhashlink"]); } - else if (System.hostArchitecture == ARM64 ) + else if (System.hostArchitecture == ARM64) { - commands.push([ - "-Dlinux", - "-Dtoolchain=linux", - "-DBINDIR=LinuxArm64", - "-DHXCPP_ARM64", - ]); + commands.push(["-Dlinux", "-Dtoolchain=linux", "-DBINDIR=LinuxArm64", "-DHXCPP_ARM64",]); } else { @@ -594,7 +618,9 @@ class LinuxPlatform extends PlatformTarget if (ndll.path == null || ndll.path == "") { - context.ndlls[i].path = NDLL.getLibraryPath(ndll, "Linux" + (( System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64) ? "Arm" : "") + (is64 ? "64" : ""), "lib", ".a", project.debug); + context.ndlls[i].path = NDLL.getLibraryPath(ndll, + "Linux" + ((System.hostArchitecture == ARMV7 || System.hostArchitecture == ARM64) ? "Arm" : "") + (is64 ? "64" : ""), "lib", ".a", + project.debug); } } } diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 8ce9f1ccef..f5cfe40914 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.io.Eof; import hxp.Haxelib; import hxp.HXML; @@ -46,56 +47,53 @@ class MacPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.window.allowHighDPI = false; @@ -230,7 +228,19 @@ class MacPlatform extends PlatformTarget // compiler command with the `arch -x86_64` command. // if we ever support ARM or Universal binaries, this will // need to be handled differently. - var command = ["arch", "-x86_64", compiler, "-O3", "-o", executablePath, "-std=c11", "-Wl,-rpath,@executable_path", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c")]; + var command = [ + "arch", + "-x86_64", + compiler, + "-O3", + "-o", + executablePath, + "-std=c11", + "-Wl,-rpath,@executable_path", + "-I", + Path.combine(targetDirectory, "obj"), + Path.combine(targetDirectory, "obj/ApplicationMain.c") + ]; for (file in System.readDirectory(executableDirectory)) { switch Path.extension(file) @@ -251,7 +261,12 @@ class MacPlatform extends PlatformTarget // when launched inside an .app file, the executable // can't find the library files unless we tell // it to search specifically from @executable_path - System.runCommand("", "install_name_tool", ["-change", Path.withoutDirectory(file), "@executable_path/" + Path.withoutDirectory(file), executablePath]); + System.runCommand("", "install_name_tool", [ + "-change", + Path.withoutDirectory(file), + "@executable_path/" + Path.withoutDirectory(file), + executablePath + ]); default: } } @@ -354,7 +369,10 @@ class MacPlatform extends PlatformTarget } } - if (System.hostPlatform != WINDOWS && targetType != "nodejs" && targetType != "java" && sys.FileSystem.exists(executablePath)) + if (System.hostPlatform != WINDOWS + && targetType != "nodejs" + && targetType != "java" + && sys.FileSystem.exists(executablePath)) { System.runCommand("", "chmod", ["755", executablePath]); } @@ -379,6 +397,17 @@ class MacPlatform extends PlatformTarget { Sys.println(executablePath); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -405,7 +434,8 @@ class MacPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -666,10 +696,7 @@ class MacPlatform extends PlatformTarget // these are the known directories where Homebrew installs its dependencies // we may need to add more in the future, but this seems to be enough for now - var homebrewDirs = [ - "/usr/local/opt/", - "/usr/local/Cellar/" - ]; + var homebrewDirs = ["/usr/local/opt/", "/usr/local/Cellar/"]; // first, collect all executables, hdlls, and dylibs that were built // by BuildHashlink.xml @@ -734,7 +761,10 @@ class MacPlatform extends PlatformTarget continue; } } - if (Lambda.exists(homebrewDirs, function(dirPath:String):Bool { return StringTools.startsWith(resolvedLibPath, dirPath); })) + if (Lambda.exists(homebrewDirs, function(dirPath:String):Bool + { + return StringTools.startsWith(resolvedLibPath, dirPath); + })) { homebrewDependencyPaths.push(libPath); pathsToSearchForHomebrewDependencies.push(resolvedLibPath); diff --git a/tools/platforms/TVOSPlatform.hx b/tools/platforms/TVOSPlatform.hx index 5125792f04..7c2bf41504 100644 --- a/tools/platforms/TVOSPlatform.hx +++ b/tools/platforms/TVOSPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.Json; import hxp.ArrayTools; import hxp.Haxelib; @@ -38,56 +39,53 @@ class TVOSPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.architectures = [Architecture.ARM64]; defaults.window.width = 0; @@ -149,6 +147,17 @@ class TVOSPlatform extends PlatformTarget { Sys.println(Path.combine(targetDirectory, project.app.file + ".xcodeproj")); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -365,7 +374,8 @@ class TVOSPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); diff --git a/tools/platforms/TizenPlatform.hx b/tools/platforms/TizenPlatform.hx index 993153fcf5..1c07a5f0ac 100644 --- a/tools/platforms/TizenPlatform.hx +++ b/tools/platforms/TizenPlatform.hx @@ -27,56 +27,53 @@ class TizenPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.architectures = [Architecture.ARMV6]; defaults.window.width = 0; diff --git a/tools/platforms/WebAssemblyPlatform.hx b/tools/platforms/WebAssemblyPlatform.hx index 53b6cc34f1..66d763add0 100644 --- a/tools/platforms/WebAssemblyPlatform.hx +++ b/tools/platforms/WebAssemblyPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import haxe.Json; import hxp.Haxelib; import hxp.HXML; @@ -32,56 +33,53 @@ class WebAssemblyPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; defaults.window.fps = 60; defaults.window.allowHighDPI = false; @@ -118,7 +116,19 @@ class WebAssemblyPlatform extends PlatformTarget } var hxml = targetDirectory + "/haxe/" + buildType + ".hxml"; - var args = [hxml, "-D", "webassembly", "-D", "wasm", "-D", "emscripten", "-D", "webgl", "-D", "static_link"]; + var args = [ + hxml, + "-D", + "webassembly", + "-D", + "wasm", + "-D", + "emscripten", + "-D", + "webgl", + "-D", + "static_link" + ]; if (Log.verbose) { @@ -190,7 +200,9 @@ 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") + || project.defines.exists("disable-exception-catching") + || project.targetFlags.exists("disable-exception-catching")) { args.push("-s"); args.push("DISABLE_EXCEPTION_CATCHING=1"); @@ -349,6 +361,17 @@ class WebAssemblyPlatform extends PlatformTarget { Sys.println(outputFile); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -363,7 +386,8 @@ class WebAssemblyPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 7a47a9f9a4..9c5baed73c 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -1,5 +1,6 @@ package; +import lime.tools.ObjectHelper; import lime.tools.HashlinkHelper; import hxp.Haxelib; import hxp.HXML; @@ -45,56 +46,53 @@ class WindowsPlatform extends PlatformTarget var defaults = new HXProject(); - defaults.meta = - { - title: "MyApplication", - description: "", - packageName: "com.example.myapp", - version: "1.0.0", - company: "", - companyUrl: "", - buildNumber: null, - companyId: "" - }; - - defaults.app = - { - main: "Main", - file: "MyApplication", - path: "bin", - preloader: "", - swfVersion: 17, - url: "", - init: null - }; - - defaults.window = - { - width: 800, - height: 600, - parameters: "{}", - background: 0xFFFFFF, - fps: 30, - hardware: true, - display: 0, - resizable: true, - borderless: false, - orientation: Orientation.AUTO, - vsync: false, - fullscreen: false, - allowHighDPI: true, - alwaysOnTop: false, - antialiasing: 0, - allowShaders: true, - requireShaders: false, - depthBuffer: true, - stencilBuffer: true, - colorDepth: 32, - maximized: false, - minimized: false, - hidden: false, - title: "" - }; + defaults.meta = { + title: "MyApplication", + description: "", + packageName: "com.example.myapp", + version: "1.0.0", + company: "", + companyUrl: "", + buildNumber: null, + companyId: "" + }; + + defaults.app = { + main: "Main", + file: "MyApplication", + path: "bin", + preloader: "", + swfVersion: 17, + url: "", + init: null + }; + + defaults.window = { + width: 800, + height: 600, + parameters: "{}", + background: 0xFFFFFF, + fps: 30, + hardware: true, + display: 0, + resizable: true, + borderless: false, + orientation: Orientation.AUTO, + vsync: false, + fullscreen: false, + allowHighDPI: true, + alwaysOnTop: false, + antialiasing: 0, + allowShaders: true, + requireShaders: false, + depthBuffer: true, + stencilBuffer: true, + colorDepth: 32, + maximized: false, + minimized: false, + hidden: false, + title: "" + }; if (project.targetFlags.exists("uwp") || project.targetFlags.exists("winjs")) { @@ -260,7 +258,15 @@ class WindowsPlatform extends PlatformTarget // start by finding visual studio var programFilesX86 = Sys.getEnv("ProgramFiles(x86)"); var vswhereCommand = programFilesX86 + "\\Microsoft Visual Studio\\Installer\\vswhere.exe"; - var vswhereOutput = System.runProcess("", vswhereCommand, ["-latest", "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-property", "installationPath"]); + var vswhereOutput = System.runProcess("", vswhereCommand, [ + "-latest", + "-products", + "*", + "-requires", + "Microsoft.Component.MSBuild", + "-property", + "installationPath" + ]); var visualStudioPath = StringTools.trim(vswhereOutput); // then, find MSBuild inside visual studio var msBuildPath = visualStudioPath + "\\MSBuild\\Current\\Bin\\MSBuild.exe"; @@ -332,8 +338,7 @@ class WindowsPlatform extends PlatformTarget { ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".hdll", applicationDirectory, project.debug, targetSuffix); - ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".lib", applicationDirectory, project.debug, - ".lib"); + ProjectHelper.copyLibrary(project, ndll, "Windows" + (is64 ? "64" : ""), "", ".lib", applicationDirectory, project.debug, ".lib"); } else { @@ -375,7 +380,18 @@ class WindowsPlatform extends PlatformTarget var command:Array = null; if (project.targetFlags.exists("gcc")) { - command = ["gcc", "-O3", "-o", executablePath, "-std=c11", "-Wl,-subsystem,windows", "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c"), "C:/Windows/System32/dbghelp.dll"]; + command = [ + "gcc", + "-O3", + "-o", + executablePath, + "-std=c11", + "-Wl,-subsystem,windows", + "-I", + Path.combine(targetDirectory, "obj"), + Path.combine(targetDirectory, "obj/ApplicationMain.c"), + "C:/Windows/System32/dbghelp.dll" + ]; for (file in System.readDirectory(applicationDirectory)) { switch Path.extension(file) @@ -392,13 +408,31 @@ class WindowsPlatform extends PlatformTarget // start by finding visual studio var programFilesX86 = Sys.getEnv("ProgramFiles(x86)"); var vswhereCommand = programFilesX86 + "\\Microsoft Visual Studio\\Installer\\vswhere.exe"; - var vswhereOutput = System.runProcess("", vswhereCommand, ["-latest", "-products", "*", "-requires", "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", "-property", "installationPath"]); + var vswhereOutput = System.runProcess("", vswhereCommand, [ + "-latest", + "-products", + "*", + "-requires", + "Microsoft.VisualStudio.Component.VC.Tools.x86.x64", + "-property", + "installationPath" + ]); var visualStudioPath = StringTools.trim(vswhereOutput); var vcvarsallPath = visualStudioPath + "\\VC\\Auxiliary\\Build\\vcvarsall.bat"; // this command sets up the environment variables and things that visual studio requires - var vcvarsallCommand = [vcvarsallPath, "x64"].map(function(arg:String):String { return ~/([&|\(\)<>\^ ])/g.replace(arg, "^$1"); }); + var vcvarsallCommand = [vcvarsallPath, "x64"].map(function(arg:String):String + { + return ~/([&|\(\)<>\^ ])/g.replace(arg, "^$1"); + }); // this command runs the cl.exe c compiler from visual studio - var clCommand = ["cl.exe", "/Ox", "/Fe:" + executablePath, "-I", Path.combine(targetDirectory, "obj"), Path.combine(targetDirectory, "obj/ApplicationMain.c")]; + var clCommand = [ + "cl.exe", + "/Ox", + "/Fe:" + executablePath, + "-I", + Path.combine(targetDirectory, "obj"), + Path.combine(targetDirectory, "obj/ApplicationMain.c") + ]; for (file in System.readDirectory(applicationDirectory)) { switch Path.extension(file) @@ -411,7 +445,10 @@ class WindowsPlatform extends PlatformTarget } clCommand.push("/link"); clCommand.push("/subsystem:windows"); - clCommand = clCommand.map(function(arg:String):String { return ~/([&|\(\)<>\^ ])/g.replace(arg, "^$1"); }); + clCommand = clCommand.map(function(arg:String):String + { + return ~/([&|\(\)<>\^ ])/g.replace(arg, "^$1"); + }); // combine both commands into one command = ["cmd.exe", "/s", "/c", vcvarsallCommand.join(" ") + " && " + clCommand.join(" ")]; } @@ -653,6 +690,17 @@ class WindowsPlatform extends PlatformTarget { Sys.println(executablePath); } + else if (project.targetFlags.exists("template-context")) + { + if (project.targetFlags.exists("json")) + { + Sys.println(ObjectHelper.formatJson(project.templateContext)); + } + else + { + Sys.println(ObjectHelper.formatForDisplay(project.templateContext)); + } + } else { Sys.println(getDisplayHXML().toString()); @@ -734,7 +782,8 @@ class WindowsPlatform extends PlatformTarget // modified more recently than the .hxml, then the .hxml cannot be // considered valid anymore. it may cause errors in editors like vscode. if (FileSystem.exists(path) - && (project.projectFilePath == null || !FileSystem.exists(project.projectFilePath) + && (project.projectFilePath == null + || !FileSystem.exists(project.projectFilePath) || (FileSystem.stat(path).mtime.getTime() > FileSystem.stat(project.projectFilePath).mtime.getTime()))) { return File.getContent(path); @@ -779,7 +828,8 @@ class WindowsPlatform extends PlatformTarget if (targetType == "hl") { // default to 64 bit, just like upstream Hashlink releases - if (!targetFlags.exists("32") && !targetFlags.exists("x86_32") + if (!targetFlags.exists("32") + && !targetFlags.exists("x86_32") && (System.hostArchitecture == X64 || targetFlags.exists("64") || targetFlags.exists("x86_64"))) { commands.push(["-Dwindows", "-DHXCPP_M64", "-Dhashlink"]); @@ -791,7 +841,8 @@ class WindowsPlatform extends PlatformTarget } else { - if (!targetFlags.exists("64") && !targetFlags.exists("x86_64") + if (!targetFlags.exists("64") + && !targetFlags.exists("x86_64") && (command == "rebuild" || System.hostArchitecture == X86 || (targetType != "cpp" && targetType != "winrt"))) { if (targetType == "winrt") @@ -808,7 +859,8 @@ class WindowsPlatform extends PlatformTarget // as previous Windows builds. For now, force -64 to be done last // so that it can be debugged in a default "rebuild" - if (!targetFlags.exists("32") && !targetFlags.exists("x86_32") + if (!targetFlags.exists("32") + && !targetFlags.exists("x86_32") && System.hostArchitecture == X64 && (command != "rebuild" || targetType == "cpp" || targetType == "neko" || targetType == "winrt")) { From 6df13a36a3df7731e69cd36e6e0123655338594e Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:11:44 -0700 Subject: [PATCH 05/14] Update hxformat config --- hxformat.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hxformat.json b/hxformat.json index f1ccef84a4..2717465e8d 100644 --- a/hxformat.json +++ b/hxformat.json @@ -1,7 +1,16 @@ { + "excludes": [ + "\\templates", + "/templates", + "\\project", + "/project" + ], "lineEnds": { "leftCurly": "both", - "rightCurly": "both" + "rightCurly": "both", + "objectLiteralCurly": { + "leftCurly": "after" + } }, "sameLine": { "ifBody": "same", From d236cbde75f681d1e3fc6775d4f11cb8c53853a1 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:19:27 -0700 Subject: [PATCH 06/14] Add LIB_(NAME)_PATH variable to template context --- src/lime/tools/HXProject.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lime/tools/HXProject.hx b/src/lime/tools/HXProject.hx index cceb84f646..aca7e1d6ae 100644 --- a/src/lime/tools/HXProject.hx +++ b/src/lime/tools/HXProject.hx @@ -1346,6 +1346,7 @@ class HXProject extends Script // #end Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxelib.name), true); + Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxelib.name) + "_PATH", Haxelib.getPath(haxelib)); if (name == "nme") { From b088cf336dc5b7e726e493b59b62c68fd25d23e1 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:23:27 -0700 Subject: [PATCH 07/14] Use instead of define --- tools/platforms/HTML5Platform.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 4163882c1a..cf1ca5da5a 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -266,7 +266,7 @@ class HTML5Platform extends PlatformTarget try { if (targetFlags.exists("npm") - || project.defines.exists("npm") + || project.config.get("html5").getBool("npm", false) || (FileSystem.exists(targetDirectory + "/package.json") && !targetFlags.exists("electron"))) { npm = true; From 8302f7714aef008a8c6e666578f2c2ab1ac6a1b9 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:44:51 -0700 Subject: [PATCH 08/14] Fix rebase issue --- tools/platforms/HTML5Platform.hx | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 0308cb021c..cf1ca5da5a 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -108,25 +108,10 @@ class HTML5Platform extends PlatformTarget { if (npm) { -<<<<<<< HEAD runNPMCommand(["run", "lime:prebuild", "--if-present"]); } ModuleHelper.buildModules(project, targetDirectory + "/obj", outputDirectory); -======= - if (command == "build") - { - var buildCommand = "build:" + (project.targetFlags.exists("final") ? "prod" : "dev"); - System.runCommand(targetDirectory + "/bin", "npm", ["run", buildCommand, "-s"]); - } - else - { - return; - } - } - - ModuleHelper.buildModules(project, targetDirectory + "/obj", targetDirectory + "/bin"); ->>>>>>> develop if (project.app.main != null) { @@ -185,14 +170,11 @@ class HTML5Platform extends PlatformTarget HTML5Helper.minify(project, outputFile); } } -<<<<<<< HEAD if (npm && (command == "build" || (command == "test" && finalRelease))) { runNPMCommand(["run", "lime:build", "--if-present"]); } -======= ->>>>>>> develop } public override function clean():Void @@ -283,18 +265,11 @@ class HTML5Platform extends PlatformTarget try { -<<<<<<< HEAD if (targetFlags.exists("npm") || project.config.get("html5").getBool("npm", false) || (FileSystem.exists(targetDirectory + "/package.json") && !targetFlags.exists("electron"))) { npm = true; -======= - if (targetFlags.exists("npm") || (FileSystem.exists(targetDirectory + "/bin/package.json") && !targetFlags.exists("electron"))) - { - npm = true; - outputFile = project.app.file + ".js"; ->>>>>>> develop } } catch (e:Dynamic) {} @@ -389,14 +364,8 @@ class HTML5Platform extends PlatformTarget // project = project.clone (); -<<<<<<< HEAD var destination = assetsDirectory + "/"; System.mkdir(assetsDirectory); -======= - var destination = targetDirectory + "/bin/"; - if (npm) destination += "dist/"; - System.mkdir(destination); ->>>>>>> develop var webfontDirectory = targetDirectory + "/obj/webfont"; var useWebfonts = true; From c40723b1ad716f99af57589865b952e168ffff38 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 18:50:08 -0700 Subject: [PATCH 09/14] Fix support for older Haxe releases --- src/lime/tools/ObjectHelper.hx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lime/tools/ObjectHelper.hx b/src/lime/tools/ObjectHelper.hx index 2ea8aa56b7..70b1aeadff 100644 --- a/src/lime/tools/ObjectHelper.hx +++ b/src/lime/tools/ObjectHelper.hx @@ -52,20 +52,21 @@ class ObjectHelper private static function prettyJson(value:Dynamic, level:Int, indent:Int):String { + var isOfType = #if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end; var pad = StringTools.lpad("", " ", level * indent); var nextPad = StringTools.lpad("", " ", (level + 1) * indent); // Primitive types if (value == null) return "null"; - if (Std.isOfType(value, Bool) || Std.isOfType(value, Int) || Std.isOfType(value, Float)) return Std.string(value); - if (Std.isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"'; + if (isOfType(value, Bool) || isOfType(value, Int) || isOfType(value, Float)) return Std.string(value); + if (isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"'; // Enums var e = Type.getEnum(value); if (e != null) return '"' + Type.enumConstructor(value) + '"'; // Arrays - if (Std.isOfType(value, Array)) + if (isOfType(value, Array)) { var arr:Array = cast value; var items = arr.map(function(v) return prettyJson(v, level + 1, indent)); From 56bc5002708f38b819c2436e3913e1794b022bd0 Mon Sep 17 00:00:00 2001 From: jgranick Date: Sun, 29 Mar 2026 19:10:19 -0700 Subject: [PATCH 10/14] Remove redundant method --- src/lime/tools/ObjectHelper.hx | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/lime/tools/ObjectHelper.hx b/src/lime/tools/ObjectHelper.hx index 70b1aeadff..d3c0b65e69 100644 --- a/src/lime/tools/ObjectHelper.hx +++ b/src/lime/tools/ObjectHelper.hx @@ -19,37 +19,6 @@ class ObjectHelper return prettyJson(obj, 0, indent); } - private static function objectToString(value:Dynamic):String - { - if (value == null) return "null"; - if (Std.isOfType(value, Bool) || Std.isOfType(value, Int) || Std.isOfType(value, Float)) return Std.string(value); - if (Std.isOfType(value, String)) return '"' + StringTools.replace(value, '"', '\\"') + '"'; - - // Handle enums - var e = Type.getEnum(value); - if (e != null) return Type.enumConstructor(value); - - // Handle arrays - if (Std.isOfType(value, Array)) - { - var arr:Array = cast value; - return "[" + arr.map(objectToString).join(", ") + "]"; - } - - // Handle objects/maps recursively - var fields = Reflect.fields(value); - if (fields.length > 0) - { - var pairs = fields.map(function(f) - { - return f + ": " + objectToString(Reflect.field(value, f)); - }); - return "{" + pairs.join(", ") + "}"; - } - - return ""; - } - private static function prettyJson(value:Dynamic, level:Int, indent:Int):String { var isOfType = #if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end; From 6cd5fa3fba4eb43046017fb679cf98ee7c1791c6 Mon Sep 17 00:00:00 2001 From: jgranick Date: Mon, 30 Mar 2026 10:15:00 -0700 Subject: [PATCH 11/14] Add FLAG_(NAME) variable to template context for target flags, add missing LIB_*_PATH variable --- src/lime/tools/HXProject.hx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lime/tools/HXProject.hx b/src/lime/tools/HXProject.hx index aca7e1d6ae..02c2c74b7a 100644 --- a/src/lime/tools/HXProject.hx +++ b/src/lime/tools/HXProject.hx @@ -1143,10 +1143,21 @@ class HXProject extends Script { if (StringTools.startsWith(haxeflag, "-lib")) { - Reflect.setField(context, "LIB_" + StringTools.formatUppercaseVariable(haxeflag.substr(5)), "true"); + var haxelibName = StringTools.formatUppercaseVariable(haxeflag.substr(5)); + Reflect.setField(context, "LIB_" + haxelibName, "true"); + try + { + Reflect.setField(context, "LIB_" + haxelibName + "_PATH", Haxelib.getPath(new Haxelib(haxelibName))); + } + catch(e: Dynamic) {} } } + for (flag in targetFlags.keys()) + { + Reflect.setField(context, "FLAG_" + StringTools.formatUppercaseVariable(flag), targetFlags.get(flag)); + } + context.assets = new Array(); for (asset in assets) From 47fa27c48179d09d9df0a44208a90d2db9e330db Mon Sep 17 00:00:00 2001 From: jgranick Date: Mon, 30 Mar 2026 10:15:48 -0700 Subject: [PATCH 12/14] Change course, push standard build output into bin on all builds (NPM or not) --- tools/platforms/HTML5Platform.hx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index cf1ca5da5a..fdf4dcf927 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -275,8 +275,8 @@ class HTML5Platform extends PlatformTarget catch (e:Dynamic) {} finalRelease = (!project.debug && project.targetFlags.exists("final")); - assetsDirectory = targetDirectory + (npm ? "/public" : "/bin"); - outputDirectory = targetDirectory + (npm ? "/build" : "/bin"); + outputDirectory = targetDirectory + "/bin"; + assetsDirectory = outputDirectory; outputFile = outputDirectory + "/" + project.app.file + ".js"; } @@ -311,7 +311,8 @@ class HTML5Platform extends PlatformTarget if (needsInstall) { - runNPMCommand(["install"]); + // Show output, even when !verbose + System.runCommand(targetDirectory, "npm", ["install"]); } } @@ -453,6 +454,7 @@ class HTML5Platform extends PlatformTarget if (npm) { + // Ensure all HXML paths are absolute var path:String; for (i in 0...project.sources.length) { From 7ff602a5f95dea8415cda93a994e2fb8cb4bab0f Mon Sep 17 00:00:00 2001 From: jgranick Date: Mon, 30 Mar 2026 10:16:39 -0700 Subject: [PATCH 13/14] Make the default NPM template configuration work as-is --- templates/html5/npm/index.html | 45 +++++++++++++++++++++++++++++ templates/html5/npm/package.json | 17 ++++++----- templates/html5/npm/vite.config.mjs | 3 ++ 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 templates/html5/npm/index.html create mode 100644 templates/html5/npm/vite.config.mjs diff --git a/templates/html5/npm/index.html b/templates/html5/npm/index.html new file mode 100644 index 0000000000..daac92480a --- /dev/null +++ b/templates/html5/npm/index.html @@ -0,0 +1,45 @@ + + + + + + + ::APP_TITLE:: + + + + + ::if favicons::::foreach (favicons):: + ::end::::end:: + + ::if linkedLibraries::::foreach (linkedLibraries):: + ::end::::end:: + + + + + + + + + ::foreach assets::::if (type == "font"):: + ::end::::end:: + +
+ + + + + \ No newline at end of file diff --git a/templates/html5/npm/package.json b/templates/html5/npm/package.json index c9fc0e365d..64f5e85d4f 100755 --- a/templates/html5/npm/package.json +++ b/templates/html5/npm/package.json @@ -3,11 +3,14 @@ "version": "::META_VERSION::", "private": true, "scripts": { - "lime:preupdate": "node -e \"/* (Optional) preupdate: Run tasks before Lime tools update (prepare environment, sync assets, etc) */\"", - "lime:update": "node -e \"/* (Optional) update: Run tasks after Lime tools update (verify updates, log info, etc) */\"", - "lime:prebuild": "node -e \"/* (Optional) prebuild: Run tasks before Lime tools build (codegen, preprocess assets, etc) */\"", - "lime:build": "node -e \"/* (Optional) build: Run tasks after Lime tools build (optimize artifacts, copy files, etc) */\"", - "lime:run": "node -e \"/* (Required) run: Run build output (vite preview, npx serve, npx http-server) */\"", - "lime:test": "node -e \"/* (Required) test: Start dev server/watch mode for non-final builds; replaces build and run lifecycle */\"" + "lime:preupdate": "", + "lime:update": "", + "lime:prebuild": "", + "lime:build": "vite build", + "lime:run": "vite preview ::if (FLAG_PORT != null)::-p ::FLAG_PORT::::end:: ::if (FLAG_NOLAUNCH != null)::::else::--open::end::", + "lime:test": "vite ::if (FLAG_PORT != null)::-p ::FLAG_PORT::::end:: ::if (FLAG_NOLAUNCH != null)::::else::--open::end::" + }, + "devDependencies": { + "vite": "^8.0.0" } -} \ No newline at end of file +} diff --git a/templates/html5/npm/vite.config.mjs b/templates/html5/npm/vite.config.mjs new file mode 100644 index 0000000000..09a5a51b97 --- /dev/null +++ b/templates/html5/npm/vite.config.mjs @@ -0,0 +1,3 @@ +export default { + publicDir: "bin" +}; \ No newline at end of file From b3c9cddfa0cba25047d7601da4e96dd381ae2a62 Mon Sep 17 00:00:00 2001 From: jgranick Date: Mon, 30 Mar 2026 10:33:19 -0700 Subject: [PATCH 14/14] Treat HTML5 bin output as canonical and consistent, do minify on -final builds into bin (NPM minification would require a second/seperate build) --- tools/platforms/HTML5Platform.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index fdf4dcf927..e67f53deee 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -165,7 +165,7 @@ class HTML5Platform extends PlatformTarget System.copyFileTemplate(project.templatePaths, "html5/output.js", outputFile, context); } - if (project.targetFlags.exists("minify") || (type == "final" && !npm)) + if (project.targetFlags.exists("minify")) { HTML5Helper.minify(project, outputFile); }