Skip to content
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

Fix: import gdnative prelude in lib.rs template #20

Closed
wants to merge 1 commit into from

Conversation

aclave1
Copy link

@aclave1 aclave1 commented Oct 30, 2022

The default lib.rs template has a compiler error with newer versions of the gdnative library. Importing the Variant type is now required to run the godot_init macro. I decided to include the prelude instead of just importing Variant to hopefully prevent these API changes from breaking things in future versions.

Test Plan:

ftw new test
cd test
ftw build

Error Output:

error[E0433]: failed to resolve: use of undeclared type `Variant`
  --> rust\src\lib.rs:13:1
   |
13 | godot_init!(init);
   | ^^^^^^^^^^^^^^^^^ not found in this scope
   |
   = note: this error originates in the macro `$crate::godot_nativescript_init` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this struct
   |
4  | use gdnative::core_types::Variant;
   |

For more information about this error, try `rustc --explain E0433`.
error: could not compile `example` due to 2 previous errors
 ERROR: The system cannot find the file specified. (os error 2)
Error: ()

lib.rs

mod game;
mod spinning_cube;

use gdnative::prelude::{godot_init, InitHandle};

// Function that registers all exposed classes to Godot
fn init(handle: InitHandle) {
    handle.add_class::<game::Game>();
    handle.add_class::<spinning_cube::SpinningCube>();
}

// macros that create the entry-points of the dynamic library.
godot_init!(init);


@macalimlim
Copy link
Owner

Hi @aclave1,

Thank you for filing this issue, may I know what target, rust version, ftw version and the operating system you are running ftw on? Based on my initial test, I seem to don't get the error that you are getting. Please see screenshot below.

2022-10-31-21:29:14

I'm on NixOS, x86_64-unknown-linux-gnu target, rust v1.64.0 and ftw v0.10.0

Mike

@aclave1
Copy link
Author

aclave1 commented Nov 2, 2022

I'm on windows 11, target is x86_64-pc-windows-msvc, rust 1.63.0, ftw 0.10.0. One thing I see from your logs is the usage of gdnative v0.11.0. The version of gdnative that mine is using is 0.10.1. This is a project generated by ftw new. Maybe my local copy of godot-rust-template is cached?

edit: I haven't verified yet, but godot-rust/gdnative#954 mentions this issue. We can probably close this issue, sorry! I need to figure out how to update the template that ftw is using.

@aclave1 aclave1 closed this Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants