Skip to content

Commit

Permalink
Expect GODOT4_BIN env or godot4 executable; document toolchain requir…
Browse files Browse the repository at this point in the history
…ements
  • Loading branch information
Bromeon committed Nov 6, 2022
1 parent 1dcbc03 commit 91e9c0b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/composite/godot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ runs:
run: |
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
echo "GODOT_BIN=$runnerDir/godot_bin/${{ inputs.binary-filename }}" >> $GITHUB_ENV
echo "GODOT4_BIN=$runnerDir/godot_bin/${{ inputs.binary-filename }}" >> $GITHUB_ENV
shell: bash

# The chmod seems still necessary, although applied before uploading artifact. Possibly modes are not preserved.
# The `| xargs` pattern trims the output, since printed version may contain extra newline, which causes problems in env vars.
- name: "Inspect Godot version"
run: |
chmod +x $GODOT_BIN
godotVer=$($GODOT_BIN --version | xargs || true)
chmod +x $GODOT4_BIN
godotVer=$($GODOT4_BIN --version | xargs || true)
gitSha=$(echo $godotVer | sed -E "s/.+custom_build\.//")
echo "GODOT_BUILT_FROM=_Built from [\`$godotVer\`](https://github.com/godotengine/godot/commit/$gitSha)._" >> $GITHUB_ENV
shell: bash
Expand Down Expand Up @@ -122,7 +122,7 @@ runs:
run: |
cd itest/godot
echo "OUTCOME=itest" >> $GITHUB_ENV
$GODOT_BIN --headless 2>&1 | tee >(grep "SCRIPT ERROR:" -q && {
$GODOT4_BIN --headless 2>&1 | tee >(grep "SCRIPT ERROR:" -q && {
printf "\n -- Godot engine encountered error, abort...\n";
pkill godot
echo "OUTCOME=godot-runtime" >> $GITHUB_ENV
Expand Down
14 changes: 14 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ However, the library can serve as a playground for experimenting.

## Getting started

### Toolchain

You need to have LLVM installed to use `bindgen`, see [the book](https://godot-rust.github.io/book/getting-started/setup.html#llvm) for instructions.

To find a version of Godot 4, the library expects either an executable of name `godot4` in the PATH, or an environment variable `GODOT4_BIN`
containing the path to the executable (including filename).

### Project setup

We currently only have a GitHub version, crates.io releases are planned once more of the foundation is ready.
In your Cargo.toml, add:

Expand Down Expand Up @@ -51,9 +60,14 @@ To register the GDExtension library with Godot, you need to create two files rel
```
res://MyExt.gdextension
```

### Examples

We highly recommend to have a look at a working example in the `examples/dodge-the-creeps` directory.
This integrates a small game with Godot and has all the necessary steps set up.

API documentation can be generated locally using `cargo doc -p godot --no-deps --open`.

Support for macOS is still ongoing, there is currently **no** support for Android, iOS or WASM.
Contributions in this regard are very welcome!

Expand Down
6 changes: 3 additions & 3 deletions godot-codegen/src/godot_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ fn dump_extension_api(godot_bin: &Path, out_file: &Path) {
}

fn locate_godot_binary() -> PathBuf {
if let Ok(string) = std::env::var("GODOT_BIN") {
println!("Found GODOT_BIN with path to executable: '{}'", string);
if let Ok(string) = std::env::var("GODOT4_BIN") {
println!("Found GODOT4_BIN with path to executable: '{}'", string);
PathBuf::from(string)
} else if let Ok(path) = which::which("godot4") {
println!("Found 'godot4' executable in PATH: {}", path.display());
path
} else {
panic!(
"Bindings generation requires 'godot4' executable or a GODOT_BIN \
"Bindings generation requires 'godot4' executable or a GODOT4_BIN \
environment variable (with the path to the executable)."
)
}
Expand Down

0 comments on commit 91e9c0b

Please sign in to comment.