Merge pull request #116 from oneton/1.0.2-command-line
Specify build configuration with command line parameters
This commit is contained in:
commit
48e6942d79
|
@ -1,7 +1,7 @@
|
||||||
osx_image: xcode8
|
osx_image: xcode8
|
||||||
language: objective-c
|
language: objective-c
|
||||||
before_install:
|
before_install:
|
||||||
- ./build-libssl.sh verbose-on-error
|
- ./build-libssl.sh --noparallel --verbose-on-error
|
||||||
- xcrun -sdk iphoneos lipo -info ./lib/*.a
|
- xcrun -sdk iphoneos lipo -info ./lib/*.a
|
||||||
- ./create-openssl-framework.sh
|
- ./create-openssl-framework.sh
|
||||||
- xcrun -sdk iphoneos lipo -info openssl.framework/openssl
|
- xcrun -sdk iphoneos lipo -info openssl.framework/openssl
|
||||||
|
|
209
build-libssl.sh
209
build-libssl.sh
|
@ -18,31 +18,40 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
###########################################################################
|
|
||||||
# Change values here #
|
|
||||||
# #
|
|
||||||
VERSION="1.0.2h" #
|
|
||||||
IOS_SDKVERSION=`xcrun -sdk iphoneos --show-sdk-version` #
|
|
||||||
TVOS_SDKVERSION=`xcrun -sdk appletvos --show-sdk-version` #
|
|
||||||
CONFIG_OPTIONS="" #
|
|
||||||
CURL_OPTIONS="" #
|
|
||||||
|
|
||||||
# ARCHS is a space-separated list of architectures to build
|
# -u Attempt to use undefined variable outputs error message, and forces an exit
|
||||||
# Options: x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64
|
set -u
|
||||||
# Please note: The framework will contain include files from the architecture listed first
|
|
||||||
ARCHS="x86_64 i386 arm64 armv7s armv7 tv_x86_64 tv_arm64"
|
|
||||||
|
|
||||||
# Set to false to disable make with multiple parallel jobs
|
DEFAULTVERSION="1.0.2h" # Default version in case no version is specified
|
||||||
PARALLEL="true"
|
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
|
||||||
|
CURL_OPTIONS="${CURL_OPTIONS:-}"
|
||||||
|
CONFIG_OPTIONS="${CONFIG_OPTIONS:-}"
|
||||||
|
|
||||||
|
echo_help()
|
||||||
|
{
|
||||||
|
echo "Usage: $0 [options...]"
|
||||||
|
echo " --archs=\"ARCH ARCH ...\" Space-separated list of architectures to build"
|
||||||
|
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 " --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 " -h, --help Print help (this message)"
|
||||||
|
echo " --ios-sdk=SDKVERSION Override iOS SDK version"
|
||||||
|
echo " --noparallel Disable running make with parallel jobs (make -j)"
|
||||||
|
echo " --tvos-sdk=SDKVERSION Override tvOS SDK version"
|
||||||
|
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 " --version=VERSION OpenSSL version to build (defaults to ${DEFAULTVERSION})"
|
||||||
|
echo " Note: This script does not yet work with OpenSSL 1.1.0"
|
||||||
|
echo
|
||||||
|
echo "For custom configure options, set variable CONFIG_OPTIONS"
|
||||||
|
echo "For custom cURL options, set variable CURL_OPTIONS"
|
||||||
|
echo " Example: CURL_OPTIONS=\"--proxy 192.168.1.1:8080\" ./build-libssl.sh"
|
||||||
|
}
|
||||||
|
|
||||||
# To set "enable-ec_nistp_64_gcc_128" configuration for x64 archs set next variable to "true"
|
|
||||||
ENABLE_EC_NISTP_64_GCC_128="" #
|
|
||||||
# #
|
|
||||||
###########################################################################
|
|
||||||
# #
|
|
||||||
# Don't change anything under this line! #
|
|
||||||
# #
|
|
||||||
###########################################################################
|
|
||||||
spinner()
|
spinner()
|
||||||
{
|
{
|
||||||
local pid=$!
|
local pid=$!
|
||||||
|
@ -84,11 +93,90 @@ check_status()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CURRENTPATH=`pwd`
|
# Init optional command line vars
|
||||||
DEVELOPER=`xcode-select -print-path`
|
ARCHS=""
|
||||||
IOS_MIN_SDK_VERSION="7.0"
|
CLEANUP=""
|
||||||
TVOS_MIN_SDK_VERSION="9.0"
|
CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
|
||||||
LOG_VERBOSE="$1" # Options: verbose (full output) or verbose-on-error (echo last 500 logged lines when error occurs)
|
IOS_SDKVERSION=""
|
||||||
|
PARALLEL=""
|
||||||
|
LOG_VERBOSE=""
|
||||||
|
TVOS_SDKVERSION=""
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
# Process command line arguments
|
||||||
|
for i in "$@"
|
||||||
|
do
|
||||||
|
case $i in
|
||||||
|
--archs=*)
|
||||||
|
ARCHS="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--cleanup)
|
||||||
|
CLEANUP="true"
|
||||||
|
;;
|
||||||
|
--ec-nistp-64-gcc-128)
|
||||||
|
CONFIG_ENABLE_EC_NISTP_64_GCC_128="true"
|
||||||
|
;;
|
||||||
|
-h|--help)
|
||||||
|
echo_help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
--ios-sdk=*)
|
||||||
|
IOS_SDKVERSION="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--noparallel)
|
||||||
|
PARALLEL="false"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--tvos-sdk=*)
|
||||||
|
TVOS_SDKVERSION="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v|--verbose)
|
||||||
|
LOG_VERBOSE="verbose"
|
||||||
|
;;
|
||||||
|
--verbose-on-error)
|
||||||
|
LOG_VERBOSE="verbose-on-error"
|
||||||
|
;;
|
||||||
|
--version=*)
|
||||||
|
VERSION="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown argument: ${i}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Preprocess/validate OpenSSL version
|
||||||
|
if [ -n "${VERSION}" ]; then
|
||||||
|
# Verify version number format. Expected: dot notation
|
||||||
|
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+[a-z]*$ ]]; then
|
||||||
|
echo "Unknown version number format. Examples: 1.0.2, 1.0.2h"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Default OpenSSL version
|
||||||
|
else
|
||||||
|
VERSION="${DEFAULTVERSION}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set GITHUB_VERSION (version with underscores instead of dots)
|
||||||
|
GITHUB_VERSION="${VERSION//./_}"
|
||||||
|
|
||||||
|
# Determine SDK versions
|
||||||
|
if [ ! -n "${IOS_SDKVERSION}" ]; then
|
||||||
|
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
|
||||||
|
fi
|
||||||
|
if [ ! -n "${TVOS_SDKVERSION}" ]; then
|
||||||
|
TVOS_SDKVERSION=$(xcrun -sdk appletvos --show-sdk-version)
|
||||||
|
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
|
||||||
|
@ -96,47 +184,82 @@ if [ "${PARALLEL}" != "false" ]; then
|
||||||
BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}')
|
BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$DEVELOPER" ]; then
|
# Write files relative to script location and validate directory
|
||||||
echo "xcode path is not set correctly $DEVELOPER does not exist"
|
CURRENTPATH=$(pwd)
|
||||||
|
case "${CURRENTPATH}" in
|
||||||
|
*\ * )
|
||||||
|
echo "Your path contains whitespaces, which is not supported by 'make install'."
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
cd "${CURRENTPATH}"
|
||||||
|
|
||||||
|
# Validate Xcode Developer path
|
||||||
|
DEVELOPER=$(xcode-select -print-path)
|
||||||
|
if [ ! -d "${DEVELOPER}" ]; then
|
||||||
|
echo "Xcode path is not set correctly ${DEVELOPER} does not exist"
|
||||||
echo "run"
|
echo "run"
|
||||||
echo "sudo xcode-select -switch <xcode path>"
|
echo "sudo xcode-select -switch <Xcode path>"
|
||||||
echo "for default installation:"
|
echo "for default installation:"
|
||||||
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
|
echo "sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $DEVELOPER in
|
case "${DEVELOPER}" in
|
||||||
*\ * )
|
*\ * )
|
||||||
echo "Your Xcode path contains whitespaces, which is not supported."
|
echo "Your Xcode path contains whitespaces, which is not supported."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
case $CURRENTPATH in
|
# Show build options
|
||||||
*\ * )
|
echo
|
||||||
echo "Your path contains whitespaces, which is not supported by 'make install'."
|
echo "Build options"
|
||||||
exit 1
|
echo " OpenSSL version: ${VERSION}"
|
||||||
;;
|
echo " Architectures: ${ARCHS}"
|
||||||
esac
|
echo " iOS SDK: ${IOS_SDKVERSION}"
|
||||||
|
echo " tvOS SDK: ${TVOS_SDKVERSION}"
|
||||||
|
echo " Number of make threads: ${BUILD_THREADS}"
|
||||||
|
if [ -n "${CONFIG_OPTIONS}" ]; then
|
||||||
|
echo " Configure options: ${CONFIG_OPTIONS}"
|
||||||
|
fi
|
||||||
|
echo " Script directory and build location: ${CURRENTPATH}"
|
||||||
|
echo
|
||||||
|
|
||||||
# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
|
# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
|
||||||
# -u Attempt to use undefined variable outputs error message, and forces an exit
|
|
||||||
# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value
|
# -o pipefail Causes a pipeline to return the exit status of the last command in the pipe that returned a non-zero return value
|
||||||
set -euo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
# Download OpenSSL when not present
|
# Download OpenSSL when not present
|
||||||
OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${VERSION//./_}
|
OPENSSL_ARCHIVE_BASE_NAME=OpenSSL_${GITHUB_VERSION}
|
||||||
OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz
|
OPENSSL_ARCHIVE_FILE_NAME=${OPENSSL_ARCHIVE_BASE_NAME}.tar.gz
|
||||||
if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
|
if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
|
||||||
echo "Downloading ${OPENSSL_ARCHIVE_FILE_NAME}"
|
echo "Downloading ${OPENSSL_ARCHIVE_FILE_NAME}..."
|
||||||
curl ${CURL_OPTIONS} -L -O https://github.com/openssl/openssl/archive/${OPENSSL_ARCHIVE_FILE_NAME}
|
curl ${CURL_OPTIONS} -L -O https://github.com/openssl/openssl/archive/${OPENSSL_ARCHIVE_FILE_NAME}
|
||||||
else
|
else
|
||||||
echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}"
|
echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "${CURRENTPATH}/src"
|
# Clean up target directories if requested and present
|
||||||
|
if [ "${CLEANUP}" == "true" ]; then
|
||||||
|
if [ -d "${CURRENTPATH}/bin" ]; then
|
||||||
|
rm -r "${CURRENTPATH}/bin"
|
||||||
|
fi
|
||||||
|
if [ -d "${CURRENTPATH}/include/openssl" ]; then
|
||||||
|
rm -r "${CURRENTPATH}/include/openssl"
|
||||||
|
fi
|
||||||
|
if [ -d "${CURRENTPATH}/lib" ]; then
|
||||||
|
rm -r "${CURRENTPATH}/lib"
|
||||||
|
fi
|
||||||
|
if [ -d "${CURRENTPATH}/src" ]; then
|
||||||
|
rm -r "${CURRENTPATH}/src"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# (Re-)create target directories
|
||||||
mkdir -p "${CURRENTPATH}/bin"
|
mkdir -p "${CURRENTPATH}/bin"
|
||||||
mkdir -p "${CURRENTPATH}/lib"
|
mkdir -p "${CURRENTPATH}/lib"
|
||||||
|
mkdir -p "${CURRENTPATH}/src"
|
||||||
|
|
||||||
# Init vars for library references
|
# Init vars for library references
|
||||||
INCLUDE_DIR=""
|
INCLUDE_DIR=""
|
||||||
|
@ -190,7 +313,7 @@ do
|
||||||
|
|
||||||
# Add optional enable-ec_nistp_64_gcc_128 configure option for 64 bit builds
|
# Add optional enable-ec_nistp_64_gcc_128 configure option for 64 bit builds
|
||||||
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
|
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
|
||||||
if [ "${ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then
|
if [ "${CONFIG_ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then
|
||||||
case "${ARCH}" in
|
case "${ARCH}" in
|
||||||
*64*)
|
*64*)
|
||||||
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
|
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
|
||||||
|
|
Loading…
Reference in New Issue