|
1 | 1 | # Using custom builds of Godot
|
2 | 2 |
|
| 3 | +As you probably know, godot-rust interacts with Godot via the GDNative interface. This interface is formally specified in a file called `api.json`, which lists all the classes, functions, constants and other symbols. In its build step, godot-rust reads this file and generates Rust code reflecting the GDNative interface. |
| 4 | + |
| 5 | +By default, godot-rust ships an `api.json` compatible with the latest Godot 3.x release. This makes it easy to use the latest version. But there are cases where you might want to use an older Godot version, or one that you built yourself (with custom compiler flags or modules). In the past, this needed quite a few manual steps; in the meantime, this process has been simplified. |
| 6 | + |
| 7 | +For using custom Godot builds, the first thing you need to do is to add the feature flag `custom-godot` when adding godot-rust as a dependency. |
| 8 | +For example, if you depend on the latest GitHub version of godot-rust, Cargo.toml would look like this: |
| 9 | +```toml |
| 10 | +gdnative = { git = "https://github.com/godot-rust/godot-rust.git", features = ["custom-godot"] } |
| 11 | +``` |
| 12 | + |
| 13 | +Next, godot-rust must be able to locate the Godot engine executable on your system. |
| 14 | +There are two options: |
| 15 | + |
| 16 | +1. Your executable is called `godot` and available in the system PATH. |
| 17 | + On Windows systems, this would also find a `godot.bat`, for example. |
| 18 | +2. You define an environment variable `GODOT_BIN` with the absolute path to your executable. |
| 19 | + It is important that you include the filename -- this is not a directory path. |
| 20 | + |
| 21 | +That's it. During build, godot-rust will invoke Godot to generate a matching `api.json` -- you might see a short Godot window popping up. |
| 22 | + |
| 23 | +Keep in mind that we only support Godot versions >= 3.2 and < 4.0 for now. Also, the GDNative API varies between versions, so you may need to adjust your client code. |
| 24 | + |
| 25 | + |
| 26 | +## Previous approach |
| 27 | + |
| 28 | +> _**Note:** this guide is now obsolete._ |
| 29 | +> _You can still use it when working with godot-rust 0.9 or `master` versions before December 2021._ |
| 30 | +
|
3 | 31 | Sometimes, users might need to use a different version of the engine that is different from the default one, or is a custom build. In order to use `godot-rust` with them, one would need to create a custom version of the `gdnative-bindings` crate, generated from an `api.json` from the custom build. This guide walks through the necessary steps to do so.
|
4 | 32 |
|
5 | 33 | First, obtain the source code for `gdnative-bindings` from crates.io. For this guide, we'll use [`cargo-download`](https://github.com/Xion/cargo-download/) to accomplish this:
|
|
0 commit comments