Skip to content

Commit 78fde06

Browse files
author
RealAstolfo
authored
Merge branch 'master' into astolfo-feature/builtin-vector
2 parents 5601237 + c37d0ce commit 78fde06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3444
-1053
lines changed

.github/composite/godot/action.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ runs:
109109
run: |
110110
cd itest/godot
111111
echo "OUTCOME=itest" >> $GITHUB_ENV
112-
$GODOT4_BIN --headless 2>&1 | tee >(grep "SCRIPT ERROR:" -q && {
112+
$GODOT4_BIN --headless 2>&1 | tee "${{ runner.temp }}/log.txt" | tee >(grep "SCRIPT ERROR:" -q && {
113113
printf "\n -- Godot engine encountered error, abort...\n";
114114
pkill godot
115115
echo "OUTCOME=godot-runtime" >> $GITHUB_ENV
@@ -119,6 +119,14 @@ runs:
119119
echo "OUTCOME=success" >> $GITHUB_ENV
120120
shell: bash
121121

122+
- name: "Check for memory leaks"
123+
run: |
124+
if grep -q "ObjectDB instances leaked at exit" "${{ runner.temp }}/log.txt"; then
125+
echo "OUTCOME=godot-leak" >> $GITHUB_ENV
126+
exit 2
127+
fi
128+
shell: bash
129+
122130
- name: "Conclusion"
123131
if: always()
124132
run: |
@@ -137,10 +145,17 @@ runs:
137145
exit 2
138146
;;
139147
148+
"godot-leak")
149+
echo "### :x: Memory leak" > $GITHUB_STEP_SUMMARY
150+
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
151+
echo "Integration tests cause memory leaks." >> $GITHUB_STEP_SUMMARY
152+
exit 3
153+
;;
154+
140155
"itest")
141156
echo "### :x: Godot integration tests failed" > $GITHUB_STEP_SUMMARY
142157
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
143-
exit 3
158+
exit 4
144159
;;
145160
146161
"header-diff")
@@ -150,7 +165,7 @@ runs:
150165
*)
151166
echo "### :x: Unknown error occurred" > $GITHUB_STEP_SUMMARY
152167
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
153-
exit 4
168+
exit 5
154169
;;
155170
esac
156171
shell: bash

.github/workflows/full-ci.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,54 @@ jobs:
3131
runs-on: ubuntu-20.04
3232
steps:
3333
- uses: actions/checkout@v3
34+
3435
- name: "Install Rust"
3536
uses: ./.github/composite/rust
3637
with:
3738
rust: stable
3839
components: rustfmt
40+
3941
- name: "Check rustfmt"
4042
run: cargo fmt --all -- --check
4143

4244

45+
clippy:
46+
runs-on: ubuntu-20.04
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- name: "Install Rust"
51+
uses: ./.github/composite/rust
52+
53+
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
54+
# Replaces also backspaces on Windows, since they cause problems in Bash
55+
- name: "Store variable to Godot binary"
56+
run: |
57+
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
58+
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
59+
echo "GODOT4_BIN=$runnerDir/godot_bin/godot.linuxbsd.editor.dev.x86_64" >> $GITHUB_ENV
60+
61+
# - name: "Check cache for installed Godot version"
62+
# id: "cache-godot"
63+
# uses: actions/cache@v3
64+
# with:
65+
# path: ${{ runner.temp }}/godot_bin
66+
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}
67+
68+
- name: "Download Godot artifact"
69+
# if: steps.cache-godot.outputs.cache-hit != 'true'
70+
run: |
71+
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/godot-linux.zip -Lo artifact.zip
72+
unzip artifact.zip -d $RUNNER_DIR/godot_bin
73+
74+
- name: "Prepare Godot executable"
75+
run: |
76+
chmod +x $GODOT4_BIN
77+
78+
- name: "Check clippy"
79+
run: cargo clippy --features $GDEXT_FEATURES $GDEXT_CRATE_ARGS -- --cfg gdext_clippy -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
80+
81+
4382
unit-test:
4483
name: unit-test (${{ matrix.name }})
4584
runs-on: ${{ matrix.os }}
@@ -95,10 +134,14 @@ jobs:
95134
if: matrix.name == 'macos'
96135

97136
- name: "Compile tests"
98-
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES --no-run
137+
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES --no-run
138+
env:
139+
RUSTFLAGS: --cfg=gdext_test
99140

100141
- name: "Test"
101-
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES ${{ matrix.testflags }}
142+
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES
143+
env:
144+
RUSTFLAGS: --cfg=gdext_test
102145

103146

104147
itest-godot:
@@ -161,6 +204,7 @@ jobs:
161204
if: github.event_name == 'push' && success()
162205
needs:
163206
- rustfmt
207+
- clippy
164208
- unit-test
165209
- itest-godot
166210
- license-guard

.github/workflows/minimal-ci.yml

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,54 @@ jobs:
3131
runs-on: ubuntu-20.04
3232
steps:
3333
- uses: actions/checkout@v3
34+
3435
- name: "Install Rust"
3536
uses: ./.github/composite/rust
3637
with:
3738
rust: stable
3839
components: rustfmt
40+
3941
- name: "Check rustfmt"
4042
run: cargo fmt --all -- --check
4143

4244

45+
clippy:
46+
runs-on: ubuntu-20.04
47+
steps:
48+
- uses: actions/checkout@v3
49+
50+
- name: "Install Rust"
51+
uses: ./.github/composite/rust
52+
53+
# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
54+
# Replaces also backspaces on Windows, since they cause problems in Bash
55+
- name: "Store variable to Godot binary"
56+
run: |
57+
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
58+
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
59+
echo "GODOT4_BIN=$runnerDir/godot_bin/godot.linuxbsd.editor.dev.x86_64" >> $GITHUB_ENV
60+
61+
# - name: "Check cache for installed Godot version"
62+
# id: "cache-godot"
63+
# uses: actions/cache@v3
64+
# with:
65+
# path: ${{ runner.temp }}/godot_bin
66+
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}
67+
68+
- name: "Download Godot artifact"
69+
# if: steps.cache-godot.outputs.cache-hit != 'true'
70+
run: |
71+
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/godot-linux.zip -Lo artifact.zip
72+
unzip artifact.zip -d $RUNNER_DIR/godot_bin
73+
74+
- name: "Prepare Godot executable"
75+
run: |
76+
chmod +x $GODOT4_BIN
77+
78+
- name: "Check clippy"
79+
run: cargo clippy --features $GDEXT_FEATURES $GDEXT_CRATE_ARGS -- --cfg gdext_clippy -D clippy::style -D clippy::complexity -D clippy::perf -D clippy::dbg_macro -D clippy::todo -D clippy::unimplemented
80+
81+
4382
unit-test:
4483
name: unit-test
4584
runs-on: ubuntu-20.04
@@ -49,15 +88,15 @@ jobs:
4988
- name: "Install Rust"
5089
uses: ./.github/composite/rust
5190

52-
- name: "Install LLVM"
53-
uses: ./.github/composite/llvm
54-
if: matrix.name == 'macos'
55-
5691
- name: "Compile tests"
57-
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES --no-run
92+
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES --no-run
93+
env:
94+
RUSTFLAGS: --cfg=gdext_test
5895

5996
- name: "Test"
60-
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES ${{ matrix.testflags }}
97+
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES
98+
env:
99+
RUSTFLAGS: --cfg=gdext_test
61100

62101

63102
itest-godot:

ReadMe.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ In your Cargo.toml, add:
4141
```toml
4242
[dependencies]
4343
godot = { git = "https://github.com/godot-rust/gdextension", branch = "master" }
44+
45+
[lib]
46+
crate-type = ["cdylib"]
4447
```
4548
To get the latest changes, you can regularly run a `cargo update` (possibly breaking). Keep your `Cargo.lock` file under version control, so that it's easy to revert updates.
4649

examples/dodge-the-creeps/rust/src/player.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl GodotExt for Player {
6262
.base
6363
.get_node_as::<AnimatedSprite2D>("AnimatedSprite2D");
6464

65-
let mut velocity = Vector2::new(0.0, 0.0).inner();
65+
let mut velocity = Vector2::new(0.0, 0.0);
6666

6767
// Note: exact=false by default, in Rust we have to provide it explicitly
6868
let input = Input::singleton();
@@ -80,7 +80,7 @@ impl GodotExt for Player {
8080
}
8181

8282
if velocity.length() > 0.0 {
83-
velocity = velocity.normalize() * self.speed;
83+
velocity = velocity.normalized() * self.speed;
8484

8585
let animation;
8686

@@ -101,10 +101,10 @@ impl GodotExt for Player {
101101
}
102102

103103
let change = velocity * delta as f32;
104-
let position = self.base.get_global_position().inner() + change;
104+
let position = self.base.get_global_position() + change;
105105
let position = Vector2::new(
106-
position.x.max(0.0).min(self.screen_size.inner().x),
107-
position.y.max(0.0).min(self.screen_size.inner().y),
106+
position.x.max(0.0).min(self.screen_size.x),
107+
position.y.max(0.0).min(self.screen_size.y),
108108
);
109109
self.base.set_global_position(position);
110110
}

godot-codegen/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ codegen-full = []
1515
quote = "1"
1616
proc-macro2 = "1"
1717
which = "4"
18-
#heck = "0.4"
18+
heck = "0.4"
1919

2020
# Version >= 1.5.5 for security: https://blog.rust-lang.org/2022/03/08/cve-2022-24713.html
2121
# 'unicode-gencat' needed for \d, see: https://docs.rs/regex/1.5.5/regex/#unicode-features

godot-codegen/input/gdextension_interface.h

Lines changed: 49 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
/*************************************************************************/
2-
/* gdextension_interface.h */
3-
/*************************************************************************/
4-
/* This file is part of: */
5-
/* GODOT ENGINE */
6-
/* https://godotengine.org */
7-
/*************************************************************************/
8-
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
9-
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
10-
/* */
11-
/* Permission is hereby granted, free of charge, to any person obtaining */
12-
/* a copy of this software and associated documentation files (the */
13-
/* "Software"), to deal in the Software without restriction, including */
14-
/* without limitation the rights to use, copy, modify, merge, publish, */
15-
/* distribute, sublicense, and/or sell copies of the Software, and to */
16-
/* permit persons to whom the Software is furnished to do so, subject to */
17-
/* the following conditions: */
18-
/* */
19-
/* The above copyright notice and this permission notice shall be */
20-
/* included in all copies or substantial portions of the Software. */
21-
/* */
22-
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23-
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24-
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
25-
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26-
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27-
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28-
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29-
/*************************************************************************/
1+
/**************************************************************************/
2+
/* gdextension_interface.h */
3+
/**************************************************************************/
4+
/* This file is part of: */
5+
/* GODOT ENGINE */
6+
/* https://godotengine.org */
7+
/**************************************************************************/
8+
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9+
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10+
/* */
11+
/* Permission is hereby granted, free of charge, to any person obtaining */
12+
/* a copy of this software and associated documentation files (the */
13+
/* "Software"), to deal in the Software without restriction, including */
14+
/* without limitation the rights to use, copy, modify, merge, publish, */
15+
/* distribute, sublicense, and/or sell copies of the Software, and to */
16+
/* permit persons to whom the Software is furnished to do so, subject to */
17+
/* the following conditions: */
18+
/* */
19+
/* The above copyright notice and this permission notice shall be */
20+
/* included in all copies or substantial portions of the Software. */
21+
/* */
22+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23+
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24+
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25+
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26+
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27+
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28+
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29+
/**************************************************************************/
3030

3131
#ifndef GDEXTENSION_INTERFACE_H
3232
#define GDEXTENSION_INTERFACE_H
@@ -503,6 +503,26 @@ typedef struct {
503503
char32_t *(*string_operator_index)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
504504
const char32_t *(*string_operator_index_const)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
505505

506+
void (*string_operator_plus_eq_string)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
507+
void (*string_operator_plus_eq_char)(GDExtensionStringPtr p_self, char32_t p_b);
508+
void (*string_operator_plus_eq_cstr)(GDExtensionStringPtr p_self, const char *p_b);
509+
void (*string_operator_plus_eq_wcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
510+
void (*string_operator_plus_eq_c32str)(GDExtensionStringPtr p_self, const char32_t *p_b);
511+
512+
/* XMLParser extra utilities */
513+
514+
GDExtensionInt (*xml_parser_open_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);
515+
516+
/* FileAccess extra utilities */
517+
518+
void (*file_access_store_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
519+
uint64_t (*file_access_get_buffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);
520+
521+
/* WorkerThreadPool extra utilities */
522+
523+
int64_t (*worker_thread_pool_add_native_group_task)(GDExtensionObjectPtr p_instance, void (*p_func)(void *, uint32_t), void *p_userdata, int p_elements, int p_tasks, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
524+
int64_t (*worker_thread_pool_add_native_task)(GDExtensionObjectPtr p_instance, void (*p_func)(void *), void *p_userdata, GDExtensionBool p_high_priority, GDExtensionConstStringPtr p_description);
525+
506526
/* Packed array functions */
507527

508528
uint8_t *(*packed_byte_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray

0 commit comments

Comments
 (0)