Skip to content

Commit e0d45a3

Browse files
bors[bot]Bromeon
andauthored
Merge #211
211: Prebuilt Godot artifacts r=Bromeon a=Bromeon Closes #12 Closes #107 From now on, gdext by default fetches pre-generated versions of these files, published in the [`godot4-prebuilt`](https://github.com/godot-rust/godot4-prebuilt) repo: * `extension_api.json` (from Godot binary) * `gdextension_interface.h` (from Godot binary) * `gdextension_interface.rs` (through bindgen -- currently supports 3 platforms) This has several benefits: 1. Significantly fewer dependencies, as bindgen is no longer needed, and thus smaller compile times. 2. Most CI jobs no longer need the Godot binary (clippy, test), speeding up CI _in addition_ to (1). 3. It's possible to change the Godot API behind gdext without manually rebuilding the artifacts. 4. Easy comparison between the Godot APIs of different released versions. ### Using a custom Godot binary It is still possible to generate those files locally like before, through the use of the `custom-godot` feature on the `godot` crate. This is necessary for any platform/configuration different from the 3 main supported ones (because bindgen generates different Rust bindings), as well as any in-development or modified Godot versions. ### Changing the Godot release By default, the latest Godot release is used as input to gdext. Switching between different Godot versions is easily possible, although a bit cumbersome. If you want to use an older version `4.0`, add this to your **workspace** (not sub-crate) `Cargo.toml`: ```toml # We need to trick Cargo into seeing a different URL; rust-lang/cargo#5478 [patch."https://github.com/godot-rust/godot4-prebuilt"] godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "4.0"} ``` We're looking into ways to simplify this. In a crates.io release (#2), we would need to rethink this anyway, mapping Godot versions to Rust release versions (which is not trivial). Co-authored-by: Jan Haller <[email protected]>
2 parents 08c6594 + 22e0288 commit e0d45a3

File tree

28 files changed

+656
-1088
lines changed

28 files changed

+656
-1088
lines changed

.github/composite/godot-itest/action.yml

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ inputs:
1919
default: ''
2020
description: "Command-line arguments passed to Godot"
2121

22+
godot-check-header:
23+
required: false
24+
default: 'false'
25+
description: "Should the job check against latest gdextension_interface.h, and warn on difference"
26+
2227
rust-toolchain:
2328
required: false
2429
default: 'stable'
@@ -60,42 +65,45 @@ runs:
6065
echo "GODOT_BUILT_FROM=_Built from [\`$godotVer\`](https://github.com/godotengine/godot/commit/$gitSha)._" >> $GITHUB_ENV
6166
shell: bash
6267

63-
# Note: if this fails, run `git diff -R > tweaks.patch` after updating the file manually
64-
- name: "Copy and compare GDExtension header"
65-
if: inputs.artifact-name == 'godot-linux'
66-
run: |
67-
mkdir -p godot-codegen/input
68-
cp $RUNNER_DIR/godot_bin/gdextension_interface.h godot-codegen/input/gdextension_interface.h
69-
git apply godot-codegen/input/tweak.patch -v
70-
git diff --exit-code --quiet || {
71-
echo "OUTCOME=header-diff" >> $GITHUB_ENV
72-
echo "gdextension_interface.h is not up-to-date; abort."
73-
echo ""
74-
75-
echo "### :x: Outdated GDExtension API header" >> $GITHUB_STEP_SUMMARY
76-
echo "gdextension_interface.h contains the following differences:" >> $GITHUB_STEP_SUMMARY
77-
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY
78-
git diff >> $GITHUB_STEP_SUMMARY
79-
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
80-
echo "After manually updating file, run: \`git diff -R > tweak.patch\`." >> $GITHUB_STEP_SUMMARY
81-
82-
exit 1
83-
}
84-
shell: bash
85-
8668
- name: "Install Rust"
8769
uses: ./.github/composite/rust
8870
with:
8971
rust: ${{ inputs.rust-toolchain }}
9072
with-llvm: ${{ inputs.with-llvm }}
9173

92-
- name: "Build godot-rust"
74+
- name: "Build gdext (itest)"
9375
run: |
9476
cargo build -p itest ${{ inputs.rust-extra-args }}
9577
shell: bash
9678
env:
9779
RUSTFLAGS: ${{ inputs.rust-env-rustflags }}
9880

81+
# Note: no longer fails, as we expect header to be forward-compatible; instead issues a warning
82+
- name: "Copy and compare GDExtension header"
83+
if: inputs.godot-check-header == 'true'
84+
run: |
85+
mv godot-ffi/src/gen/gdextension_interface.h godot-ffi/src/gen/gdextension_interface_prebuilt.h
86+
mv $RUNNER_DIR/godot_bin/gdextension_interface.h godot-ffi/src/gen/gdextension_interface.h
87+
git apply godot-bindings/res/tweak.patch
88+
cd godot-ffi/src/gen
89+
git diff --no-index --exit-code --quiet gdextension_interface_prebuilt.h gdextension_interface.h || {
90+
echo "OUTCOME=header-diff" >> $GITHUB_ENV
91+
echo "::warning::gdextension_interface.h is not up-to-date."
92+
echo ""
93+
94+
echo "### :warning: Outdated GDExtension API header" >> $GITHUB_STEP_SUMMARY
95+
echo "gdextension_interface.h contains the following differences:" >> $GITHUB_STEP_SUMMARY
96+
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY
97+
git diff --no-index gdextension_interface_prebuilt.h gdextension_interface.h >> $GITHUB_STEP_SUMMARY || true
98+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
99+
echo "After manually updating file, run: \`git diff -R > tweak.patch\`." >> $GITHUB_STEP_SUMMARY
100+
101+
# Undo modifications
102+
mv gdextension_interface_prebuilt.h gdextension_interface.h
103+
#exit 1
104+
}
105+
shell: bash
106+
99107
- name: "Run Godot integration tests"
100108
# Aborts immediately if Godot outputs certain keywords (would otherwise stall until CI runner times out).
101109
# Explanation:
@@ -120,19 +128,20 @@ runs:
120128
run: |
121129
if grep -q "ObjectDB instances leaked at exit" "${{ runner.temp }}/log.txt"; then
122130
echo "OUTCOME=godot-leak" >> $GITHUB_ENV
123-
exit 2
131+
exit 3
124132
fi
125133
shell: bash
126134

127135
- name: "Conclusion"
128136
if: always()
129137
run: |
130-
echo "Evaluate conclusion ($OUTCOME)"
138+
echo "Evaluate conclusion: $OUTCOME"
131139
132140
case $OUTCOME in
133141
"success")
134-
echo "### :heavy_check_mark: Godot integration tests passed" > $GITHUB_STEP_SUMMARY
135-
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
142+
# Do not output success for now, to keep summary focused on warnings/errors
143+
#echo "### :heavy_check_mark: Godot integration tests passed" > $GITHUB_STEP_SUMMARY
144+
#echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
136145
;;
137146
138147
"godot-runtime")

.github/composite/llvm/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ runs:
2424
- name: "Cache LLVM and clang"
2525
id: cache-llvm
2626
# Note: conditionals not yet supported; see https://github.com/actions/runner/issues/834
27-
# if: ${{ inputs.llvm == 'true' }}
27+
# if: inputs.llvm == 'true'
2828
uses: actions/cache@v3
2929
with:
3030
# path: |
@@ -34,7 +34,7 @@ runs:
3434
key: llvm-10.0
3535

3636
- uses: KyleMayes/install-llvm-action@v1
37-
# if: ${{ inputs.llvm == 'true' }}
37+
# if: inputs.llvm == 'true'
3838
with:
3939
version: "10.0"
4040
directory: ${{ env.LLVM_INSTALL_DIR }}

.github/composite/rust/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ runs:
6161
cache-on-failure: true
6262

6363
- name: "Install LLVM"
64+
if: inputs.with-llvm == 'true'
6465
uses: ./.github/composite/llvm
65-
if: ${{ inputs.with-llvm == 'true' }}
6666

6767
- name: "Set environment variables used by toolchain"
6868
run: |

.github/workflows/full-ci.yml

Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,49 +42,28 @@ jobs:
4242
- name: "Install Rust"
4343
uses: ./.github/composite/rust
4444
with:
45-
rust: stable
4645
components: rustfmt
4746

4847
- name: "Check rustfmt"
4948
run: cargo fmt --all -- --check
5049

5150

5251
clippy:
53-
name: clippy (${{ matrix.name }})
5452
runs-on: ubuntu-20.04
55-
strategy:
56-
fail-fast: false
57-
matrix:
58-
include:
59-
- name: linux
60-
rust-toolchain: stable
61-
godot-binary: godot.linuxbsd.editor.dev.x86_64
62-
63-
- name: linux-double
64-
rust-toolchain: stable
65-
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
66-
rust-extra-args: --features double-precision
6753
steps:
6854
- uses: actions/checkout@v3
6955

7056
- name: "Install Rust"
7157
uses: ./.github/composite/rust
72-
73-
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
74-
# Replaces also backspaces on Windows, since they cause problems in Bash
75-
- name: "Install Godot"
76-
uses: ./.github/composite/godot-install
7758
with:
78-
artifact-name: godot-${{ matrix.name }}
79-
godot-binary: ${{ matrix.godot-binary }}
59+
components: clippy
8060

8161
- name: "Check clippy"
8262
run: |
8363
cargo clippy --all-targets $GDEXT_FEATURES ${{ matrix.rust-extra-args }} -- \
8464
-D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf \
8565
-D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings
8666
87-
8867
unit-test:
8968
name: unit-test (${{ matrix.name }}${{ matrix.rust-special }})
9069
runs-on: ${{ matrix.os }}
@@ -98,28 +77,19 @@ jobs:
9877
include:
9978
- name: macos
10079
os: macos-11
101-
rust-toolchain: stable
102-
godot-binary: godot.macos.editor.dev.x86_64
103-
with-llvm: true
10480

10581
- name: windows
10682
os: windows-latest
107-
rust-toolchain: stable-x86_64-pc-windows-msvc
108-
godot-binary: godot.windows.editor.dev.x86_64.exe
10983

11084
# Don't use latest Ubuntu (22.04) as it breaks lots of ecosystem compatibility.
11185
# If ever moving to ubuntu-latest, need to manually install libtinfo5 for LLVM.
11286
- name: linux
11387
os: ubuntu-20.04
114-
rust-toolchain: stable
115-
godot-binary: godot.linuxbsd.editor.dev.x86_64
11688

11789
- name: linux
11890
os: ubuntu-20.04
119-
rust-toolchain: stable
12091
rust-special: -minimal-deps
121-
godot-binary: godot.linuxbsd.editor.dev.x86_64
122-
92+
12393
steps:
12494
- uses: actions/checkout@v3
12595

@@ -128,26 +98,17 @@ jobs:
12898
with:
12999
rust: stable
130100
cache-key: ${{ matrix.rust-special }} # '-minimal-deps' or empty/not defined
131-
with-llvm: ${{ matrix.with-llvm }}
132101

133102
- name: "Install Rust nightly (minimal deps)"
103+
if: matrix.rust-special == '-minimal-deps'
134104
uses: ./.github/composite/rust
135105
with:
136106
rust: nightly
137107
cache-key: minimal-deps-nightly
138-
if: ${{ matrix.rust-special == '-minimal-deps' }}
139108

140109
- name: "Install minimal dependency versions from Cargo"
110+
if: matrix.rust-special == '-minimal-deps'
141111
run: cargo +nightly update -Z minimal-versions
142-
if: ${{ matrix.rust-special == '-minimal-deps' }}
143-
144-
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
145-
# Replaces also backspaces on Windows, since they cause problems in Bash
146-
- name: "Install Godot"
147-
uses: ./.github/composite/godot-install
148-
with:
149-
artifact-name: godot-${{ matrix.name }}
150-
godot-binary: ${{ matrix.godot-binary }}
151112

152113
- name: "Compile tests"
153114
run: cargo test $GDEXT_FEATURES --no-run ${{ matrix.rust-extra-args }}
@@ -170,41 +131,52 @@ jobs:
170131
include:
171132
- name: macos
172133
os: macos-12
173-
rust-toolchain: stable
174134
godot-binary: godot.macos.editor.dev.x86_64
175-
with-llvm: true
176-
135+
177136
- name: macos-double
178137
os: macos-12
179-
rust-toolchain: stable
180138
godot-binary: godot.macos.editor.dev.double.x86_64
181139
rust-extra-args: --features double-precision
140+
141+
- name: macos-nightly
142+
os: macos-12
143+
artifact-name: macos
144+
godot-binary: godot.macos.editor.dev.x86_64
145+
rust-extra-args: --features godot/custom-godot
182146
with-llvm: true
183147

184148
- name: windows
185149
os: windows-latest
186-
rust-toolchain: stable-x86_64-pc-windows-msvc
187150
godot-binary: godot.windows.editor.dev.x86_64.exe
188151

189152
- name: windows-double
190153
os: windows-latest
191-
rust-toolchain: stable-x86_64-pc-windows-msvc
192154
godot-binary: godot.windows.editor.dev.double.x86_64.exe
193155
rust-extra-args: --features double-precision
194156

157+
- name: windows-nightly
158+
os: windows-latest
159+
artifact-name: windows
160+
godot-binary: godot.windows.editor.dev.x86_64.exe
161+
rust-extra-args: --features godot/custom-godot
162+
195163
# Don't use latest Ubuntu (22.04) as it breaks lots of ecosystem compatibility.
196164
# If ever moving to ubuntu-latest, need to manually install libtinfo5 for LLVM.
197165
- name: linux
198166
os: ubuntu-20.04
199-
rust-toolchain: stable
200167
godot-binary: godot.linuxbsd.editor.dev.x86_64
201168

202169
- name: linux-double
203170
os: ubuntu-20.04
204-
rust-toolchain: stable
205171
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
206172
rust-extra-args: --features double-precision
207173

174+
- name: linux-nightly
175+
os: ubuntu-20.04
176+
artifact-name: linux
177+
godot-binary: godot.linuxbsd.editor.dev.x86_64
178+
rust-extra-args: --features godot/custom-godot
179+
208180
# Special Godot binaries compiled with AddressSanitizer/LeakSanitizer to detect UB/leaks.
209181
# Additionally, the Godot source is patched to make dlclose() a no-op, as unloading dynamic libraries loses stacktrace and
210182
# cause false positives like println!. See https://github.com/google/sanitizers/issues/89.
@@ -231,13 +203,14 @@ jobs:
231203
- name: "Run Godot integration test"
232204
uses: ./.github/composite/godot-itest
233205
with:
234-
artifact-name: godot-${{ matrix.name }}
206+
artifact-name: godot-${{ matrix.artifact-name || matrix.name }}
235207
godot-binary: ${{ matrix.godot-binary }}
236208
godot-args: ${{ matrix.godot-args }}
237209
rust-extra-args: ${{ matrix.rust-extra-args }}
238-
rust-toolchain: ${{ matrix.rust-toolchain }}
210+
rust-toolchain: ${{ matrix.rust-toolchain || 'stable' }}
239211
rust-env-rustflags: ${{ matrix.rust-env-rustflags }}
240212
with-llvm: ${{ matrix.with-llvm }}
213+
godot-check-header: ${{ matrix.name == 'linux' }}
241214

242215

243216
license-guard:

.github/workflows/minimal-ci.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,40 +44,21 @@ jobs:
4444

4545

4646
clippy:
47-
name: clippy (${{ matrix.name }})
4847
runs-on: ubuntu-20.04
49-
strategy:
50-
fail-fast: false
51-
matrix:
52-
include:
53-
- name: linux
54-
rust-toolchain: stable
55-
godot-binary: godot.linuxbsd.editor.dev.x86_64
56-
57-
- name: linux-double
58-
rust-toolchain: stable
59-
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
60-
rust-extra-args: --features double-precision
6148
steps:
6249
- uses: actions/checkout@v3
6350

6451
- name: "Install Rust"
6552
uses: ./.github/composite/rust
66-
67-
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
68-
# Replaces also backspaces on Windows, since they cause problems in Bash
69-
- name: "Install Godot"
70-
uses: ./.github/composite/godot-install
7153
with:
72-
artifact-name: godot-${{ matrix.name }}
73-
godot-binary: ${{ matrix.godot-binary }}
54+
components: clippy
7455

7556
- name: "Check clippy"
7657
run: |
7758
cargo clippy --all-targets $GDEXT_FEATURES ${{ matrix.rust-extra-args }} -- \
7859
-D clippy::suspicious -D clippy::style -D clippy::complexity -D clippy::perf \
7960
-D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented -D warnings
80-
61+
8162
8263
unit-test:
8364
name: unit-test
@@ -88,12 +69,6 @@ jobs:
8869
- name: "Install Rust"
8970
uses: ./.github/composite/rust
9071

91-
- name: "Install Godot"
92-
uses: ./.github/composite/godot-install
93-
with:
94-
artifact-name: godot-linux
95-
godot-binary: godot.linuxbsd.editor.dev.x86_64
96-
9772
- name: "Compile tests"
9873
run: cargo test $GDEXT_FEATURES --no-run
9974

@@ -113,7 +88,6 @@ jobs:
11388
with:
11489
artifact-name: godot-linux
11590
godot-binary: godot.linuxbsd.editor.dev.x86_64
116-
#godot_ver: ${{ matrix.godot }}
11791

11892

11993
license-guard:

0 commit comments

Comments
 (0)