diff --git a/Cargo.toml b/Cargo.toml index e2b1052..888c739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,12 +39,18 @@ path = "src/lib.rs" path = "src/bin_foreign_document_test.rs" required-features = ["foreign_document_test"] +[[bin]] + name = "wasm" + path = "src/bin_wasm.rs" + required-features = ["wasm"] + [dependencies] futures = { version = "0.3.28", optional = true } nom = "7.1.1" opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] } opentelemetry-otlp = { version = "0.13.0", optional = true } opentelemetry-semantic-conventions = { version = "0.12.0", optional = true } +serde = { version = "1.0.193", optional = true, features = ["derive"] } tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] } tracing = { version = "0.1.37", optional = true } tracing-opentelemetry = { version = "0.20.0", optional = true } @@ -60,6 +66,7 @@ compare = ["tokio/process", "tokio/macros"] foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir", "tokio/process"] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"] event_count = [] +wasm = ["dep:serde"] # Optimized build for any sort of release. [profile.release-lto] @@ -79,3 +86,8 @@ strip = "symbols" inherits = "release" lto = true debug = true + +[profile.wasm] +inherits = "release" +lto = true +strip = true diff --git a/Makefile b/Makefile index 67a8fc9..939dec8 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,10 @@ build: release: > cargo build --release $(RELEASEFLAGS) +.PHONY: wasm +wasm: +> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm + .PHONY: clean clean: > cargo clean diff --git a/src/bin_wasm.rs b/src/bin_wasm.rs new file mode 100644 index 0000000..2496df2 --- /dev/null +++ b/src/bin_wasm.rs @@ -0,0 +1,6 @@ +#![no_main] + +#[no_mangle] +pub extern "C" fn add(left: usize, right: usize) -> usize { + left + right +}