Skip to content

Commit 949c2bc

Browse files
committed
Fix test run for windows x86
1 parent ceeff42 commit 949c2bc

File tree

4 files changed

+54
-22
lines changed

4 files changed

+54
-22
lines changed

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ jobs:
128128
shell: bash
129129
run: |
130130
set -eux
131-
python tests/run.py 0-gdscript --build-dir build/ -- --headless
132-
python tests/run.py 1-gdextension --build-dir build/ -- --headless
133-
python tests/run.py 2-pythonscript-init --build-dir build/ -- --headless
131+
python tests/run.py 0-gdscript --build-dir build/ --godot-binary "${{ matrix.PLATFORM }}:" -- --headless
132+
python tests/run.py 1-gdextension --build-dir build/ --godot-binary "${{ matrix.PLATFORM }}:" -- --headless
133+
python tests/run.py 2-pythonscript-init --build-dir build/ --godot-binary "${{ matrix.PLATFORM }}:" -- --headless
134134
# - name: 'Install Mesa3D OpenGL'
135135
# shell: bash
136136
# run: |

scripts/fetch_godot.py

+42-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
import platform
77
import shutil
8-
from typing import Tuple
8+
from typing import Optional, Tuple
99
import subprocess
1010
import argparse
1111
from pathlib import Path
@@ -23,18 +23,49 @@ def log(*args, **kwargs):
2323
print(*args, **kwargs, file=sys.stderr)
2424

2525

26+
def get_default_godot_version_from_meson(build_dir: Path) -> str:
27+
# Ultra lazy & fast json parsing ^^
28+
meson_build_options = build_dir / "meson-info/intro-buildoptions.json"
29+
version = (
30+
meson_build_options.read_text()
31+
.split('"name": "godot_version", "value": "', 1)[-1]
32+
.split('"', 1)[0]
33+
)
34+
assert version
35+
return version
36+
37+
38+
def parse_raw_version(raw_version: str) -> GodotBinaryVersion:
39+
# Provided value is version information with format <major>.<minor>.<patch>[-<extra>]
40+
match = re.match(r"^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-(\w+))?$", raw_version)
41+
if match:
42+
major, minor, patch, extra = match.groups()
43+
else:
44+
raise ValueError(
45+
f"`{raw_version}` is neither an existing file nor a valid <major>.<minor>.<patch>[-<extra>] Godot version format"
46+
)
47+
return (major, minor, patch, extra or "stable")
48+
49+
2650
def parse_godot_binary_hint(
2751
godot_binary_hint: str,
28-
) -> Tuple[GodotBinaryPlatform, GodotBinaryVersion]:
52+
) -> Tuple[GodotBinaryPlatform, Optional[GodotBinaryVersion]]:
2953
try:
3054
build_machine, raw_version = godot_binary_hint.split(":")
3155
except ValueError:
3256
build_machine = ""
3357
raw_version = godot_binary_hint
34-
raw_version = raw_version
35-
build_machine = build_machine or platform.machine()
3658

37-
build_platform = f"{platform.system()}-{build_machine}".lower()
59+
# e.g. `build_machine == "x86"`
60+
build_machine = (build_machine or platform.machine()).lower()
61+
# e.g. `build_platform_prefix == "windows-"`
62+
build_platform_prefix = f"{platform.system()}-".lower()
63+
if build_machine.startswith(build_platform_prefix):
64+
build_platform = build_machine
65+
else:
66+
build_platform = build_platform_prefix + build_machine
67+
# e.g. `build_platform == "windows-x86"`
68+
3869
godot_build_platform = {
3970
"linux-x86_64": "linux.x86_64",
4071
"linux-x64": "linux.x86_64",
@@ -53,20 +84,16 @@ def parse_godot_binary_hint(
5384
f"Don't know how to download a Godot binary for your platform `{build_platform}`"
5485
)
5586

56-
# Provided value is version information with format <major>.<minor>.<patch>[-<extra>]
57-
match = re.match(r"^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-(\w+))?$", raw_version)
58-
if match:
59-
major, minor, patch, extra = match.groups()
60-
else:
61-
raise ValueError(
62-
f"`{raw_version}` is neither an existing file nor a valid <major>.<minor>.<patch>[-<extra>] Godot version format"
63-
)
64-
return godot_build_platform, (major, minor, patch, extra or "stable")
87+
# If version has not been provided, it will be determined later with `get_default_godot_version_from_meson()`
88+
version = parse_raw_version(raw_version) if raw_version else None
89+
return godot_build_platform, version
6590

6691

6792
def fetch_godot_binary(
68-
build_dir: Path, godot_platform: GodotBinaryPlatform, version: GodotBinaryVersion
93+
build_dir: Path, godot_platform: GodotBinaryPlatform, version: Optional[GodotBinaryVersion]
6994
) -> Path:
95+
if not version:
96+
version = parse_raw_version(get_default_godot_version_from_meson(build_dir))
7097
major, minor, patch, extra = version
7198
strversion = f"{major}.{minor}.{patch}" if patch != "0" else f"{major}.{minor}"
7299
binary_name = f"Godot_v{strversion}-{extra}_{godot_platform}"

tests/1-gdextension/build.py

+8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
import platform
22
from pathlib import Path
33
import subprocess
4+
import shutil
45

56

67
PROJECT_DIR = Path(__file__).resolve().parent
78
GDEXTENSION_DIR = PROJECT_DIR / "gdextension_api"
89

910

1011
if platform.system() == "Windows":
12+
if not shutil.which("cl.exe"):
13+
raise SystemExit(
14+
"`cl.exe` command is missing, have you run `<Visual Studio Path>/vcvarsall.bat` ?"
15+
)
16+
1117
cmd = ["cl.exe", "/DEBUG", "/LD", "my.c", "/I", str(GDEXTENSION_DIR)]
1218
print(f"cd {PROJECT_DIR} && " + " ".join(cmd))
1319
subprocess.check_call(cmd, cwd=PROJECT_DIR)
1420

1521
else:
1622
assert platform.system() in ("Linux", "Darwin")
23+
if not shutil.which("cc"):
24+
raise SystemExit("`cc` command is missing")
1725

1826
cmd = [
1927
"cc",

tests/run.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
from tempfile import TemporaryDirectory
1414

1515

16-
DEFAULT_GODOT_BINARY_VERSION = "4.0.1"
17-
18-
1916
BASEDIR = Path(__file__).resolve().parent
2017
RED = "\033[0;31m"
2118
GREEN = "\033[0;32m"
@@ -195,7 +192,7 @@ def run_test(
195192
)
196193
parser.add_argument(
197194
"--godot-binary",
198-
default=DEFAULT_GODOT_BINARY_VERSION,
195+
default="",
199196
help="Path to Godot binary to use, or version of Godot to download and use",
200197
)
201198
parser.add_argument(

0 commit comments

Comments
 (0)