Building basic wasm.

This commit is contained in:
Tom Alexander 2023-12-24 00:39:57 -05:00
parent 59222c58b1
commit a48d76321e
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
3 changed files with 22 additions and 0 deletions

View File

@ -39,12 +39,18 @@ path = "src/lib.rs"
path = "src/bin_foreign_document_test.rs" path = "src/bin_foreign_document_test.rs"
required-features = ["foreign_document_test"] required-features = ["foreign_document_test"]
[[bin]]
name = "wasm"
path = "src/bin_wasm.rs"
required-features = ["wasm"]
[dependencies] [dependencies]
futures = { version = "0.3.28", optional = true } futures = { version = "0.3.28", optional = true }
nom = "7.1.1" nom = "7.1.1"
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] } opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
opentelemetry-otlp = { version = "0.13.0", optional = true } opentelemetry-otlp = { version = "0.13.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.12.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"] } tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] }
tracing = { version = "0.1.37", optional = true } tracing = { version = "0.1.37", optional = true }
tracing-opentelemetry = { version = "0.20.0", 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"] 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"] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
event_count = [] event_count = []
wasm = ["dep:serde"]
# Optimized build for any sort of release. # Optimized build for any sort of release.
[profile.release-lto] [profile.release-lto]
@ -79,3 +86,8 @@ strip = "symbols"
inherits = "release" inherits = "release"
lto = true lto = true
debug = true debug = true
[profile.wasm]
inherits = "release"
lto = true
strip = true

View File

@ -29,6 +29,10 @@ build:
release: release:
> cargo build --release $(RELEASEFLAGS) > cargo build --release $(RELEASEFLAGS)
.PHONY: wasm
wasm:
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
.PHONY: clean .PHONY: clean
clean: clean:
> cargo clean > cargo clean

6
src/bin_wasm.rs Normal file
View File

@ -0,0 +1,6 @@
#![no_main]
#[no_mangle]
pub extern "C" fn add(left: usize, right: usize) -> usize {
left + right
}