浏览代码

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

* [ci] add hlc test on Windows using MSBuild

* [tests] make TestInt64 int64eq display correct pos

* [hlc] force shift overflow behavior

* Fix path change in merge

* Disable quick test

* Restore deps to windows64-build

* Restore download-artifact in test

* Add missing hlgen.makefile in hxml

* Restore full ci test

* [ci] restore timeout in extra/github-actions
Yuxiao Mao 5 月之前
父节点
当前提交
d3defe6090

+ 5 - 0
.github/workflows/main.yml

@@ -734,6 +734,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

+ 1 - 0
extra/github-actions/test-mac.yml

@@ -30,3 +30,4 @@
     echo "" > sys/compile-fs.hxml
     haxe RunCi.hxml
   working-directory: ${{github.workspace}}/tests
+  timeout-minutes: 60

+ 6 - 0
extra/github-actions/test-windows.yml

@@ -53,7 +53,13 @@
     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
+  timeout-minutes: 20

+ 2 - 0
extra/github-actions/workflows/main.yml

@@ -179,6 +179,7 @@ jobs:
       - name: Test
         run: haxe RunCi.hxml
         working-directory: ${{github.workspace}}/tests
+        timeout-minutes: 20
 
   test-docgen:
     needs: linux-build
@@ -361,6 +362,7 @@ jobs:
       - name: Test
         run: haxe RunCi.hxml
         working-directory: ${{github.workspace}}/tests
+        timeout-minutes: 20
 
   mac-build:
     strategy:

+ 7 - 6
src/generators/hl2c.ml

@@ -875,14 +875,15 @@ let generate_function gctx 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) ->

+ 18 - 1
tests/runci/targets/Hl.hx

@@ -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) {
@@ -97,6 +102,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>) {
@@ -105,7 +122,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");
 	}
 

+ 4 - 0
tests/sys/compile-hlc.hxml

@@ -1,18 +1,22 @@
 compile-each.hxml
 --main Main
 -hl bin/hlc/sys/sys.c
+-D hlgen.makefile=ci
 
 --next
 compile-each.hxml
 --main TestArguments
 -hl bin/hlc/testArguments/TestArguments.c
+-D hlgen.makefile=ci
 
 --next
 compile-each.hxml
 --main ExitCode
 -hl bin/hlc/exitCode/ExitCode.c
+-D hlgen.makefile=ci
 
 --next
 compile-each.hxml
 --main UtilityProcess
 -hl bin/hlc/utilityProcess/UtilityProcess.c
+-D hlgen.makefile=ci

+ 1 - 0
tests/unit/compile-hlc.hxml

@@ -4,3 +4,4 @@ compile-each.hxml
 #-D interp
 -D hl-check
 -D hl-ver=1.16.0
+-D hlgen.makefile=ci

+ 1 - 1
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() {