Skip to content

Commit

Permalink
Merge branch 'master' into astolfo-feature/builtin-vector
Browse files Browse the repository at this point in the history
  • Loading branch information
RealAstolfo authored Jan 27, 2023
2 parents 5601237 + c37d0ce commit 78fde06
Show file tree
Hide file tree
Showing 74 changed files with 3,444 additions and 1,053 deletions.
21 changes: 18 additions & 3 deletions .github/composite/godot/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ runs:
run: |
cd itest/godot
echo "OUTCOME=itest" >> $GITHUB_ENV
$GODOT4_BIN --headless 2>&1 | tee >(grep "SCRIPT ERROR:" -q && {
$GODOT4_BIN --headless 2>&1 | tee "${{ runner.temp }}/log.txt" | tee >(grep "SCRIPT ERROR:" -q && {
printf "\n -- Godot engine encountered error, abort...\n";
pkill godot
echo "OUTCOME=godot-runtime" >> $GITHUB_ENV
Expand All @@ -119,6 +119,14 @@ runs:
echo "OUTCOME=success" >> $GITHUB_ENV
shell: bash

- name: "Check for memory leaks"
run: |
if grep -q "ObjectDB instances leaked at exit" "${{ runner.temp }}/log.txt"; then
echo "OUTCOME=godot-leak" >> $GITHUB_ENV
exit 2
fi
shell: bash

- name: "Conclusion"
if: always()
run: |
Expand All @@ -137,10 +145,17 @@ runs:
exit 2
;;
"godot-leak")
echo "### :x: Memory leak" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
echo "Integration tests cause memory leaks." >> $GITHUB_STEP_SUMMARY
exit 3
;;
"itest")
echo "### :x: Godot integration tests failed" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
exit 3
exit 4
;;
"header-diff")
Expand All @@ -150,7 +165,7 @@ runs:
*)
echo "### :x: Unknown error occurred" > $GITHUB_STEP_SUMMARY
echo "$GODOT_BUILT_FROM" >> $GITHUB_STEP_SUMMARY
exit 4
exit 5
;;
esac
shell: bash
48 changes: 46 additions & 2 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,54 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust
with:
rust: stable
components: rustfmt

- name: "Check rustfmt"
run: cargo fmt --all -- --check


clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust

# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Store variable to Godot binary"
run: |
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
echo "GODOT4_BIN=$runnerDir/godot_bin/godot.linuxbsd.editor.dev.x86_64" >> $GITHUB_ENV
# - name: "Check cache for installed Godot version"
# id: "cache-godot"
# uses: actions/cache@v3
# with:
# path: ${{ runner.temp }}/godot_bin
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}

- name: "Download Godot artifact"
# if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/godot-linux.zip -Lo artifact.zip
unzip artifact.zip -d $RUNNER_DIR/godot_bin
- name: "Prepare Godot executable"
run: |
chmod +x $GODOT4_BIN
- name: "Check clippy"
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


unit-test:
name: unit-test (${{ matrix.name }})
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -95,10 +134,14 @@ jobs:
if: matrix.name == 'macos'

- name: "Compile tests"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES --no-run
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES --no-run
env:
RUSTFLAGS: --cfg=gdext_test

- name: "Test"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES ${{ matrix.testflags }}
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES
env:
RUSTFLAGS: --cfg=gdext_test


itest-godot:
Expand Down Expand Up @@ -161,6 +204,7 @@ jobs:
if: github.event_name == 'push' && success()
needs:
- rustfmt
- clippy
- unit-test
- itest-godot
- license-guard
Expand Down
51 changes: 45 additions & 6 deletions .github/workflows/minimal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,54 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust
with:
rust: stable
components: rustfmt

- name: "Check rustfmt"
run: cargo fmt --all -- --check


clippy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3

- name: "Install Rust"
uses: ./.github/composite/rust

# TODO get rid of Godot binary, once the JSON is either versioned or fetched from somewhere
# Replaces also backspaces on Windows, since they cause problems in Bash
- name: "Store variable to Godot binary"
run: |
runnerDir=$(echo "${{ runner.temp }}" | sed "s!\\\\!/!")
echo "RUNNER_DIR=$runnerDir" >> $GITHUB_ENV
echo "GODOT4_BIN=$runnerDir/godot_bin/godot.linuxbsd.editor.dev.x86_64" >> $GITHUB_ENV
# - name: "Check cache for installed Godot version"
# id: "cache-godot"
# uses: actions/cache@v3
# with:
# path: ${{ runner.temp }}/godot_bin
# key: ${{ inputs.artifact-name }}-v${{ inputs.godot-ver }}

- name: "Download Godot artifact"
# if: steps.cache-godot.outputs.cache-hit != 'true'
run: |
curl https://nightly.link/Bromeon/godot4-nightly/workflows/compile-godot/master/godot-linux.zip -Lo artifact.zip
unzip artifact.zip -d $RUNNER_DIR/godot_bin
- name: "Prepare Godot executable"
run: |
chmod +x $GODOT4_BIN
- name: "Check clippy"
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


unit-test:
name: unit-test
runs-on: ubuntu-20.04
Expand All @@ -49,15 +88,15 @@ jobs:
- name: "Install Rust"
uses: ./.github/composite/rust

- name: "Install LLVM"
uses: ./.github/composite/llvm
if: matrix.name == 'macos'

- name: "Compile tests"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES --no-run
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES --no-run
env:
RUSTFLAGS: --cfg=gdext_test

- name: "Test"
run: cargo test $GDEXT_CRATE_ARGS --features unit-test,$GDEXT_FEATURES ${{ matrix.testflags }}
run: cargo test $GDEXT_CRATE_ARGS --features $GDEXT_FEATURES
env:
RUSTFLAGS: --cfg=gdext_test


itest-godot:
Expand Down
3 changes: 3 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ In your Cargo.toml, add:
```toml
[dependencies]
godot = { git = "https://github.com/godot-rust/gdextension", branch = "master" }

[lib]
crate-type = ["cdylib"]
```
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.

Expand Down
10 changes: 5 additions & 5 deletions examples/dodge-the-creeps/rust/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl GodotExt for Player {
.base
.get_node_as::<AnimatedSprite2D>("AnimatedSprite2D");

let mut velocity = Vector2::new(0.0, 0.0).inner();
let mut velocity = Vector2::new(0.0, 0.0);

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

if velocity.length() > 0.0 {
velocity = velocity.normalize() * self.speed;
velocity = velocity.normalized() * self.speed;

let animation;

Expand All @@ -101,10 +101,10 @@ impl GodotExt for Player {
}

let change = velocity * delta as f32;
let position = self.base.get_global_position().inner() + change;
let position = self.base.get_global_position() + change;
let position = Vector2::new(
position.x.max(0.0).min(self.screen_size.inner().x),
position.y.max(0.0).min(self.screen_size.inner().y),
position.x.max(0.0).min(self.screen_size.x),
position.y.max(0.0).min(self.screen_size.y),
);
self.base.set_global_position(position);
}
Expand Down
2 changes: 1 addition & 1 deletion godot-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ codegen-full = []
quote = "1"
proc-macro2 = "1"
which = "4"
#heck = "0.4"
heck = "0.4"

# Version >= 1.5.5 for security: https://blog.rust-lang.org/2022/03/08/cve-2022-24713.html
# 'unicode-gencat' needed for \d, see: https://docs.rs/regex/1.5.5/regex/#unicode-features
Expand Down
78 changes: 49 additions & 29 deletions godot-codegen/input/gdextension_interface.h
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/*************************************************************************/
/* gdextension_interface.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
/**************************************************************************/
/* gdextension_interface.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef GDEXTENSION_INTERFACE_H
#define GDEXTENSION_INTERFACE_H
Expand Down Expand Up @@ -503,6 +503,26 @@ typedef struct {
char32_t *(*string_operator_index)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
const char32_t *(*string_operator_index_const)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);

void (*string_operator_plus_eq_string)(GDExtensionStringPtr p_self, GDExtensionConstStringPtr p_b);
void (*string_operator_plus_eq_char)(GDExtensionStringPtr p_self, char32_t p_b);
void (*string_operator_plus_eq_cstr)(GDExtensionStringPtr p_self, const char *p_b);
void (*string_operator_plus_eq_wcstr)(GDExtensionStringPtr p_self, const wchar_t *p_b);
void (*string_operator_plus_eq_c32str)(GDExtensionStringPtr p_self, const char32_t *p_b);

/* XMLParser extra utilities */

GDExtensionInt (*xml_parser_open_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_buffer, size_t p_size);

/* FileAccess extra utilities */

void (*file_access_store_buffer)(GDExtensionObjectPtr p_instance, const uint8_t *p_src, uint64_t p_length);
uint64_t (*file_access_get_buffer)(GDExtensionConstObjectPtr p_instance, uint8_t *p_dst, uint64_t p_length);

/* WorkerThreadPool extra utilities */

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);
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);

/* Packed array functions */

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

0 comments on commit 78fde06

Please sign in to comment.