forked from coolwanglu/vim.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·122 lines (101 loc) · 2.35 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -e
: ${EM_DIR:?"EM_DIR is not set!"}
# must be > 1
JOB_COUNT=6
do_config() {
echo config
# something wrong with emcc + cproto, use gcc as CPP instead
CPPFLAGS="-DFEAT_GUI_WEB" \
CPP="gcc -E" \
$EM_DIR/emconfigure ./configure \
--enable-gui=web \
--with-features=small \
--disable-selinux \
--disable-xsmp \
--disable-xmp-interact \
--disable-luainterp \
--disable-mzschemeinterp \
--disable-perlinterp \
--disable-pythoninterp \
--disable-python3interp \
--disable-tclinterp \
--disable-rubyinterp \
--disable-cscope \
--disable-workshop \
--disable-netbeans \
--disable-sniff \
--disable-multibye \
--disable-hangulinput \
--disable-xim \
--disable-fontset \
--disable-gtk2-check \
--disable-gnome-check \
--disable-motif-check \
--disable-athena-check \
--disable-nextaw-check \
--disable-carbon-check \
--disable-gtktest \
--disable-largefile \
--disable-acl \
--disable-gpm \
--disable-sysmouse \
--disable-nls \
--with-modified-by="Lu Wang" \
--with-compiledby="Lu Wang" \
}
do_make() {
$EM_DIR/emmake make
}
do_link() {
pushd web
cp ../src/vim vim.bc
#cp vim_lib.js usr/local/share/vim/example.js
cat vim_lib.js | sed -e "1 s/\(foldmethod\|foldmarker\)[^ ]\+//g" > usr/local/share/vim/example.js
# Use vim.js as filename to generate vim.js.mem
$EM_DIR/emcc vim.bc \
-o vim.js \
-O0 \
--closure 0 \
--memory-init-file 1 \
--js-library vim_lib.js \
-s EXPORTED_FUNCTIONS="['_main', '_input_available', '_gui_web_handle_key', '_gui_resize_shell']" \
--embed-file usr \
mv vim.js vim-1.js
popd
}
do_transform() {
pushd web
# vim-2._js is counted as a job
JOB_COUNT=$((JOB_COUNT-1))
echo "Transfoming..."
node transform.js vim-1.js vim-2 $JOB_COUNT
echo "Compiling with streamline.js..."
_node -li -c vim-2._js &
for ((i=0; i < JOB_COUNT; i++))
do
_node -li -c vim-2.$i._js &
done
wait
for ((i=0; i < JOB_COUNT; i++))
do
cat vim-2.$i.js >> vim-2.js
done
popd
}
do_compress() {
pushd web
echo "Optimizing with closure compiler"
#--compilation_level ADVANCED_OPTIMIZATIONS \
java -Xmx2048m \
-jar $EM_DIR/third_party/closure-compiler/compiler.jar \
--language_in ECMASCRIPT5 \
--js vim-2.js\
--js_output_file vim.js \
popd
}
do_config
do_make
do_link
do_transform
do_compress