mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-06 00:03:35 -04:00
* Replace OQS_PORTABLE_BUILD with OQS_DIST_BUILD Also introduces OQS_OPT_TARGET and removes OQS_USE_CPU_EXTENSIONS * Only compile sha3 avx2 code on Linux|Darwin * Use new ARCH_ARM[X] flags in SIKE CMakeLists * Update test_portability and rename to test_distbuild * Update documentation for building Windows AMD64 from Ubuntu Bionic * Update scripts/build-android.sh * More specific CMAKE_SYSTEM_PROCESSOR for rasppi toolchain * CI: Use OQS_DIST_BUILD in some jobs * Replace OQS_get_available_CPU_extensions by OQS_CPU_has_extension * ARM64v8/ARM32v7 runtime cpu feature detection * Compile-time detection of some ARM features * Toolchain files to cross compile for ARM32v7 and ARM64v8 * Remove unnecessary references to CMAKE_BUILD_TYPE=Release * Use OQS_DIST_BUILD=ON on Windows
116 lines
2.5 KiB
Bash
116 lines
2.5 KiB
Bash
#!/bin/bash
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
set -e
|
|
|
|
show_help() {
|
|
echo ""
|
|
echo " Usage: ./build-android <ndk-dir> -a [abi] -b [build-directory] -s [sdk-version]"
|
|
|
|
echo " ndk-dir: the directory of the Android NDK (required)"
|
|
echo " abi: the Android ABI to target for the build"
|
|
echo " build-directory: the directory in which to build the project"
|
|
echo " sdk-version: the minimum Android SDK version to target"
|
|
echo ""
|
|
exit 0
|
|
}
|
|
|
|
# If no arguments provided, show help
|
|
if [ $# -eq 0 ]
|
|
then
|
|
show_help
|
|
fi
|
|
|
|
# If help requested, show help
|
|
for arg in "$@"
|
|
do
|
|
if [ "$arg" == "--help" ] || [ "$arg" == "-h" ]
|
|
then
|
|
show_help
|
|
fi
|
|
done
|
|
|
|
# Make sure script will work the same if called from
|
|
# root directory or scripts directory
|
|
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
|
|
cd "$parent_path/.."
|
|
|
|
NDK=$1
|
|
# Verify NDK is valid directory
|
|
if [ -d "$NDK" ]
|
|
then
|
|
echo "Valid directory for NDK at $NDK"
|
|
else
|
|
echo "Directory for NDK doesn't exist at $NDK"
|
|
exit 1
|
|
fi
|
|
|
|
# Parse optional parameters
|
|
ABI="armeabi-v7a"
|
|
MINSDKVERSION=21
|
|
BUILDDIR="build"
|
|
|
|
OPTIND=2
|
|
while getopts "a:s:b:" flag
|
|
do
|
|
case $flag in
|
|
a) ABI=$OPTARG;;
|
|
s) MINSDKVERSION=$OPTARG;;
|
|
b) BUILDDIR=$OPTARG;;
|
|
*) exit 1
|
|
esac
|
|
done
|
|
|
|
# Check ABI is supported
|
|
valid_abis=("armeabi-v7a" "arm64-v8a" "x86" "x86_64")
|
|
abi_match=false
|
|
for i in "${valid_abis[@]}"
|
|
do
|
|
:
|
|
if [ "$ABI" == "$i" ]
|
|
then abi_match=true
|
|
fi
|
|
done
|
|
if [ "$abi_match" = true ]
|
|
then
|
|
echo "Compiling for ABI $ABI"
|
|
else
|
|
echo "Invalid Android ABI of $ABI"
|
|
echo "Valid ABIs are:"
|
|
printf "%s\\n" "${valid_abis[@]}"
|
|
exit 1
|
|
fi
|
|
|
|
# Check SDK version is supported
|
|
highestSdkVersion=29
|
|
if (( 1 <= MINSDKVERSION && MINSDKVERSION <= highestSdkVersion ))
|
|
then
|
|
echo "Compiling for SDK $MINSDKVERSION"
|
|
else
|
|
echo "Invalid SDK level of $MINSDKVERSION"
|
|
exit 1
|
|
fi
|
|
|
|
# Remove build directory if it exists
|
|
if [ -d "$BUILDDIR" ]
|
|
then
|
|
echo "Cleaning up previous build"
|
|
rm -r "$BUILDDIR"
|
|
fi
|
|
|
|
echo "Building in directory $BUILDDIR"
|
|
|
|
# Build
|
|
mkdir "$BUILDDIR" && cd "$BUILDDIR"
|
|
cmake .. -DOQS_USE_OPENSSL=OFF \
|
|
-DBUILD_SHARED_LIBS=ON \
|
|
-DCMAKE_TOOLCHAIN_FILE="$NDK"/build/cmake/android.toolchain.cmake \
|
|
-DANDROID_ABI="$ABI" \
|
|
-DANDROID_NATIVE_API_LEVEL="$MINSDKVERSION" \
|
|
-DOQS_ENABLE_SIG_PICNIC=OFF
|
|
cmake --build ./
|
|
|
|
# Provide rudimentary information following build
|
|
echo "Completed build run for ABI $ABI, SDK Version $MINSDKVERSION"
|