ystero-dev / scalpel

Packet Dissection and sculpting in Rust
Other
3 stars 6 forks source link

Error in building `scalpel` for `web` target #68

Closed hgupta12 closed 6 months ago

hgupta12 commented 6 months ago

Building scalpel with the command wasm-pack build --target web throws error.

Command Output

[INFO]: Checking for the Wasm target... [INFO]: Compiling to Wasm... Compiling scalpel v0.4.0 (/home/harshit/code/scalpel) error: feature "wasm" is required for "wasm32" targets. --> src/lib.rs:45:1 | 45 | compile_error!("feature \"wasm\" is required for \"wasm32\" targets."); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0433]: failed to resolve: use of undeclared crate or module wasm_bindgen --> src/lib.rs:87:5 | 87 | use wasm_bindgen::prelude::*; | ^^^^^^^^^^^^ use of undeclared crate or module wasm_bindgen

error[E0432]: unresolved imports crate::Layer, crate::Packet, crate::ENCAP_TYPE_ETH, crate::Layer, crate::Layer, crate::Layer, crate::Packet, crate::ENCAP_TYPE_LINUX_SLL, crate::Layer, crate::Packet, crate::ENCAP_TYPE_LINUX_SLL2, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer, crate::Layer --> src/layers/ethernet/mod.rs:13:13 13 use crate::{Layer, Packet, ENCAP_TYPE_ETH}; ^^^^^ ^^^^^^ ^^^^^^^^^^^^^^
::: src/layers/ipv4.rs:12:5 12 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/ipv6.rs:12:5 12 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/linux_sll.rs:8:13 8 use crate::{Layer, Packet, ENCAP_TYPE_LINUX_SLL}; ^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^
::: src/layers/linux_sll2.rs:8:13 8 use crate::{Layer, Packet, ENCAP_TYPE_LINUX_SLL2}; ^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
::: src/layers/tcp.rs:11:5 11 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/udp.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/dns.rs:11:5 11 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/icmp.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/icmpv6.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/arp.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/sctp.rs:12:5 12 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/m3ua.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/mpls.rs:10:5 10 use crate::Layer; ^^^^^^^^^^^^
::: src/layers/vxlan.rs:7:5 7 use crate::Layer; ^^^^^^^^^^^^

::: src/packet.rs:13:5 | 13 | use crate::Layer; | ^^^^^^^^^^^^

error: cannot find attribute wasm_bindgen in this scope --> src/lib.rs:90:3 | 90 | #[wasm_bindgen] | ^^^^^^^^^^^^

Some errors have detailed explanations: E0432, E0433. For more information about an error, try rustc --explain E0432. error: could not compile scalpel (lib) due to 4 previous errors Error: Compiling your crate to WebAssembly failed Caused by: Compiling your crate to WebAssembly failed Caused by: failed to execute cargo build: exited with exit status: 101 full command: cd "/home/harshit/code/scalpel" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

System Info

OS: Ubuntu 20.04 CPU Architecture: x86_64 Rust version: 1.75.0

gabhijit commented 6 months ago

Can you try by adding --features wasm to the command line? So the entire command line should look like -

wasm-pack build --target web --features wasm
hgupta12 commented 6 months ago

Yes, this solves the issue. Thanks a lot!