-
Notifications
You must be signed in to change notification settings - Fork 85
/
build-and-run
executable file
·91 lines (80 loc) · 2.31 KB
/
build-and-run
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
#!/usr/bin/env bash
#
# © 2018-2019 Konstantin Gredeskoul, All Rights Reserved.
# MIT License
#
# WARNING: This BASH script is completely optional. You don't need it to build this project.
#
# If you choose to run this script to build the project, run:
#
# $ ./build-and-run
#
# It will clean, build and run the tests.
#
[[ -z $(which git) ]] && {
echo "You need git installed. Please run 'xcode-select --install' first."
exit 1
}
export BashMatic="${HOME}/.bashmatic"
[[ ! -f "${BashMatic}/init.sh" ]] && {
bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -l"
}
source "${BashMatic}/init.sh"
export ProjectRoot=$(pwd)
export BuildDir="${ProjectRoot}/build/run"
export BashLibRoot="${ProjectRoot}/bin/lib-bash"
export LibBashRepo="https://github.com/kigster/lib-bash"
simple.header() {
h1.purple "Simple Tokenizer"
local OIFC=${IFC}
IFS="|" read -r -a gcc_info <<< "$(gcc --version 2>&1 | tr '\n' '|')"
export IFC=${OIFC}
h1 "${bldylw}GCC" "${gcc_info[1]}" "${gcc_info[2]}" "${gcc_info[3]}" "${gcc_info[4]}"
h1 "${bldylw}GIT: ${bldblu}$(git --version)"
h1 "${bldylw}CMAKE: ${bldblu}$(cmake --version | tr '\n' ' ')"
}
simple.setup() {
hl.subtle "Creating Build Folder..."
run "mkdir -p build/run"
}
simple.clean() {
hl.subtle "Cleaning output folders..."
run 'rm -rf bin/* include/* lib/* build/*'
}
simple.build() {
hl.subtle "build..."
run "cd build/run"
find . -name "*.gcda" -print0 | xargs -0 rm
run "cmake -DCODE_COVERAGE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=${ProjectRoot}/output ../.."
run.set-next show-output-on
run "make -j 12"
run "make install | egrep -v 'gmock|gtest'"
run "cd ${ProjectRoot}"
}
simple.tests() {
hl.subtle "testing..."
run.set-all show-output-on
run "cd build/run"
run "ctest . -V"
run "cd ${ProjectRoot}"
}
simple.example() {
[[ ! -f ./output/bin/sqlite3 ]] && {
error "You don't have the cmpiled sqlite3 binary yet".
exit 3
}
hl.subtle "run example..."
run "cd output/bin/"
run "cat ${ProjectRoot}/example.sql ${ProjectRoot}/example-jieba.sql | ./sqlite3"
run "./simple_cpp_example"
run "cd ${ProjectRoot}"
run "python3 examples/python3/db_connector.py './output/bin/libsimple'"
}
main() {
simple.header
simple.setup
simple.build
simple.tests
simple.example
}
(( $_s_ )) || main