-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·77 lines (64 loc) · 1.28 KB
/
build.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
#!/bin/bash
#!/bin/bash
BUILD_DIRECTORY_NAME=build
MODULES=(m_common m_hash m_mem m_str m_list m_map m_lrucache m_args)
function print_help {
echo "$0 <module|all|help> [--install]"
echo
echo "Supported modules are"
for module in ${MODULES[@]}
do
echo " - $module"
done
}
function build {
BUILD_DIR=$1/$BUILD_DIRECTORY_NAME
if [[ ! -d $BUILD_DIR ]]; then
mkdir $BUILD_DIR
fi
cd $BUILD_DIR
cmake ..
make
if [[ "$INSTALL" == "--install" ]]; then
sudo make install
fi
cd ../..
}
if [ "$#" -lt 1 ]; then
print_help
exit 1
elif [ "$#" -eq 2 ]; then
if [[ "$2" != "--install" ]]; then
print_help
exit 2
fi
elif [ "$#" -gt 2 ]; then
print_help
exit 3
fi
INSTALL=$2
case $1 in
"all")
for module in "${MODULES[@]}"
do
build $module
done
;;
"help")
print_help
;;
*)
module=$1
declare -A module_map_helper
for key in "${!MODULES[@]}"
do
module_map_helper[${MODULES[$key]}]="$key"
done
if [[ -n "${module_map_helper[$module]}" ]]
then
build $module
else
echo "Not supported module"
fi
;;
esac