build changes

This commit is contained in:
Simon Gardling 2022-04-26 23:24:53 -04:00
parent 5c9614f6b2
commit d1e89f9967
3 changed files with 6 additions and 13 deletions

View File

@ -1,3 +0,0 @@
[target.wasm32-unknown-unknown]
rustflags = ["-C", "linker-plugin-lto=yes", "-C", "inline-threshold=275"]

View File

@ -19,8 +19,6 @@ opt-level = "z" #optimize for size
lto = "fat"
strip = true
panic = "abort"
overflow-checks = false
debug-assertions = false
[profile.dev]
debug = true
@ -39,9 +37,7 @@ epi = { git = "https://github.com/Titaniumtown/egui.git", default-features = fal
emath = { git = "https://github.com/Titaniumtown/egui.git", default-features = false }
shadow-rs = { version = "0.11", default-features = false }
const_format = { version = "0.2", default-features = false, features = [
"fmt",
] }
const_format = { version = "0.2", default-features = false, features = ["fmt"] }
cfg-if = "1"
lazy_static = "1"
tar = "0.4"
@ -71,9 +67,7 @@ async-lock = { version = "2.5", optional = true }
instant = { version = "0.1", features = ["wasm-bindgen"] }
console_error_panic_hook = "0.1"
wee_alloc = "0.4"
wasm-bindgen = { version = "0.2", default-features = false, features = [
"std",
] }
wasm-bindgen = { version = "0.2", default-features = false, features = ["std"] }
web-sys = "0.3"
tracing-wasm = "0.2"

View File

@ -11,16 +11,18 @@ wasm_opt() {
wasm-opt -Oz -o pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
mv pkg/ytbn_graphing_software_bg_2.wasm pkg/ytbn_graphing_software_bg.wasm
}
#export RUSTFLAGS="--cfg=web_sys_unstable_apis"
export COMMON_PACK="--target web --no-typescript -- -Z build-std=std,panic_abort -C linker-plugin-lto=yes -C inline-threshold=275"
if test "$1" == "" || test "$1" == "release"; then
RUSTFLAGS=--cfg=web_sys_unstable_apis wasm-pack build --target web --release --no-typescript
wasm-pack build --release
echo "Binary size (pre-wasm_opt): $(du -sb pkg/ytbn_graphing_software_bg.wasm)"
wasm_opt #apply wasm optimizations
echo "Binary size (pre-strip): $(du -sb pkg/ytbn_graphing_software_bg.wasm)"
llvm-strip --strip-all pkg/ytbn_graphing_software_bg.wasm
elif test "$1" == "debug"; then
RUSTFLAGS=--cfg=web_sys_unstable_apis wasm-pack build --target web --dev --no-typescript
wasm-pack build --dev $COMMON_PACK
else
echo "ERROR: build.sh, argument invalid"
exit 1