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

How to generate a WASM build? #102

Open
VikramTiwari opened this issue Dec 4, 2020 · 9 comments
Open

How to generate a WASM build? #102

VikramTiwari opened this issue Dec 4, 2020 · 9 comments
Labels

Comments

@VikramTiwari
Copy link

Describe your Question
I am trying to generate a WASM build for the project, but I am running into some issues.

Describe your Goal
I am using cargo to build a WASM build for the project that I aim to use with a node.js project. To achieve this, I am doing following:

  • Edit Cargo.toml file and add following
[lib]
crate-type = ["cdylib"]
  • Build using cargo build --target wasm32-unknown-unknown --release --verbose

I get following error:

$ cargo build --target wasm32-unknown-unknown --release --verbose
       Fresh pkg-config v0.3.19
   Compiling enigo v0.0.14 (/Users/vikramtiwari/Documents/code/vikram/test/enigo)
     Running `rustc --crate-name enigo --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=0773f0cf9d704118 --out-dir /Users/vikramtiwari/Documents/code/vikram/test/enigo/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/Users/vikramtiwari/Documents/code/vikram/test/enigo/target/wasm32-unknown-unknown/release/deps -L dependency=/Users/vikramtiwari/Documents/code/vikram/test/enigo/target/release/deps`
error[E0412]: cannot find type `Enigo` in this scope
   --> src/lib.rs:380:6
    |
380 | impl Enigo {
    |      ^^^^^ not found in this scope

error[E0412]: cannot find type `Enigo` in this scope
   --> src/lib.rs:396:21
    |
396 | impl fmt::Debug for Enigo {
    |                     ^^^^^ not found in this scope

warning: use of deprecated associated function `std::error::Error::description`: use the Display impl or to_string()
  --> src/dsl.rs:40:26
   |
40 |         f.write_str(self.description())
   |                          ^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default

error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0412`.
error: could not compile `enigo`

Caused by:
  process didn't exit successfully: `rustc --crate-name enigo --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=0773f0cf9d704118 --out-dir /Users/vikramtiwari/Documents/code/vikram/test/enigo/target/wasm32-unknown-unknown/release/deps --target wasm32-unknown-unknown -L dependency=/Users/vikramtiwari/Documents/code/vikram/test/enigo/target/wasm32-unknown-unknown/release/deps -L dependency=/Users/vikramtiwari/Documents/code/vikram/test/enigo/target/release/deps` (exit code: 1)

I am sure I am missing something basic but I don't have any experience in Rust and thus the question. Any pointers would be helpful. Thanks!

Environment (please complete the following information):

  • OS: MacOSX 10.15.7
  • Rust: rustc 1.48.0
  • Library Version: Current master: 5bb84e9
@pythoneer
Copy link
Member

Hi and thanks for opening the issue. Unfortunately i don't think the ultimate goal you're trying to achieve by compiling it to a WASM target is achievable. Enigo is very dependent on the platform it is targeting/running on because it needs to invoke specific system functionality that is not present in WASM AFAIK. I don't think any WASM-Runtime has equivalent functionality currently. What is your goal anyway?

@pythoneer
Copy link
Member

[sorry accidentally click the close button, that was not intentional]

@pythoneer pythoneer reopened this Dec 4, 2020
@VikramTiwari
Copy link
Author

Thanks for the details @pythoneer. I was thinking of writing a nodejs binding for enigo using wasm. I am not targeting browsers, only nodejs. I saw that there are already some binding available but they require electron and neon and I thought that maybe with wasm we can do it without those extra dependencies.

@SOVLOOKUP
Copy link

@VikramTiwari Any progress about this? I need a nodejs binding for enigo too.

@VikramTiwari
Copy link
Author

Hey @SOVLOOKUP no! I wasn't able to make it work. Let me know if you get some progress on it.

@SOVLOOKUP
Copy link

@VikramTiwari No... But I find https://github.com/nut-tree/nut.js is also a good choice

@SOVLOOKUP
Copy link

@VikramTiwari I have a very good news! neon could compile rust code into native Node.js modules.

Are you still interested in this idea?Let's using rdev and neon to create a modern package that replaces iohook and robotjs!

@SOVLOOKUP
Copy link

It's done. I created this library ( rubickbase ) to replace iohook and robotjs!

@Lzzzzzq
Copy link

Lzzzzzq commented Jun 27, 2022

@VikramTiwari Any progress about this? I have this problem too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants