Skip to content

Commit

Permalink
Added generated version header
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Jul 26, 2023
1 parent 3162be2 commit 49f6c88
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions binding_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def generate_bindings(api_filepath, use_template_get_node, bits="64", precision=
print("Built-in type config: " + real_t + "_" + bits)

generate_global_constants(api, target_dir)
generate_version_header(api, target_dir)
generate_global_constant_binds(api, target_dir)
generate_builtin_bindings(api, target_dir, real_t + "_" + bits)
generate_engine_classes_bindings(api, target_dir, use_template_get_node)
Expand Down Expand Up @@ -1659,6 +1660,35 @@ def generate_global_constants(api, output_dir):
header_file.write("\n".join(header))


def generate_version_header(api, output_dir):
header = []
header_filename = "version.hpp"
add_header(header_filename, header)

include_gen_folder = Path(output_dir) / "include" / "godot_cpp" / "core"
include_gen_folder.mkdir(parents=True, exist_ok=True)

header_file_path = include_gen_folder / header_filename

header_guard = "GODOT_CPP_VERSION_HPP"
header.append(f"#ifndef {header_guard}")
header.append(f"#define {header_guard}")
header.append("")

header.append(f"#define GODOT_VERSION_MAJOR {api['header']['version_major']}")
header.append(f"#define GODOT_VERSION_MINOR {api['header']['version_minor']}")
header.append(f"#define GODOT_VERSION_PATCH {api['header']['version_patch']}")
header.append(f"#define GODOT_VERSION_STATUS \"{api['header']['version_status']}\"")
header.append(f"#define GODOT_VERSION_BUILD \"{api['header']['version_build']}\"")

header.append("")
header.append(f"#endif // {header_guard}")
header.append("")

with header_file_path.open("w+", encoding="utf-8") as header_file:
header_file.write("\n".join(header))


def generate_global_constant_binds(api, output_dir):
include_gen_folder = Path(output_dir) / "include" / "godot_cpp" / "classes"
source_gen_folder = Path(output_dir) / "src" / "classes"
Expand Down

0 comments on commit 49f6c88

Please sign in to comment.