From 0cbd8d084371a0c3eebbb818237cd0a3b0cd77b9 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 11 Sep 2024 12:06:49 +0100 Subject: [PATCH 1/3] [tests] Use install target for installing hashlink This allows for a proper install with all the paths set up correctly --- tests/runci/targets/Hl.hx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/runci/targets/Hl.hx b/tests/runci/targets/Hl.hx index 07ff7999687..cf867237ccb 100644 --- a/tests/runci/targets/Hl.hx +++ b/tests/runci/targets/Hl.hx @@ -10,13 +10,15 @@ using StringTools; class Hl { static final hlSrc = Path.join([getDownloadPath(), "hashlink"]); - static final hlBuild = Path.join([getInstallPath(), "hashlink_build"]); + static final hlBuild = Path.join([getDownloadPath(), "hashlink_build"]); - static final hlBuildBinDir = Path.join([getInstallPath(), "hashlink_build", "bin"]); + static final hlInstallDir = Path.join([getInstallPath(), "hashlink"]); + static final hlInstallBinDir = if (systemName == "Windows") hlInstallDir else Path.join([hlInstallDir, "bin"]); + static final hlInstallLibDir = if (systemName == "Windows") hlInstallDir else Path.join([hlInstallDir, "lib"]); static final hlBinary = if (isCi() || !commandSucceed("hl", ["--version"])){ - Path.join([hlBuildBinDir, "hl"]) + ((systemName == "Windows") ? ".exe" : ""); + Path.join([hlInstallBinDir, "hl"]) + ((systemName == "Windows") ? ".exe" : ""); } else { commandResult(if(systemName == "Windows") "where" else "which", ["hl"]).stdout.trim(); }; @@ -56,16 +58,18 @@ class Hl { "-DWITH_UI=OFF", "-DWITH_UV=OFF", "-DWITH_VIDEO=OFF", + "-DCMAKE_INSTALL_PREFIX=" + hlInstallDir, "-B" + hlBuild, "-H" + hlSrc ])); runCommand("cmake", [ "--build", hlBuild ]); + runCommand("cmake", ["--build", hlBuild, "--target", "install"]); + addToPATH(hlInstallBinDir); + addToLIBPATH(hlInstallLibDir); runCommand(hlBinary, ["--version"]); - addToPATH(hlBuildBinDir); - addToLIBPATH(hlBuildBinDir); haxelibDev("hashlink", '$hlSrc/other/haxelib/'); } @@ -79,12 +83,12 @@ class Hl { "-o", '$dir/$filename.exe', '$dir/$filename.c', '-I$dir', - '-I$hlSrc/src', - '$hlBuildBinDir/fmt.hdll', - '$hlBuildBinDir/ssl.hdll', - '$hlBuildBinDir/sqlite.hdll', + '-I$hlInstallDir/include', + '$hlInstallLibDir/fmt.hdll', + '$hlInstallLibDir/ssl.hdll', + '$hlInstallLibDir/sqlite.hdll', "-lm", - '-L$hlBuildBinDir', "-lhl" + '-L$hlInstallLibDir', "-lhl" ]); run('$dir/$filename.exe', []); From 672a88fb82a11a748349a0cdd3c0d6910dcb164b Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 11 Sep 2024 12:42:49 +0100 Subject: [PATCH 2/3] [tests] Fix env variable for mac loader path --- tests/runci/System.hx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/runci/System.hx b/tests/runci/System.hx index 0db5c6b95fe..01a405ae91e 100644 --- a/tests/runci/System.hx +++ b/tests/runci/System.hx @@ -134,11 +134,13 @@ class System { } static public function addToLIBPATH(path:String):Void { - infoMsg('Prepending $path to LD_LIBRARY_PATH.'); + infoMsg('Prepending $path to loader path.'); switch (systemName) { case "Windows": // pass - case "Mac", "Linux": + case "Linux": Sys.putEnv("LD_LIBRARY_PATH", path + ":" + Sys.getEnv("LD_LIBRARY_PATH")); + case "Mac": + Sys.putEnv("DYLD_LIBRARY_PATH", path + ":" + Sys.getEnv("DYLD_LIBRARY_PATH")); } } From 15cd99193207ad68c9d7eabd0488c3e0d077c334 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 11 Sep 2024 14:53:54 +0100 Subject: [PATCH 3/3] [tests] Run hlc tests on windows and mac Using gcc on windows and clang on mac --- tests/runci/targets/Hl.hx | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/runci/targets/Hl.hx b/tests/runci/targets/Hl.hx index cf867237ccb..75f7238c3ad 100644 --- a/tests/runci/targets/Hl.hx +++ b/tests/runci/targets/Hl.hx @@ -77,24 +77,26 @@ class Hl { static function buildAndRunHlc(dir:String, filename:String, ?run) { if (run == null) run = runCommand; - switch (systemName) { - case "Linux" if (isCi()): - runCommand("gcc", [ - "-o", '$dir/$filename.exe', - '$dir/$filename.c', - '-I$dir', - '-I$hlInstallDir/include', - '$hlInstallLibDir/fmt.hdll', - '$hlInstallLibDir/ssl.hdll', - '$hlInstallLibDir/sqlite.hdll', - "-lm", - '-L$hlInstallLibDir', "-lhl" - ]); - - run('$dir/$filename.exe', []); - - case _: // TODO hl/c for mac/windows - } + if (!isCi()) + return; + + final compiler = if (systemName == "Mac") "clang" else "gcc"; + final extraCompilerFlags = if (systemName == "Windows") ["-ldbghelp", "-municode"] else []; + + runCommand(compiler, [ + "-o", '$dir/$filename.exe', + '$dir/$filename.c', + '-I$dir', + '-I$hlInstallDir/include', + '-L$hlInstallLibDir', + '$hlInstallLibDir/fmt.hdll', + '$hlInstallLibDir/ssl.hdll', + '$hlInstallLibDir/sqlite.hdll', + "-lm", + "-lhl" + ].concat(extraCompilerFlags)); + + run('$dir/$filename.exe', []); } static function buildAndRun(hxml:String, target:String, ?args:Array) {