-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathemcc-cvmfs
executable file
·59 lines (47 loc) · 1.17 KB
/
emcc-cvmfs
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
#!/bin/bash
set -e
SRC_DIR="$( cd "$( dirname "$0" )" && pwd )"
FS_DIR=$SRC_DIR/fs
SWCACHE_DIR=$SRC_DIR/sw-cache
EMC=emcc
if [ $1 == "em++" ]; then
EMC=em++
shift
fi
OUTPUT_DIR=""
OUTPUT_JS="a.out.js"
SWCACHE=0
SWCACHE_OPTS=""
i=1
while [ "$i" -le "$#" ]; do
eval "arg=\${$i}"
if [[ $arg == "-o" ]]; then
i=$((i + 1))
eval "OUTPATH=\${$i}"
OUTPUT_DIR=$(dirname $OUTPATH)
OUTFILE=$(basename $OUTPATH)
if [[ $OUTFILE == *.html || $OUTFILE == *.js ]]; then
OUTPUT_JS=$OUTPUT_DIR/${OUTFILE%*.*}.js
else
echo "Please specify either an HTML or JavaScript output." && exit -1
fi
elif [[ $arg == "-swcache" ]]; then
SWCACHE=1
SWCACHE_OPTS="--pre-js $SWCACHE_DIR/sw-pre.js"
set -- "${@:1:i-1}" "${@:i+1}" # clear ith argument
fi
i=$((i + 1))
done
$SRC_DIR/generate-cvmfs.sh
$EMC $* \
--js-library $FS_DIR/library_cvmfs.js \
--js-library $FS_DIR/library_fs.js \
--pre-js $SRC_DIR/cvmfs.js \
$SWCACHE_OPTS
if [ $SWCACHE -eq 1 ]; then
cp $SWCACHE_DIR/sw-cache.js $OUTPUT_DIR
fi
OUTPUT_JS_TMP=$OUTPUT_JS.tmp
cat $SRC_DIR/third_party/sql.js > $OUTPUT_JS_TMP
cat $OUTPUT_JS >> $OUTPUT_JS_TMP
mv $OUTPUT_JS_TMP $OUTPUT_JS