-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
install-macos-framework.sh
executable file
·37 lines (30 loc) · 1.15 KB
/
install-macos-framework.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
#!/bin/bash
set -xeu
macos_version="$(sw_vers -productVersion)"
dist_dir="$HOME/dist/"
base_dir="$HOME/build/opencv/"
build_dir="$base_dir/opencv-$OPENCV_VERSION-build/"
mkdir -p "$dist_dir" "$base_dir" "$build_dir"
# if the build framework already present assume it's the current version and skip build to save time
# the build_framework.py doesn't seem to handle the rebuild with unchanged sources too well and does a full rebuild
if [[ -d "$build_dir/opencv2.framework" ]]; then
exit 0
fi
opencv_src="$dist_dir/opencv-$OPENCV_VERSION"
if [ ! -d "$opencv_src" ]; then
curl -L "https://github.com/opencv/opencv/archive/$OPENCV_VERSION.tar.gz" | tar -xz -C "$dist_dir"
fi
opencv_contrib_src="$dist_dir/opencv_contrib-$OPENCV_VERSION"
if [ ! -d "$opencv_contrib_src" ]; then
curl -L "https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.tar.gz" | tar -xz -C "$dist_dir"
fi
if [[ "$OPENCV_VERSION" == "3.4.20" ]]; then # old OpenCV doesn't support choosing archs
arch_arg=
else
arch_arg="--macos_archs $(uname -m)"
fi
python "$opencv_src/platforms/osx/build_framework.py" \
--contrib "$opencv_contrib_src" \
--enable_nonfree \
$arch_arg \
"$build_dir"