You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -147,3 +147,64 @@ generic reusable template.
147
147
148
148
Or checkout the code for the [Summator example](https://github.com/paddy-exe/GDExtensionSummator)
149
149
as shown in the [official documentation](https://docs.godotengine.org/en/latest/tutorials/scripting/gdextension/gdextension_cpp_example.html).
150
+
151
+
## Godot and Godot Cpp Compatibility
152
+
153
+
If you intend to target both building as a GDExtension and as a module using godot repo, you can generate compatibility includes that will target either GDExtension or module, based on the GODOT_MODULE_COMPAT define.
154
+
155
+
If you want such headers, when running the build command, `scons`, pass the `godot_repo` param with the path to the godot repository. Eg. if you have the godot repository cloned at path `../godot`, then do:
156
+
157
+
```sh
158
+
scons godot_repo="../godot"
159
+
```
160
+
161
+
This will generate something like this:
162
+
```
163
+
gen/include/godot_cpp/..
164
+
gen/include/godot_compat/..
165
+
```
166
+
167
+
Now, all you need to do is when writting your addon/module, replace includes like these:
168
+
169
+
```cpp
170
+
#include<godot_cpp/classes/a_star_grid2d.hpp>
171
+
```
172
+
173
+
with
174
+
175
+
```cpp
176
+
#include<godot_compat/classes/a_star_grid2d.hpp>
177
+
```
178
+
179
+
Inside, this file will have code for both godot and godot-cpp:
180
+
181
+
```cpp
182
+
#ifdef GODOT_MODULE_COMPAT
183
+
#include <core/math/a_star_grid_2d.h>
184
+
#else
185
+
#include <godot_cpp/classes/a_star_grid2d.hpp>
186
+
#endif
187
+
```
188
+
189
+
### Manually generate mapping files
190
+
191
+
The mappings can be manually generated by running the `compat_generator.py` script.
192
+
193
+
Example of how to run `compat_generator.py`:
194
+
195
+
```sh
196
+
git clone godotengine/godot
197
+
python compat_generator.py godot
198
+
```
199
+
200
+
The first argument of `compat_generator.py` is the folder where the repo is (can be godot or godot-cpp repo). If this folder is not given, the current directory is assumed. The output of this is either `output_header_mapping_godot.json` or `output_header_mapping_godot_cpp.json`
201
+
202
+
### Manually match the mapping files
203
+
204
+
If you want to manually match the godot mapping file with the godot-cpp one, you can do that by running:
205
+
206
+
```sh
207
+
python header_matcher.py
208
+
```
209
+
210
+
This will generate the `header_matches.json` file with matches from godot and godot_cpp repo.
0 commit comments