-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
executable file
·106 lines (93 loc) · 2.81 KB
/
build.sh
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
#################################
# compile time decoder settings #
#################################
# EMSCRIPTEN_PATH
# Path to emscripten SDK.
# Change this if you have emscripten already installed somewhere
# and/or dont want to use the auto installation.
# (auto install script is under bin/install_emscripten.sh)
EMSCRIPTEN_PATH=../emsdk/emsdk_env.sh
# CHUNK_SIZE
# Maximum size of a single chunk, that can be loaded into the decoder.
# This has only a tiny impact on the decoder speed, thus we can go with
# a rather low value (aligned with typical PIPE_BUF values).
# Use one of 2 ^ (8 .. 16).
CHUNK_SIZE=16384
# PALETTE_SIZE
# Maximum color slots the internal palette may hold.
# Most SIXEL images never request more than 256 colors (demanded by the spec).
# We use a much higher default of 4096, thus can deal up to 12bit-RGB.
# Use one of 2 ^ (8 .. 16).
PALETTE_SIZE=4096
# MAX_WIDTH
# Maximum width of a pixel line the decoder can handle.
# Changing this will also change the memory needs below.
# This value must be a multiple of 128 to stay in line with the clear logic.
MAX_WIDTH=16384
# MEMORY
# Memory used by an instance. Formula is roughly MAX_WIDTH * 4 * 6 + 65536.
MEMORY=$((7 * 65536))
##################
# compile script #
##################
# activate emscripten env
source $EMSCRIPTEN_PATH
# compile with customizations
emcc -O3 \
-DCHUNK_SIZE=$CHUNK_SIZE \
-DPALETTE_SIZE=$PALETTE_SIZE \
-DMAX_WIDTH=$MAX_WIDTH \
-s ASSERTIONS=0 \
-s IMPORTED_MEMORY=0 \
-s MALLOC=none \
-s ALLOW_MEMORY_GROWTH=0 \
-s SAFE_HEAP=0 \
-s WARN_ON_UNDEFINED_SYMBOLS=0 \
-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
-s DISABLE_EXCEPTION_CATCHING=1 \
-s DEFAULT_TO_CXX=0 \
-s STRICT=1 \
-s SUPPORT_ERRNO=0 \
-s TOTAL_STACK=0 \
-s INITIAL_MEMORY=$MEMORY \
-s MAXIMUM_MEMORY=$MEMORY \
-s EXPORTED_FUNCTIONS='[
"_init",
"_decode",
"_current_width",
"_get_state_address",
"_get_chunk_address",
"_get_p0_address",
"_get_palette_address"
]' \
--no-entry -mbulk-memory decoder.cpp -o decoder.wasm
# export compile time settings with settings.json
echo "{\"CHUNK_SIZE\": $CHUNK_SIZE, \"PALETTE_SIZE\": $PALETTE_SIZE, \"MAX_WIDTH\": $MAX_WIDTH}" > settings.json
# SIMD test
#emcc -O3 \
#-DCHUNK_SIZE=$CHUNK_SIZE \
#-DPALETTE_SIZE=$PALETTE_SIZE \
#-DMAX_WIDTH=$MAX_WIDTH \
#-s ASSERTIONS=0 \
#-s IMPORTED_MEMORY=0 \
#-s MALLOC=none \
#-s ALLOW_MEMORY_GROWTH=0 \
#-s SAFE_HEAP=0 \
#-s WARN_ON_UNDEFINED_SYMBOLS=0 \
#-s ERROR_ON_UNDEFINED_SYMBOLS=0 \
#-s DISABLE_EXCEPTION_CATCHING=1 \
#-s DEFAULT_TO_CXX=0 \
#-s STRICT=1 \
#-s SUPPORT_ERRNO=0 \
#-s TOTAL_STACK=0 \
#-s INITIAL_MEMORY=$((145 * 65536)) \
#-s MAXIMUM_MEMORY=$((145 * 65536)) \
#-s EXPORTED_FUNCTIONS='[
# "_init",
# "_decode",
# "_get_chunk_address",
# "_get_canvas_address",
# "_get_palette_address"
#]' \
#--no-entry -msimd128 -msse -msse2 -msse4.1 decoder-simd.cpp -o decoder-simd.wasm