-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild_g++.sh
executable file
·117 lines (94 loc) · 2.55 KB
/
build_g++.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
#!/bin/bash
# todo:
cd $(git rev-parse --show-toplevel)
cd ./js_iteration_1/
# python ~/install/styleguide/cpplint/cpplint.py --linelength=1200 centroids_projection.cpp 2>lint.txt
# echo "@rem em++ -I /usr/local/inlcude/boost_1_61_0/ -s EXPORTED_FUNCTIONS="['_main']" -pedantic -std=c++14 -DNDEBUG -DBOOST_UBLAS_NDEBUG -DBOOST_DISABLE_ASSERTS -O3 vect_test_2.cpp -o vect_test_2.js"
#BOOST_FOLDER=/usr/local/include/boost_1_61_0
#BOOST_FOLDER=./boost_1_61_0
#if [ -z ${EM_PREPARE+x} ]
if [[ -n "$EM_PREPARE" ]]
then
echo ""
else
echo "First run \"source em_prepare.sh\""
exit
fi
OPTIM=0
SAVE_BC=0
TEMP=`getopt -o dob -l dev,opt,bitcode -- "$@"`
eval set -- "$TEMP"
# echo $TEMP
# extract options and their arguments into variables
USAGE=$'Usage: ./build_mcc2.sh [option]
-d or --dev for development version
-o or --opt for optimized version
-b or --bitcode to emit llvm Code'
if [ "$#" -lt 2 ]; then
echo "$USAGE"
exit 1
fi
while true; do
case "$1" in
-d|--dev)
OPTIM=0
shift
;;
-o|--opt)
OPTIM=1
shift
;;
-b|--bitcode)
SAVE_BC=1
shift
;;
--)
shift; break ;;
*) echo "Internal Error"; exit 1 ;;
esac
done
if [ $SAVE_BC -eq 1 ]
then
echo "Optimized version, bytecode will be emitted in the file " mcc2.ll
g++ \
--save-bc mcc2.bc \
-I $BOOST_FOLDER \
-I $EIGEN_LIB_FOLDER \
-O3 \
--profiling \
-DNDEBUG -DBOOST_UBLAS_NDEBUG -DBOOST_DISABLE_ASSERTS \
-Winline \
-s TOTAL_MEMORY=30100100 \
-s ABORTING_MALLOC=0 \
-pedantic -std=c++14 \
mcc2.cpp \
-o mcc2.compiled.js
echo "Producing human readable LLVM ... "
llvm-dis mcc2.bc -o mcc2.ll && rm mcc2.bc # transform to human-readable form and delete bytecode file.
exit 0
fi
if [ $OPTIM -eq 0 ]
then
echo "** dev version **"
EMCC_DEBUG=1
g++ -I $BOOST_FOLDER \
-I $EIGEN_LIB_FOLDER \
-pedantic -std=c++14 \
mcc2.cpp -o mcc2.compiled.js
# --profiling \
exit 0
fi
if [ $OPTIM -eq 1 ]
then
echo "** optimised version **"
g++ \
-I $BOOST_FOLDER \
-I $EIGEN_LIB_FOLDER \
-O3 \
-DNDEBUG -DBOOST_UBLAS_NDEBUG -DBOOST_DISABLE_ASSERTS \
-Winline \
-pedantic -std=c++14 \
mcc2.cpp \
-o mcc2.compiled.js
exit 0
fi