/
makeruby
executable file
·52 lines (42 loc) · 1.29 KB
/
makeruby
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
#!/bin/bash
FLAGS=" -fno-operator-names -fpermissive"
RELOOP=0
RUBY_LIB_PATH=lib
CLOSURE_JAR=/home/max/emscripten-workspace/closure/build/compiler.jar
RUN_CLOSURE=1
EMMAKEN=`pwd`/emscripten/tools/emmakenxx.py
EMSCRIPTEN=`pwd`/emscripten/emscripten.py
set -e
cd ruby-1.8.7
echo 'Compiling to LLVM...'
CFLAGS=$FLAGS RANLIB=$EMMAKEN AR=$EMMAKEN CXX=$EMMAKEN CC=$EMMAKEN ./configure --without-pthread
patch config.h < ../config.h.patch
make miniruby
echo 'Running Emscripten...'
$EMSCRIPTEN \
libruby-static.a.bc \
-m \
-O \
-o ruby.js \
-s EXCEPTION_DEBUG=0 \
-s CORRECT_SIGNS=1 \
-s CORRECT_OVERFLOWS=1 \
-s INVOKE_RUN=0 \
-s SAFE_HEAP=0 \
-s ASSERTIONS=0 \
-s OPTIMIZE=1 \
-s RELOOP=$RELOOP
echo 'Touching up...'
mkdir -p ../dist
cp ruby.js ../dist
cp -r lib ../dist
../map_filesystem.py lib/ >> ../dist/ruby.js
sed -i "s~\", \"./~\", \"./$RUBY_LIB_PATH/~" ../dist/ruby.js
cat ../entry_point.js >> ../dist/ruby.js
echo 'Running eliminator...'
coffee /home/max/emscripten-workspace/emscripten/tools/eliminator/eliminator.coffee < ../dist/ruby.js > ../dist/ruby.opt.js
if [ $RUN_CLOSURE -eq 1 ]; then
echo 'Running closure compiler...'
java -Xmx4g -jar $CLOSURE_JAR --compilation_level SIMPLE_OPTIMIZATIONS --js ../dist/ruby.opt.js --js_output_file ../dist/ruby.closure.js
fi;
echo 'Done.'