From 2d45d08722b456e91b985ada5dc5d98f23261c03 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Fri, 21 Feb 2025 14:11:07 -0600 Subject: [PATCH] Check that precision of `extension_api.json` matches build options (cherry picked from commit 0a73df5f531ca1b8409d5dd984f7b857b7ae56ac) --- binding_generator.py | 9 +++++++-- misc/scripts/check_get_file_list.py | 1 + tools/godotcpp.py | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/binding_generator.py b/binding_generator.py index 103214e2..b8ea6b76 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -290,10 +290,15 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision= api = {} with open(api_filepath, encoding="utf-8") as api_file: api = json.load(api_file) - _generate_bindings(api, use_template_get_node, bits, precision, output_dir) + _generate_bindings(api, api_filepath, use_template_get_node, bits, precision, output_dir) -def _generate_bindings(api, use_template_get_node, bits="64", precision="single", output_dir="."): +def _generate_bindings(api, api_filepath, use_template_get_node, bits="64", precision="single", output_dir="."): + if "precision" in api["header"] and precision != api["header"]["precision"]: + raise Exception( + f"Cannot do a precision={precision} build using '{api_filepath}' which was generated by Godot built with precision={api['header']['precision']}" + ) + target_dir = Path(output_dir) / "gen" shutil.rmtree(target_dir, ignore_errors=True) diff --git a/misc/scripts/check_get_file_list.py b/misc/scripts/check_get_file_list.py index ac90777a..6ea5d6f7 100755 --- a/misc/scripts/check_get_file_list.py +++ b/misc/scripts/check_get_file_list.py @@ -19,6 +19,7 @@ def test(profile_filepath=""): api = generate_trimmed_api(api_filepath, profile_filepath) _generate_bindings( api, + api_filepath, use_template_get_node=False, bits=bits, precision=precision, diff --git a/tools/godotcpp.py b/tools/godotcpp.py index 8931e6dc..3646264b 100644 --- a/tools/godotcpp.py +++ b/tools/godotcpp.py @@ -154,6 +154,7 @@ def scons_generate_bindings(target, source, env): _generate_bindings( api, + str(source[0]), env["generate_template_get_node"], "32" if "32" in env["arch"] else "64", env["precision"],