Skip to content

Commit e143bc0

Browse files
committed
[OVPN3-129] android: improve build system in order to perform full build
the scripts/android/build-all script is now in charge of performing all the steps required to build a full android core. Signed-off-by: Antonio Quartulli <[email protected]>
1 parent 06d23ec commit e143bc0

File tree

6 files changed

+106
-22
lines changed

6 files changed

+106
-22
lines changed

javacli/build-android

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ fi
3131
echo SWIG
3232
swig -c++ -java -package $pkg -I$O3/core/client -I$O3/core ovpncli.i
3333

34-
for TARGET in android-a7a android-a8a android-x86; do
34+
TARGETS=${TARGETS:-android-a7a android-a8a android-x86}
35+
36+
for TARGET in $TARGETS; do
3537

3638
if [ "$DEBUG_BUILD" = "1" ]; then
3739
. ../vars/vars-${TARGET}-dbg
@@ -63,6 +65,7 @@ echo CORE $ABI
6365
$GPP_CMD \
6466
$CXX_COMPILER_FLAGS \
6567
$PLATFORM_FLAGS \
68+
$OTHER_COMPILER_FLAGS \
6669
$LIB_OPT_LEVEL $LIB_FPIC \
6770
-Wall -Wno-sign-compare -Wno-unused-parameter \
6871
-Wno-unused-local-typedefs \
@@ -85,6 +88,7 @@ echo WRAP $ABI
8588
$GPP_CMD \
8689
$CXX_COMPILER_FLAGS \
8790
$PLATFORM_FLAGS \
91+
$OTHER_COMPILER_FLAGS \
8892
$opt2 $LIB_FPIC \
8993
-fno-strict-aliasing \
9094
-Wall \

scripts/android/build-all

+33-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,36 @@
11
#!/usr/bin/env bash
2-
# Build Android dependencies (run after build-toolchain)
2+
# Build the entire core package as required by Android App
33
set -e
44
if [ -z "$O3" ]; then
5-
echo O3 var must point to ovpn3 tree ; exit 1
5+
echo O3 var must point to ovpn3 tree
6+
exit 1
67
fi
7-
export DEP_DIR=${DEP_DIR:-$HOME/src/android}
8+
9+
[ -z "$ECHO" ] && ECHO=0
10+
11+
if [ "$ECHO" -eq 0 ]; then
12+
exec > $O3/android_build.log
13+
exec 2>&1
14+
fi
15+
16+
[ -z "$DEP_DIR" ] && export DEP_DIR=${O3}/deps
17+
[ -z "$DL" ] && export DL=~/dl
18+
19+
mkdir -p $DEP_DIR
20+
mkdir -p $DL
21+
22+
export NO_MOD_PATH=1
23+
. $O3/core/vars/android-sdk-path
24+
25+
echo BUILD ANDROID SDK
26+
$O3/core/scripts/android/build-sdk
27+
28+
echo BUILD TOOLCHAIN
29+
$O3/core/scripts/android/build-toolchain
30+
31+
echo BUILD DEPS
832
cd $DEP_DIR
9-
rm -rf asio* boost* lz4* lzo* minicrypto openssl* polarssl* snappy* mbedtls*
33+
rm -rf asio* lz4* mbedtls* #lzo* boost* minicrypto openssl* polarssl* snappy*
1034
echo "******* ASIO"
1135
$O3/core/deps/asio/build-asio
1236
echo "******* MBEDTLS"
@@ -24,3 +48,8 @@ $O3/core/scripts/android/build-lz4
2448
#$O3/core/scripts/android/build-lzo
2549
#echo "******* SNAPPY"
2650
#$O3/core/scripts/android/build-snappy
51+
52+
echo BUILD CORE LIBRARY
53+
$O3/core/javacli/build-android
54+
55+
echo DONE.

scripts/android/build-lz4

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
set -e
44
if [ -z "$O3" ]; then
5-
echo O3 var must point to ovpn3 tree ; exit 1
5+
echo O3 var must point to ovpn3 tree
6+
exit 1
67
fi
78
if [ -z "$DEP_DIR" ]; then
8-
echo DEP_DIR var must point to ovpn3 dependency tree
9+
echo DEP_DIR var must point to the dependency build directory
910
exit 1
1011
fi
11-
cd $DEP_DIR
1212

1313
. $O3/core/vars/android-sdk-path
1414

15+
cd $DEP_DIR
1516
rm -rf lz4
1617
mkdir lz4
1718

18-
for target in android-a8a android-a8a-dbg \
19-
android-a7a android-a7a-dbg \
20-
android android-dbg \
21-
android-x86 ; do
19+
TARGETS=${TARGETS:-android-a7a android-a8a android-x86}
20+
21+
for target in $TARGETS; do
2222
echo '***************' TARGET $target
2323
TARGET=$target $O3/core/deps/lz4/build-lz4
2424
done

scripts/android/build-mbedtls

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@
22

33
set -e
44
if [ -z "$O3" ]; then
5-
echo O3 var must point to ovpn3 tree ; exit 1
5+
echo O3 var must point to ovpn3 tree
6+
exit 1
67
fi
8+
79
if [ -z "$DEP_DIR" ]; then
8-
echo DEP_DIR var must point to ovpn3 dependency tree
10+
echo DEP_DIR var must point to the dependency build directory
911
exit 1
1012
fi
11-
cd $DEP_DIR
1213

1314
. $O3/core/vars/android-sdk-path
1415

16+
cd $DEP_DIR
17+
rm -rf mbedtls
18+
mkdir -p mbedtls
19+
1520
# disable minicrypto for now
1621
mini=0
1722

18-
rm -rf mbedtls
23+
TARGETS=${TARGETS:-android-a7a android-a8a android-x86}
1924

20-
for target in android-a8a android-a8a-dbg \
21-
android-a7a android-a7a-dbg \
22-
android android-dbg \
23-
android-x86; do
25+
for target in $TARGETS; do
2426
echo '***************' TARGET $target
2527
VERBOSE=1 TARGET=$target CMAKE_TARGET=android USE_MINICRYPTO=$mini MINICRYPTO_DIR=$(pwd)/minicrypto/minicrypto-$target $O3/core/deps/mbedtls/build-mbedtls
2628
[ "$ANDROID_DBG_ONLY" = "1" ] && exit

scripts/android/build-sdk

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
if [ -z "$O3" ]; then
5+
echo O3 var must point to ovpn3 tree
6+
exit 1
7+
fi
8+
9+
if [ -z "$DEP_DIR" ]; then
10+
echo DEP_DIR var must point to the dependency build directory
11+
exit 1
12+
fi
13+
14+
[ -z "$SDK" ] && export SDK=$DEP_DIR/android-sdk
15+
16+
if [ -d "$SDK" ]; then
17+
echo "Android SDK already exists at $SDK. Doing only update"
18+
yes | $SDK/tools/bin/sdkmanager --licenses
19+
$SDK/tools/bin/sdkmanager --update
20+
exit 0
21+
fi
22+
23+
. $O3/core/deps/functions.sh
24+
25+
FNAME=sdk-tools-linux-3859397.zip
26+
URL=https://dl.google.com/android/repository/${FNAME}
27+
CSUM=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0
28+
29+
download
30+
31+
cd $DEP_DIR
32+
rm -rf android-sdk
33+
mkdir android-sdk
34+
35+
. $O3/core/vars/android-sdk-path
36+
37+
cd $SDK
38+
unzip $DL/$FNAME
39+
40+
yes | $SDK/tools/bin/sdkmanager --licenses
41+
$SDK/tools/bin/sdkmanager --update
42+
$SDK/tools/bin/sdkmanager 'build-tools;26.0.2' \
43+
'ndk-bundle' \
44+
'extras;android;m2repository' \
45+
'patcher;v4' \
46+
'platform-tools' \
47+
'platforms;android-26' \
48+
'tools'
49+
50+
exit 0

vars/android-sdk-path

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# setup PATH for Android SDK and NDK
2-
AD=$HOME/src/android
3-
[ -z "$SDK" ] && export SDK=$AD/android-sdk-macosx
2+
[ -z "$SDK" ] && export SDK=$DEP_DIR/android-sdk
43
[ -z "$NDK" ] && export NDK=$SDK/ndk-bundle
54
if [ "$NO_MOD_PATH" != "1" ]; then
65
export PATH="$SDK/tools:$SDK/platform-tools:$PATH"

0 commit comments

Comments
 (0)