Search code examples
windowsrustbuildrust-cargodeno

cargo build is stuck on last binary


When running cargo build --verbose or cargo run --verbose, it compiles all the dependencies on a specific Rust project but gets stuck on the last file.

Output:

       Fresh unicode-ident v1.0.8
       Fresh proc-macro2 v1.0.56
       Fresh quote v1.0.27
       Fresh memchr v2.5.0
       Fresh syn v2.0.15
       Fresh aho-corasick v1.0.1
       Fresh serde_derive v1.0.163
       Fresh regex-syntax v0.7.1
       Fresh regex v1.8.1
       Fresh serde v1.0.163
       Fresh lazy_static v1.4.0
       Fresh itoa v1.0.6
       Fresh ryu v1.0.13
       Fresh Inflector v0.11.4
       Fresh windows_x86_64_msvc v0.48.0
       Fresh serde_json v1.0.96
       Fresh syn v1.0.109
       Fresh windows-targets v0.48.0
       Fresh deno_bindgen_macro v0.8.0
       Fresh windows v0.48.0
       Fresh deno_bindgen v0.8.0
   Compiling win_user_interaction v0.1.0 (C:\..\win_user_interaction)
     Running `rustc --crate-name win_user_interaction --edition=2021 src\lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=130 --crate-type cdylib --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=67ea228bc136237f --out-dir C:\...\win_user_interaction\target\debug\deps -C incremental=C:\...\win_user_interaction\target\debug\incremental -L dependency=C:\...\win_user_interaction\target\debug\deps --extern deno_bindgen=C:\...\win_user_interaction\target\debug\deps\libdeno_bindgen-1e5d169b6ae8380d.rlib --extern serde=C:\...\win_user_interaction\target\debug\deps\libserde-985b6777e5633ea0.rlib --extern windows=C:\...\win_user_interaction\target\debug\deps\libwindows-3a8b4eb173ae451b.rlib -L native=C:\...\.cargo\registry\src\github.com-1ecc6299db9ec823\windows_x86_64_msvc-0.48.0\lib`
    Building [=========================> ] 35/36: win_user_interaction

The project is just one file i.e.,

use deno_bindgen::deno_bindgen;

pub mod touch_injection {
    use windows::Win32::UI::Input::Pointer::{InitializeTouchInjection, TOUCH_FEEDBACK_MODE};

    #[deno_bindgen]
    pub enum TouchFeedbackMode {
        Default = 0x1,
        Indirect = 0x2,
        None = 0x3
    }

    #[deno_bindgen]
    pub fn initialize_touch_injection(max_count: u32, mode: TouchFeedbackMode) {
        unsafe {
            InitializeTouchInjection(max_count, TOUCH_FEEDBACK_MODE(mode as u32));
        }
    }
}
  • cargo --version: cargo 1.69.0 (6e9a83356 2023-04-12)

  • rustc --version: rustc 1.69.0 (84c898d65 2023-04-16)

  • rustup --version: rustup 1.26.0 (5af9b9484 2023-04-05)

  • rustup toolchain list: stable-x86_64-pc-windows-msvc (default)

Cargo.toml:

[package]
name = "win_user_interaction"
version = "0.1.0"
edition = "2021"

[lib]
name = "win_user_interaction"
crate-type = ["cdylib"]

[dependencies]
deno_bindgen = "0.8.0"
serde = { version = "1.0.163", features = ["derive"] }
windows = { version = "0.48.0", features = ["Win32_Foundation", "Win32_UI_Input_Pointer"] }

Possible solutions I tried but didn't work:

  • cargo clean
  • rustup update
  • creating a new rust project and copying in Cargo.toml + the contents of the

Solution

  • Apparently the problem was as mentioned by @Finomnis, I was importing deno_bindgen outside of the module.

    I am using IntelliJ Idea with Rust plugin and Cargo Check turned on but it didn't show the error and even rustc just stuck on it without showing any error.