From 8d07d4a05823c5bed016cc3dd3ecd431eacbfc11 Mon Sep 17 00:00:00 2001 From: tobil4sk Date: Mon, 26 Aug 2024 16:46:16 +0100 Subject: [PATCH] Allow compiling client with hxcpp target (#643) * Allow compiling client with hxcpp target * Add tests for hxcpp build of haxelib * Put shared flags into each.hxml --- Earthfile | 20 +++++++++++++++----- client.hxml | 5 +---- client_cpp.hxml | 6 ++++++ client_legacy.hxml | 5 +---- client_tests.hxml | 5 +---- each.hxml | 4 ++++ integration_tests.hxml | 7 ++----- libs.hxml | 1 + package.hxml | 5 +---- server_each.hxml | 5 +---- server_gitrepo.hxml | 5 +---- server_legacy.hxml | 1 - src/Package.hx | 1 - src/haxelib/client/Main.hx | 10 +++++----- test/IntegrationTests.hx | 2 ++ test/RunCi.hx | 22 ++++++++-------------- 16 files changed, 49 insertions(+), 55 deletions(-) create mode 100644 client_cpp.hxml create mode 100644 each.hxml diff --git a/Earthfile b/Earthfile index 33eaa6950..fe7ee78ac 100644 --- a/Earthfile +++ b/Earthfile @@ -205,10 +205,19 @@ run.n: COPY .git .git COPY src src COPY hx3compat hx3compat - COPY client.hxml haxelib.json . + COPY client.hxml each.hxml haxelib.json . RUN haxe client.hxml SAVE ARTIFACT run.n AS LOCAL run.n +haxelib-binary: + FROM +devcontainer + COPY .git .git + COPY src src + COPY hx3compat hx3compat + COPY client_cpp.hxml each.hxml haxelib.json . + RUN haxe client_cpp.hxml + SAVE ARTIFACT haxelib AS LOCAL haxelib + package-haxelib: FROM +devcontainer-base COPY src src @@ -350,7 +359,7 @@ haxelib-server-builder: haxelib-server-legacy: FROM +haxelib-server-builder - COPY server_legacy.hxml server_each.hxml . + COPY server_legacy.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat COPY www/legacy www/legacy @@ -359,7 +368,7 @@ haxelib-server-legacy: haxelib-server-website: FROM +haxelib-server-builder - COPY server_website.hxml server_each.hxml . + COPY server_website.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_website.hxml @@ -373,7 +382,7 @@ haxelib-server-website-highlighter: haxelib-server-tasks: FROM +haxelib-server-builder - COPY server_tasks.hxml server_each.hxml . + COPY server_tasks.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_tasks.hxml @@ -381,7 +390,7 @@ haxelib-server-tasks: haxelib-server-api: FROM +haxelib-server-builder - COPY server_api.hxml server_each.hxml . + COPY server_api.hxml server_each.hxml each.hxml . COPY src src COPY hx3compat hx3compat RUN haxe server_api.hxml @@ -518,6 +527,7 @@ ci-tests: # for package.hxml COPY haxelib.json README.md . COPY +run.n/run.n . + COPY +haxelib-binary/haxelib . COPY +ci-runner/ci.n bin/ci.n ENV HAXELIB_SERVER=localhost diff --git a/client.hxml b/client.hxml index e5a3ae3c8..8339bdfde 100644 --- a/client.hxml +++ b/client.hxml @@ -1,6 +1,3 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -neko run.n -main haxelib.client.Main diff --git a/client_cpp.hxml b/client_cpp.hxml new file mode 100644 index 000000000..0873c8816 --- /dev/null +++ b/client_cpp.hxml @@ -0,0 +1,6 @@ +each.hxml +--cpp bin/cpp +--main haxelib.client.Main +-D destination=../../haxelib{EXESUFFIX} +--dce full +-D analyzer-optimize diff --git a/client_legacy.hxml b/client_legacy.hxml index b35394fe9..cea405795 100644 --- a/client_legacy.hxml +++ b/client_legacy.hxml @@ -1,6 +1,3 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -neko bin/legacyhaxelib.n -main legacyhaxelib.Main \ No newline at end of file diff --git a/client_tests.hxml b/client_tests.hxml index 38c610239..63d96abaa 100644 --- a/client_tests.hxml +++ b/client_tests.hxml @@ -1,8 +1,5 @@ --p src +each.hxml -p test --p hx3compat/std --p hx4compat/std --p crypto/src --main HaxelibTests --debug --neko bin/test.n diff --git a/each.hxml b/each.hxml new file mode 100644 index 000000000..1442fc5a0 --- /dev/null +++ b/each.hxml @@ -0,0 +1,4 @@ +-cp src +-cp hx3compat/std +-cp hx4compat/std +-cp crypto/src diff --git a/integration_tests.hxml b/integration_tests.hxml index 37ab3b6ef..418ac9317 100644 --- a/integration_tests.hxml +++ b/integration_tests.hxml @@ -1,7 +1,4 @@ --cp src --cp test --lib hx3compat --cp hx4compat/std --cp crypto/src +each.hxml +-p test -main IntegrationTests -neko bin/integration_tests.n \ No newline at end of file diff --git a/libs.hxml b/libs.hxml index ef9ca5b34..02cf8bace 100644 --- a/libs.hxml +++ b/libs.hxml @@ -29,4 +29,5 @@ -cmd curl -sSLk https://lib.haxe.org/files/3.0/ufront-2,0,0.zip -o haxelib_global/ufront.zip && neko run.n install --always --skip-dependencies haxelib_global/ufront.zip -cmd curl -sSLk https://lib.haxe.org/files/3.0/utest-1,9,6.zip -o haxelib_global/utest.zip && neko run.n install --always --skip-dependencies haxelib_global/utest.zip -cmd curl -sSLk https://lib.haxe.org/files/3.0/hxnodejs-12,1,0.zip -o haxelib_global/hxnodejs.zip && neko run.n install --always --skip-dependencies haxelib_global/hxnodejs.zip +-cmd curl -sSLk https://lib.haxe.org/files/3.0/hxcpp-4,3,2.zip -o haxelib_global/hxcpp.zip && neko run.n install --always --skip-dependencies haxelib_global/hxcpp.zip -cmd neko run.n dev record-macros lib/record-macros diff --git a/package.hxml b/package.hxml index 0531ad3e3..1449485ce 100755 --- a/package.hxml +++ b/package.hxml @@ -1,5 +1,2 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +-p src --run Package \ No newline at end of file diff --git a/server_each.hxml b/server_each.hxml index aac315465..329e27b7b 100644 --- a/server_each.hxml +++ b/server_each.hxml @@ -1,7 +1,4 @@ --cp src --cp hx3compat/std --cp hx4compat/std --cp crypto/src +each.hxml -lib ufront -lib ufront-mail:1.0.0-rc.4 -lib ufront-ufadmin diff --git a/server_gitrepo.hxml b/server_gitrepo.hxml index 8a93ca921..b3276ec08 100644 --- a/server_gitrepo.hxml +++ b/server_gitrepo.hxml @@ -1,9 +1,6 @@ ---class-path src +each.hxml --class-path lib/dts2hx-generated --class-path lib/node-sys-db ---class-path hx3compat/std ---class-path hx4compat/std ---class-path crypto/src --library hxnodejs --library record-macros --js gitrepo.js diff --git a/server_legacy.hxml b/server_legacy.hxml index 3e559317b..f522ee63d 100644 --- a/server_legacy.hxml +++ b/server_legacy.hxml @@ -1,5 +1,4 @@ server_each.hxml --cp src -neko www/legacy/index.n -main legacyhaxelib.Site -lib hx2compat diff --git a/src/Package.hx b/src/Package.hx index d5ddc229f..bf8435202 100644 --- a/src/Package.hx +++ b/src/Package.hx @@ -5,7 +5,6 @@ import haxe.zip.Tools; import sys.io.File; import sys.FileSystem; -import haxelib.client.Main.VERSION; import haxelib.Data.Infos; using StringTools; diff --git a/src/haxelib/client/Main.hx b/src/haxelib/client/Main.hx index fc4385115..eb943a8ad 100644 --- a/src/haxelib/client/Main.hx +++ b/src/haxelib/client/Main.hx @@ -214,7 +214,7 @@ class Main { Version => create(version, 0), Help => create(usage, 0), - #if neko + #if !js Submit => create(submit, 3, true), #end Register => create(register, 5, true), @@ -227,7 +227,7 @@ class Main { DeleteRepo => create(deleteRepo, 0), ConvertXml => create(convertXml, 0), Run => create(run, null), - #if neko + #if !js Proxy => create(proxy, 5, true), #end FixRepo => create(fixRepo, 0), @@ -264,7 +264,7 @@ class Main { try { if (commandInfo.net) { - #if neko + #if !js loadProxy(); #end checkUpdate(); @@ -367,7 +367,7 @@ class Main { return encodedPassword; } - #if neko + #if !js function getContributor(contributors:Array): {name:String, password:String} { var user:String = contributors[0]; @@ -780,7 +780,7 @@ class Main { } } - #if neko + #if !js function proxy() { final rep = getRepositoryPath(); final host = getArgument("Proxy host"); diff --git a/test/IntegrationTests.hx b/test/IntegrationTests.hx index 532c1466e..cc6f2b19d 100644 --- a/test/IntegrationTests.hx +++ b/test/IntegrationTests.hx @@ -97,6 +97,8 @@ class IntegrationTests extends TestBase { function haxelib(args:Array, ?input:String):Process { final p = #if system_haxelib new Process("haxelib", ["-R", serverUrl].concat(args)); + #elseif haxelib_path + new Process(haxe.macro.Compiler.getDefine("haxelib_path"), ["-R", serverUrl].concat(args)); #else new Process("neko", [haxelibBin, "-R", serverUrl].concat(args)); #end diff --git a/test/RunCi.hx b/test/RunCi.hx index 268b178e8..40c4dd0f7 100644 --- a/test/RunCi.hx +++ b/test/RunCi.hx @@ -370,19 +370,6 @@ Listen 2000 } static function integrationTests():Void { - function test():Void { - switch (Sys.getEnv("TRAVIS_HAXE_VERSION")) { - case null, "development": - runCommand("haxe", ["integration_tests.hxml"]); - case "3.1.3": - runCommand("haxe", ["integration_tests.hxml", "-D", "system_haxelib"]); - case _: - runCommand("haxe", ["integration_tests.hxml"]); - runCommand("neko", ["bin/integration_tests.n"]); - runCommand("haxe", ["integration_tests.hxml", "-D", "system_haxelib"]); - } - runCommand("neko", ["bin/integration_tests.n"]); - } var dbConfigPath = Path.join(["www", "dbconfig.json"]); saveContent(dbConfigPath, Json.stringify({ user: Sys.getEnv("HAXELIB_DB_USER"), @@ -391,7 +378,14 @@ Listen 2000 port: Std.parseInt(Sys.getEnv("HAXELIB_DB_PORT")), database: Sys.getEnv("HAXELIB_DB_NAME"), }, "\t")); - test(); + runCommand("haxe", ["integration_tests.hxml"]); + runCommand("neko", ["bin/integration_tests.n"]); + runCommand("haxe", [ + "integration_tests.hxml", + "-D", + 'haxelib_path=${Path.join([Sys.getCwd(), "haxelib"])}' + ]); + runCommand("neko", ["bin/integration_tests.n"]); } static function deploy():Void {