forked from OpenDroneMap/ODM
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure_macos.sh
executable file
·121 lines (100 loc) · 3.15 KB
/
configure_macos.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
117
118
119
120
121
#!/bin/bash
uname=$(uname)
if [[ "$uname" != "Darwin" ]]; then
echo "This script is meant for MacOS only."
exit 1
fi
if [[ $2 =~ ^[0-9]+$ ]] ; then
processes=$2
else
processes=$(sysctl -n hw.ncpu)
fi
ensure_prereqs() {
export DEBIAN_FRONTEND=noninteractive
if ! command -v xcodebuild &> /dev/null; then
echo "You need to install Xcode first. Go to the App Store and download Xcode"
exit 1
fi
if ! command -v brew &> /dev/null; then
echo "You need to install Homebrew first. https://brew.sh/"
exit 1
fi
}
installreqs() {
ensure_prereqs
brew install cmake gcc@12 python@3.8 tbb@2020 eigen gdal boost cgal libomp
brew link tbb@2020
python3.8 -m pip install virtualenv
if [ ! -e ${RUNPATH}/venv ]; then
python3.8 -m virtualenv venv
fi
source venv/bin/activate
pip install --ignore-installed -r requirements.txt
}
install() {
installreqs
echo "Compiling SuperBuild"
cd ${RUNPATH}/SuperBuild
mkdir -p build && cd build
cmake .. && make -j$processes
cd /tmp
pip download GDAL==3.6.2
tar -xpzf GDAL-3.6.2.tar.gz
cd GDAL-3.6.2
if [ -e /opt/homebrew/bin/gdal-config ]; then
python setup.py build_ext --gdal-config /opt/homebrew/bin/gdal-config
else
python setup.py build_ext --gdal-config /usr/local/bin/gdal-config
fi
python setup.py build
python setup.py install
rm -fr /tmp/GDAL-3.6.2 /tmp/GDAL-3.6.2.tar.gz
cd ${RUNPATH}
echo "Configuration Finished"
}
uninstall() {
echo "Removing SuperBuild and build directories"
cd ${RUNPATH}/SuperBuild
rm -rfv build src download install
cd ../
rm -rfv build
}
reinstall() {
echo "Reinstalling ODM modules"
uninstall
install
}
clean() {
rm -rf \
${RUNPATH}/SuperBuild/build \
${RUNPATH}/SuperBuild/download \
${RUNPATH}/SuperBuild/src
# find in /code and delete static libraries and intermediate object files
find ${RUNPATH} -type f -name "*.a" -delete -or -type f -name "*.o" -delete
}
usage() {
echo "Usage:"
echo "bash configure.sh <install|update|uninstall|installreqs|help> [nproc]"
echo "Subcommands:"
echo " install"
echo " Installs all dependencies and modules for running OpenDroneMap"
echo " reinstall"
echo " Removes SuperBuild and build modules, then re-installs them. Note this does not update OpenDroneMap to the latest version. "
echo " uninstall"
echo " Removes SuperBuild and build modules. Does not uninstall dependencies"
echo " installreqs"
echo " Only installs the requirements (does not build SuperBuild)"
echo " clean"
echo " Cleans the SuperBuild directory by removing temporary files. "
echo " help"
echo " Displays this message"
echo "[nproc] is an optional argument that can set the number of processes for the make -j tag. By default it uses $(nproc)"
}
if [[ $1 =~ ^(install|installruntimedepsonly|reinstall|uninstall|installreqs|clean)$ ]]; then
RUNPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
"$1"
else
echo "Invalid instructions." >&2
usage
exit 1
fi