3 Commits

Author SHA1 Message Date
26206a312a add filter-exports command to automatically remove unused exports
this removes the need for a manual step in the rust example
2022-01-01 19:02:58 +01:00
6a75988489 update rust example 2022-01-01 15:51:18 +01:00
397ff19d80 test remaining control codes 2022-01-01 15:37:17 +01:00
15 changed files with 213 additions and 19 deletions

54
Cargo.lock generated
View File

@@ -674,6 +674,15 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.1.19" version = "0.1.19"
@@ -698,6 +707,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "id-arena"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.7.0" version = "1.7.0"
@@ -1529,6 +1544,12 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]] [[package]]
name = "unicode-width" name = "unicode-width"
version = "0.1.9" version = "0.1.9"
@@ -1585,6 +1606,7 @@ dependencies = [
"pbr", "pbr",
"pico-args", "pico-args",
"upkr", "upkr",
"walrus",
"wasm-encoder", "wasm-encoder",
"wasmparser 0.81.0", "wasmparser 0.81.0",
] ]
@@ -1618,6 +1640,32 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "walrus"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb08e48cde54c05f363d984bb54ce374f49e242def9468d2e1b6c2372d291f8"
dependencies = [
"anyhow",
"id-arena",
"leb128",
"log",
"walrus-macro",
"wasmparser 0.77.0",
]
[[package]]
name = "walrus-macro"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a6e5bd22c71e77d60140b0bd5be56155a37e5bd14e24f5f87298040d0cc40d7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.10.2+wasi-snapshot-preview1" version = "0.10.2+wasi-snapshot-preview1"
@@ -1687,6 +1735,12 @@ dependencies = [
"leb128", "leb128",
] ]
[[package]]
name = "wasmparser"
version = "0.77.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6"
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.80.2" version = "0.80.2"

View File

@@ -13,7 +13,11 @@ data 0x20000 {
i8(14, 10, 10, 10) // scroll down 2 lines i8(14, 10, 10, 10) // scroll down 2 lines
i8(31, 40, 3, 14, 10, 15, 0xf0) "Other colors" i8(31, 40, 3, 14, 10, 15, 0xf0) "Other colors"
i8(24, 0xb0) "inverted" i8(24, 0xb0) "inverted"
i8(13, 10, 8, 8) "->"
i8(10, 10, 9, 9, 1) "|<-"
i8(5, 31, 7, 28+17, 15, 0xe3) "Graphics text!" i8(5, 31, 7, 28+17, 15, 0xe3) "Graphics text!"
i8(5, 31, 6, 28+16, 15, 0xe5) "Graphics text!" i8(5, 31, 6, 28+16, 15, 0xe5) "Graphics text!"
i8(4, 24, 14, 10, 0x90, 0x80, 0xf1)
i8(31, 37, 29, 0xf1, 0x80, 0x90)
i8(0) i8(0)
} }

View File

@@ -1,2 +1,3 @@
rustc --target=wasm32-unknown-unknown --crate-type cdylib -C opt-level="z" -C "link-args=--import-memory --initial-memory=262144 -zstack-size=65536" -o tunnel.wasm tunnel.rs && \ rustc --target=wasm32-unknown-unknown --crate-type cdylib -C opt-level="z" -C "link-args=--import-memory --initial-memory=262144 -zstack-size=65536" -o tunnel.wasm tunnel.rs && \
uw8 filter-exports tunnel.wasm tunnel.wasm && \
wasm-opt -Oz -o tunnel.wasm tunnel.wasm wasm-opt -Oz -o tunnel.wasm tunnel.wasm

View File

@@ -5,8 +5,8 @@ A nightly rust compiler is needed for the unstable sqrtf32
intrinsic. intrinsic.
Simply compiling with rustc as shown in build.sh results in a Simply compiling with rustc as shown in build.sh results in a
342 byte tunnel.wasm. Using wasm-opt this can be reduced to 371 byte tunnel.wasm. Using wasm-opt this can be reduced to
243 bytes. 260 bytes.
When you disassemble this wasm file using wasm2wat you can see When you disassemble this wasm file using wasm2wat you can see
these globals and exports: these globals and exports:
@@ -18,8 +18,10 @@ these globals and exports:
They are meant to be used for heap allocations and stack for any They are meant to be used for heap allocations and stack for any
values that are not simple scalars (i32, f32, etc.). Since our values that are not simple scalars (i32, f32, etc.). Since our
code doesn't actually use any of that, we can just delete them code doesn't actually use any of that, the globals are only
in a text editor and assemble the code again with wat2wasm. referenced by the exports and we can remove them using
'uw8 filter-exports' (preferably before running wasm-opt) which
removes all exports except those used by the MicroW8 platform.
This gives us a 199 byte wasm file. Running this through This gives us a 216 byte wasm file. Running this through
uw8-tool pack brings us to the final size of 137 bytes. uw8 pack brings us to the final size of 119 bytes.

View File

@@ -9,12 +9,20 @@ mod env {
extern "C" { extern "C" {
pub fn atan2(x: f32, y: f32) -> f32; pub fn atan2(x: f32, y: f32) -> f32;
} }
extern "C" {
pub fn time() -> f32;
}
} }
fn atan2(x: f32, y: f32) -> f32 { fn atan2(x: f32, y: f32) -> f32 {
unsafe { env::atan2(x, y) } unsafe { env::atan2(x, y) }
} }
fn time() -> f32 {
unsafe { env::time() }
}
fn sqrt(v: f32) -> f32 { fn sqrt(v: f32) -> f32 {
unsafe { core::intrinsics::sqrtf32(v) } unsafe { core::intrinsics::sqrtf32(v) }
} }
@@ -29,14 +37,14 @@ fn ftoi(v: f32) -> i32 {
} }
#[no_mangle] #[no_mangle]
pub fn tic(time: i32) { pub fn upd() {
for i in 0..320 * 240 { for i in 0..320 * 240 {
let t = time as f32 / 10 as f32; let t = time() * 63 as f32;
let x = (i % 320 - 160) as f32; let x = (i % 320 - 160) as f32;
let y = (i / 320 - 120) as f32; let y = (i / 320 - 120) as f32;
let d = 40000 as f32 / sqrt(x * x + y * y + 1 as f32); let d = 40000 as f32 / sqrt(x * x + y * y + 1 as f32);
let u = atan2(x, y) * 512f32 / 3.141; let u = atan2(x, y) * 512f32 / 3.141;
let c = (ftoi(d + t * 2 as f32) ^ ftoi(u + t)) as u8; let c = (ftoi(d + t * 2 as f32) ^ ftoi(u + t)) as u8 >> 4;
unsafe { unsafe {
*((120 + i) as *mut u8) = c; *((120 + i) as *mut u8) = c;
} }

Binary file not shown.

Binary file not shown.

View File

@@ -326,7 +326,7 @@ fn printSingleChar(char: i32) {
if char == 4 | char == 5 { if char == 4 | char == 5 {
graphicsText = char == 5; graphicsText = char == 5;
textCursorX = 0; textCursorX = 0;
textCursorY = 0; textCursorY = 0;
return; return;
} }
@@ -341,6 +341,9 @@ fn printSingleChar(char: i32) {
} }
if char == 9 { if char == 9 {
if !graphicsText & textCursorX >= 320 {
printChar(0xd0a);
}
textCursorX = textCursorX + 8; textCursorX = textCursorX + 8;
return; return;
} }
@@ -406,6 +409,10 @@ fn printSingleChar(char: i32) {
return; return;
} }
if char < 31 {
return;
}
drawChar(char); drawChar(char);
} }

View File

@@ -120,7 +120,7 @@ possible but no examples are provided, yet.
## Examples ## Examples
* [Fireworks](v0.1pre5#AgwvgP+M59snqjl4CMKw5sqm1Zw9yJCbSviMjeLUdHus2a3yl/a99+uiBeqZgP/2jqSjrLjRk73COMM6OSLpsxK8ugT1kuk/q4hQUqqPpGozHoa0laulzGGcahzdfdJsYaK1sIdeIYS9M5PnJx/Wk9H+PvWEPy2Zvv7I6IW7Fg==) (127 bytes): Some fireworks to welcome 2022. * [Fireworks](v0.1pre5#AgwvgP+M59snqjl4CMKw5sqm1Zw9yJCbSviMjeLUdHus2a3yl/a99+uiBeqZgP/2jqSjrLjRk73COMM6OSLpsxK8ugT1kuk/q4hQUqqPpGozHoa0laulzGGcahzdfdJsYaK1sIdeIYS9M5PnJx/Wk9H+PvWEPy2Zvv7I6IW7Fg==) (127 bytes): Some fireworks to welcome 2022.
* [Skip Ahead](v0.1pre4#AiP94km33q5hBFbBcKl2W1ZMY67wHByUz15/qRHIr71Dvq8bTVux/DXZzSTKU5MufRXxnGEn6mOul4dil/5WLT1Y+Y/4TGd1E3U4rQaxlpcKObxc5YLdr4xo6jyBND96a569LoECv6Q4EIqxJi+3QPE21r/++js41XsBLr44X/O2XpP3kHQva3B8o6duD5WkLCf7PhsxjTBeND1ADIaJe05JCrBim18RPY9VYFmltqQ9gVzbxE/ZpojR/GJ4aCbx0hRn73RPhpA7Cd4jk0AVSOeRx+7kuHrLzpaeqeYWK5pYd/4Rv+8=) (230 bytes): A port of my [TIC-80 256byte game](http://tic80.com/play?cart=1735) from LoveByte'21 * [Skip Ahead](v0.1pre5#AgyfpZ80wkW28kiUZ9VIK4v+RPnVxqjK1dz2BcDoNyQPsS2g4OgEzkTe6jyoAfFOmqKrS8SM2aRljBal9mjNn8i4fP9eBK+RehQKxxGtJa9FqftvqEnh3ez1YaYxqj7jgTdzJ/WAYVmKMovBT1myrX3FamqKSOgMsNedLhVTLAhQup3sNcYEjGNo8b0HZ5+AgMgCwYRGCe//XQOMAaAAzqDILgmpEZ/43RKHcQpHEQwbURfNQJpadJe2sz3q5FlQnTGXQ9oSMokidhlC+aR/IpNHieuBGLhFZ2GfnwVQ0geBbQpTPA==) (229 bytes): A port of my [TIC-80 256byte game](http://tic80.com/play?cart=1735) from LoveByte'21
* [OhNoAnotherTunnel](v0.1pre4#Ag95rdCB5Ww5NofyQaKF4P1mrNRso4azgiem4hK99Gh8OMzSpFq3NsNDo7O7pqln10D11l9uXr/ritw7OEzKwbEfCdvaRnS2Z0Kz0iDEZt/gIqOdvFmxsL1MjPQ4XInPbUJpQUonhQq29oP2omFabnQxn0bzoK7mZjcwc5GetHG+hGajkJcRr8oOnjfCol8RD+ha33GYtPnut+GLe4ktzf5UxZwGs6oT9qqC61lRDakN) (177 bytes): A port of my [entry](http://tic80.com/play?cart=1871) in the Outline'21 bytebattle final * [OhNoAnotherTunnel](v0.1pre4#Ag95rdCB5Ww5NofyQaKF4P1mrNRso4azgiem4hK99Gh8OMzSpFq3NsNDo7O7pqln10D11l9uXr/ritw7OEzKwbEfCdvaRnS2Z0Kz0iDEZt/gIqOdvFmxsL1MjPQ4XInPbUJpQUonhQq29oP2omFabnQxn0bzoK7mZjcwc5GetHG+hGajkJcRr8oOnjfCol8RD+ha33GYtPnut+GLe4ktzf5UxZwGs6oT9qqC61lRDakN) (177 bytes): A port of my [entry](http://tic80.com/play?cart=1871) in the Outline'21 bytebattle final
* [Technotunnel](v0.1pre4#AqL8HeK1M9dn2nWNIF5vaq/Vh64pMt5nJIFoFKpBMPUsGtDtpqjo1JbT9LzPhAxCqJ7Yh4TA6oTGd4xhLowf+cWZMY73+7AZmfXJJsBi4cej/hH+4wlAgxFIrnOYnr/18IpnZbsHf0eGm1BhahX74+cVR0TRmNQmYC7GhCNS3mv/3MJn74lCj7t28aBJPjEZhP9fGXdG2u5Egh/Tjdg=) (158 bytes): A port of my [entry](https://tic80.com/play?cart=1873) in the Outline'21 bytebattle quater final * [Technotunnel](v0.1pre4#AqL8HeK1M9dn2nWNIF5vaq/Vh64pMt5nJIFoFKpBMPUsGtDtpqjo1JbT9LzPhAxCqJ7Yh4TA6oTGd4xhLowf+cWZMY73+7AZmfXJJsBi4cej/hH+4wlAgxFIrnOYnr/18IpnZbsHf0eGm1BhahX74+cVR0TRmNQmYC7GhCNS3mv/3MJn74lCj7t28aBJPjEZhP9fGXdG2u5Egh/Tjdg=) (158 bytes): A port of my [entry](https://tic80.com/play?cart=1873) in the Outline'21 bytebattle quater final
* [Font & Palette](v0.1pre4#AgKaeeOuwg5gCKvFIeiitEwMpUI2rymEcu+DDB1vMu9uBoufvUxIr4Y5p4Jj2ukoNO4PE7QS5cN1ZyDMCRfSzYIGZxKlN2J6NKEWK7KVPk9wVUgn1Ip+hsMinWgEO8ETKfPuHoIa4kjI+ULFOMad7vd3rt/lh1Vy9w+R2MXG/7T61d3c7C6KY+eQNS0eW3ys4iU8R6SycuWZuuZ2Sg3Qxp826s+Kt+2qBojpzNOSoyFqyrVyYMTKEkSl0BZOj59Cs1hPm5bq0F1MmVhGAzMhW9V4YeAe): Just a simple viewer for the default font and palette. * [Font & Palette](v0.1pre4#AgKaeeOuwg5gCKvFIeiitEwMpUI2rymEcu+DDB1vMu9uBoufvUxIr4Y5p4Jj2ukoNO4PE7QS5cN1ZyDMCRfSzYIGZxKlN2J6NKEWK7KVPk9wVUgn1Ip+hsMinWgEO8ETKfPuHoIa4kjI+ULFOMad7vd3rt/lh1Vy9w+R2MXG/7T61d3c7C6KY+eQNS0eW3ys4iU8R6SycuWZuuZ2Sg3Qxp826s+Kt+2qBojpzNOSoyFqyrVyYMTKEkSl0BZOj59Cs1hPm5bq0F1MmVhGAzMhW9V4YeAe): Just a simple viewer for the default font and palette.

File diff suppressed because one or more lines are too long

View File

@@ -19,16 +19,18 @@ fn main() -> Result<()> {
match args.subcommand()?.as_ref().map(|s| s.as_str()) { match args.subcommand()?.as_ref().map(|s| s.as_str()) {
Some("run") => run(args), Some("run") => run(args),
Some("pack") => pack(args), Some("pack") => pack(args),
Some(other) => { Some("filter-exports") => filter_exports(args),
eprintln!("Unknown command '{}'", other); Some("help") | None => {
process::exit(1);
}
None => {
println!("Usage:"); println!("Usage:");
println!(" uw8 run [-w/--watch] [-p/--pack] [-u/--uncompressed] [-l/--level] [-o/--output <out-file>] <file>"); println!(" uw8 run [-w/--watch] [-p/--pack] [-u/--uncompressed] [-l/--level] [-o/--output <out-file>] <file>");
println!(" uw8 pack [-u/--uncompressed] [-l/--level] <in-file> <out-file>"); println!(" uw8 pack [-u/--uncompressed] [-l/--level] <in-file> <out-file>");
println!(" uw8 filter-exports <in-wasm> <out-wasm>");
Ok(()) Ok(())
} }
Some(other) => {
eprintln!("Unknown command '{}'", other);
process::exit(1);
}
} }
} }
@@ -153,3 +155,12 @@ fn pack(mut args: Arguments) -> Result<()> {
Ok(()) Ok(())
} }
fn filter_exports(mut args: Arguments) -> Result<()> {
let in_file = args.free_from_os_str::<PathBuf, bool>(|s| Ok(s.into()))?;
let out_file = args.free_from_os_str::<PathBuf, bool>(|s| Ok(s.into()))?;
uw8_tool::filter_exports(&in_file, &out_file)?;
Ok(())
}

100
uw8-tool/Cargo.lock generated
View File

@@ -56,6 +56,21 @@ dependencies = [
"lazy_static", "lazy_static",
] ]
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "id-arena"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005"
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@@ -74,6 +89,15 @@ version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "log"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if",
]
[[package]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.14" version = "0.2.14"
@@ -101,6 +125,24 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468" checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468"
[[package]]
name = "proc-macro2"
version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [
"proc-macro2",
]
[[package]] [[package]]
name = "sacabase" name = "sacabase"
version = "2.0.0" version = "2.0.0"
@@ -110,6 +152,17 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "syn"
version = "1.0.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]] [[package]]
name = "time" name = "time"
version = "0.1.44" version = "0.1.44"
@@ -121,6 +174,18 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]] [[package]]
name = "upkr" name = "upkr"
version = "0.1.0" version = "0.1.0"
@@ -140,8 +205,35 @@ dependencies = [
"pbr", "pbr",
"pico-args", "pico-args",
"upkr", "upkr",
"walrus",
"wasm-encoder", "wasm-encoder",
"wasmparser", "wasmparser 0.81.0",
]
[[package]]
name = "walrus"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb08e48cde54c05f363d984bb54ce374f49e242def9468d2e1b6c2372d291f8"
dependencies = [
"anyhow",
"id-arena",
"leb128",
"log",
"walrus-macro",
"wasmparser 0.77.0",
]
[[package]]
name = "walrus-macro"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a6e5bd22c71e77d60140b0bd5be56155a37e5bd14e24f5f87298040d0cc40d7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
] ]
[[package]] [[package]]
@@ -159,6 +251,12 @@ dependencies = [
"leb128", "leb128",
] ]
[[package]]
name = "wasmparser"
version = "0.77.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35c86d22e720a07d954ebbed772d01180501afe7d03d464f413bb5f8914a8d6"
[[package]] [[package]]
name = "wasmparser" name = "wasmparser"
version = "0.81.0" version = "0.81.0"

View File

@@ -8,6 +8,7 @@ edition = "2021"
[dependencies] [dependencies]
wasmparser = "0.81" wasmparser = "0.81"
wasm-encoder = "0.8" wasm-encoder = "0.8"
walrus = "0.19"
anyhow = "1" anyhow = "1"
pico-args = "0.4" pico-args = "0.4"
upkr = { git = "https://github.com/exoticorn/upkr.git", rev = "2e7983fc" } upkr = { git = "https://github.com/exoticorn/upkr.git", rev = "2e7983fc" }

View File

@@ -1,5 +1,7 @@
mod base_module; mod base_module;
mod pack; mod pack;
mod filter_exports;
pub use base_module::BaseModule; pub use base_module::BaseModule;
pub use pack::{pack, pack_file, unpack, unpack_file, PackConfig}; pub use pack::{pack, pack_file, unpack, unpack_file, PackConfig};
pub use filter_exports::filter_exports;

View File

@@ -27,6 +27,11 @@ fn main() -> Result<()> {
let dest: PathBuf = args.free_from_str()?; let dest: PathBuf = args.free_from_str()?;
uw8_tool::unpack_file(&source, &dest)?; uw8_tool::unpack_file(&source, &dest)?;
} }
"filter-exports" => {
let source: PathBuf = args.free_from_str()?;
let dest: PathBuf = args.free_from_str()?;
uw8_tool::filter_exports(&source, &dest)?;
}
_ => { _ => {
eprintln!("Unknown subcommand '{}'", cmd); eprintln!("Unknown subcommand '{}'", cmd);
print_help(); print_help();
@@ -44,6 +49,7 @@ fn print_help() {
"Usage: "Usage:
uw8-tool make-base <version> uw8-tool make-base <version>
uw8-tool pack <wasm file> <uw8 file> uw8-tool pack <wasm file> <uw8 file>
uw8-tool unpack <uw8 file> <wasm file>" uw8-tool unpack <uw8 file> <wasm file>
uw8-tool filter-exports <wasm file> <wasm file>"
); );
} }