forked from bytedeco/javacpp-presets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cppbuild.sh
101 lines (94 loc) · 2.42 KB
/
cppbuild.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
#!/bin/bash
# Scripts to build and install native C++ libraries
KERNEL=(`uname -s | tr [A-Z] [a-z]`)
ARCH=(`uname -m | tr [A-Z] [a-z]`)
case $KERNEL in
darwin)
OS=macosx
;;
mingw*)
OS=windows
KERNEL=windows
if [[ $TARGET_CPU == "x64" ]]; then
ARCH=x86_64
fi
;;
*)
OS=$KERNEL
;;
esac
case $ARCH in
arm*)
ARCH=arm
;;
i386|i486|i586|i686)
ARCH=x86
;;
amd64|x86-64)
ARCH=x86_64
;;
esac
PLATFORM=$OS-$ARCH
echo "Detected platform \"$PLATFORM\""
while [[ $# > 0 ]]; do
case "$1" in
-platform)
shift
PLATFORM="$1"
;;
install)
OPERATION=install
;;
clean)
OPERATION=clean
;;
*)
PROJECTS+=("$1")
;;
esac
shift
done
echo "Targeting platform \"$PLATFORM\""
if [[ -z "$OPERATION" ]]; then
echo "Usage: ANDROID_NDK=/path/to/android-ndk/ bash cppbuild.sh [-platform <name>] [<install | clean>] [projects]"
echo "where platform includes: android-arm, android-x86, linux-x86, linux-x86_64, macosx-x86_64, windows-x86, windows-x86_64, etc."
exit 1
fi
if [[ -z "$ANDROID_NDK" ]]; then
ANDROID_NDK=~/projects/android/android-ndk/
fi
export ANDROID_NDK
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/4.6/"
case $PLATFORM in
android-x86)
export ANDROID_BIN="$ANDROID_NDK/toolchains/x86-4.6/prebuilt/$KERNEL-$ARCH/bin/i686-linux-android"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-9/arch-x86/"
;;
*)
export ANDROID_BIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/$KERNEL-$ARCH/bin/arm-linux-androideabi"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-9/arch-arm/"
;;
esac
function download {
COMMAND="curl -C - -L $1 -o $2"
echo "$COMMAND"
$COMMAND
}
if [[ ${#PROJECTS[@]} -eq 0 ]]; then
PROJECTS=(opencv ffmpeg flycapture libdc1394 libfreenect videoinput artoolkitplus)
fi
for PROJECT in ${PROJECTS[@]}; do
case $OPERATION in
install)
echo "Installing \"$PROJECT\""
mkdir $PROJECT/cppbuild
cd $PROJECT/cppbuild
source ../cppbuild.sh
cd ../..
;;
clean)
echo "Cleaning \"$PROJECT\""
rm -Rf $PROJECT/cppbuild
;;
esac
done