Prepare for 1.1.0 build (amended)

- Prepare (command line) options
- Prepare script output for parallel 1.0.2/1.1.0 Travis build
- Show number of make threads
- cd to correct dir before removing source to prevent errors
This commit is contained in:
Anton Tieleman 2016-11-06 12:19:26 +01:00
parent cce9b09d10
commit c683e1b3d8
1 changed files with 85 additions and 28 deletions

View File

@ -22,24 +22,30 @@
# -u Attempt to use undefined variable outputs error message, and forces an exit # -u Attempt to use undefined variable outputs error message, and forces an exit
set -u set -u
DEFAULTVERSION="1.0.2j" # Default version in case no version is specified # SCRIPT DEFAULTS
IOS_MIN_SDK_VERSION="7.0" # Minimum iOS SDK version to build for
TVOS_MIN_SDK_VERSION="9.0" # Minimum tvOS SDK version to build for
# Init optional env variables # Default version in case no version is specified
DEFAULTVERSION="1.0.2j"
# Default (=full) set of architectures (OpenSSL <= 1.0.2) or targets (OpenSSL >= 1.1.0) to build
DEFAULTARCHS="x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64"
DEFAULTTARGETS="ios-sim-cross-x86_64 ios-sim-cross-i386 ios64-cross-arm64 ios-cross-armv7s ios-cross-armv7 tvos-sim-cross-x86_64 tvos64-cross-arm64"
# Minimum iOS/tvOS SDK version to build for
IOS_MIN_SDK_VERSION="7.0"
TVOS_MIN_SDK_VERSION="9.0"
# Init optional env variables (use available variable or default to empty string)
CURL_OPTIONS="${CURL_OPTIONS:-}" CURL_OPTIONS="${CURL_OPTIONS:-}"
CONFIG_OPTIONS="${CONFIG_OPTIONS:-}" CONFIG_OPTIONS="${CONFIG_OPTIONS:-}"
echo_help() echo_help()
{ {
echo "Usage: $0 [options...]" echo "Usage: $0 [options...]"
echo " --archs=\"ARCH ARCH ...\" Space-separated list of architectures to build" echo "Generic options"
echo " Options: x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64"
echo " Note: The framework will contain include files from the architecture listed first"
echo " --branch=BRANCH Select OpenSSL branch to build. The script will determine and download the latest release for that branch" echo " --branch=BRANCH Select OpenSSL branch to build. The script will determine and download the latest release for that branch"
echo " Note: This script does not yet work with OpenSSL 1.1.0"
echo " --cleanup Clean up build directories (bin, include/openssl, lib, src) before starting build" echo " --cleanup Clean up build directories (bin, include/openssl, lib, src) before starting build"
echo " --ec-nistp-64-gcc-128 Enable config option enable-ec_nistp_64_gcc_128 for 64 bit builds" echo " --ec-nistp-64-gcc-128 Enable configure option enable-ec_nistp_64_gcc_128 for 64 bit builds"
echo " -h, --help Print help (this message)" echo " -h, --help Print help (this message)"
echo " --ios-sdk=SDKVERSION Override iOS SDK version" echo " --ios-sdk=SDKVERSION Override iOS SDK version"
echo " --noparallel Disable running make with parallel jobs (make -j)" echo " --noparallel Disable running make with parallel jobs (make -j)"
@ -47,7 +53,17 @@ echo_help()
echo " -v, --verbose Enable verbose logging" echo " -v, --verbose Enable verbose logging"
echo " --verbose-on-error Dump last 500 lines from log file if an error occurs (for Travis builds)" echo " --verbose-on-error Dump last 500 lines from log file if an error occurs (for Travis builds)"
echo " --version=VERSION OpenSSL version to build (defaults to ${DEFAULTVERSION})" echo " --version=VERSION OpenSSL version to build (defaults to ${DEFAULTVERSION})"
echo " Note: This script does not yet work with OpenSSL 1.1.0" echo
echo "Options for OpenSSL 1.0.2 and lower ONLY"
echo " --archs=\"ARCH ARCH ...\" Space-separated list of architectures to build"
echo " Options: ${DEFAULTARCHS}"
echo " Note: The framework will contain include files from the architecture listed first"
echo
echo "Options for OpenSSL 1.1.0 and higher ONLY"
echo " --deprecated Exclude no-deprecated configure option and build with deprecated methods"
echo " --targets=\"TARGET TARGET ...\" Space-separated list of build targets"
echo " Options: ${DEFAULTTARGETS}"
echo " Note: The library will use include files from the target listed first"
echo echo
echo "For custom configure options, set variable CONFIG_OPTIONS" echo "For custom configure options, set variable CONFIG_OPTIONS"
echo "For custom cURL options, set variable CURL_OPTIONS" echo "For custom cURL options, set variable CURL_OPTIONS"
@ -64,9 +80,8 @@ spinner()
printf " [%c]" "$spinstr" printf " [%c]" "$spinstr"
local spinstr=$temp${spinstr%"$temp"} local spinstr=$temp${spinstr%"$temp"}
sleep $delay sleep $delay
printf "\b\b\b\b" printf "\b\b\b\b\b"
done done
printf " \b\b"
wait $pid wait $pid
return $? return $?
@ -78,7 +93,6 @@ check_status()
local STATUS=$1 local STATUS=$1
local COMMAND=$2 local COMMAND=$2
echo "\n"
if [ "${STATUS}" != 0 ]; then if [ "${STATUS}" != 0 ]; then
if [[ "${LOG_VERBOSE}" != "verbose"* ]]; then if [[ "${LOG_VERBOSE}" != "verbose"* ]]; then
echo "Problem during ${COMMAND} - Please check ${LOG}" echo "Problem during ${COMMAND} - Please check ${LOG}"
@ -100,9 +114,11 @@ ARCHS=""
BRANCH="" BRANCH=""
CLEANUP="" CLEANUP=""
CONFIG_ENABLE_EC_NISTP_64_GCC_128="" CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_NO_DEPRECATED=""
IOS_SDKVERSION="" IOS_SDKVERSION=""
PARALLEL=""
LOG_VERBOSE="" LOG_VERBOSE=""
PARALLEL=""
TARGETS=""
TVOS_SDKVERSION="" TVOS_SDKVERSION=""
VERSION="" VERSION=""
@ -121,6 +137,9 @@ case $i in
--cleanup) --cleanup)
CLEANUP="true" CLEANUP="true"
;; ;;
--deprecated)
CONFIG_NO_DEPRECATED="false"
;;
--ec-nistp-64-gcc-128) --ec-nistp-64-gcc-128)
CONFIG_ENABLE_EC_NISTP_64_GCC_128="true" CONFIG_ENABLE_EC_NISTP_64_GCC_128="true"
;; ;;
@ -134,6 +153,9 @@ case $i in
;; ;;
--noparallel) --noparallel)
PARALLEL="false" PARALLEL="false"
;;
--targets=*)
TARGETS="${i#*=}"
shift shift
;; ;;
--tvos-sdk=*) --tvos-sdk=*)
@ -207,6 +229,38 @@ fi
# Set GITHUB_VERSION (version with underscores instead of dots) # Set GITHUB_VERSION (version with underscores instead of dots)
GITHUB_VERSION="${VERSION//./_}" GITHUB_VERSION="${VERSION//./_}"
# Build type:
# In short, type "archs" is used for OpenSSL versions in the 1.0 branch and type "targets" for later versions.
#
# Significant changes to the build process were introduced with OpenSSL 1.1.0. As a result, this script was updated
# to include two separate build loops for versions <= 1.0 and versions >= 1.1. The type "archs" matches the key variable
# used to determine for which platforms to build for the 1.0 branch. Since 1.1, all platforms are defined in a separate/
# custom configuration file as build targets. Therefore the key variable and type are called targets for 1.1 (and later).
# OpenSSL branches <= 1.0
if [[ "${GITHUB_VERSION}" =~ ^(0_9|1_0) ]]; then
BUILD_TYPE="archs"
# Set default for ARCHS if not specified
if [ ! -n "${ARCHS}" ]; then
ARCHS="${DEFAULTARCHS}"
fi
# OpenSSL branches >= 1.1
else
BUILD_TYPE="targets"
# Set default for TARGETS if not specified
if [ ! -n "${TARGETS}" ]; then
TARGETS="${DEFAULTTARGETS}"
fi
# Add no-deprecated config option (if not overwritten)
if [ "${CONFIG_NO_DEPRECATED}" != "false" ]; then
CONFIG_OPTIONS="${CONFIG_OPTIONS} no-deprecated"
fi
fi
# Determine SDK versions # Determine SDK versions
if [ ! -n "${IOS_SDKVERSION}" ]; then if [ ! -n "${IOS_SDKVERSION}" ]; then
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version) IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
@ -215,18 +269,16 @@ if [ ! -n "${TVOS_SDKVERSION}" ]; then
TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version) TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version)
fi fi
# Set default for ARCHS if not specified
if [ ! -n "${ARCHS}" ]; then
ARCHS="x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64"
fi
# Determine number of cores for (parallel) build # Determine number of cores for (parallel) build
BUILD_THREADS=1 BUILD_THREADS=1
if [ "${PARALLEL}" != "false" ]; then if [ "${PARALLEL}" != "false" ]; then
BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}') BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}')
fi fi
# Write files relative to script location and validate directory # Determine script directory
SCRIPTDIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
# Write files relative to current location and validate directory
CURRENTPATH=$(pwd) CURRENTPATH=$(pwd)
case "${CURRENTPATH}" in case "${CURRENTPATH}" in
*\ * ) *\ * )
@ -258,14 +310,18 @@ esac
echo echo
echo "Build options" echo "Build options"
echo " OpenSSL version: ${VERSION}" echo " OpenSSL version: ${VERSION}"
echo " Architectures: ${ARCHS}" if [ "${BUILD_TYPE}" == "archs" ]; then
echo " Architectures: ${ARCHS}"
else
echo " Targets: ${TARGETS}"
fi
echo " iOS SDK: ${IOS_SDKVERSION}" echo " iOS SDK: ${IOS_SDKVERSION}"
echo " tvOS SDK: ${TVOS_SDKVERSION}" echo " tvOS SDK: ${TVOS_SDKVERSION}"
echo " Number of make threads: ${BUILD_THREADS}" echo " Number of make threads: ${BUILD_THREADS}"
if [ -n "${CONFIG_OPTIONS}" ]; then if [ -n "${CONFIG_OPTIONS}" ]; then
echo " Configure options: ${CONFIG_OPTIONS}" echo " Configure options: ${CONFIG_OPTIONS}"
fi fi
echo " Script directory and build location: ${CURRENTPATH}" echo " Build location: ${CURRENTPATH}"
echo echo
# Download OpenSSL when not present # Download OpenSSL when not present
@ -397,7 +453,7 @@ do
fi fi
# Run Configure # Run Configure
echo " Configure...\c" echo " Configure..."
set +e set +e
if [ "${LOG_VERBOSE}" == "verbose" ]; then if [ "${LOG_VERBOSE}" == "verbose" ]; then
./Configure ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}" ./Configure ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}"
@ -428,7 +484,7 @@ do
fi fi
# Run make # Run make
echo " Make...\c" echo " Make (using ${BUILD_THREADS} thread(s))..."
if [ "${LOG_VERBOSE}" == "verbose" ]; then if [ "${LOG_VERBOSE}" == "verbose" ]; then
make -j "${BUILD_THREADS}" | tee -a "${LOG}" make -j "${BUILD_THREADS}" | tee -a "${LOG}"
else else
@ -446,7 +502,8 @@ do
make install_sw >> "${LOG}" 2>&1 make install_sw >> "${LOG}" 2>&1
fi fi
# Remove source dir # Return to ${CURRENTPATH} and remove source dir
cd "${CURRENTPATH}"
rm -r "${SOURCEDIR}" rm -r "${SOURCEDIR}"
# Add references to library files to relevant arrays # Add references to library files to relevant arrays