From 4899a48ee0a9bd23aad2b90207f836091f9d6cf4 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 7 Mar 2024 15:16:22 -0600 Subject: [PATCH] add hxp add hxformat.json --- Build.hx | 16 ++++++++---- build/index.js | 50 +++++++++++++++++++++--------------- hxformat.json | 18 +++++++++++++ src/Haxelib.hx | 27 ++++++++++++------- src/Main.hx | 70 ++++++++++++++++++++++++++++++++------------------ 5 files changed, 121 insertions(+), 60 deletions(-) create mode 100644 hxformat.json diff --git a/Build.hx b/Build.hx index 77edb25..ec8ef41 100644 --- a/Build.hx +++ b/Build.hx @@ -1,17 +1,23 @@ import haxe.macro.Compiler; import sys.io.File; -function main() { +function main() +{ trace("Running: ncc build build/haxe-output.js -o build"); Sys.command("ncc build build/haxe-output.js -o build"); - + final path = "build/index.js"; final file = File.getContent(path); - if (file == null) { + if (file == null) + { trace('No file named index.js found, creation unsuccesful'); - } else if (file.indexOf('// Generated by Haxe') == 0) { + } + else if (file.indexOf('// Generated by Haxe') == 0) + { trace('File index.js was not updated'); - } else { + } + else + { trace('index.js created or updated, successfully'); final haxe = Compiler.getDefine("haxe"); File.saveContent(path, '// Generated by Haxe $haxe\n' + file); diff --git a/build/index.js b/build/index.js index 004addb..1e35e0f 100644 --- a/build/index.js +++ b/build/index.js @@ -3225,7 +3225,6 @@ function Main_installHaxelibs(limeVersion,openflVersion,flixelVersions) { let lib3 = "nape-haxe4"; let lib4 = "haxeui-core"; let lib5 = "haxeui-flixel"; - let lib6 = "format"; let user2 = "HaxeFoundation"; let haxelib2 = "hscript"; let user3 = "larsiusprime"; @@ -3237,30 +3236,30 @@ function Main_installHaxelibs(limeVersion,openflVersion,flixelVersions) { let user5 = "larsiusprime"; let haxelib5 = "steamwrap"; let defaultUser = "openfl"; - let lib7 = "lime"; + let lib6 = "lime"; let version = limeVersion; let defaultUser1 = "openfl"; - let lib8 = "openfl"; + let lib7 = "openfl"; let version1 = openflVersion; let defaultUser2 = "HaxeFlixel"; - let lib9 = "flixel"; + let lib8 = "flixel"; let version2 = flixelVersions; let defaultUser3 = "HaxeFlixel"; - let lib10 = "flixel-tools"; + let lib9 = "flixel-tools"; let version3 = flixelVersions; let defaultUser4 = "HaxeFlixel"; - let lib11 = "flixel-templates"; + let lib10 = "flixel-templates"; let version4 = flixelVersions; let defaultUser5 = "HaxeFlixel"; - let lib12 = "flixel-demos"; + let lib11 = "flixel-demos"; let version5 = flixelVersions; let defaultUser6 = "HaxeFlixel"; - let lib13 = "flixel-addons"; + let lib12 = "flixel-addons"; let version6 = flixelVersions; let defaultUser7 = "HaxeFlixel"; - let lib14 = "flixel-ui"; + let lib13 = "flixel-ui"; let version7 = flixelVersions; - return Command_runUntilFailure([function() { + let libs = [function() { return Haxelib_git(user,haxelib,githubLib,branch,path); },function() { return Haxelib_git(user1,haxelib1,githubLib1,branch1,path1); @@ -3276,8 +3275,6 @@ function Main_installHaxelibs(limeVersion,openflVersion,flixelVersions) { return Haxelib_install(lib4); },function() { return Haxelib_install(lib5); - },function() { - return Haxelib_install(lib6); },function() { return Haxelib_git(user2,haxelib2); },function() { @@ -3287,22 +3284,33 @@ function Main_installHaxelibs(limeVersion,openflVersion,flixelVersions) { },function() { return Haxelib_git(user5,haxelib5); },function() { - return Haxelib_fromVersion(defaultUser,lib7,version); + return Haxelib_fromVersion(defaultUser,lib6,version); },function() { - return Haxelib_fromVersion(defaultUser1,lib8,version1); + return Haxelib_fromVersion(defaultUser1,lib7,version1); },function() { - return Haxelib_fromVersion(defaultUser2,lib9,version2); + return Haxelib_fromVersion(defaultUser2,lib8,version2); },function() { - return Haxelib_fromVersion(defaultUser3,lib10,version3); + return Haxelib_fromVersion(defaultUser3,lib9,version3); },function() { - return Haxelib_fromVersion(defaultUser4,lib11,version4); + return Haxelib_fromVersion(defaultUser4,lib10,version4); },function() { - return Haxelib_fromVersion(defaultUser5,lib12,version5); + return Haxelib_fromVersion(defaultUser5,lib11,version5); },function() { - return Haxelib_fromVersion(defaultUser6,lib13,version6); + return Haxelib_fromVersion(defaultUser6,lib12,version6); },function() { - return Haxelib_fromVersion(defaultUser7,lib14,version7); - }]); + return Haxelib_fromVersion(defaultUser7,lib13,version7); + }]; + if(limeVersion == "dev") { + let lib = "format"; + libs.push(function() { + return Haxelib_install(lib); + }); + let lib1 = "hxp"; + libs.push(function() { + return Haxelib_install(lib1); + }); + } + return Command_runUntilFailure(libs); } function Main_installHxcpp(target) { if(target != "cpp") { diff --git a/hxformat.json b/hxformat.json new file mode 100644 index 0000000..d747ff5 --- /dev/null +++ b/hxformat.json @@ -0,0 +1,18 @@ +{ + "lineEnds": { + "leftCurly": "both", + "rightCurly": "both", + "objectLiteralCurly": { + "leftCurly": "after" + } + }, + "sameLine": { + "ifElse": "next", + "doWhile": "next", + "tryBody": "next", + "tryCatch": "next" + }, + "indentation":{ + "trailingWhitespace": true + } +} diff --git a/src/Haxelib.hx b/src/Haxelib.hx index 4df2d2e..f9e9c83 100644 --- a/src/Haxelib.hx +++ b/src/Haxelib.hx @@ -1,12 +1,15 @@ import Command.ExitCode; import Main.LibVersion; -function run(args:Array):ExitCode { +function run(args:Array):ExitCode +{ return Command.run("haxelib", ["run"].concat(args)); } -function fromVersion(defaultUser:String, lib:String, version:LibVersion):ExitCode { - return switch (version) { +function fromVersion(defaultUser:String, lib:String, version:LibVersion):ExitCode +{ + return switch (version) + { case Dev: Haxelib.git(defaultUser, lib); case Release | "" | null: @@ -16,9 +19,11 @@ function fromVersion(defaultUser:String, lib:String, version:LibVersion):ExitCod } } -function install(lib:String, ?version:String):ExitCode { +function install(lib:String, ?version:String):ExitCode +{ final args = ["install", lib]; - if (version != null) { + if (version != null) + { args.push(version); } args.push("--quiet"); @@ -26,15 +31,19 @@ function install(lib:String, ?version:String):ExitCode { return Command.run("haxelib", args); } -function git(user:String, haxelib:String, ?githubLib:String, ?branch:String, ?path:String):ExitCode { - if (githubLib == null) { +function git(user:String, haxelib:String, ?githubLib:String, ?branch:String, ?path:String):ExitCode +{ + if (githubLib == null) + { githubLib = haxelib; } final args = ["git", haxelib, 'https://github.com/$user/$githubLib']; - if (branch != null) { + if (branch != null) + { args.push(branch); } - if (path != null) { + if (path != null) + { args.push(path); } args.push("--quiet"); diff --git a/src/Main.hx b/src/Main.hx index 0a8608b..4ea6be8 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -7,17 +7,20 @@ import sys.io.File; using StringTools; -enum abstract LibVersion(String) from String { +enum abstract LibVersion(String) from String +{ final Dev = "dev"; final Release = "release"; } -enum abstract TestLocation(String) from String { +enum abstract TestLocation(String) from String +{ final Local = "local"; final Git = "git"; } -enum abstract HaxeVersion(String) from String to String { +enum abstract HaxeVersion(String) from String to String +{ final Latest = "latest"; final Stable = "stable"; final Nightly = "nightly"; @@ -27,7 +30,8 @@ enum abstract HaxeVersion(String) from String to String { private final HaxelibRepo = Path.join([Sys.getEnv("HOME"), "haxe/haxelib"]); -function main() { +function main() +{ final haxeVersion:HaxeVersion = Core.getInput("haxe-version"); final limeVersion:LibVersion = Core.getInput("lime-version"); final openflVersion:LibVersion = Core.getInput("openfl-version"); @@ -35,13 +39,15 @@ function main() { final testLocation:TestLocation = Core.getInput("test-location"); final target:Target = Core.getInput("target"); final runTests:Bool = Core.getInput("run-tests") == "true"; - - if (runTests) { - if (target == Hl && haxeVersion.startsWith("3")) { + + if (runTests) + { + if (target == Hl && haxeVersion.startsWith("3")) + { return; // OpenFL's HL target and Haxe 3 don't work together } } - + Core.startGroup("Installing Haxe Dependencies"); final installationResult = runUntilFailure([ setupLix.bind(haxeVersion), @@ -53,12 +59,13 @@ function main() { installHaxelibs.bind(limeVersion, openflVersion, flixelVersions), installHxcpp.bind(target) ]); - if (installationResult != Success) { + if (installationResult != Success) + { Sys.exit(Failure); } Core.exportVariable("HAXELIB_REPO", HaxelibRepo); Core.endGroup(); - + Core.startGroup("Listing Dependencies"); if (haxeVersion != Current) run("lix -v"); @@ -69,40 +76,44 @@ function main() { run("haxelib fixrepo"); run("haxelib list"); Core.endGroup(); - - if (runTests) { + + if (runTests) + { Core.startGroup("Test Preparation"); - + if (testLocation == Local) // When testing changes to flixel, flixel is set to the dev version cd("tests"); else // otherwise use git version cd(Path.join([HaxelibRepo, "flixel/git/tests"])); - + putEnv("HXCPP_SILENT", "1"); putEnv("HXCPP_COMPILE_CACHE", Sys.getEnv("HOME") + "/hxcpp_cache"); putEnv("HXCPP_CACHE_MB", "5000"); Core.endGroup(); - + Sys.exit(runAllNamed(Tests.make(target))); } } -private function setupLix(haxeVersion):ExitCode { +private function setupLix(haxeVersion):ExitCode +{ if (haxeVersion == Current) return Success; - + Sys.command("lix scope"); final path = Path.join([Sys.getEnv("HOME"), "haxe/.haxerc"]); - if (!FileSystem.exists(path)) { + if (!FileSystem.exists(path)) + { return Failure; } File.saveContent(path, '{"version": "stable", "resolveLibs": "haxelib"}'); return run('lix install haxe $haxeVersion --global'); } -private function installHaxelibs(limeVersion:LibVersion, openflVersion:LibVersion, flixelVersions:LibVersion):ExitCode { +private function installHaxelibs(limeVersion:LibVersion, openflVersion:LibVersion, flixelVersions:LibVersion):ExitCode +{ final libs = [ // TODO: fix git version failing on nightly // Haxelib.git.bind("massive-oss", "munit", "MassiveUnit", "master", "src"), @@ -114,27 +125,36 @@ private function installHaxelibs(limeVersion:LibVersion, openflVersion:LibVersio Haxelib.install.bind("nape-haxe4"), Haxelib.install.bind("haxeui-core"), Haxelib.install.bind("haxeui-flixel"), - Haxelib.install.bind("format"), // needed for git lime + Haxelib.git.bind("HaxeFoundation", "hscript"), Haxelib.git.bind("larsiusprime", "firetongue"), Haxelib.git.bind("Geokureli", "spinehaxe", "spinehaxe", "haxe4.3.1"), Haxelib.git.bind("larsiusprime", "steamwrap"), - + Haxelib.fromVersion.bind("openfl", "lime", limeVersion), Haxelib.fromVersion.bind("openfl", "openfl", openflVersion), - + Haxelib.fromVersion.bind("HaxeFlixel", "flixel", flixelVersions), Haxelib.fromVersion.bind("HaxeFlixel", "flixel-tools", flixelVersions), Haxelib.fromVersion.bind("HaxeFlixel", "flixel-templates", flixelVersions), Haxelib.fromVersion.bind("HaxeFlixel", "flixel-demos", flixelVersions), Haxelib.fromVersion.bind("HaxeFlixel", "flixel-addons", flixelVersions), - Haxelib.fromVersion.bind("HaxeFlixel", "flixel-ui", flixelVersions), + Haxelib.fromVersion.bind("HaxeFlixel", "flixel-ui", flixelVersions) ]; + + if (limeVersion == Dev) + { + // needed for git lime + libs.push(Haxelib.install.bind("format")); + libs.push(Haxelib.install.bind("hxp")); + } return runUntilFailure(libs); } -private function installHxcpp(target:Target):ExitCode { - if (target != Cpp) { +private function installHxcpp(target:Target):ExitCode +{ + if (target != Cpp) + { return Success; } final hxcppDir = Path.join([HaxelibRepo, "hxcpp/git/"]);