2018-09-20 01:41:22 +00:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# This file is part of BOINC.
|
|
|
|
# http://boinc.berkeley.edu
|
2020-01-24 12:10:59 +00:00
|
|
|
# Copyright (C) 2020 University of California
|
2018-09-20 01:41:22 +00:00
|
|
|
#
|
|
|
|
# BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Lesser General Public License
|
|
|
|
# as published by the Free Software Foundation,
|
|
|
|
# either version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# BOINC is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2020-07-05 01:23:25 +00:00
|
|
|
# When you want to invalidate openssl and curl without change their versions.
|
|
|
|
export REV=1
|
2020-01-24 12:10:59 +00:00
|
|
|
export OPENSSL_VERSION=1.0.2s
|
2018-11-27 14:57:49 +00:00
|
|
|
export CURL_VERSION=7.62.0
|
2020-07-03 05:05:51 +00:00
|
|
|
export NDK_VERSION=21d
|
2018-09-26 19:44:35 +00:00
|
|
|
|
2018-09-20 01:41:22 +00:00
|
|
|
export ANDROID_HOME=$HOME/Android/Sdk
|
|
|
|
export NDK_ROOT=$HOME/Android/Ndk
|
|
|
|
export ANDROID_TC=$HOME/Android/Toolchains
|
|
|
|
|
|
|
|
# checks if a given path is canonical (absolute and does not contain relative links)
|
|
|
|
# from http://unix.stackexchange.com/a/256437
|
|
|
|
isPathCanonical() {
|
|
|
|
case "x$1" in
|
|
|
|
(x*/..|x*/../*|x../*|x*/.|x*/./*|x./*)
|
|
|
|
rc=1
|
|
|
|
;;
|
|
|
|
(x/*)
|
|
|
|
rc=0
|
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
rc=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return $rc
|
|
|
|
}
|
|
|
|
|
|
|
|
doclean=""
|
|
|
|
cache_dir=""
|
|
|
|
arch=""
|
2019-01-03 07:51:20 +00:00
|
|
|
silent=""
|
2020-06-11 23:03:01 +00:00
|
|
|
verbose="${VERBOSE:-no}"
|
2020-07-03 05:05:51 +00:00
|
|
|
ci=""
|
2020-06-11 23:03:01 +00:00
|
|
|
|
2018-09-20 01:41:22 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
key="$1"
|
|
|
|
case $key in
|
|
|
|
--cache_dir)
|
|
|
|
cache_dir="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-09-25 08:00:01 +00:00
|
|
|
--build_dir)
|
|
|
|
build_dir="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2018-09-20 01:41:22 +00:00
|
|
|
--clean)
|
|
|
|
doclean="yes"
|
|
|
|
;;
|
|
|
|
--arch)
|
|
|
|
arch="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2019-01-03 07:51:20 +00:00
|
|
|
--silent)
|
|
|
|
silent="yes"
|
|
|
|
;;
|
2020-06-11 22:53:51 +00:00
|
|
|
--verbose)
|
|
|
|
verbose="yes"
|
|
|
|
;;
|
2020-07-03 05:05:51 +00:00
|
|
|
--ci)
|
|
|
|
ci="yes"
|
|
|
|
;;
|
2018-09-20 01:41:22 +00:00
|
|
|
*)
|
|
|
|
echo "unrecognized option $key"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift # past argument or value
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x$cache_dir" != "x" ]; then
|
|
|
|
if isPathCanonical "$cache_dir" && [ "$cache_dir" != "/" ]; then
|
|
|
|
PREFIX="$cache_dir"
|
|
|
|
else
|
|
|
|
echo "cache_dir must be an absolute path without ./ or ../ in it"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cd ../
|
2018-09-25 08:00:01 +00:00
|
|
|
PREFIX="$(pwd)/3rdParty/buildCache/android-tc"
|
|
|
|
cd android/
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "x$build_dir" != "x" ]; then
|
|
|
|
if isPathCanonical "$build_dir" && [ "$build_dir" != "/" ]; then
|
2019-05-10 21:10:17 +00:00
|
|
|
BUILD_DIR="$build_dir"
|
2018-09-25 08:00:01 +00:00
|
|
|
else
|
|
|
|
echo "build_dir must be an absolute path without ./ or ../ in it"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
cd ../
|
|
|
|
BUILD_DIR="$(pwd)/3rdParty/android"
|
2018-09-20 01:41:22 +00:00
|
|
|
cd android/
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${PREFIX}"
|
2018-09-25 08:00:01 +00:00
|
|
|
mkdir -p "${BUILD_DIR}"
|
2020-07-03 22:08:23 +00:00
|
|
|
|
2018-09-20 01:41:22 +00:00
|
|
|
if [ "${doclean}" = "yes" ]; then
|
|
|
|
echo "cleaning cache"
|
|
|
|
rm -rf "${PREFIX}"
|
|
|
|
mkdir -p "${PREFIX}"
|
2018-09-25 08:00:01 +00:00
|
|
|
echo "cleaning build dir"
|
|
|
|
rm -rf "${BUILD_DIR}"
|
|
|
|
mkdir -p "${BUILD_DIR}"
|
2020-03-13 15:24:13 +00:00
|
|
|
echo "cleaning downloaded cache files"
|
2020-07-03 15:48:50 +00:00
|
|
|
rm -f /tmp/ndk_${NDK_VERSION}.zip
|
|
|
|
rm -f /tmp/openssl_${OPENSSL_VERSION}.tgz
|
|
|
|
rm -f /tmp/curl_${CURL_VERSION}.tgz
|
2020-07-05 01:15:34 +00:00
|
|
|
./clear_environment.sh
|
2018-09-20 01:41:22 +00:00
|
|
|
fi
|
|
|
|
|
2019-01-03 07:51:20 +00:00
|
|
|
if [ "${silent}" = "yes" ]; then
|
|
|
|
export STDOUT_TARGET="/dev/null"
|
|
|
|
fi
|
|
|
|
|
2018-09-20 01:41:22 +00:00
|
|
|
export COMPILEOPENSSL="no"
|
2018-12-08 09:58:43 +00:00
|
|
|
export COMPILECURL="no"
|
2020-07-05 01:51:14 +00:00
|
|
|
export NDK_FLAGFILE="$PREFIX/NDK-${NDK_VERSION}_done"
|
|
|
|
export NDK_CI_FLAGFILE="$PREFIX/NDK-${NDK_VERSION}-${arch}-${REV}_done"
|
2020-07-03 18:11:48 +00:00
|
|
|
export CURL_FLAGFILE="$PREFIX/curl-${CURL_VERSION}-${NDK_VERSION}-${arch}_done"
|
|
|
|
export OPENSSL_FLAGFILE="$PREFIX/openssl-${OPENSSL_VERSION}-${NDK_VERSION}-${arch}_done"
|
2020-07-03 15:40:14 +00:00
|
|
|
export CREATED_NDK_FOLDER=${CREATED_NDK_FOLDER:-"no"}
|
2020-07-03 05:05:51 +00:00
|
|
|
|
2020-07-03 15:40:14 +00:00
|
|
|
createNDKFolder()
|
|
|
|
{
|
|
|
|
if [ $CREATED_NDK_FOLDER = "no" ]; then
|
2020-07-03 05:05:51 +00:00
|
|
|
rm -rf "$BUILD_DIR/android-ndk-r${NDK_VERSION}"
|
2020-07-03 15:48:50 +00:00
|
|
|
wget -c --no-verbose -O /tmp/ndk_${NDK_VERSION}.zip https://dl.google.com/android/repository/android-ndk-r${NDK_VERSION}-linux-x86_64.zip
|
|
|
|
unzip -qq /tmp/ndk_${NDK_VERSION}.zip -d $BUILD_DIR
|
2020-07-03 15:40:14 +00:00
|
|
|
export CREATED_NDK_FOLDER="yes"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2020-07-04 22:46:04 +00:00
|
|
|
if [ "$ci" = "yes" ]; then
|
2020-07-05 01:51:14 +00:00
|
|
|
if [ ! -e "${NDK_CI_FLAGFILE}" ]; then
|
2020-07-05 01:23:25 +00:00
|
|
|
rm -rf "${PREFIX}/${arch}"
|
|
|
|
rm -rf "${OPENSSL_FLAGFILE}"
|
|
|
|
rm -rf "${CURL_FLAGFILE}"
|
2020-07-05 01:51:14 +00:00
|
|
|
touch "${NDK_CI_FLAGFILE}"
|
2020-07-05 01:23:25 +00:00
|
|
|
fi
|
2020-07-03 15:40:14 +00:00
|
|
|
createNDKFolder
|
|
|
|
else
|
|
|
|
if [ ! -e "${NDK_FLAGFILE}" ]; then
|
2020-07-03 18:17:52 +00:00
|
|
|
export CREATED_NDK_FOLDER="no"
|
2020-07-03 15:40:14 +00:00
|
|
|
createNDKFolder
|
2020-07-03 18:11:48 +00:00
|
|
|
touch "${NDK_FLAGFILE}"
|
2020-07-03 05:05:51 +00:00
|
|
|
fi
|
2018-12-08 09:58:43 +00:00
|
|
|
fi
|
2020-07-03 05:05:51 +00:00
|
|
|
|
2020-05-17 11:38:35 +00:00
|
|
|
export NDK_ROOT=$BUILD_DIR/android-ndk-r${NDK_VERSION}
|
2018-12-08 09:58:43 +00:00
|
|
|
|
2018-09-25 08:00:01 +00:00
|
|
|
if [ ! -e "${OPENSSL_FLAGFILE}" ]; then
|
2018-12-27 00:47:10 +00:00
|
|
|
rm -rf "$BUILD_DIR/openssl-${OPENSSL_VERSION}"
|
2020-07-03 15:48:50 +00:00
|
|
|
wget -c --no-verbose -O /tmp/openssl_${OPENSSL_VERSION}.tgz https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
|
|
|
|
tar xzf /tmp/openssl_${OPENSSL_VERSION}.tgz --directory=$BUILD_DIR
|
2018-09-20 01:41:22 +00:00
|
|
|
export COMPILEOPENSSL="yes"
|
|
|
|
fi
|
2018-09-25 08:00:01 +00:00
|
|
|
export OPENSSL_SRC=$BUILD_DIR/openssl-${OPENSSL_VERSION}
|
2018-09-20 01:41:22 +00:00
|
|
|
|
2018-09-25 08:00:01 +00:00
|
|
|
if [ ! -e "${CURL_FLAGFILE}" ]; then
|
2018-12-27 00:47:10 +00:00
|
|
|
rm -rf "$BUILD_DIR/curl-${CURL_VERSION}"
|
2020-07-03 15:48:50 +00:00
|
|
|
wget -c --no-verbose -O /tmp/curl_${CURL_VERSION}.tgz https://curl.haxx.se/download/curl-${CURL_VERSION}.tar.gz
|
|
|
|
tar xzf /tmp/curl_${CURL_VERSION}.tgz --directory=$BUILD_DIR
|
2018-09-20 01:41:22 +00:00
|
|
|
export COMPILECURL="yes"
|
|
|
|
fi
|
2018-09-25 08:00:01 +00:00
|
|
|
export CURL_SRC=$BUILD_DIR/curl-${CURL_VERSION}
|
2018-09-20 01:41:22 +00:00
|
|
|
|
2018-09-25 08:00:01 +00:00
|
|
|
export ANDROID_TC=$PREFIX
|
2018-09-20 01:41:22 +00:00
|
|
|
|
2020-06-11 22:53:51 +00:00
|
|
|
export VERBOSE=$verbose
|
|
|
|
|
2018-09-20 01:41:22 +00:00
|
|
|
case "$arch" in
|
|
|
|
"arm")
|
|
|
|
./build_openssl_arm.sh
|
|
|
|
./build_curl_arm.sh
|
|
|
|
./build_boinc_arm.sh
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"arm64")
|
|
|
|
./build_openssl_arm64.sh
|
|
|
|
./build_curl_arm64.sh
|
|
|
|
./build_boinc_arm64.sh
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"x86")
|
|
|
|
./build_openssl_x86.sh
|
|
|
|
./build_curl_x86.sh
|
|
|
|
./build_boinc_x86.sh
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
"x86_64")
|
|
|
|
./build_openssl_x86_64.sh
|
|
|
|
./build_curl_x86_64.sh
|
|
|
|
./build_boinc_x86_64.sh
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "unknown architecture: $arch"
|
2018-11-27 14:57:49 +00:00
|
|
|
exit 1
|