Skip to content

Implementation of Plane integration tests #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c9d2955
Add ExportInfo struct
lilizoey Apr 22, 2023
072ad33
Parse gdextension_interface.h declarations using regex
Bromeon May 18, 2023
71d6c64
AsUninit trait to convert FFI pointers to their uninitialized versions
Bromeon May 19, 2023
4bf912e
GodotFfi::from_sys_init() now uses uninitialized pointer types
Bromeon May 19, 2023
59b04bc
Introduce GDExtensionUninitialized*Ptr, without changing semantics
Bromeon May 20, 2023
c7bcb9d
Adjust init code to new get_proc_address mechanism
Bromeon May 20, 2023
bdc05ae
Make `trace` feature available in godot-ffi, fix interface access bef…
Bromeon May 20, 2023
0925a64
Compatibility layer between Godot 4.0 and 4.1 (different GDExtension …
Bromeon May 21, 2023
926705a
Add GdextBuild to access build/runtime metadata
Bromeon May 22, 2023
d3097ea
Detect 4.0 <-> 4.1 mismatches in both directions + missing `compatibi…
Bromeon May 22, 2023
cdfae6f
Detect legacy/modern version of C header (also without `custom-godot`…
Bromeon May 22, 2023
887dcf4
CI: add jobs that use patched 4.0.x versions
Bromeon May 23, 2023
625e064
Remove several memory leaks by constructing into uninitialized pointers
Bromeon May 24, 2023
1307753
CI: memcheck jobs for both 4.0.3 and nightly
Bromeon May 24, 2023
d7cbeb9
Implement virtual methods that accept or return pointers (per #191)
Mercerenies May 14, 2023
1ea0f4f
Remove ToVariant, FromVariant, and VariantMetadata impls for pointers
Mercerenies May 15, 2023
3f5a4f0
Adds FromVariant and ToVariant proc macros
Apr 27, 2023
60f7c7a
godot-core: builtin: reimplement Plane functions/methods
T4rmyn May 9, 2023
26dc53d
impl GodotFfi for Option<T> when T is pointer sized and nullable #240
TitanNano Apr 27, 2023
ce44f03
itest: rust: src: Plane integration tests implementation
T4rmyn May 27, 2023
b116e75
godot-core: src: builtin: changed Plane function to be more accurate …
T4rmyn Jun 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions .github/composite/godot-itest/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ inputs:
default: 'false'
description: "Should the job check against latest gdextension_interface.h, and warn on difference"

godot-prebuilt-patch:
required: false
default: ''
description: "If specified, sets the branch name of the godot4-prebuilt crate to this value"

rust-toolchain:
required: false
default: 'stable'
Expand Down Expand Up @@ -71,14 +76,56 @@ runs:
rust: ${{ inputs.rust-toolchain }}
with-llvm: ${{ inputs.with-llvm }}

- name: "Patch prebuilt version ({{ inputs.godot-prebuilt-patch }})"
if: inputs.godot-prebuilt-patch != ''
env:
VERSION: ${{ inputs.godot-prebuilt-patch }}
# sed -i'' needed for macOS compatibility, see https://stackoverflow.com/q/4247068
run: |
echo "Patch prebuilt version to $VERSION..."

# For newer versions, update the compatibility_minimum in .gdextension files to 4.1
# Once a 4.1.0 is released, we can invert this and set compatibility_minimum to 4.0 for older versions.
if [[ "$VERSION" == "4.1" ]]; then
echo "Update compatibility_minimum in .gdextension files..."
dirs=("itest" "examples")
for dir in "${dirs[@]}"; do
find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' 's/compatibility_minimum = 4\.0/compatibility_minimum = 4.1/' {} +
done

# Versions 4.0.x
else
# Patch only needed if version is not already set
if grep -E 'godot4-prebuilt = { .+ branch = "$VERSION" }' godot-bindings/Cargo.toml; then
echo "Already has version $version; no need for patch."
else
cat << HEREDOC >> Cargo.toml
[patch."https://github.com/godot-rust/godot4-prebuilt"]
godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "$VERSION" }
HEREDOC
echo "Patched Cargo.toml for version $version."
fi
fi

shell: bash

# else
- name: "No patch selected"
if: inputs.godot-prebuilt-patch == ''
run: |
echo "No patch selected; use default godot4-prebuilt version."
shell: bash

- name: "Build gdext (itest)"
run: |
cargo build -p itest ${{ inputs.rust-extra-args }}
shell: bash
env:
RUSTFLAGS: ${{ inputs.rust-env-rustflags }}

# Note: no longer fails, as we expect header to be forward-compatible; instead issues a warning
# This step no longer fails if there's a diff, as we expect header to be forward-compatible; instead issues a warning
# However, still fails if patch cannot be applied (conflict).
# Step is only run in latest, not for compat 4.0.1 etc. -> no need to take into account different header versions.
- name: "Copy and compare GDExtension header"
if: inputs.godot-check-header == 'true'
run: |
Expand All @@ -96,7 +143,7 @@ runs:
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY
git diff --no-index gdextension_interface_prebuilt.h gdextension_interface.h >> $GITHUB_STEP_SUMMARY || true
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "After manually updating file, run: \`git diff -R > tweak.patch\`." >> $GITHUB_STEP_SUMMARY
echo "After manually updating file, run: \`git diff -R > tweak2.patch && mv tweak2.patch tweak.patch\`." >> $GITHUB_STEP_SUMMARY

# Undo modifications
mv gdextension_interface_prebuilt.h gdextension_interface.h
Expand Down
68 changes: 62 additions & 6 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,13 @@ jobs:
# Additionally, the 'linux (msrv *)' special case will then be listed next to the other 'linux' jobs.
# Note: Windows uses '--target x86_64-pc-windows-msvc' by default as Cargo argument.
include:
- name: macos
# macOS

- name: macos-4.0.3
os: macos-12
artifact-name: macos
godot-binary: godot.macos.editor.dev.x86_64
godot-prebuilt-patch: '4.0.3'

- name: macos-double
os: macos-12
Expand All @@ -142,10 +146,15 @@ jobs:
godot-binary: godot.macos.editor.dev.x86_64
rust-extra-args: --features godot/custom-godot
with-llvm: true
godot-prebuilt-patch: '4.1'

- name: windows
# Windows

- name: windows-4.0.3
os: windows-latest
artifact-name: windows
godot-binary: godot.windows.editor.dev.x86_64.exe
godot-prebuilt-patch: '4.0.3'

- name: windows-double
os: windows-latest
Expand All @@ -157,12 +166,35 @@ jobs:
artifact-name: windows
godot-binary: godot.windows.editor.dev.x86_64.exe
rust-extra-args: --features godot/custom-godot
godot-prebuilt-patch: '4.1'

# Linux

# Don't use latest Ubuntu (22.04) as it breaks lots of ecosystem compatibility.
# If ever moving to ubuntu-latest, need to manually install libtinfo5 for LLVM.
- name: linux
- name: linux-4.0.3
os: ubuntu-20.04
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
godot-check-header: false # disabled for now

- name: linux-4.0.2
os: ubuntu-20.04
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
godot-prebuilt-patch: '4.0.2'

- name: linux-4.0.1
os: ubuntu-20.04
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
godot-prebuilt-patch: '4.0.1'

- name: linux-4.0
os: ubuntu-20.04
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
godot-prebuilt-patch: '4.0'

- name: linux-double
os: ubuntu-20.04
Expand All @@ -180,27 +212,50 @@ jobs:
artifact-name: linux
godot-binary: godot.linuxbsd.editor.dev.x86_64
rust-extra-args: --features godot/custom-godot
godot-prebuilt-patch: '4.1'

# Special Godot binaries compiled with AddressSanitizer/LeakSanitizer to detect UB/leaks.
# Additionally, the Godot source is patched to make dlclose() a no-op, as unloading dynamic libraries loses stacktrace and
# cause false positives like println!. See https://github.com/google/sanitizers/issues/89.
# The gcc version can possibly be removed later, as it is slower and needs a larger artifact than the clang one.

# --disallow-focus: fail if #[itest(focus)] is encountered, to prevent running only a few tests for full CI
- name: linux-memcheck-gcc
- name: linux-memcheck-gcc-4.0.3
os: ubuntu-20.04
artifact-name: linux-memcheck-gcc
godot-binary: godot.linuxbsd.editor.dev.x86_64.san
godot-args: -- --disallow-focus
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout

- name: linux-memcheck-clang
- name: linux-memcheck-clang-4.0.3
os: ubuntu-20.04
artifact-name: linux-memcheck-clang
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
godot-args: -- --disallow-focus
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout

- name: linux-memcheck-gcc-nightly
os: ubuntu-20.04
artifact-name: linux-memcheck-gcc
godot-binary: godot.linuxbsd.editor.dev.x86_64.san
godot-args: -- --disallow-focus
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout
rust-extra-args: --features godot/custom-godot
godot-prebuilt-patch: '4.1'

- name: linux-memcheck-clang-nightly
os: ubuntu-20.04
artifact-name: linux-memcheck-clang
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
godot-args: -- --disallow-focus
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout
rust-extra-args: --features godot/custom-godot
godot-prebuilt-patch: '4.1'


steps:
- uses: actions/checkout@v3
Expand All @@ -211,11 +266,12 @@ jobs:
artifact-name: godot-${{ matrix.artifact-name || matrix.name }}
godot-binary: ${{ matrix.godot-binary }}
godot-args: ${{ matrix.godot-args }}
godot-prebuilt-patch: ${{ matrix.godot-prebuilt-patch }}
rust-extra-args: ${{ matrix.rust-extra-args }}
rust-toolchain: ${{ matrix.rust-toolchain || 'stable' }}
rust-env-rustflags: ${{ matrix.rust-env-rustflags }}
with-llvm: ${{ matrix.with-llvm }}
godot-check-header: ${{ matrix.name == 'linux' }}
godot-check-header: ${{ matrix.godot-check-header }}


license-guard:
Expand Down
1 change: 1 addition & 0 deletions examples/dodge-the-creeps/godot/DodgeTheCreeps.gdextension
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[configuration]
entry_symbol = "gdext_rust_init"
compatibility_minimum = 4.0

[libraries]
linux.debug.x86_64 = "res://../../../target/debug/libdodge_the_creeps.so"
Expand Down
2 changes: 1 addition & 1 deletion godot-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ custom-godot = ["dep:bindgen", "dep:regex", "dep:which"]
custom-godot-extheader = []

[dependencies]
godot4-prebuilt = { optional = true, git = "https://github.com/godot-rust/godot4-prebuilt", branch = "4.0.1" }
godot4-prebuilt = { optional = true, git = "https://github.com/godot-rust/godot4-prebuilt", branch = "4.0.3" }

# 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
41 changes: 33 additions & 8 deletions godot-bindings/res/tweak.patch
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
diff --git b/godot-ffi/src/gen/gdextension_interface.h a/godot-ffi/src/gen/gdextension_interface.h
index 0b7615f..6db266e 100644
index 4e4f300..e1cd5fb 100644
--- b/godot-ffi/src/gen/gdextension_interface.h
+++ a/godot-ffi/src/gen/gdextension_interface.h
@@ -139,22 +139,22 @@ typedef enum {

} GDExtensionVariantOperator;
@@ -155,27 +155,27 @@ typedef enum {
// - Some types have no destructor (see `extension_api.json`'s `has_destructor` field), for
// them it is always safe to skip the constructor for the return value if you are in a hurry ;-)

-typedef void *GDExtensionVariantPtr;
-typedef const void *GDExtensionConstVariantPtr;
-typedef void *GDExtensionUninitializedVariantPtr;
-typedef void *GDExtensionStringNamePtr;
-typedef const void *GDExtensionConstStringNamePtr;
-typedef void *GDExtensionUninitializedStringNamePtr;
-typedef void *GDExtensionStringPtr;
-typedef const void *GDExtensionConstStringPtr;
-typedef void *GDExtensionUninitializedStringPtr;
-typedef void *GDExtensionObjectPtr;
-typedef const void *GDExtensionConstObjectPtr;
-typedef void *GDExtensionUninitializedObjectPtr;
-typedef void *GDExtensionTypePtr;
-typedef const void *GDExtensionConstTypePtr;
-typedef void *GDExtensionUninitializedTypePtr;
-typedef const void *GDExtensionMethodBindPtr;
+typedef struct __GdextVariant *GDExtensionVariantPtr;
+typedef const struct __GdextVariant *GDExtensionConstVariantPtr;
+typedef struct __GdextUninitializedVariant *GDExtensionUninitializedVariantPtr;
+typedef struct __GdextStringName *GDExtensionStringNamePtr;
+typedef const struct __GdextStringName *GDExtensionConstStringNamePtr;
+typedef struct __GdextUninitializedStringName *GDExtensionUninitializedStringNamePtr;
+typedef struct __GdextString *GDExtensionStringPtr;
+typedef const struct __GdextString *GDExtensionConstStringPtr;
+typedef struct __GdextUninitializedString *GDExtensionUninitializedStringPtr;
+typedef struct __GdextObject *GDExtensionObjectPtr;
+typedef const struct __GdextObject *GDExtensionConstObjectPtr;
+typedef struct __GdextUninitializedObject *GDExtensionUninitializedObjectPtr;
+typedef struct __GdextType *GDExtensionTypePtr;
+typedef const struct __GdextType *GDExtensionConstTypePtr;
+typedef struct __GdextUninitializedType *GDExtensionUninitializedTypePtr;
+typedef const struct __GdextMethodBind *GDExtensionMethodBindPtr;
typedef int64_t GDExtensionInt;
typedef uint8_t GDExtensionBool;
Expand All @@ -38,7 +48,22 @@ index 0b7615f..6db266e 100644

/* VARIANT DATA I/O */

@@ -203,7 +203,7 @@ typedef struct {
@@ -195,11 +195,11 @@ typedef struct {
int32_t expected;
} GDExtensionCallError;

-typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionVariantPtr, GDExtensionTypePtr);
-typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionTypePtr, GDExtensionVariantPtr);
+typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionUninitializedVariantPtr, GDExtensionTypePtr);
+typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionUninitializedTypePtr, GDExtensionVariantPtr);
typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
-typedef void (*GDExtensionPtrConstructor)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args);
+typedef void (*GDExtensionPtrConstructor)(GDExtensionUninitializedTypePtr p_base, const GDExtensionConstTypePtr *p_args);
typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
@@ -224,7 +224,7 @@ typedef struct {

/* EXTENSION CLASSES */

Expand All @@ -47,7 +72,7 @@ index 0b7615f..6db266e 100644

typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
@@ -266,7 +266,7 @@ typedef struct {
@@ -287,7 +287,7 @@ typedef struct {
void *class_userdata; // Per-class user data, later accessible in instance bindings.
} GDExtensionClassCreationInfo;

Expand All @@ -56,7 +81,7 @@ index 0b7615f..6db266e 100644

/* Method */

@@ -323,7 +323,7 @@ typedef struct {
@@ -345,7 +345,7 @@ typedef struct {

/* SCRIPT INSTANCE EXTENSION */

Expand All @@ -65,7 +90,7 @@ index 0b7615f..6db266e 100644

typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
@@ -353,13 +353,13 @@ typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtens
@@ -375,13 +375,13 @@ typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtens
typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);

Expand Down
Loading