Skip to content

Commit 13c5472

Browse files
committed
Improve extension_api_parser and check it configs in the CI
1 parent 97713c6 commit 13c5472

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ jobs:
6565
python --version
6666
pip install -U pip
6767
pip install -r requirements.in
68+
- name: 'Sanity check on extension_api_parser'
69+
run: python -m scripts.extension_api_parser
6870
- name: 'Setup project'
6971
run: python .github/scripts/meson_setup_or_dump_log.py build/
7072
- name: 'Build project'

scripts/extension_api_parser/__main__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,29 @@
22
Helper to debug the parser
33
"""
44

5+
import os
56
import sys
67
from pathlib import Path
78

89
from . import parse_extension_api_json, BuildConfig
910

1011

11-
parse_extension_api_json(Path(sys.argv[1]), BuildConfig.DOUBLE_64)
12+
try:
13+
extension_api_path = Path(sys.argv[1])
14+
except IndexError:
15+
extension_api_path = (
16+
(Path(__file__).parent / "../../godot_headers/extension_api.json")
17+
.resolve()
18+
.relative_to(os.getcwd())
19+
)
20+
21+
22+
try:
23+
build_configs = [BuildConfig(sys.argv[2])]
24+
except IndexError:
25+
build_configs = BuildConfig
26+
27+
28+
for build_config in build_configs:
29+
print(f"Checking {extension_api_path} with config {build_config.value}")
30+
parse_extension_api_json(extension_api_path, build_config)

scripts/extension_api_parser/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,18 @@ def merge_builtins_size_info(api_json: dict, build_config: BuildConfig) -> None:
211211
for item in api_json["builtin_classes"]:
212212
name = item["name"]
213213
item["size"] = builtin_class_sizes[name]
214+
# TODO: correct me once https://github.com/godotengine/godot/pull/64365 is merged
214215
for member in builtin_class_member_offsets.get(name, ()):
215216
for item_member in item["members"]:
216217
if item_member["name"] == member["member"]:
217218
item_member["offset"] = member["offset"]
218219
# Float builtin in extension_api.json is always 64bits long,
219220
# however builtins made of floating point number can be made of
220221
# 32bits (C float) or 64bits (C double)
221-
if item_member["type"] == "float":
222+
# But Color is a special case: it is always made of 32bits floats !
223+
if name == "Color":
224+
item_member["type"] = "meta:float"
225+
elif item_member["type"] == "float":
222226
if build_config in (BuildConfig.FLOAT_32, BuildConfig.FLOAT_64):
223227
item_member["type"] = "meta:float"
224228
else:

0 commit comments

Comments
 (0)