File tree Expand file tree Collapse file tree 1 file changed +49
-3
lines changed Expand file tree Collapse file tree 1 file changed +49
-3
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -e
4
+ SELF_DIR=" $( dirname $( readlink -f $0 ) ) "
5
+ cd " $SELF_DIR "
6
+
7
+ function set_flag() {
8
+ local append=false
9
+
10
+ if [[ " $1 " == " --append" ]]; then
11
+ shift
12
+ append=true
13
+ fi
14
+
15
+ local var=" $1 " ; shift
16
+ declare -n ref=" $var "
17
+ if [[ " $ref " == " " ]]; then
18
+ ref=" $@ "
19
+ elif [[ " $append " == true ]]; then
20
+ ref=" $ref $@ "
21
+ fi
22
+ }
23
+
24
+ COMMON_FLAGS=" -I ../include -shared -fPIC -s -O3 -ldl"
25
+ DEFAULT_CXXFLAGS=" -std=c++11 $COMMON_FLAGS "
26
+ DEFAULT_CFLAGS=" $COMMON_FLAGS "
27
+ DEFAULT_LDFLAGS=" "
28
+ DEFAULT_CXX=g++
29
+ DEFAULT_CC=gcc
30
+
31
+ set_flag CC $DEFAULT_CC
32
+ set_flag CXX $DEFAULT_CXX
33
+ set_flag --append CFLAGS $DEFAULT_CFLAGS
34
+ set_flag --append CXXFLAGS $DEFAULT_CXXFLAGS
35
+ set_flag --append LDFLAGS $DEFAULT_LDFLAGS
36
+
37
+ while [[ " $1 " x != " " x ]]; do
38
+ arg=" $1 " ; shift
39
+ case " $arg " in
40
+ --cxxflags=* ) CXXFLAGS=" ${arg## --cxxflags=} " ;;
41
+ --ldflags=* ) LDFLAGS=" ${arg## --ldflags=} " ;;
42
+ " --" ) break ;;
43
+ esac
44
+ done
45
+
1
46
mkdir -p build
2
47
cd build
3
48
mkdir -p imports
4
- gcc -I ../include -fPIC -s -O3 -c ../sqlite3.c
5
- g++ -std=c++11 -I ../include -shared -fPIC -s -O3 ../sqlite.cpp ./sqlite3.o -o ./imports/sqlite.cse
6
- rm sqlite3.o
49
+ $CC $CFLAGS -c ../sqlite3.c
50
+ $CXX $CXXFLAGS ../sqlite.cpp ./sqlite3.o $LDFLAGS -o ./imports/sqlite.cse
51
+ rm ./sqlite3.o
52
+
You can’t perform that action at this time.
0 commit comments