-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·106 lines (90 loc) · 3.19 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
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
#!/bin/bash
source $SCRIPT_PATH/build_scripts/expand_path.sh
usage_msg="Build script for setting up the DiFfRG library and its dependencies.
For configuration of build flags, please edit the config file.
Usage: build.sh [options]
Options:
-f Perform a full build and install of everything without confirmations.
-c Use CUDA when building the DiFfRG library.
-i <directory> Set the installation directory for the library.
-j <threads> Set the number of threads passed to make and git fetch.
--help Display this information.
"
# ##############################################################################
# Script setup
# ##############################################################################
threads='1'
full_inst='n'
INSTALLPATH=''
cuda_flag=''
config_file='config'
config_flag=''
while getopts :i:j:fcd flag; do
case "${flag}" in
d)
config_file="config_docker"
config_flag="-d"
;;
i) INSTALLPATH=${OPTARG} ;;
j) threads=${OPTARG} ;;
f) full_inst='y' ;;
c) cuda_flag="-c" ;;
?)
printf "${usage_msg}"
exit 2
;;
esac
done
# Get the path where this script is located
SCRIPTPATH="$(
cd -- "$(dirname "$0")" >/dev/null 2>&1
pwd -P
)"
LOGPATH=${SCRIPTPATH}/logs
mkdir -p ${LOGPATH}
# Obtain possibly user-defined configuration
source ${SCRIPTPATH}/${config_file}
# ##############################################################################
# Build bundled libraries
# ##############################################################################
git submodule update --init --recursive --jobs ${threads}
if [[ -z ${INSTALLPATH} ]]; then
echo
read -p "Install DiFfRG library globally to /opt/DiFfRG? [y/N/path] " INSTALLPATH
INSTALLPATH=${INSTALLPATH:-N}
fi
if [[ ${INSTALLPATH} == "y" ]]; then
INSTALLPATH="/opt/DiFfRG"
fi
if [[ ${INSTALLPATH} != "n" ]] && [[ ${INSTALLPATH} != "N" ]]; then
cd ${SCRIPTPATH}
# Make sure the install directory is absolute
idir=$(expandPath ${INSTALLPATH})
#idir=$(readlink --canonicalize ${idir})
echo "DiFfRG library will be installed in ${idir}"
# Install dependencies
start=$(date +%s)
cd ${SCRIPTPATH}/external
echo "Installing dependencies..."
bash ./install.sh -i ${idir}/bundled -j ${threads} ${cuda_flag} 2>&1 | tee ${LOGPATH}/DiFfRG_dependencies_install.log
end=$(date +%s)
runtime=$((end - start))
elapsed="Elapsed: $(($runtime / 3600))hrs $((($runtime / 60) % 60))min $(($runtime % 60))sec"
echo " Done. (${elapsed})"
echo
fi
# ##############################################################################
# Setup and build library
# ##############################################################################
if [[ "$full_inst" == "y" ]] && [[ "$INSTALLPATH" != "" ]]; then
bash ${SCRIPTPATH}/update_DiFfRG.sh -j ${threads} -m ${cuda_flag} ${config_flag} -i ${INSTALLPATH}
else
if [[ "$full_inst" == "y" ]]; then
bash ${SCRIPTPATH}/update_DiFfRG.sh -j ${threads} -m ${cuda_flag} ${config_flag}
else
bash ${SCRIPTPATH}/update_DiFfRG.sh -j ${threads} ${config_flag}
fi
fi
# ##############################################################################
# Finish
# ##############################################################################