Skip to content

Commit e89f408

Browse files
committed
feat: Add wasi compatibility.
- wasip2 will require +nightly until rust-lang/rust#130323 is resolved and/or std::os::wasip2 is available in stable. - Support was added to rustix for version 0.38.39 bytecodealliance/rustix#1205 - Support was added to tempfile for version 3.14 Stebalien/tempfile#305
1 parent 2395bd2 commit e89f408

File tree

10 files changed

+1147
-16
lines changed

10 files changed

+1147
-16
lines changed

make_test_images/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ nom = "7.1.3"
2828
regex = "1.5.6"
2929
serde = "1.0.197"
3030
serde_json = { version = "1.0.117", features = ["preserve_order"] }
31-
tempfile = "3.10.1"
31+
tempfile = "3.15.0"
3232

3333
[features]
3434
# prevents these features from being always enabled in the workspace

sdk/Cargo.toml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ byteorder = { version = "1.4.3", default-features = false }
7474
byteordered = "0.6.0"
7575
c2pa-crypto = { path = "../internal/crypto", version = "0.6.2" }
7676
c2pa-status-tracker = { path = "../internal/status-tracker", version = "0.5.0" }
77-
chrono = { version = "0.4.39", default-features = false, features = [
78-
"serde",
79-
"wasmbind",
80-
] }
77+
chrono = { version = "0.4.39", default-features = false, features = ["serde"] }
8178
ciborium = "0.2.2"
8279
config = { version = "0.14.0", default-features = false, features = [
8380
"json",
@@ -119,30 +116,46 @@ serde_with = "3.11.0"
119116
serde-transcode = "1.1.1"
120117
sha1 = "0.10.6"
121118
sha2 = "0.10.6"
122-
tempfile = "3.10.1"
119+
tempfile = "3.15"
123120
thiserror = "2.0.8"
124121
treeline = "0.1.0"
125122
url = "2.5.3"
126-
uuid = { version = "1.10.0", features = ["serde", "v4", "js"] }
123+
uuid = { version = "1.10.0", features = ["serde", "v4"] }
124+
x509-certificate = "0.23.1"
127125
x509-parser = "0.16.0"
128-
x509-certificate = "0.21.0"
129126
zip = { version = "2.2.1", default-features = false }
130127

128+
[target.'cfg(target_arch = "wasm32")'.dependencies]
129+
rsa = { version = "0.9.6", features = ["sha2"] }
130+
spki = "0.7.3"
131+
132+
[target.'cfg(target_env = "p2")'.dependencies]
133+
tempfile = { version = "3.15", features = ["nightly"] }
134+
131135
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
132136
ureq = "2.4.0"
137+
138+
[target.'cfg(any(target_os = "wasi", not(target_arch = "wasm32")))'.dependencies]
133139
image = { version = "0.24.7", default-features = false, features = [
134140
"jpeg",
135141
"png",
136142
], optional = true }
137143

138-
[target.'cfg(target_arch = "wasm32")'.dependencies]
144+
[target.'cfg(target_os = "wasi")'.dependencies]
145+
getrandom = "0.2.7"
146+
147+
148+
[target.'cfg(all(target_arch = "wasm32",not(target_os = "wasi")))'.dependencies]
149+
chrono = { version = "0.4.39", default-features = false, features = [
150+
"serde",
151+
"wasmbind",
152+
] }
139153
console_log = { version = "1.0.0", features = ["color"] }
140154
getrandom = { version = "0.2.7", features = ["js"] }
141155
js-sys = "0.3.58"
142156
rand_core = "0.9.0-alpha.2"
143-
rsa = { version = "0.9.6", features = ["sha2"] }
144157
serde-wasm-bindgen = "0.6.5"
145-
spki = "0.7.3"
158+
uuid = { version = "1.10.0", features = ["serde", "v4", "js"] }
146159
wasm-bindgen = "0.2.83"
147160
wasm-bindgen-futures = "0.4.31"
148161
web-sys = { version = "0.3.58", features = [
@@ -160,8 +173,8 @@ hex-literal = "0.4.1"
160173
jumbf = "0.4.0"
161174
mockall = "0.13.1"
162175

163-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
164-
wasm-bindgen-test = "0.3.31"
176+
[target.'cfg(all(target_arch = "wasm32",not(target_os = "wasi")))'.dev-dependencies]
177+
wasm-bindgen-test = "0.3.45"
165178

166179
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
167180
actix = "0.13.1"

sdk/src/asset_handlers/jpeg_io.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ pub mod tests {
11251125

11261126
use std::io::{Read, Seek};
11271127

1128-
#[cfg(target_arch = "wasm32")]
1128+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
11291129
use wasm_bindgen_test::*;
11301130

11311131
use super::*;
@@ -1223,7 +1223,10 @@ pub mod tests {
12231223
}
12241224

12251225
#[cfg_attr(not(target_arch = "wasm32"), actix::test)]
1226-
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
1226+
#[cfg_attr(
1227+
all(target_arch = "wasm32", not(target_os = "wasi")),
1228+
wasm_bindgen_test
1229+
)]
12271230
async fn test_xmp_read_write_stream() {
12281231
let source_bytes = include_bytes!("../../tests/fixtures/CA.jpg");
12291232

sdk/src/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,7 @@ impl Builder {
11081108
mod tests {
11091109
#![allow(clippy::expect_used)]
11101110
#![allow(clippy::unwrap_used)]
1111+
#![cfg(not(target_os = "wasi"))]
11111112
use std::io::Cursor;
11121113

11131114
use c2pa_crypto::raw_signature::SigningAlg;

sdk/src/ingredient.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,7 @@ impl IngredientOptions for DefaultOptions {
14951495
mod tests {
14961496
#![allow(clippy::expect_used)]
14971497
#![allow(clippy::unwrap_used)]
1498+
#![cfg(not(target_os = wasi))]
14981499

14991500
#[cfg(target_arch = "wasm32")]
15001501
use wasm_bindgen_test::*;

sdk/src/manifest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@ impl SignatureInfo {
15461546
pub(crate) mod tests {
15471547
#![allow(clippy::expect_used)]
15481548
#![allow(clippy::unwrap_used)]
1549+
#![cfg(not(target_os = wasi))]
15491550

15501551
use std::io::Cursor;
15511552

sdk/src/manifest_store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ impl std::fmt::Display for ManifestStore {
599599
mod tests {
600600
#![allow(clippy::expect_used)]
601601
#![allow(clippy::unwrap_used)]
602+
#![cfg(not(target_os = wasi))]
602603

603604
use c2pa_status_tracker::OneShotStatusTracker;
604605
#[cfg(target_arch = "wasm32")]

sdk/src/utils/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl WebCryptoSigner {
428428
}
429429
}
430430
431-
#[cfg(target_arch = "wasm32")]
431+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
432432
#[async_trait::async_trait(?Send)]
433433
impl AsyncSigner for WebCryptoSigner {
434434
fn alg(&self) -> SigningAlg {

0 commit comments

Comments
 (0)