Skip to content

Commit 5875628

Browse files
Merge pull request #285 from theseus-rs/correct-wasm-build-configuration
build: correct wasm build configuration
2 parents 8888d85 + 9bebcba commit 5875628

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

examples/class_loader/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ version.workspace = true
88
[dependencies]
99
ristretto_classloader = { path = "../../ristretto_classloader" }
1010

11-
[target.'cfg(target_arch = "wasm32")'.dependencies]
11+
[target.'cfg(target_family = "wasm")'.dependencies]
1212
tokio = { workspace = true }
1313

14-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
14+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
1515
tokio = { workspace = true, features = ["rt-multi-thread"] }

examples/runtime_class_loader/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ version.workspace = true
88
[dependencies]
99
ristretto_classloader = { path = "../../ristretto_classloader" }
1010

11-
[target.'cfg(target_arch = "wasm32")'.dependencies]
11+
[target.'cfg(target_family = "wasm")'.dependencies]
1212
tokio = { workspace = true }
1313

14-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
14+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
1515
tokio = { workspace = true, features = ["rt-multi-thread"] }

ristretto_classloader/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ tracing = { workspace = true }
2525
walkdir = { workspace = true }
2626
zip = { workspace = true }
2727

28-
[target.'cfg(target_arch = "wasm32")'.dependencies]
28+
[target.'cfg(target_family = "wasm")'.dependencies]
2929
tokio = { workspace = true }
3030

31-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
31+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
3232
tokio = { workspace = true, features = ["fs"] }
3333

3434
[dev-dependencies]
3535
criterion = { workspace = true }
3636
indoc = { workspace = true }
3737

38-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
38+
[target.'cfg(target_family = "wasm")'.dev-dependencies]
3939
tokio = { workspace = true }
4040

41-
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
41+
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
4242
tokio = { workspace = true, features = ["rt-multi-thread"] }
4343

4444
[features]

ristretto_classloader/src/runtime/bootstrap.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ pub async fn home_class_loader(java_home: &PathBuf) -> Result<(PathBuf, String,
3232
// property (e.g. 21.0.5).
3333
let java_version = if version_file.exists() {
3434
let version_file = java_home.join("version.txt");
35-
#[cfg(target_arch = "wasm32")]
35+
#[cfg(target_family = "wasm")]
3636
let java_version = std::fs::read_to_string(version_file)?;
37-
#[cfg(not(target_arch = "wasm32"))]
37+
#[cfg(not(target_family = "wasm"))]
3838
let java_version = tokio::fs::read_to_string(version_file).await?;
3939
java_version.trim().to_string()
4040
} else {
4141
let release_file = java_home.join("release");
4242

43-
#[cfg(target_arch = "wasm32")]
43+
#[cfg(target_family = "wasm")]
4444
let release = std::fs::read_to_string(release_file)?;
45-
#[cfg(not(target_arch = "wasm32"))]
45+
#[cfg(not(target_family = "wasm"))]
4646
let release = tokio::fs::read_to_string(release_file).await?;
4747

4848
let Some(java_version_line) = release
@@ -73,9 +73,9 @@ pub async fn home_class_loader(java_home: &PathBuf) -> Result<(PathBuf, String,
7373
pub async fn version_class_loader(version: &str) -> Result<(PathBuf, String, ClassLoader)> {
7474
let current_dir = env::current_dir().unwrap_or_default();
7575

76-
#[cfg(target_arch = "wasm32")]
76+
#[cfg(target_family = "wasm")]
7777
let home_dir = current_dir;
78-
#[cfg(not(target_arch = "wasm32"))]
78+
#[cfg(not(target_family = "wasm"))]
7979
let home_dir = {
8080
#[expect(deprecated)]
8181
env::home_dir().unwrap_or(current_dir)
@@ -138,9 +138,9 @@ async fn extract_archive(
138138
archive: &Vec<u8>,
139139
out_dir: &PathBuf,
140140
) -> Result<PathBuf> {
141-
#[cfg(target_arch = "wasm32")]
141+
#[cfg(target_family = "wasm")]
142142
std::fs::create_dir_all(out_dir)?;
143-
#[cfg(not(target_arch = "wasm32"))]
143+
#[cfg(not(target_family = "wasm"))]
144144
tokio::fs::create_dir_all(out_dir).await?;
145145

146146
let Some(extension) = file_name.split('.').last() else {
@@ -165,7 +165,7 @@ async fn extract_archive(
165165
tar.unpack(extract_dir.clone())?;
166166
};
167167

168-
#[cfg(target_arch = "wasm32")]
168+
#[cfg(target_family = "wasm")]
169169
let runtime_dir = {
170170
let mut entries = std::fs::read_dir(&extract_dir)?;
171171
let Some(runtime_dir) = entries.next() else {
@@ -175,7 +175,7 @@ async fn extract_archive(
175175
};
176176
runtime_dir?
177177
};
178-
#[cfg(not(target_arch = "wasm32"))]
178+
#[cfg(not(target_family = "wasm"))]
179179
let runtime_dir = {
180180
let mut entries = tokio::fs::read_dir(&extract_dir).await?;
181181
let Some(runtime_dir) = entries.next_entry().await? else {
@@ -192,9 +192,9 @@ async fn extract_archive(
192192
// Rename the runtime directory to the installation directory. Another process may have
193193
// already installed the runtime, so we need to check if the installation directory exists.
194194
// If it does, we can ignore the error.
195-
#[cfg(target_arch = "wasm32")]
195+
#[cfg(target_family = "wasm")]
196196
let rename_result = std::fs::rename(runtime_dir.clone(), installation_dir.clone());
197-
#[cfg(not(target_arch = "wasm32"))]
197+
#[cfg(not(target_family = "wasm"))]
198198
let rename_result = tokio::fs::rename(runtime_dir.clone(), installation_dir.clone()).await;
199199

200200
if let Err(error) = rename_result {
@@ -208,9 +208,9 @@ async fn extract_archive(
208208
}
209209
}
210210

211-
#[cfg(target_arch = "wasm32")]
211+
#[cfg(target_family = "wasm")]
212212
std::fs::remove_dir_all(&extract_dir)?;
213-
#[cfg(not(target_arch = "wasm32"))]
213+
#[cfg(not(target_family = "wasm"))]
214214
tokio::fs::remove_dir_all(&extract_dir).await?;
215215

216216
debug!(

ristretto_cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ ristretto_vm = { path = "../ristretto_vm", version = "0.14.0" }
2929
tracing = { workspace = true }
3030
tracing-subscriber = { workspace = true, features = ["env-filter"] }
3131

32-
[target.'cfg(target_arch = "wasm32")'.dependencies]
32+
[target.'cfg(target_family = "wasm")'.dependencies]
3333
tokio = { workspace = true }
3434

35-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
35+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
3636
tokio = { workspace = true, features = ["rt-multi-thread"] }
3737

3838
[features]

ristretto_cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct Cli {
5858

5959
const VERSION: &str = env!("CARGO_PKG_VERSION");
6060

61-
#[cfg(target_arch = "wasm32")]
61+
#[cfg(target_family = "wasm")]
6262
#[tokio::main(flavor = "current_thread")]
6363
async fn main() -> Result<()> {
6464
logging::initialize();
@@ -69,7 +69,7 @@ async fn main() -> Result<()> {
6969
Ok(())
7070
}
7171

72-
#[cfg(not(target_arch = "wasm32"))]
72+
#[cfg(not(target_family = "wasm"))]
7373
#[tokio::main]
7474
async fn main() -> Result<()> {
7575
logging::initialize();

ristretto_vm/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ thiserror = { workspace = true }
2929
tracing = { workspace = true }
3030
whoami = { workspace = true }
3131

32-
[target.'cfg(target_arch = "wasm32")'.dependencies]
32+
[target.'cfg(target_family = "wasm")'.dependencies]
3333
getrandom = { workspace = true, features = ["wasm_js"] }
3434
tokio = { workspace = true }
3535

36-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
36+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
3737
getrandom = { workspace = true }
3838
tokio = { workspace = true, features = ["fs"] }
3939

ristretto_vm/src/native_methods/java/lang/thread.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ async fn sleep(_thread: Arc<Thread>, mut parameters: Parameters) -> Result<Optio
282282
let millis = parameters.pop_long()?;
283283
let millis = u64::try_from(millis)?;
284284
let duration = Duration::from_millis(millis);
285-
#[cfg(not(target_arch = "wasm32"))]
285+
#[cfg(not(target_family = "wasm"))]
286286
tokio::time::sleep(duration).await;
287-
#[cfg(target_arch = "wasm32")]
287+
#[cfg(target_family = "wasm")]
288288
std::thread::sleep(duration);
289289
Ok(None)
290290
}
@@ -299,9 +299,9 @@ async fn sleep_nanos_0(_thread: Arc<Thread>, mut parameters: Parameters) -> Resu
299299
let nanos = parameters.pop_long()?;
300300
let nanos = u64::try_from(nanos)?;
301301
let duration = Duration::from_nanos(nanos);
302-
#[cfg(not(target_arch = "wasm32"))]
302+
#[cfg(not(target_family = "wasm"))]
303303
tokio::time::sleep(duration).await;
304-
#[cfg(target_arch = "wasm32")]
304+
#[cfg(target_family = "wasm")]
305305
std::thread::sleep(duration);
306306
Ok(None)
307307
}
@@ -326,9 +326,9 @@ async fn suspend_0(_thread: Arc<Thread>, _parameters: Parameters) -> Result<Opti
326326

327327
#[async_recursion(?Send)]
328328
async fn r#yield(_thread: Arc<Thread>, _parameters: Parameters) -> Result<Option<Value>> {
329-
#[cfg(not(target_arch = "wasm32"))]
329+
#[cfg(not(target_family = "wasm"))]
330330
tokio::task::yield_now().await;
331-
#[cfg(target_arch = "wasm32")]
331+
#[cfg(target_family = "wasm")]
332332
std::thread::yield_now();
333333
Ok(None)
334334
}

0 commit comments

Comments
 (0)