From fadd4a4bd9ed821bd9437bad4650de5abe21bb03 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Wed, 24 Jul 2024 11:02:41 +0200 Subject: [PATCH 1/4] [ci] add hlc test on Windows using MSBuild --- .github/workflows/main.yml | 32 +++++++++++++++++---------- extra/github-actions/test-windows.yml | 5 +++++ tests/runci/targets/Hl.hx | 17 ++++++++++++-- tests/unit/compile-hlc.hxml | 1 + 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3998cd73e9..ee0e36e1a09 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,7 @@ on: [push, pull_request] jobs: windows64-build: + if: false runs-on: windows-latest env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true @@ -121,6 +122,7 @@ jobs: linux-build: + if: false runs-on: ubuntu-20.04 env: PLATFORM: linux64 @@ -228,6 +230,7 @@ jobs: path: extra/doc linux-test: + if: false needs: linux-build runs-on: ubuntu-20.04 env: @@ -315,6 +318,7 @@ jobs: working-directory: ${{github.workspace}}/tests test-docgen: + if: false needs: linux-build runs-on: ubuntu-20.04 env: @@ -395,6 +399,7 @@ jobs: working-directory: ${{github.workspace}}/tests/docgen linux-arm64: + if: false runs-on: ubuntu-20.04 permissions: packages: write @@ -451,6 +456,7 @@ jobs: path: out/linux/arm64 mac-build: + if: false strategy: fail-fast: false matrix: @@ -566,7 +572,6 @@ jobs: windows64-test: - needs: windows64-build runs-on: windows-latest env: ACTIONS_ALLOW_UNSECURE_COMMANDS: true @@ -578,15 +583,11 @@ jobs: fail-fast: false matrix: # TODO enable lua after https://github.com/HaxeFoundation/haxe/issues/10919 - target: [macro, js, hl, cpp, jvm, php, python, flash, neko] + target: [hl] steps: - uses: actions/checkout@main with: submodules: recursive - - uses: actions/download-artifact@v4 - with: - name: win${{env.ARCH}}Binaries - path: win${{env.ARCH}}Binaries - name: Install Neko from S3 shell: pwsh @@ -604,12 +605,12 @@ jobs: with: node-version: 18.17.1 - # - name: Quick test - # shell: pwsh - # run: | - # $DOWNLOADDIR="./win$($env:ARCH)Binaries" - # new-item -Name $DOWNLOADDIR -ItemType directory - # Invoke-WebRequest https://build.haxe.org/builds/haxe/$env:PLATFORM/haxe_latest.zip -OutFile $DOWNLOADDIR/haxe_bin.zip + - name: Quick test + shell: pwsh + run: | + $DOWNLOADDIR="./win$($env:ARCH)Binaries" + new-item -Name $DOWNLOADDIR -ItemType directory + Invoke-WebRequest https://build.haxe.org/builds/haxe/$env:PLATFORM/haxe_latest.zip -OutFile $DOWNLOADDIR/haxe_bin.zip - name: Setup Haxe shell: pwsh @@ -655,6 +656,11 @@ jobs: mkdir "$env:HAXELIB_ROOT" haxelib setup "$env:HAXELIB_ROOT" + - name: Add msbuild to PATH (hl/c) + uses: microsoft/setup-msbuild@v2 + with: + msbuild-architecture: x64 + - name: Test shell: pwsh run: haxe RunCi.hxml @@ -662,6 +668,7 @@ jobs: mac-build-universal: + if: false needs: mac-build runs-on: macos-latest steps: @@ -695,6 +702,7 @@ jobs: path: out mac-test: + if: false needs: mac-build-universal runs-on: macos-13 env: diff --git a/extra/github-actions/test-windows.yml b/extra/github-actions/test-windows.yml index 96c02751847..9f3bf59dd4e 100644 --- a/extra/github-actions/test-windows.yml +++ b/extra/github-actions/test-windows.yml @@ -53,6 +53,11 @@ mkdir "$env:HAXELIB_ROOT" haxelib setup "$env:HAXELIB_ROOT" +- name: Add msbuild to PATH (hl/c) + uses: microsoft/setup-msbuild@v2 + with: + msbuild-architecture: x64 + - name: Test shell: pwsh run: haxe RunCi.hxml diff --git a/tests/runci/targets/Hl.hx b/tests/runci/targets/Hl.hx index 07ff7999687..c59414d19e4 100644 --- a/tests/runci/targets/Hl.hx +++ b/tests/runci/targets/Hl.hx @@ -68,6 +68,11 @@ class Hl { addToLIBPATH(hlBuildBinDir); haxelibDev("hashlink", '$hlSrc/other/haxelib/'); + + if (systemName == "Windows") { + Sys.putEnv("HASHLINK_SRC", hlSrc); + Sys.putEnv("HASHLINK_BIN", hlBuildBinDir); + } } static function buildAndRunHlc(dir:String, filename:String, ?run) { @@ -88,7 +93,15 @@ class Hl { ]); run('$dir/$filename.exe', []); - + case "Windows" if(isCi()): + runCommand("MSBuild.exe", [ + '$dir/$filename.sln', + '-nologo', '-verbosity:minimal', + '-t:$filename', + '-property:Configuration=Release', + '-property:Platform=x64' + ]); + run('$dir/x64/Release/$filename.exe', []); case _: // TODO hl/c for mac/windows } } @@ -99,7 +112,7 @@ class Hl { runCommand("haxe", [hxml, "-hl", '$target/hl-jit.hl'].concat(args)); runCommand(hlBinary, ['$target/hl-jit.hl']); - runCommand("haxe", [hxml, "-hl", '$target/hlc.c'].concat(args)); + runCommand("haxe", [hxml, "-hl", '$target/hlc.c', "-D", "hlgen.makefile=ci"].concat(args)); buildAndRunHlc(target, "hlc"); } diff --git a/tests/unit/compile-hlc.hxml b/tests/unit/compile-hlc.hxml index 61c9f1d83a4..e68d492aaaa 100644 --- a/tests/unit/compile-hlc.hxml +++ b/tests/unit/compile-hlc.hxml @@ -4,3 +4,4 @@ compile-each.hxml #-D interp -D hl-check -D hl-ver=1.13.0 +-D hlgen.makefile=ci From e9ee1ab39a221839341b1a061fa3c16dc16da624 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Thu, 8 Aug 2024 11:03:14 +0200 Subject: [PATCH 2/4] [tests] make TestInt64 int64eq display correct pos --- tests/unit/src/unit/TestInt64.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/src/unit/TestInt64.hx b/tests/unit/src/unit/TestInt64.hx index a49e1be434b..97c320927c9 100644 --- a/tests/unit/src/unit/TestInt64.hx +++ b/tests/unit/src/unit/TestInt64.hx @@ -489,7 +489,7 @@ class TestInt64 extends Test { } function int64eq(v:Int64, v2:Int64, ?pos) { - t(v == v2); + t(v == v2, pos); } public function testParseString() { From cf4e75166ee94772a7e1467fec44643cca183b6a Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Thu, 8 Aug 2024 12:02:05 +0200 Subject: [PATCH 3/4] [hlc] force shift overflow behavior --- src/generators/hl2c.ml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/generators/hl2c.ml b/src/generators/hl2c.ml index ced5dd506e6..e21db648331 100644 --- a/src/generators/hl2c.ml +++ b/src/generators/hl2c.ml @@ -841,14 +841,15 @@ let generate_function ctx f = | OUMod (r,a,b) -> sexpr "%s = %s == 0 ? 0 : ((unsigned)%s) %% ((unsigned)%s)" (reg r) (reg b) (reg a) (reg b) | OShl (r,a,b) -> - sexpr "%s = %s << %s" (reg r) (reg a) (reg b) + let size = (match rtype r with HUI8 -> 8 | HUI16 -> 16 | HI32 -> 32 | HI64 -> 64 |_ -> Globals.die "" __LOC__ ) in + sexpr "%s = %s << (%s %% %d)" (reg r) (reg a) (reg b) size | OSShr (r,a,b) -> - sexpr "%s = %s >> %s" (reg r) (reg a) (reg b) + let size = (match rtype r with HUI8 -> 8 | HUI16 -> 16 | HI32 -> 32 | HI64 -> 64 |_ -> Globals.die "" __LOC__ ) in + sexpr "%s = %s >> (%s %% %d)" (reg r) (reg a) (reg b) size | OUShr (r,a,b) -> - (match rtype r with - | HI64 -> sexpr "%s = ((uint64)%s) >> %s" (reg r) (reg a) (reg b) - | _ -> sexpr "%s = ((unsigned)%s) >> %s" (reg r) (reg a) (reg b) - ); + let size = (match rtype r with HUI8 -> 8 | HUI16 -> 16 | HI32 -> 32 | HI64 -> 64 |_ -> Globals.die "" __LOC__ ) in + let prefix = (match rtype r with HI64 -> "uint64" | _ -> "unsigned") in + sexpr "%s = ((%s)%s) >> (%s %% %d)" (reg r) prefix (reg a) (reg b) size | OAnd (r,a,b) -> sexpr "%s = %s & %s" (reg r) (reg a) (reg b) | OOr (r,a,b) -> From 6cbf3205ad6a8612d743d29c3970497dc1dbc531 Mon Sep 17 00:00:00 2001 From: Yuxiao Mao Date: Tue, 15 Oct 2024 12:35:38 +0200 Subject: [PATCH 4/4] Fix path change in merge --- tests/runci/targets/Hl.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/runci/targets/Hl.hx b/tests/runci/targets/Hl.hx index ca2faf46310..3a561ef712a 100644 --- a/tests/runci/targets/Hl.hx +++ b/tests/runci/targets/Hl.hx @@ -75,7 +75,7 @@ class Hl { if (systemName == "Windows") { Sys.putEnv("HASHLINK_SRC", hlSrc); - Sys.putEnv("HASHLINK_BIN", hlBuildBinDir); + Sys.putEnv("HASHLINK_BIN", hlInstallBinDir); } }