forked from foxglove/wasm-zstd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·47 lines (44 loc) · 2.26 KB
/
build.sh
File metadata and controls
executable file
·47 lines (44 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -euo pipefail
mkdir -p dist
emcc \
vendor/zstd/lib/common/debug.c \
vendor/zstd/lib/common/entropy_common.c \
vendor/zstd/lib/common/error_private.c \
vendor/zstd/lib/common/fse_decompress.c \
vendor/zstd/lib/common/pool.c \
vendor/zstd/lib/common/threading.c \
vendor/zstd/lib/common/xxhash.c \
vendor/zstd/lib/common/zstd_common.c \
vendor/zstd/lib/compress/fse_compress.c \
vendor/zstd/lib/compress/hist.c \
vendor/zstd/lib/compress/huf_compress.c \
vendor/zstd/lib/compress/zstd_compress.c \
vendor/zstd/lib/compress/zstd_compress_literals.c \
vendor/zstd/lib/compress/zstd_compress_sequences.c \
vendor/zstd/lib/compress/zstd_compress_superblock.c \
vendor/zstd/lib/compress/zstd_double_fast.c \
vendor/zstd/lib/compress/zstd_fast.c \
vendor/zstd/lib/compress/zstd_lazy.c \
vendor/zstd/lib/compress/zstd_ldm.c \
vendor/zstd/lib/compress/zstd_opt.c \
vendor/zstd/lib/compress/zstdmt_compress.c \
vendor/zstd/lib/decompress/huf_decompress.c \
vendor/zstd/lib/decompress/zstd_ddict.c \
vendor/zstd/lib/decompress/zstd_decompress.c \
vendor/zstd/lib/decompress/zstd_decompress_block.c \
-o dist/wasm-zstd.js src/wasm-zstd.c `# this runs emscripten on the code in wasm-zstd.c` \
-O3 `# compile with all optimizations enabled` \
-s WASM=1 `# compile to .wasm instead of asm.js` \
-s MODULARIZE=1 `# expose a module factory instead of mutating globals` \
-s EXPORT_ES6=1 `# emit an ES module that Vite can bundle` \
-s ENVIRONMENT=web,worker `# avoid Node-only fs/path/require branches in browser builds` \
-s NO_EXIT_RUNTIME=1 `# keep the process around after main exits` \
-s TOTAL_STACK=1048576 `# use a 1MB stack size instead of the default 5MB` \
-s INITIAL_MEMORY=2097152 `# start with a 2MB allocation instead of 16MB, we will dynamically grow` \
-s ALLOW_MEMORY_GROWTH=1 `# need this because we don't know how large decompressed blocks will be` \
-s NODEJS_CATCH_EXIT=0 `# we don't use exit() and catching exit will catch all exceptions` \
-s NODEJS_CATCH_REJECTION=0 `# prevent emscripten from adding an unhandledRejection handler` \
-s "EXPORTED_FUNCTIONS=['_malloc', '_free']" `# index.js uses Module._malloc and Module._free`
cp src/index.js dist/index.js
node scripts/patch-emscripten-output.mjs