Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #829
Browse files Browse the repository at this point in the history
829: Support Godot 3.4 r=Bromeon a=Bromeon

Updates api.json, CI scripts and examples.

This is a **breaking change**. Some GDNative APIs added default parameters, which can currently not be modeled in a backwards-compatible way in godot-rust (Rust itself doesn't support default parameters). It is however possible to manually generate `api.json` for an older Godot version (3.2 or 3.3) and keep using godot-rust normally.

Addresses #814 in the short-term 🛠️ 
Still on the radar: #640 📡 

Co-authored-by: Jan Haller <[email protected]>
bors[bot] and Bromeon authored Dec 15, 2021
2 parents 99a0d34 + 8185e2f commit b0c51b2
Showing 5 changed files with 12,103 additions and 1,913 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ env:

# Local variables
# Note: using variables is limited at the moment, see https://github.com/actions/runner/issues/480
GODOT_VER: '3.3'
GODOT_VER: "3.4"
GODOT_REL: stable

on:
2 changes: 1 addition & 1 deletion .github/workflows/minimal-ci.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ env:

# Local variables
# Note: using variables is limited at the moment, see https://github.com/actions/runner/issues/480
GODOT_VER: "3.3"
GODOT_VER: "3.4"
GODOT_REL: stable

on:
47 changes: 32 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,19 +12,22 @@

## Stability

The bindings cover most of the exposed API of Godot 3.2, and are being used on a number of projects in development, but we still expect non-trivial breaking changes in the API in the coming releases. godot-rust adheres to [Cargo's semantic versioning](https://doc.rust-lang.org/cargo/reference/semver.html).
The bindings cover most of the exposed API of Godot 3.4, and are being used on a number of projects in development, but we still expect non-trivial breaking changes in the API in the coming releases. godot-rust adheres to [Cargo's semantic versioning](https://doc.rust-lang.org/cargo/reference/semver.html).

## Engine compatibility

We are committed to keeping compatibility with the latest stable patch releases of all minor versions of the engine, starting from Godot 3.2.
We are committed to keeping compatibility with the latest stable patch releases of all minor versions of the engine, starting from Godot 3.2:
* Godot 3.4 (works out-of-the-box)
* Godot 3.3 (needs api.json adjustment)
* Godot 3.2 (needs api.json adjustment)

The current minimum compatible version, with `api.json` replacement, is Godot 3.2. Godot 3.3 is supported as well. Changes to this will be considered a breaking change, and will be called out in the release notes.
For versions 3.2 and 3.3, you will need to generate an `api.json` manually, using `godot --gdnative-generate-json-api api.json` to replace the file in the `gdnative-bindings` directory.

The bindings do _**not**_ support Godot 4.0 currently. Support is planned as the native extensions become more stable.
The bindings do _**not**_ support in-development Godot 4 versions at the moment. Support is planned as the native extensions become more stable.

## Requirements

The generator makes use of `bindgen`, which depends on Clang. Instructions for installing `bindgen`'s dependencies for popular OSes can be found in their documentation: https://rust-lang.github.io/rust-bindgen/requirements.html.
The generator makes use of `bindgen`, which depends on Clang. Instructions for installing `bindgen`'s dependencies for popular OSes can be found [in their documentation](https://rust-lang.github.io/rust-bindgen/requirements.html).

`bindgen` may complain about a missing `llvm-config` binary, but it is not actually required to build the `gdnative` crate. If you see a warning about `llvm-config` and a failed build, it's likely that you're having a different problem!

@@ -40,10 +43,22 @@ This means that `bindgen` was unable to find the C system headers for your platf

## Usage

### Godot 3.2.3-stable
### Latest `master` version + Godot 3.4

After `bindgen` dependencies are installed, add the `gdnative` crate as a dependency, and set the crate type to `cdylib`:

```toml
[dependencies]
gdnative = { git = "https://github.com/godot-rust/godot-rust.git" }

[lib]
crate-type = ["cdylib"]
```

### Godot 3.2.3-stable

To access the last released version on crates.io, use the following. If you are starting, we recommend using the `master` version at this point, as there have been significant API changes since v0.9.3.

```toml
[dependencies]
gdnative = "0.9.3"
@@ -56,9 +71,9 @@ crate-type = ["cdylib"]

The bindings are currently generated from the API description of Godot 3.2.3-stable by default. To use the bindings with another version or a custom build, see [Using custom builds of Godot](https://godot-rust.github.io/book/advanced-guides/custom-bindings.html) in the user guide.

### Async / "`yield`" support
### Async / `yield` support

Async support is a work-in-progress, with a low-level API available in the `gdnative-async` crate. This crate is re-exported as `gdnative::tasks`, if the `async` feature is enabled on `gdnative`.
Async support is a work-in-progress, with a low-level API available in the `gdnative-async` crate. This crate is re-exported as `gdnative::tasks`, if the `async` feature is enabled on `gdnative`. See [this page](https://godot-rust.github.io/book/recipes/async-tokio.html) in the book for an introduction to use the async feature with Tokio.

## Example

@@ -107,15 +122,17 @@ godot_init!(init);
The [/examples](https://github.com/godot-rust/godot-rust/tree/master/examples) directory contains several ready to use examples, complete with Godot projects and setup for easy compilation from Cargo:

- [/examples/hello_world](https://github.com/godot-rust/godot-rust/tree/master/examples/hello_world) - Your first project, writes to the console
- [/examples/spinning_cube/](https://github.com/godot-rust/godot-rust/tree/master/examples/spinning_cube) - Spinning our own node in place, exposing editor properties.
- [/examples/scene_create](https://github.com/godot-rust/godot-rust/tree/master/examples/scene_create) - Shows you how to load, instance and place scenes using Rust code
- [/examples/signals](https://github.com/godot-rust/godot-rust/tree/master/examples/signals) - Shows you how to handle signals.
- [/examples/resource](https://github.com/godot-rust/godot-rust/tree/master/examples/resource) - Shows you how to create and use custom resources.
- [/examples/native_plugin](https://github.com/godot-rust/godot-rust/tree/master/examples/native_plugin) - Shows you how to create custom node plugins.
- [**hello_world**](https://github.com/godot-rust/godot-rust/tree/master/examples/hello_world) - Your first project, writes to the console
- [**spinning_cube**](https://github.com/godot-rust/godot-rust/tree/master/examples/spinning_cube) - Spinning our own node in place, exposing editor properties.
- [**scene_create**](https://github.com/godot-rust/godot-rust/tree/master/examples/scene_create) - Shows you how to load, instance and place scenes using Rust code
- [**signals**](https://github.com/godot-rust/godot-rust/tree/master/examples/signals) - Shows you how to handle signals.
- [**resource**](https://github.com/godot-rust/godot-rust/tree/master/examples/resource) - Shows you how to create and use custom resources.
- [**native_plugin**](https://github.com/godot-rust/godot-rust/tree/master/examples/native_plugin) - Shows you how to create custom node plugins.

## Third-party resources

See also (work-in-progress): [Third-party projects](https://godot-rust.github.io/book/projects.html) in the book.

### Tools and integrations

- [godot-egui](https://github.com/setzer22/godot-egui) (setzer22, jacobsky) - combine the [egui](https://github.com/emilk/egui) library with Godot
@@ -139,4 +156,4 @@ See the [contribution guidelines](CONTRIBUTING.md).

## License

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed under the [MIT license](LICENSE.md), without any additional terms or conditions.
Any contribution intentionally submitted for inclusion in the work by you shall be licensed under the [MIT license](LICENSE.md), without any additional terms or conditions.
9 changes: 5 additions & 4 deletions examples/dodge_the_creeps/src/player.rs
Original file line number Diff line number Diff line change
@@ -47,16 +47,17 @@ impl Player {
let input = Input::godot_singleton();
let mut velocity = Vector2::new(0.0, 0.0);

if Input::is_action_pressed(input, "ui_right") {
// Note: exact=false by default, in Rust we have to provide it explicitly
if Input::is_action_pressed(input, "ui_right", false) {
velocity.x += 1.0
}
if Input::is_action_pressed(input, "ui_left") {
if Input::is_action_pressed(input, "ui_left", false) {
velocity.x -= 1.0
}
if Input::is_action_pressed(input, "ui_down") {
if Input::is_action_pressed(input, "ui_down", false) {
velocity.y += 1.0
}
if Input::is_action_pressed(input, "ui_up") {
if Input::is_action_pressed(input, "ui_up", false) {
velocity.y -= 1.0
}

13,956 changes: 12,064 additions & 1,892 deletions gdnative-bindings/api.json

Large diffs are not rendered by default.

0 comments on commit b0c51b2

Please sign in to comment.