Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] add hlc test on Windows using MSBuild #11733

Draft
wants to merge 5 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on: [push, pull_request]

jobs:
windows64-build:
if: false
runs-on: windows-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Expand Down Expand Up @@ -121,6 +122,7 @@ jobs:


linux-build:
if: false
runs-on: ubuntu-20.04
env:
PLATFORM: linux64
Expand Down Expand Up @@ -228,6 +230,7 @@ jobs:
path: extra/doc

linux-test:
if: false
needs: linux-build
runs-on: ubuntu-20.04
env:
Expand Down Expand Up @@ -315,6 +318,7 @@ jobs:
working-directory: ${{github.workspace}}/tests

test-docgen:
if: false
needs: linux-build
runs-on: ubuntu-20.04
env:
Expand Down Expand Up @@ -395,6 +399,7 @@ jobs:
working-directory: ${{github.workspace}}/tests/docgen

linux-arm64:
if: false
runs-on: ubuntu-20.04
permissions:
packages: write
Expand Down Expand Up @@ -451,6 +456,7 @@ jobs:
path: out/linux/arm64

mac-build:
if: false
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -564,7 +570,6 @@ jobs:


windows64-test:
needs: windows64-build
runs-on: windows-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
Expand All @@ -576,15 +581,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
Expand All @@ -602,12 +603,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
Expand Down Expand Up @@ -653,13 +654,19 @@ 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
working-directory: ${{github.workspace}}/tests


mac-build-universal:
if: false
needs: mac-build
runs-on: macos-latest
steps:
Expand Down Expand Up @@ -693,6 +700,7 @@ jobs:
path: out

mac-test:
if: false
needs: mac-build-universal
runs-on: macos-13
env:
Expand Down
5 changes: 5 additions & 0 deletions extra/github-actions/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions src/generators/hl2c.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
20 changes: 18 additions & 2 deletions tests/runci/targets/Hl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ class Hl {
runCommand(hlBinary, ["--version"]);

haxelibDev("hashlink", '$hlSrc/other/haxelib/');

if (systemName == "Windows") {
Sys.putEnv("HASHLINK_SRC", hlSrc);
Sys.putEnv("HASHLINK_BIN", hlInstallBinDir);
}
}

static function buildAndRunHlc(dir:String, filename:String, ?run) {
Expand All @@ -82,7 +87,6 @@ class Hl {

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',
Expand All @@ -97,6 +101,18 @@ class Hl {
].concat(extraCompilerFlags));

run('$dir/$filename.exe', []);

// Run with MSBuild
if (systemName == "Windows") {
runCommand("MSBuild.exe", [
'$dir/$filename.sln',
'-nologo', '-verbosity:minimal',
'-t:$filename',
'-property:Configuration=Release',
'-property:Platform=x64'
]);
run('$dir/x64/Release/$filename.exe', []);
}
}

static function buildAndRun(hxml:String, target:String, ?args:Array<String>) {
Expand All @@ -105,7 +121,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");
}

Expand Down
1 change: 1 addition & 0 deletions tests/unit/compile-hlc.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ compile-each.hxml
#-D interp
-D hl-check
-D hl-ver=1.13.0
-D hlgen.makefile=ci
2 changes: 1 addition & 1 deletion tests/unit/src/unit/TestInt64.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading