File: android-build-freerdp.sh

package info (click to toggle)
freerdp2 2.0.0~git20190204.1.2693389a+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 22,772 kB
  • sloc: ansic: 307,908; xml: 1,676; sh: 770; perl: 231; makefile: 158; python: 65
file content (153 lines) | stat: -rwxr-xr-x 3,306 bytes parent folder | download | duplicates (2)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash

JPEG_TAG=master
OPENH264_TAG=master
OPENSSL_TAG=master

WITH_JPEG=0
WITH_OPENH264=0
WITH_OPENSSL=0

SRC_DIR=$(pwd)
BUILD_SRC=$(pwd)
BUILD_DST=$(pwd)

CMAKE_BUILD_TYPE=Debug
BUILD_DEPS=0

SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}")
source $SCRIPT_PATH/android-build-common.sh
source $SCRIPT_PATH/android-build.conf

# Parse arguments.
REMAINING=""
while [[ $# > 0 ]]
do
	key="$1"
	case $key in
		--freerdp-src)
			SRC_DIR="$2"
			shift
			;;
		--jpeg)
			WITH_JPEG=1
			shift
			;;
		--openh264)
			WITH_OPENH264=1
			shift
			;;
		--openssl)
			WITH_OPENSSL=1
			shift
			;;
		--debug)
			CMAKE_BUILD_TYPE=Debug
			shift
			;;
		--release)
			CMAKE_BUILD_TYPE=Release
			shift
			;;
		--relWithDebug)
			CMAKE_BUILD_TYPE=RelWithDebug
			shift
			;;
		--build-deps)
			BUILD_DEPS=1
			shift
			;;
		*)
			REMAINING="$REMAINING $key"
			shift
			;;
	esac
done
common_parse_arguments $REMAINING

# clean up top
if [ -d $BUILD_SRC ];
then
	common_clean $BUILD_SRC
fi

if [ -d $BUILD_DST ];
then
	common_run mkdir -p $BUILD_DST
fi

# Prepare the environment
common_run mkdir -p $BUILD_SRC

CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \
	-DANDROID_NATIVE_API_LEVEL=android-${NDK_TARGET} \
	-DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/cmake/AndroidToolchain.cmake \
	-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
	-DFREERDP_EXTERNAL_PATH=$BUILD_DST \
	-DCMAKE_MAKE_PROGRAM=make"

BASE=$(pwd)
for ARCH in $BUILD_ARCH
do
    # build dependencies.
    if [ $WITH_JPEG -ne 0 ];
    then
        if [ $BUILD_DEPS -ne 0 ];
        then
            common_run bash $SCRIPT_PATH/android-build-jpeg.sh \
                --src $BUILD_SRC/jpeg --dst $BUILD_DST \
                --ndk $ANDROID_NDK \
                --arch $ARCH \
                --target $NDK_TARGET \
                --tag $JPEG_TAG
        fi
        CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_JPEG=ON"
    else
        CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_JPEG=OFF"
    fi
    if [ $WITH_OPENH264 -ne 0 ];
    then
        if [ $BUILD_DEPS -ne 0 ];
        then
            common_run bash $SCRIPT_PATH/android-build-openh264.sh \
                --src $BUILD_SRC/openh264 --dst $BUILD_DST \
                --ndk $ANDROID_NDK \
                --arch $ARCH \
                --target $NDK_TARGET \
                --tag $OPENH264_TAG
        fi
        CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=ON"
    else
        CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=OFF"
    fi
    if [ $WITH_OPENSSL -ne 0 ];
    then
        if [ $BUILD_DEPS -ne 0 ];
        then
            common_run bash $SCRIPT_PATH/android-build-openssl.sh \
                --src $BUILD_SRC/openssl --dst $BUILD_DST \
                --ndk $ANDROID_NDK \
                --arch $ARCH \
		--target $NDK_TARGET \
                --tag $OPENSSL_TAG
        fi
    fi

    # Build and install the library.
    if [ $DEPS_ONLY -eq 0 ];
    then
	common_run cd $BASE
	common_run mkdir -p $BUILD_SRC/freerdp-build/$ARCH
	common_run cd $BUILD_SRC/freerdp-build/$ARCH
	common_run export ANDROID_NDK=$ANDROID_NDK
	common_run cmake $CMAKE_CMD_ARGS \
		-DANDROID_ABI=$ARCH \
		-DCMAKE_INSTALL_PREFIX=$BUILD_DST/$ARCH \
		-DCMAKE_INSTALL_LIBDIR=. \
		$SRC_DIR
	echo $(pwd)
	common_run cmake --build . --target install
    fi
done

echo "Successfully build library for architectures $BUILD_ARCH"