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" lto = "fat"
strip = true strip = true
panic = "abort" panic = "abort"
overflow-checks = false
debug-assertions = false
[profile.dev] [profile.dev]
debug = true 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 } emath = { git = "https://github.com/Titaniumtown/egui.git", default-features = false }
shadow-rs = { version = "0.11", default-features = false } shadow-rs = { version = "0.11", default-features = false }
const_format = { version = "0.2", default-features = false, features = [ const_format = { version = "0.2", default-features = false, features = ["fmt"] }
"fmt",
] }
cfg-if = "1" cfg-if = "1"
lazy_static = "1" lazy_static = "1"
tar = "0.4" tar = "0.4"
@ -71,9 +67,7 @@ async-lock = { version = "2.5", optional = true }
instant = { version = "0.1", features = ["wasm-bindgen"] } instant = { version = "0.1", features = ["wasm-bindgen"] }
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
wee_alloc = "0.4" wee_alloc = "0.4"
wasm-bindgen = { version = "0.2", default-features = false, features = [ wasm-bindgen = { version = "0.2", default-features = false, features = ["std"] }
"std",
] }
web-sys = "0.3" web-sys = "0.3"
tracing-wasm = "0.2" 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 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 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 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)" echo "Binary size (pre-wasm_opt): $(du -sb pkg/ytbn_graphing_software_bg.wasm)"
wasm_opt #apply wasm optimizations wasm_opt #apply wasm optimizations
echo "Binary size (pre-strip): $(du -sb pkg/ytbn_graphing_software_bg.wasm)" echo "Binary size (pre-strip): $(du -sb pkg/ytbn_graphing_software_bg.wasm)"
llvm-strip --strip-all pkg/ytbn_graphing_software_bg.wasm llvm-strip --strip-all pkg/ytbn_graphing_software_bg.wasm
elif test "$1" == "debug"; then 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 else
echo "ERROR: build.sh, argument invalid" echo "ERROR: build.sh, argument invalid"
exit 1 exit 1