Skip to content

Commit 0e858dc

Browse files
committed
Add wasi compatibility.
Compiling to wasi. OpenSSL None web wasm versions of files. Successfully building wasip1/p2 compatibility Add backtrace panic Fix test targets Adding ring to web web and wasi working. Synchronous web validation. Reorganize web dependencies. Build directly to wasip2 Support compiling to wasm32-wasip2 - 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 06fc905 commit 0e858dc

File tree

12 files changed

+1150
-19
lines changed

12 files changed

+1150
-19
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
@@ -78,10 +78,7 @@ byteorder = { version = "1.4.3", default-features = false }
7878
byteordered = "0.6.0"
7979
c2pa-crypto = { path = "../internal/crypto", version = "0.3.0" }
8080
c2pa-status-tracker = { path = "../internal/status-tracker", version = "0.3.0" }
81-
chrono = { version = "0.4.39", default-features = false, features = [
82-
"serde",
83-
"wasmbind",
84-
] }
81+
chrono = { version = "0.4.39", default-features = false, features = ["serde"] }
8582
ciborium = "0.2.2"
8683
config = { version = "0.14.0", default-features = false, features = [
8784
"json",
@@ -124,30 +121,46 @@ serde_with = "3.11.0"
124121
serde-transcode = "1.1.1"
125122
sha1 = "0.10.6"
126123
sha2 = "0.10.6"
127-
tempfile = "3.10.1"
124+
tempfile = "3.15"
128125
thiserror = "2.0.8"
129126
treeline = "0.1.0"
130127
url = "2.5.3"
131-
uuid = { version = "1.10.0", features = ["serde", "v4", "js"] }
128+
uuid = { version = "1.10.0", features = ["serde", "v4"] }
129+
x509-certificate = "0.23.1"
132130
x509-parser = "0.16.0"
133-
x509-certificate = "0.21.0"
134131
zip = { version = "2.2.1", default-features = false }
135132

133+
[target.'cfg(target_arch = "wasm32")'.dependencies]
134+
rsa = { version = "0.9.6", features = ["sha2"] }
135+
spki = "0.7.3"
136+
137+
[target.'cfg(target_env = "p2")'.dependencies]
138+
tempfile = { version = "3.15", features = ["nightly"] }
139+
136140
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
137141
ureq = "2.4.0"
142+
143+
[target.'cfg(any(target_os = "wasi", not(target_arch = "wasm32")))'.dependencies]
138144
image = { version = "0.24.7", default-features = false, features = [
139145
"jpeg",
140146
"png",
141147
], optional = true }
142148

143-
[target.'cfg(target_arch = "wasm32")'.dependencies]
149+
[target.'cfg(target_os = "wasi")'.dependencies]
150+
getrandom = "0.2.7"
151+
152+
153+
[target.'cfg(all(target_arch = "wasm32",not(target_os = "wasi")))'.dependencies]
154+
chrono = { version = "0.4.39", default-features = false, features = [
155+
"serde",
156+
"wasmbind",
157+
] }
144158
console_log = { version = "1.0.0", features = ["color"] }
145159
getrandom = { version = "0.2.7", features = ["js"] }
146160
js-sys = "0.3.58"
147161
rand_core = "0.9.0-alpha.2"
148-
rsa = { version = "0.9.6", features = ["sha2"] }
149162
serde-wasm-bindgen = "0.6.5"
150-
spki = "0.7.3"
163+
uuid = { version = "1.10.0", features = ["serde", "v4", "js"] }
151164
wasm-bindgen = "0.2.83"
152165
wasm-bindgen-futures = "0.4.31"
153166
web-sys = { version = "0.3.58", features = [
@@ -168,8 +181,8 @@ hex-literal = "0.4.1"
168181
jumbf = "0.4.0"
169182
mockall = "0.13.1"
170183

171-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
172-
wasm-bindgen-test = "0.3.31"
184+
[target.'cfg(all(target_arch = "wasm32",not(target_os = "wasi")))'.dev-dependencies]
185+
wasm-bindgen-test = "0.3.45"
173186

174187
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
175188
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
@@ -1081,6 +1081,7 @@ impl Builder {
10811081
mod tests {
10821082
#![allow(clippy::expect_used)]
10831083
#![allow(clippy::unwrap_used)]
1084+
#![cfg(not(target_os = "wasi"))]
10841085
use std::io::Cursor;
10851086

10861087
use c2pa_crypto::raw_signature::SigningAlg;

sdk/src/ingredient.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,7 @@ impl IngredientOptions for DefaultOptions {
14511451
mod tests {
14521452
#![allow(clippy::expect_used)]
14531453
#![allow(clippy::unwrap_used)]
1454+
#![cfg(not(target_os = wasi))]
14541455

14551456
#[cfg(target_arch = "wasm32")]
14561457
use wasm_bindgen_test::*;

sdk/src/manifest.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ impl SignatureInfo {
15011501
pub(crate) mod tests {
15021502
#![allow(clippy::expect_used)]
15031503
#![allow(clippy::unwrap_used)]
1504+
#![cfg(not(target_os = wasi))]
15041505

15051506
use std::io::Cursor;
15061507

sdk/src/manifest_store.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ impl std::fmt::Display for ManifestStore {
584584
mod tests {
585585
#![allow(clippy::expect_used)]
586586
#![allow(clippy::unwrap_used)]
587+
#![cfg(not(target_os = wasi))]
587588

588589
use c2pa_status_tracker::OneShotStatusTracker;
589590
#[cfg(target_arch = "wasm32")]

sdk/src/salt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ impl Default for DefaultSalt {
5555

5656
impl SaltGenerator for DefaultSalt {
5757
fn generate_salt(&self) -> Option<Vec<u8>> {
58-
#[cfg(target_arch = "wasm32")]
58+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
5959
{
6060
Some(crate::wasm::util::get_random_values(self.salt_len).ok()?)
6161
}
62-
#[cfg(not(target_arch = "wasm32"))]
62+
#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
6363
{
6464
use rand::prelude::*;
6565

sdk/src/utils/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl WebCryptoSigner {
479479
}
480480
}
481481

482-
#[cfg(target_arch = "wasm32")]
482+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
483483
#[async_trait::async_trait(?Send)]
484484
impl AsyncSigner for WebCryptoSigner {
485485
fn alg(&self) -> SigningAlg {

sdk/src/wasm/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
// specific language governing permissions and limitations under
1212
// each license.
1313

14-
#[cfg(target_arch = "wasm32")]
14+
#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
1515
pub(crate) mod util;

0 commit comments

Comments
 (0)