From 608ef6226191e52320d297e29b482827088e6be2 Mon Sep 17 00:00:00 2001 From: Krusty/Benediction Date: Sun, 17 Sep 2023 22:14:53 +0200 Subject: [PATCH] [wasm] Fix new compilation issues --- Cargo.lock | 163 +++++++++++++++++++++++--------- Cargo.toml | 2 +- cpclib-asm/src/assembler/mod.rs | 3 +- cpclib-image/src/image.rs | 11 ++- 4 files changed, 128 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfa9ace2..2ab3cec7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,7 +118,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "once_cell", "serde", "version_check 0.9.4", @@ -360,7 +360,7 @@ checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", "autocfg", - "cfg-if", + "cfg-if 1.0.0", "concurrent-queue", "futures-lite", "log", @@ -391,7 +391,7 @@ dependencies = [ "async-lock", "autocfg", "blocking", - "cfg-if", + "cfg-if 1.0.0", "event-listener", "futures-lite", "rustix 0.37.23", @@ -480,7 +480,7 @@ checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" dependencies = [ "addr2line", "cc", - "cfg-if", + "cfg-if 1.0.0", "libc", "miniz_oxide", "object", @@ -732,6 +732,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + [[package]] name = "cfg-if" version = "1.0.0" @@ -760,7 +766,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14b8f0b65b7b08ae3c8187e8d77174de20cb6777864c6b832d8ad365999cf1ea" dependencies = [ "arrayvec 0.5.2", - "cfg-if", + "cfg-if 1.0.0", "encoding_rs", "memchr", "rayon", @@ -952,6 +958,16 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if 1.0.0", + "wasm-bindgen", +] + [[package]] name = "contracts" version = "0.6.3" @@ -1010,7 +1026,7 @@ dependencies = [ "anyhow", "arrayref", "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-asm", "cpclib-basic", "cpclib-common", @@ -1048,7 +1064,7 @@ dependencies = [ "build-deps", "built", "cc", - "cfg-if", + "cfg-if 1.0.0", "chardetng", "codespan-reporting", "cpclib-basic", @@ -1088,7 +1104,7 @@ version = "0.7.0" dependencies = [ "arrayref", "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "cpclib-disc", "cpclib-sna", @@ -1199,7 +1215,7 @@ version = "0.7.0" dependencies = [ "arrayref", "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "cpclib-tokens", "custom_error", @@ -1256,7 +1272,7 @@ name = "cpclib-sna" version = "0.7.0" dependencies = [ "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "delegate", "matches", @@ -1273,7 +1289,7 @@ name = "cpclib-tokens" version = "0.7.0" dependencies = [ "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "cpclib-sna", "delegate", @@ -1307,13 +1323,28 @@ dependencies = [ "static_vcruntime", ] +[[package]] +name = "cpclib-wasm" +version = "0.2.1-alpha.2" +dependencies = [ + "console_error_panic_hook", + "cpclib-asm", + "cpclib-basic", + "cpclib-sna", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-test", + "web-sys", + "wee_alloc", +] + [[package]] name = "cpclib-xfer" version = "0.7.0" dependencies = [ "arrayref", "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "cpclib-disc", "cpclib-sna", @@ -1337,7 +1368,7 @@ dependencies = [ "anyhow", "arrayref", "built", - "cfg-if", + "cfg-if 1.0.0", "cpclib-common", "cpclib-disc", "cpclib-sna", @@ -1369,7 +1400,7 @@ dependencies = [ name = "cpclib-z80emu" version = "0.7.0" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpclib-asm", "cpclib-common", "cpclib-sna", @@ -1409,7 +1440,7 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1454,7 +1485,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", ] @@ -1464,7 +1495,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "crossbeam-epoch", "crossbeam-utils", ] @@ -1476,7 +1507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" dependencies = [ "autocfg", - "cfg-if", + "cfg-if 1.0.0", "crossbeam-utils", "memoffset 0.9.0", "scopeguard", @@ -1488,7 +1519,7 @@ version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -1574,7 +1605,7 @@ version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6943ae99c34386c84a470c499d3414f66502a41340aa895406e0d2e4a207b91d" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "hashbrown 0.14.0", "lock_api", "once_cell", @@ -1646,7 +1677,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "dirs-sys-next", ] @@ -1843,7 +1874,7 @@ version = "0.8.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] @@ -2029,7 +2060,7 @@ version = "3.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "rustix 0.38.8", "windows-sys 0.48.0", ] @@ -2069,7 +2100,7 @@ version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall 0.3.5", "windows-sys 0.48.0", @@ -2271,7 +2302,7 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "libc", "wasi", @@ -2752,7 +2783,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -2836,7 +2867,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" dependencies = [ "cesu8", - "cfg-if", + "cfg-if 1.0.0", "combine", "jni-sys", "log", @@ -2971,7 +3002,7 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "winapi", ] @@ -2981,7 +3012,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d580318f95776505201b28cf98eb1fa5e4be3b689633ba6a3e6cd880ff22d8cb" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "windows-sys 0.48.0", ] @@ -3082,6 +3113,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + [[package]] name = "mime" version = "0.3.17" @@ -3202,7 +3239,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ "bitflags 1.3.2", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset 0.6.5", ] @@ -3215,7 +3252,7 @@ checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4" dependencies = [ "autocfg", "bitflags 1.3.2", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset 0.6.5", ] @@ -3227,7 +3264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ "bitflags 1.3.2", - "cfg-if", + "cfg-if 1.0.0", "libc", "memoffset 0.7.1", "static_assertions", @@ -3531,7 +3568,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" dependencies = [ "bitflags 1.3.2", - "cfg-if", + "cfg-if 1.0.0", "foreign-types", "libc", "once_cell", @@ -3651,7 +3688,7 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall 0.3.5", "smallvec", @@ -3781,7 +3818,7 @@ checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", "bitflags 1.3.2", - "cfg-if", + "cfg-if 1.0.0", "concurrent-queue", "libc", "log", @@ -4220,7 +4257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "994eca4bca05c87e86e15d90fc7a91d1be64b4482b38cb2d27474568fe7c9db9" dependencies = [ "bitflags 2.4.0", - "cfg-if", + "cfg-if 1.0.0", "clipboard-win", "fd-lock", "home", @@ -4441,7 +4478,7 @@ version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", ] @@ -4452,7 +4489,7 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479fb9d862239e610720565ca91403019f2f00410f1864c5aa7479b950a76ed8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "cpufeatures", "digest", ] @@ -4754,7 +4791,7 @@ version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "fastrand 2.0.0", "redox_syscall 0.3.5", "rustix 0.38.8", @@ -4886,7 +4923,7 @@ dependencies = [ "arrayref", "arrayvec 0.7.4", "bytemuck", - "cfg-if", + "cfg-if 1.0.0", "png", "tiny-skia-path", ] @@ -5019,7 +5056,7 @@ version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -5252,7 +5289,7 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "wasm-bindgen-macro", ] @@ -5277,7 +5314,7 @@ version = "0.4.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "js-sys", "wasm-bindgen", "web-sys", @@ -5312,6 +5349,30 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +[[package]] +name = "wasm-bindgen-test" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e6e302a7ea94f83a6d09e78e7dc7d9ca7b186bc2829c24a22d0753efd680671" +dependencies = [ + "console_error_panic_hook", + "js-sys", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecb993dd8c836930ed130e020e77d9b2e65dd0fbab1b67c790b0f5d80b11a575" +dependencies = [ + "proc-macro2 1.0.66", + "quote 1.0.32", +] + [[package]] name = "wayland-client" version = "0.29.5" @@ -5424,6 +5485,18 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wee_alloc" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "memory_units", + "winapi", +] + [[package]] name = "weezl" version = "0.1.7" @@ -5873,7 +5946,3 @@ dependencies = [ "quote 1.0.32", "syn 1.0.109", ] - -[[patch.unused]] -name = "cpclib-wasm" -version = "0.2.1-alpha.2" diff --git a/Cargo.toml b/Cargo.toml index d818846a..b10f523a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ "cpclib-imgconverter", "cpclib-visual-basm", "cpclib-visual-bndbuild", - # "cpclib-wasm" + "cpclib-wasm" ] resolver = "2" diff --git a/cpclib-asm/src/assembler/mod.rs b/cpclib-asm/src/assembler/mod.rs index 7f081328..3a27a702 100644 --- a/cpclib-asm/src/assembler/mod.rs +++ b/cpclib-asm/src/assembler/mod.rs @@ -1071,7 +1071,8 @@ impl Env { .sum::() as u64; if self.options.show_progress() { - Progress::progress().create_save_bar(nb_files_to_save); + #[cfg(not(target_arch = "wasm32"))] + Progress::progress().create_save_bar(nb_files_to_save); } // save from snapshot diff --git a/cpclib-image/src/image.rs b/cpclib-image/src/image.rs index 031742f6..2434dc88 100644 --- a/cpclib-image/src/image.rs +++ b/cpclib-image/src/image.rs @@ -4,6 +4,8 @@ use std::collections::HashSet; use anyhow::Context; use cpclib_common::itertools::Itertools; + +#[cfg(not(target_arch = "wasm32"))] use cpclib_common::rayon::iter::{IntoParallelRefIterator, ParallelIterator}; use {anyhow, image as im}; @@ -147,8 +149,13 @@ fn merge_mode0_mode3(line1: &[u8], line2: &[u8]) -> Vec { // Convert inks to pens fn inks_to_pens(inks: &[Vec], p: &Palette) -> Vec> { - inks.par_iter() - .map(|line| { + #[cfg(not(target_arch = "wasm32"))] + let iter = inks.par_iter(); + #[cfg(target_arch = "wasm32")] + let mut iter = inks.iter(); + + + iter.map(|line| { line.iter() .map(|ink| { p.get_pen_for_ink(*ink).unwrap_or_else(|| {