diff --git a/CMakeLists.txt b/CMakeLists.txt index d09abbbd..f3cf4fb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,8 @@ # CMAKE_BUILD_TYPE: Compilation target (Debug or Release defaults to Debug) # # godot-cpp cmake arguments -# GODOT_HEADERS_DIR: Custom include path for the GDExtension. It should include interface header at this subpath: godot/gdextension_interface.h -# GODOT_CUSTOM_API_FILE: Custom path for extension_api.json +# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file +# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`) # FLOAT_TYPE Floating-point precision (32, 64) # # Android cmake arguments @@ -57,9 +57,14 @@ if(NOT DEFINED BITS) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) endif() -# Input from user for godot headers and the api file -set(GODOT_HEADERS_DIR "godot-headers" CACHE STRING "") -set(GODOT_CUSTOM_API_FILE "godot-headers/extension_api.json" CACHE STRING "") +# Input from user for GDExtension interface header and the API JSON file +set(GODOT_GDEXTENSION_DIR "gdextension" CACHE STRING "") +set(GODOT_CUSTOM_API_FILE "" CACHE STRING "") + +set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json") +if (NOT "${GODOT_CUSTOM_API_FILE}" STREQUAL "") # User-defined override. + set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}") +endif() set(GODOT_COMPILE_FLAGS ) set(GODOT_LINKER_FLAGS ) @@ -125,16 +130,16 @@ else() set(GENERATE_BINDING_PARAMETERS "False") endif() -execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_CUSTOM_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" +execute_process(COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.print_file_list(\"${GODOT_GDEXTENSION_API_FILE}\", \"${CMAKE_CURRENT_BINARY_DIR}\", headers=True, sources=True)" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE GENERATED_FILES_LIST ) add_custom_command(OUTPUT ${GENERATED_FILES_LIST} - COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_CUSTOM_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_TYPE_FLAG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" + COMMAND "${Python3_EXECUTABLE}" "-c" "import binding_generator; binding_generator.generate_bindings(\"${GODOT_GDEXTENSION_API_FILE}\", \"${GENERATE_BINDING_PARAMETERS}\", \"${BITS}\", \"${FLOAT_TYPE_FLAG}\", \"${CMAKE_CURRENT_BINARY_DIR}\")" VERBATIM WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE} + MAIN_DEPENDENCY ${GODOT_GDEXTENSION_API_FILE} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/binding_generator.py COMMENT "Generating bindings" ) @@ -173,7 +178,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC # Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC - ${GODOT_HEADERS_DIR} + ${GODOT_GDEXTENSION_DIR} ) # Add the compile flags diff --git a/README.md b/README.md index 225ecc7c..d1f0b9dd 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,9 @@ Stable releases are also tagged on this repository: this repository as a Git submodule, checking out the specific tag matching your Godot version.** -> As the `master` and `3.x` branches are constantly getting updates, if you are +> As the `master` branch of Godot is constantly getting updated, if you are > using `godot-cpp` against a more current version of Godot, see the instructions -> in [**godot-headers**](https://github.com/godotengine/godot-headers) for -> updating the relevant files. +> in the `gdextension` folder to update the relevant files. ## Contributing diff --git a/SConstruct b/SConstruct index 7fafbc45..09a963f9 100644 --- a/SConstruct +++ b/SConstruct @@ -77,10 +77,20 @@ opts.Add( ) opts.Add( PathVariable( - "headers_dir", "Path to the directory containing Godot headers", "godot-headers", PathVariable.PathIsDir + "gdextension_dir", + "Path to the directory containing GDExtension interface header and API JSON file", + "gdextension", + PathVariable.PathIsDir, + ) +) +opts.Add( + PathVariable( + "custom_api_file", + "Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)", + None, + PathVariable.PathIsFile, ) ) -opts.Add(PathVariable("custom_api_file", "Path to a custom JSON API file", None, PathVariable.PathIsFile)) opts.Add( BoolVariable("generate_bindings", "Force GDExtension API bindings generation. Auto-detected by default.", False) ) @@ -179,11 +189,11 @@ json_api_file = "" if "custom_api_file" in env: json_api_file = env["custom_api_file"] else: - json_api_file = os.path.join(os.getcwd(), env["headers_dir"], "extension_api.json") + json_api_file = os.path.join(os.getcwd(), env["gdextension_dir"], "extension_api.json") bindings = env.GenerateBindings( env.Dir("."), - [json_api_file, os.path.join(env["headers_dir"], "godot", "gdextension_interface.h"), "binding_generator.py"], + [json_api_file, os.path.join(env["gdextension_dir"], "gdextension_interface.h"), "binding_generator.py"], ) scons_cache_path = os.environ.get("SCONS_CACHE") @@ -197,7 +207,7 @@ if env["generate_bindings"]: NoCache(bindings) # Includes -env.Append(CPPPATH=[[env.Dir(d) for d in [env["headers_dir"], "include", os.path.join("gen", "include")]]]) +env.Append(CPPPATH=[[env.Dir(d) for d in [env["gdextension_dir"], "include", os.path.join("gen", "include")]]]) # Sources to compile sources = [] diff --git a/binding_generator.py b/binding_generator.py index db752581..ec034c78 100644 --- a/binding_generator.py +++ b/binding_generator.py @@ -377,7 +377,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl if len(fully_used_classes) > 0: result.append("") - result.append(f"#include ") + result.append(f"#include ") result.append("") result.append("namespace godot {") result.append("") diff --git a/gdextension/README.md b/gdextension/README.md new file mode 100644 index 00000000..1e11f9a3 --- /dev/null +++ b/gdextension/README.md @@ -0,0 +1,20 @@ +# GDExtension header and API + +This repository contains the C header and API JSON for +[**Godot Engine**](https://github.com/godotengine/godot)'s *GDExtensions* API. + +## Updating header and API + +If the current branch is not up-to-date for your needs, or if you want to sync +the header and API JSON with your own modified version of Godot, here is the +update procedure used to sync this repository with upstream releases: + +- Compile [Godot Engine](https://github.com/godotengine/godot) at the specific + version/commit which you are using. + * Or if you use an official release, download that version of the Godot editor. +- Use the compiled or downloaded executable to generate the `extension_api.json` + and `gdextension_interface.h` files with: + +``` +godot --dump-extension-api --dump-gdextension-interface +``` diff --git a/godot-headers/extension_api.json b/gdextension/extension_api.json similarity index 100% rename from godot-headers/extension_api.json rename to gdextension/extension_api.json diff --git a/godot-headers/godot/gdextension_interface.h b/gdextension/gdextension_interface.h similarity index 100% rename from godot-headers/godot/gdextension_interface.h rename to gdextension/gdextension_interface.h diff --git a/godot-headers/README.md b/godot-headers/README.md deleted file mode 100644 index 970bc8a9..00000000 --- a/godot-headers/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# godot-headers - -This repository contains C headers for -[**Godot Engine**](https://github.com/godotengine/godot)'s *GDExtensions* API. - -## Updating Headers - -If the current branch is not up-to-date for your needs, or if you want to sync -the headers with your own modified version of Godot, here is the update -procedure used to sync this repository with upstream releases: - -- Compile [Godot Engine](https://github.com/godotengine/godot) at the specific - version/commit which you are using. -- Use the compiled executable to generate the `extension_api.json` file with: - `godot --dump-extension-api extension_api.json` -- Copy the file `core/extension/gdextension_interface.h` to `godot` diff --git a/include/godot_cpp/core/binder_common.hpp b/include/godot_cpp/core/binder_common.hpp index 30ff8f38..e97702de 100644 --- a/include/godot_cpp/core/binder_common.hpp +++ b/include/godot_cpp/core/binder_common.hpp @@ -31,7 +31,7 @@ #ifndef GODOT_BINDER_COMMON_HPP #define GODOT_BINDER_COMMON_HPP -#include +#include #include #include diff --git a/include/godot_cpp/core/builtin_ptrcall.hpp b/include/godot_cpp/core/builtin_ptrcall.hpp index 1b5aadd9..ba0546be 100644 --- a/include/godot_cpp/core/builtin_ptrcall.hpp +++ b/include/godot_cpp/core/builtin_ptrcall.hpp @@ -31,7 +31,7 @@ #ifndef GODOT_BUILTIN_PTRCALL_HPP #define GODOT_BUILTIN_PTRCALL_HPP -#include +#include #include diff --git a/include/godot_cpp/core/class_db.hpp b/include/godot_cpp/core/class_db.hpp index 8d7740fe..91483598 100644 --- a/include/godot_cpp/core/class_db.hpp +++ b/include/godot_cpp/core/class_db.hpp @@ -31,7 +31,7 @@ #ifndef GODOT_CLASS_DB_HPP #define GODOT_CLASS_DB_HPP -#include +#include #include #include diff --git a/include/godot_cpp/core/engine_ptrcall.hpp b/include/godot_cpp/core/engine_ptrcall.hpp index 9400cd8f..f3611666 100644 --- a/include/godot_cpp/core/engine_ptrcall.hpp +++ b/include/godot_cpp/core/engine_ptrcall.hpp @@ -31,7 +31,7 @@ #ifndef GODOT_ENGINE_PTRCALL_HPP #define GODOT_ENGINE_PTRCALL_HPP -#include +#include #include #include diff --git a/include/godot_cpp/core/math.hpp b/include/godot_cpp/core/math.hpp index 1436f209..22745692 100644 --- a/include/godot_cpp/core/math.hpp +++ b/include/godot_cpp/core/math.hpp @@ -33,7 +33,7 @@ #include -#include +#include #include diff --git a/include/godot_cpp/core/method_bind.hpp b/include/godot_cpp/core/method_bind.hpp index 260500ff..0b5925b6 100644 --- a/include/godot_cpp/core/method_bind.hpp +++ b/include/godot_cpp/core/method_bind.hpp @@ -36,7 +36,7 @@ #include -#include +#include #include diff --git a/include/godot_cpp/core/object.hpp b/include/godot_cpp/core/object.hpp index 9fa2bb12..f6348be5 100644 --- a/include/godot_cpp/core/object.hpp +++ b/include/godot_cpp/core/object.hpp @@ -41,7 +41,7 @@ #include -#include +#include #include diff --git a/include/godot_cpp/core/property_info.hpp b/include/godot_cpp/core/property_info.hpp index a0c51263..ea961568 100644 --- a/include/godot_cpp/core/property_info.hpp +++ b/include/godot_cpp/core/property_info.hpp @@ -39,7 +39,7 @@ #include -#include +#include namespace godot { diff --git a/include/godot_cpp/core/type_info.hpp b/include/godot_cpp/core/type_info.hpp index e570db79..ddbb0b6b 100644 --- a/include/godot_cpp/core/type_info.hpp +++ b/include/godot_cpp/core/type_info.hpp @@ -35,7 +35,7 @@ #include #include -#include +#include namespace godot { diff --git a/include/godot_cpp/godot.hpp b/include/godot_cpp/godot.hpp index 547c623c..c7613ac9 100644 --- a/include/godot_cpp/godot.hpp +++ b/include/godot_cpp/godot.hpp @@ -31,7 +31,7 @@ #ifndef GODOT_GODOT_HPP #define GODOT_GODOT_HPP -#include +#include namespace godot { diff --git a/include/godot_cpp/variant/variant.hpp b/include/godot_cpp/variant/variant.hpp index 18fa5bac..3d91a0a5 100644 --- a/include/godot_cpp/variant/variant.hpp +++ b/include/godot_cpp/variant/variant.hpp @@ -36,7 +36,7 @@ #include #include -#include +#include #include diff --git a/misc/scripts/check_get_file_list.py b/misc/scripts/check_get_file_list.py index cdf6245e..d86b65fd 100755 --- a/misc/scripts/check_get_file_list.py +++ b/misc/scripts/check_get_file_list.py @@ -8,7 +8,7 @@ sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "..")) from binding_generator import get_file_list, generate_bindings -api_filepath = "godot-headers/extension_api.json" +api_filepath = "gdextension/extension_api.json" bits = "64" double = "float" output_dir = "self_test" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f229253e..0538c5d7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ project(godot-cpp-test) cmake_minimum_required(VERSION 3.6) -set(GODOT_HEADERS_PATH ../godot-headers/ CACHE STRING "Path to Godot headers") +set(GODOT_GDEXTENSION_DIR ../gdextension/ CACHE STRING "Path to GDExtension interface header directory") set(CPP_BINDINGS_PATH ../ CACHE STRING "Path to C++ bindings") if(CMAKE_SYSTEM_NAME STREQUAL "Linux") @@ -102,8 +102,8 @@ add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${CPP_BINDINGS_PATH}/include - ${CPP_BINDINGS_PATH}/gen/include - ${GODOT_HEADERS_PATH} + ${CPP_BINDINGS_PATH}/gen/include + ${GODOT_GDEXTENSION_DIR} ) # Create the correct name (godot.os.build_type.system_bits) diff --git a/test/src/register_types.cpp b/test/src/register_types.cpp index 917d669e..e22662fc 100644 --- a/test/src/register_types.cpp +++ b/test/src/register_types.cpp @@ -5,7 +5,7 @@ #include "register_types.h" -#include +#include #include #include