Skip to content

Commit bab247d

Browse files
committed
Rename godot-headers to gdextension, move header to top folder
Changes the `<godot/gdextension_interface.h>` include to simply `<gdextension_interface.h>`. Refactor and better document the SCons and CMake logic around setting the paths to the header and API JSON file.
1 parent 1e8eb1c commit bab247d

22 files changed

+68
-50
lines changed

CMakeLists.txt

+14-9
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# CMAKE_BUILD_TYPE: Compilation target (Debug or Release defaults to Debug)
33
#
44
# godot-cpp cmake arguments
5-
# GODOT_HEADERS_DIR: Custom include path for the GDExtension. It should include interface header at this subpath: godot/gdextension_interface.h
6-
# GODOT_CUSTOM_API_FILE: Custom path for extension_api.json
5+
# GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file
6+
# GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)
77
# FLOAT_TYPE Floating-point precision (32, 64)
88
#
99
# Android cmake arguments
@@ -57,9 +57,14 @@ if(NOT DEFINED BITS)
5757
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
5858
endif()
5959

60-
# Input from user for godot headers and the api file
61-
set(GODOT_HEADERS_DIR "godot-headers" CACHE STRING "")
62-
set(GODOT_CUSTOM_API_FILE "godot-headers/extension_api.json" CACHE STRING "")
60+
# Input from user for GDExtension interface header and the API JSON file
61+
set(GODOT_GDEXTENSION_DIR "gdextension" CACHE STRING "")
62+
set(GODOT_CUSTOM_API_FILE "" CACHE STRING "")
63+
64+
set(GODOT_GDEXTENSION_API_FILE "${GODOT_GDEXTENSION_DIR}/extension_api.json")
65+
if (NOT "${GODOT_CUSTOM_API_FILE}" STREQUAL "") # User-defined override.
66+
set(GODOT_GDEXTENSION_API_FILE "${GODOT_CUSTOM_API_FILE}")
67+
endif()
6368

6469
set(GODOT_COMPILE_FLAGS )
6570
set(GODOT_LINKER_FLAGS )
@@ -125,16 +130,16 @@ else()
125130
set(GENERATE_BINDING_PARAMETERS "False")
126131
endif()
127132

128-
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)"
133+
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)"
129134
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
130135
OUTPUT_VARIABLE GENERATED_FILES_LIST
131136
)
132137

133138
add_custom_command(OUTPUT ${GENERATED_FILES_LIST}
134-
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}\")"
139+
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}\")"
135140
VERBATIM
136141
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
137-
MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE}
142+
MAIN_DEPENDENCY ${GODOT_GDEXTENSION_API_FILE}
138143
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/binding_generator.py
139144
COMMENT "Generating bindings"
140145
)
@@ -173,7 +178,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
173178
# Put godot headers as SYSTEM PUBLIC to exclude warnings from irrelevant headers
174179
target_include_directories(${PROJECT_NAME}
175180
SYSTEM PUBLIC
176-
${GODOT_HEADERS_DIR}
181+
${GODOT_GDEXTENSION_DIR}
177182
)
178183

179184
# Add the compile flags

README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ Stable releases are also tagged on this repository:
2424
this repository as a Git submodule, checking out the specific tag matching your
2525
Godot version.**
2626

27-
> As the `master` and `3.x` branches are constantly getting updates, if you are
27+
> As the `master` branch of Godot is constantly getting updated, if you are
2828
> using `godot-cpp` against a more current version of Godot, see the instructions
29-
> in [**godot-headers**](https://github.com/godotengine/godot-headers) for
30-
> updating the relevant files.
29+
> in the `gdextension` folder to update the relevant files.
3130
3231
## Contributing
3332

SConstruct

+15-5
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,20 @@ opts.Add(
7777
)
7878
opts.Add(
7979
PathVariable(
80-
"headers_dir", "Path to the directory containing Godot headers", "godot-headers", PathVariable.PathIsDir
80+
"gdextension_dir",
81+
"Path to the directory containing GDExtension interface header and API JSON file",
82+
"gdextension",
83+
PathVariable.PathIsDir,
84+
)
85+
)
86+
opts.Add(
87+
PathVariable(
88+
"custom_api_file",
89+
"Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)",
90+
None,
91+
PathVariable.PathIsFile,
8192
)
8293
)
83-
opts.Add(PathVariable("custom_api_file", "Path to a custom JSON API file", None, PathVariable.PathIsFile))
8494
opts.Add(
8595
BoolVariable("generate_bindings", "Force GDExtension API bindings generation. Auto-detected by default.", False)
8696
)
@@ -179,11 +189,11 @@ json_api_file = ""
179189
if "custom_api_file" in env:
180190
json_api_file = env["custom_api_file"]
181191
else:
182-
json_api_file = os.path.join(os.getcwd(), env["headers_dir"], "extension_api.json")
192+
json_api_file = os.path.join(os.getcwd(), env["gdextension_dir"], "extension_api.json")
183193

184194
bindings = env.GenerateBindings(
185195
env.Dir("."),
186-
[json_api_file, os.path.join(env["headers_dir"], "godot", "gdextension_interface.h"), "binding_generator.py"],
196+
[json_api_file, os.path.join(env["gdextension_dir"], "gdextension_interface.h"), "binding_generator.py"],
187197
)
188198

189199
scons_cache_path = os.environ.get("SCONS_CACHE")
@@ -197,7 +207,7 @@ if env["generate_bindings"]:
197207
NoCache(bindings)
198208

199209
# Includes
200-
env.Append(CPPPATH=[[env.Dir(d) for d in [env["headers_dir"], "include", os.path.join("gen", "include")]]])
210+
env.Append(CPPPATH=[[env.Dir(d) for d in [env["gdextension_dir"], "include", os.path.join("gen", "include")]]])
201211

202212
# Sources to compile
203213
sources = []

binding_generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def generate_builtin_class_header(builtin_api, size, used_classes, fully_used_cl
377377
if len(fully_used_classes) > 0:
378378
result.append("")
379379

380-
result.append(f"#include <godot/gdextension_interface.h>")
380+
result.append(f"#include <gdextension_interface.h>")
381381
result.append("")
382382
result.append("namespace godot {")
383383
result.append("")

gdextension/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# GDExtension header and API
2+
3+
This repository contains the C header and API JSON for
4+
[**Godot Engine**](https://github.com/godotengine/godot)'s *GDExtensions* API.
5+
6+
## Updating header and API
7+
8+
If the current branch is not up-to-date for your needs, or if you want to sync
9+
the header and API JSON with your own modified version of Godot, here is the
10+
update procedure used to sync this repository with upstream releases:
11+
12+
- Compile [Godot Engine](https://github.com/godotengine/godot) at the specific
13+
version/commit which you are using.
14+
* Or if you use an official release, download that version of the Godot editor.
15+
- Use the compiled or downloaded executable to generate the `extension_api.json`
16+
and `gdextension_interface.h` files with:
17+
18+
```
19+
godot --dump-extension-api --dump-gdextension-interface
20+
```
File renamed without changes.

godot-headers/README.md

-16
This file was deleted.

include/godot_cpp/core/binder_common.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifndef GODOT_BINDER_COMMON_HPP
3232
#define GODOT_BINDER_COMMON_HPP
3333

34-
#include <godot/gdextension_interface.h>
34+
#include <gdextension_interface.h>
3535

3636
#include <godot_cpp/core/method_ptrcall.hpp>
3737
#include <godot_cpp/core/type_info.hpp>

include/godot_cpp/core/builtin_ptrcall.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifndef GODOT_BUILTIN_PTRCALL_HPP
3232
#define GODOT_BUILTIN_PTRCALL_HPP
3333

34-
#include <godot/gdextension_interface.h>
34+
#include <gdextension_interface.h>
3535

3636
#include <array>
3737

include/godot_cpp/core/class_db.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifndef GODOT_CLASS_DB_HPP
3232
#define GODOT_CLASS_DB_HPP
3333

34-
#include <godot/gdextension_interface.h>
34+
#include <gdextension_interface.h>
3535

3636
#include <godot_cpp/core/defs.hpp>
3737
#include <godot_cpp/core/error_macros.hpp>

include/godot_cpp/core/engine_ptrcall.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifndef GODOT_ENGINE_PTRCALL_HPP
3232
#define GODOT_ENGINE_PTRCALL_HPP
3333

34-
#include <godot/gdextension_interface.h>
34+
#include <gdextension_interface.h>
3535

3636
#include <godot_cpp/core/binder_common.hpp>
3737
#include <godot_cpp/core/object.hpp>

include/godot_cpp/core/math.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
#include <godot_cpp/core/defs.hpp>
3535

36-
#include <godot/gdextension_interface.h>
36+
#include <gdextension_interface.h>
3737

3838
#include <cmath>
3939

include/godot_cpp/core/method_bind.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include <godot_cpp/core/memory.hpp>
3838

39-
#include <godot/gdextension_interface.h>
39+
#include <gdextension_interface.h>
4040

4141
#include <godot_cpp/classes/global_constants.hpp>
4242

include/godot_cpp/core/object.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#include <godot_cpp/godot.hpp>
4343

44-
#include <godot/gdextension_interface.h>
44+
#include <gdextension_interface.h>
4545

4646
#include <vector>
4747

include/godot_cpp/core/property_info.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
#include <godot_cpp/godot.hpp>
4141

42-
#include <godot/gdextension_interface.h>
42+
#include <gdextension_interface.h>
4343

4444
namespace godot {
4545

include/godot_cpp/core/type_info.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <godot_cpp/variant/typed_array.hpp>
3636
#include <godot_cpp/variant/variant.hpp>
3737

38-
#include <godot/gdextension_interface.h>
38+
#include <gdextension_interface.h>
3939

4040
namespace godot {
4141

include/godot_cpp/godot.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifndef GODOT_GODOT_HPP
3232
#define GODOT_GODOT_HPP
3333

34-
#include <godot/gdextension_interface.h>
34+
#include <gdextension_interface.h>
3535

3636
namespace godot {
3737

include/godot_cpp/variant/variant.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <godot_cpp/variant/builtin_types.hpp>
3737
#include <godot_cpp/variant/variant_size.hpp>
3838

39-
#include <godot/gdextension_interface.h>
39+
#include <gdextension_interface.h>
4040

4141
#include <array>
4242

misc/scripts/check_get_file_list.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from binding_generator import get_file_list, generate_bindings
1010

11-
api_filepath = "godot-headers/extension_api.json"
11+
api_filepath = "gdextension/extension_api.json"
1212
bits = "64"
1313
double = "float"
1414
output_dir = "self_test"

test/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
project(godot-cpp-test)
22
cmake_minimum_required(VERSION 3.6)
33

4-
set(GODOT_HEADERS_PATH ../godot-headers/ CACHE STRING "Path to Godot headers")
4+
set(GODOT_GDEXTENSION_DIR ../gdextension/ CACHE STRING "Path to GDExtension interface header directory")
55
set(CPP_BINDINGS_PATH ../ CACHE STRING "Path to C++ bindings")
66

77
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@@ -102,8 +102,8 @@ add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
102102
target_include_directories(${PROJECT_NAME} SYSTEM
103103
PRIVATE
104104
${CPP_BINDINGS_PATH}/include
105-
${CPP_BINDINGS_PATH}/gen/include
106-
${GODOT_HEADERS_PATH}
105+
${CPP_BINDINGS_PATH}/gen/include
106+
${GODOT_GDEXTENSION_DIR}
107107
)
108108

109109
# Create the correct name (godot.os.build_type.system_bits)

test/src/register_types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include "register_types.h"
77

8-
#include <godot/gdextension_interface.h>
8+
#include <gdextension_interface.h>
99

1010
#include <godot_cpp/core/class_db.hpp>
1111
#include <godot_cpp/core/defs.hpp>

0 commit comments

Comments
 (0)