Merge pull request #128 from oneton/1.1.0-build-cleaned

Allow building OpenSSL 1.1.0 (clean branch)
This commit is contained in:
Felix Schulze 2016-11-07 17:18:10 +01:00 committed by GitHub
commit 3b971c6658
6 changed files with 505 additions and 172 deletions

View File

@ -1,12 +1,10 @@
osx_image: xcode8
language: objective-c
before_install:
- ./build-libssl.sh --noparallel --verbose-on-error
- xcrun -sdk iphoneos lipo -info ./lib/*.a
- ./create-openssl-framework.sh
- xcrun -sdk iphoneos lipo -info openssl.framework/openssl
- ./travis-build.sh
script:
- xcodebuild -project OpenSSL-for-iOS.xcodeproj -scheme OpenSSL-for-iOS -sdk iphonesimulator clean build
- cd targets && xcodebuild -project OpenSSL-for-iOS.xcodeproj -scheme OpenSSL-for-iOS -sdk iphonesimulator clean build
# xctool 0.2.9 doesn't support Xcode 8 yet (see https://github.com/facebook/xctool/issues/704)
#- xctool -project OpenSSL-for-iOS.xcodeproj -scheme OpenSSL-for-iOS -sdk iphonesimulator clean build

View File

@ -22,24 +22,30 @@
# -u Attempt to use undefined variable outputs error message, and forces an exit
set -u
DEFAULTVERSION="1.0.2j" # Default version in case no version is specified
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
# SCRIPT DEFAULTS
# 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:-}"
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 "Generic options"
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 " --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 " --ios-sdk=SDKVERSION Override iOS SDK version"
echo " --noparallel Disable running make with parallel jobs (make -j)"
@ -47,7 +53,17 @@ echo_help()
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 "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 "For custom configure options, set variable CONFIG_OPTIONS"
echo "For custom cURL options, set variable CURL_OPTIONS"
@ -61,24 +77,41 @@ spinner()
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c]" "$spinstr"
printf " [%c]" "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b"
printf "\b\b\b\b\b"
done
printf " \b\b"
wait $pid
return $?
}
# Prepare target and source dir in build loop
prepare_target_source_dirs()
{
# Prepare target dir
TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
mkdir -p "${TARGETDIR}"
LOG="${TARGETDIR}/build-openssl-${VERSION}.log"
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}..."
echo " Logfile: ${LOG}"
# Prepare source dir
SOURCEDIR="${CURRENTPATH}/src/${PLATFORM}-${ARCH}"
mkdir -p "${SOURCEDIR}"
tar zxf "${CURRENTPATH}/${OPENSSL_ARCHIVE_FILE_NAME}" -C "${SOURCEDIR}"
cd "${SOURCEDIR}/openssl-${OPENSSL_ARCHIVE_BASE_NAME}"
chmod u+x ./Configure
}
# Check for error status
check_status()
{
local STATUS=$1
local COMMAND=$2
echo "\n"
if [ "${STATUS}" != 0 ]; then
if [[ "${LOG_VERBOSE}" != "verbose"* ]]; then
echo "Problem during ${COMMAND} - Please check ${LOG}"
@ -95,14 +128,67 @@ check_status()
fi
}
# Run Configure in build loop
run_configure()
{
echo " Configure..."
set +e
if [ "${LOG_VERBOSE}" == "verbose" ]; then
./Configure ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}"
else
(./Configure ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "Configure"
}
# Run make in build loop
run_make()
{
echo " Make (using ${BUILD_THREADS} thread(s))..."
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make -j "${BUILD_THREADS}" | tee -a "${LOG}"
else
(make -j "${BUILD_THREADS}" >> "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "make"
}
# Cleanup and bookkeeping at end of build loop
finish_build_loop()
{
# Return to ${CURRENTPATH} and remove source dir
cd "${CURRENTPATH}"
rm -r "${SOURCEDIR}"
# Add references to library files to relevant arrays
if [[ "${PLATFORM}" == AppleTV* ]]; then
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
else
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
fi
# Keep reference to first build target for include file
if [ -z "${INCLUDE_DIR}" ]; then
INCLUDE_DIR="${TARGETDIR}/include/openssl"
fi
}
# Init optional command line vars
ARCHS=""
BRANCH=""
CLEANUP=""
CONFIG_ENABLE_EC_NISTP_64_GCC_128=""
CONFIG_NO_DEPRECATED=""
IOS_SDKVERSION=""
PARALLEL=""
LOG_VERBOSE=""
PARALLEL=""
TARGETS=""
TVOS_SDKVERSION=""
VERSION=""
@ -121,6 +207,9 @@ case $i in
--cleanup)
CLEANUP="true"
;;
--deprecated)
CONFIG_NO_DEPRECATED="false"
;;
--ec-nistp-64-gcc-128)
CONFIG_ENABLE_EC_NISTP_64_GCC_128="true"
;;
@ -134,6 +223,9 @@ case $i in
;;
--noparallel)
PARALLEL="false"
;;
--targets=*)
TARGETS="${i#*=}"
shift
;;
--tvos-sdk=*)
@ -207,6 +299,38 @@ fi
# Set GITHUB_VERSION (version with underscores instead of dots)
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
if [ ! -n "${IOS_SDKVERSION}" ]; then
IOS_SDKVERSION=$(xcrun -sdk iphoneos --show-sdk-version)
@ -215,18 +339,16 @@ 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
BUILD_THREADS=1
if [ "${PARALLEL}" != "false" ]; then
BUILD_THREADS=$(sysctl hw.ncpu | awk '{print $2}')
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)
case "${CURRENTPATH}" in
*\ * )
@ -258,14 +380,18 @@ esac
echo
echo "Build options"
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 " 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 " Build location: ${CURRENTPATH}"
echo
# Download OpenSSL when not present
@ -276,7 +402,7 @@ if [ ! -e ${OPENSSL_ARCHIVE_FILE_NAME} ]; then
OPENSSL_ARCHIVE_URL="https://github.com/openssl/openssl/archive/${OPENSSL_ARCHIVE_FILE_NAME}"
# -L follow Location header, -f fail silently for 4xx errors and return status 22, -O Use server-specified filename for download
curl ${CURL_OPTIONS} -LfO "${OPENSSL_ARCHIVE_URL}"
# Check for success status
if [ $? -ne 0 ]; then
echo "An error occured when trying to download OpenSSL ${VERSION} from ${OPENSSL_ARCHIVE_URL}."
@ -287,6 +413,10 @@ else
echo "Using ${OPENSSL_ARCHIVE_FILE_NAME}"
fi
# Set reference to custom configuration (OpenSSL 1.1.0)
# See: https://github.com/openssl/openssl/commit/afce395cba521e395e6eecdaf9589105f61e4411
export OPENSSL_LOCAL_CONFIG_DIR="${SCRIPTDIR}/config"
# -e Abort script at first error, when a command exits with non-zero status (except in until or while loops, if-tests, list constructs)
# -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 -eo pipefail
@ -319,150 +449,12 @@ LIBCRYPTO_IOS=()
LIBSSL_TVOS=()
LIBCRYPTO_TVOS=()
for ARCH in ${ARCHS}
do
# Determine relevant SDK version
if [[ "$ARCH" == tv* ]]; then
SDKVERSION=${TVOS_SDKVERSION}
else
SDKVERSION=${IOS_SDKVERSION}
fi
# Determine platform, override arch for tvOS builds
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
elif [ "${ARCH}" == "tv_x86_64" ]; then
ARCH="x86_64"
PLATFORM="AppleTVSimulator"
elif [ "${ARCH}" == "tv_arm64" ]; then
ARCH="arm64"
PLATFORM="AppleTVOS"
else
PLATFORM="iPhoneOS"
fi
# Set env vars for Configure
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
# Prepare target dir
TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
mkdir -p "${TARGETDIR}"
LOG="${TARGETDIR}/build-openssl-${VERSION}.log"
echo "Building openssl-${VERSION} for ${PLATFORM} ${SDKVERSION} ${ARCH}..."
echo " Logfile: ${LOG}"
# Prepare source dir
SOURCEDIR="${CURRENTPATH}/src/${PLATFORM}-${ARCH}"
mkdir -p "${SOURCEDIR}"
tar zxf "${CURRENTPATH}/${OPENSSL_ARCHIVE_FILE_NAME}" -C "${SOURCEDIR}"
cd "${SOURCEDIR}/openssl-${OPENSSL_ARCHIVE_BASE_NAME}"
chmod u+x ./Configure
# Add optional enable-ec_nistp_64_gcc_128 configure option for 64 bit builds
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
if [ "${CONFIG_ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then
case "${ARCH}" in
*64*)
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
;;
esac
fi
# Embed bitcode for SDK >= 9
if [[ "${SDKVERSION}" == 9.* || "${SDKVERSION}" == [0-9][0-9].* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -fembed-bitcode"
fi
# Add platform specific config options
if [[ "${PLATFORM}" == AppleTV* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}"
echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:tvOS/' "./Configure"
else
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}"
fi
# Add --openssldir option
LOCAL_CONFIG_OPTIONS="--openssldir=${TARGETDIR} ${LOCAL_CONFIG_OPTIONS}"
# Determine configure target
if [ "${ARCH}" == "x86_64" ]; then
LOCAL_CONFIG_OPTIONS="darwin64-x86_64-cc no-asm ${LOCAL_CONFIG_OPTIONS}"
else
LOCAL_CONFIG_OPTIONS="iphoneos-cross ${LOCAL_CONFIG_OPTIONS}"
fi
# Run Configure
echo " Configure...\c"
set +e
if [ "${LOG_VERBOSE}" == "verbose" ]; then
./Configure ${LOCAL_CONFIG_OPTIONS} | tee "${LOG}"
else
(./Configure ${LOCAL_CONFIG_OPTIONS} > "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "Configure"
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
if [ "${ARCH}" == "x86_64" ]; then
echo " Patching Makefile..."
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"
fi
# Run make depend if relevant
if [[ ! -z "${CONFIG_OPTIONS}" ]]; then
echo " Make depend...\c"
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make depend | tee -a "${LOG}"
else
(make depend >> "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "make depend"
fi
# Run make
echo " Make...\c"
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make -j "${BUILD_THREADS}" | tee -a "${LOG}"
else
(make -j "${BUILD_THREADS}" >> "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "make"
# Run make install
set -e
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make install_sw | tee -a "${LOG}"
else
make install_sw >> "${LOG}" 2>&1
fi
# Remove source dir
rm -r "${SOURCEDIR}"
# Add references to library files to relevant arrays
if [[ "${PLATFORM}" == AppleTV* ]]; then
LIBSSL_TVOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_TVOS+=("${TARGETDIR}/lib/libcrypto.a")
else
LIBSSL_IOS+=("${TARGETDIR}/lib/libssl.a")
LIBCRYPTO_IOS+=("${TARGETDIR}/lib/libcrypto.a")
fi
# Keep reference to first build target for include file
if [ -z "${INCLUDE_DIR}" ]; then
INCLUDE_DIR="${TARGETDIR}/include/openssl"
fi
done
# Run relevant build loop (archs = 1.0 style, targets = 1.1 style)
if [ "${BUILD_TYPE}" == "archs" ]; then
source "${SCRIPTDIR}/scripts/build-loop-archs.sh"
else
source "${SCRIPTDIR}/scripts/build-loop-targets.sh"
fi
# Build iOS library if selected for build
if [ ${#LIBSSL_IOS} -gt 0 ]; then

View File

@ -0,0 +1,91 @@
## -*- mode: perl; -*-
## iOS configuration targets
%targets = (
## Base settings for iOS-tvOS cross-compile
# Based on 10-main.conf: iphoneos-cross
# Add generic compiler flags
# Add embed-bitcode option if SDK version is 9 or higher
"ios-tvos-cross-base" => {
template => 1,
cflags => combine('-isysroot $(CROSS_TOP)/SDKs/$(CROSS_SDK) -fno-common',
sub { (defined($ENV{'SDKVERSION'}) && $ENV{'SDKVERSION'} =~ /^(9|[1-9][0-9]+)\./ && $disabled{shared})
? '-fembed-bitcode' : (); },
),
},
## Base settings for iOS
"ios-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ],
template => 1,
cflags => add(sub { defined($ENV{'IOS_MIN_SDK_VERSION'}) ? '-mios-version-min=$(IOS_MIN_SDK_VERSION)' : '-mios-version-min=7.0'; }),
},
## Base settings for tvOS
# Defines to skip functionality that uses unsupported functions
"tvos-cross-base" => {
inherit_from => [ "ios-tvos-cross-base" ],
template => 1,
cflags => add(sub { defined($ENV{'TVOS_MIN_SDK_VERSION'}) ? '-mtvos-version-min=$(TVOS_MIN_SDK_VERSION)' : '-mtvos-version-min=9.0'; }),
defines => [ "HAVE_FORK=0" ],
},
## Apple iOS simulator (x86_64)
# Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc
"ios-sim-cross-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "ios-cross-base" ],
sys_id => "iOS",
},
## Apple iOS simulator (i386)
# Based on 10-main.conf: iphoneos-cross / darwin-i386-cc
"ios-sim-cross-i386" => {
inherit_from => [ "darwin-i386-cc", "ios-cross-base" ],
sys_id => "iOS",
},
## Apple iOS (arm64)
# Based on 10-main.conf: ios64-cross
"ios64-cross-arm64" => {
inherit_from => [ "darwin-common", "ios-cross-base", asm("aarch64_asm") ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",
sys_id => "iOS",
},
## Apple iOS (armv7s)
# Based on 10-main.conf: ios-cross
"ios-cross-armv7s" => {
inherit_from => [ "darwin-common", "ios-cross-base", asm("armv4_asm") ],
cflags => add("-arch armv7s"),
perlasm_scheme => "ios32",
sys_id => "iOS",
},
## Apple iOS (armv7)
# Based on 10-main.conf: ios-cross
"ios-cross-armv7" => {
inherit_from => [ "darwin-common", "ios-cross-base", asm("armv4_asm") ],
cflags => add("-arch armv7"),
perlasm_scheme => "ios32",
sys_id => "iOS",
},
## Apple tvOS simulator (x86_64)
# Based on 10-main.conf: iphoneos-cross / darwin64-x86_64-cc
"tvos-sim-cross-x86_64" => {
inherit_from => [ "darwin64-x86_64-cc", "tvos-cross-base" ],
sys_id => "tvOS",
},
## Apple tvOS (arm64)
# Based on 10-main.conf: ios64-cross
"tvos64-cross-arm64" => {
inherit_from => [ "darwin-common", "tvos-cross-base", asm("aarch64_asm") ],
cflags => add("-arch arm64"),
bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
perlasm_scheme => "ios64",
sys_id => "tvOS",
},
);

123
scripts/build-loop-archs.sh Executable file
View File

@ -0,0 +1,123 @@
#!/bin/sh
# Automatic build script for libssl and libcrypto
# for iPhoneOS and iPhoneSimulator
#
# Created by Felix Schulze on 16.12.10.
# Copyright 2010-2016 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
for ARCH in ${ARCHS}
do
# Determine relevant SDK version
if [[ "$ARCH" == tv* ]]; then
SDKVERSION=${TVOS_SDKVERSION}
else
SDKVERSION=${IOS_SDKVERSION}
fi
# Determine platform, override arch for tvOS builds
if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
PLATFORM="iPhoneSimulator"
elif [ "${ARCH}" == "tv_x86_64" ]; then
ARCH="x86_64"
PLATFORM="AppleTVSimulator"
elif [ "${ARCH}" == "tv_arm64" ]; then
ARCH="arm64"
PLATFORM="AppleTVOS"
else
PLATFORM="iPhoneOS"
fi
# Set env vars for Configure
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
export BUILD_TOOLS="${DEVELOPER}"
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
# Prepare TARGETDIR and SOURCEDIR
prepare_target_source_dirs
# Add optional enable-ec_nistp_64_gcc_128 configure option for 64 bit builds
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
if [ "${CONFIG_ENABLE_EC_NISTP_64_GCC_128}" == "true" ]; then
case "${ARCH}" in
*64*)
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
;;
esac
fi
# Embed bitcode for SDK >= 9
if [[ "${SDKVERSION}" == 9.* || "${SDKVERSION}" == [0-9][0-9].* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -fembed-bitcode"
fi
# Add platform specific config options
if [[ "${PLATFORM}" == AppleTV* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -DHAVE_FORK=0 -mtvos-version-min=${TVOS_MIN_SDK_VERSION}"
echo " Patching Configure..."
LC_ALL=C sed -i -- 's/D\_REENTRANT\:iOS/D\_REENTRANT\:tvOS/' "./Configure"
else
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -miphoneos-version-min=${IOS_MIN_SDK_VERSION}"
fi
# Add --openssldir option
LOCAL_CONFIG_OPTIONS="--openssldir=${TARGETDIR} ${LOCAL_CONFIG_OPTIONS}"
# Determine configure target
if [ "${ARCH}" == "x86_64" ]; then
LOCAL_CONFIG_OPTIONS="darwin64-x86_64-cc no-asm ${LOCAL_CONFIG_OPTIONS}"
else
LOCAL_CONFIG_OPTIONS="iphoneos-cross ${LOCAL_CONFIG_OPTIONS}"
fi
# Run Configure
run_configure
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
if [ "${ARCH}" == "x86_64" ]; then
echo " Patching Makefile..."
sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} !" "Makefile"
fi
# Run make depend if relevant
if [[ ! -z "${CONFIG_OPTIONS}" ]]; then
echo " Make depend...\c"
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make depend | tee -a "${LOG}"
else
(make depend >> "${LOG}" 2>&1) & spinner
fi
# Check for error status
check_status $? "make depend"
fi
# Run make
run_make
# Run make install
set -e
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make install_sw | tee -a "${LOG}"
else
make install_sw >> "${LOG}" 2>&1
fi
# Remove source dir, add references to library files to relevant arrays
# Keep reference to first build target for include file
finish_build_loop
done

89
scripts/build-loop-targets.sh Executable file
View File

@ -0,0 +1,89 @@
#!/bin/sh
# Automatic build script for libssl and libcrypto
# for iPhoneOS and iPhoneSimulator
#
# Created by Felix Schulze on 16.12.10.
# Copyright 2010-2016 Felix Schulze. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
for TARGET in ${TARGETS}
do
# Determine relevant SDK version
if [[ "${TARGET}" == tvos* ]]; then
SDKVERSION="${TVOS_SDKVERSION}"
else
SDKVERSION="${IOS_SDKVERSION}"
fi
# These variables are used in the configuration file
export SDKVERSION
export IOS_MIN_SDK_VERSION
export TVOS_MIN_SDK_VERSION
# Determine platform
if [[ "${TARGET}" == "ios-sim-cross-"* ]]; then
PLATFORM="iPhoneSimulator"
elif [[ "${TARGET}" == "tvos-sim-cross-"* ]]; then
PLATFORM="AppleTVSimulator"
elif [[ "${TARGET}" == "tvos64-cross-"* ]]; then
PLATFORM="AppleTVOS"
else
PLATFORM="iPhoneOS"
fi
# Extract ARCH from TARGET (part after last dash)
ARCH=$(echo "${TARGET}" | sed -E 's|^.*\-([^\-]+)$|\1|g')
# Cross compile references, see Configurations/10-main.conf
export CROSS_COMPILE="${DEVELOPER}/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
export CROSS_SDK="${PLATFORM}${SDKVERSION}.sdk"
# Prepare TARGETDIR and SOURCEDIR
prepare_target_source_dirs
## Determine config options
# Add build target, --prefix and prevent creation of shared libraries (default since 1.1.0)
LOCAL_CONFIG_OPTIONS="${TARGET} --prefix=${TARGETDIR} ${CONFIG_OPTIONS} no-shared"
# Only relevant for 64 bit builds
if [[ "${CONFIG_ENABLE_EC_NISTP_64_GCC_128}" == "true" && "${ARCH}" == *64 ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} enable-ec_nistp_64_gcc_128"
fi
# Disable unavailable async for tvOS builds
if [[ "${PLATFORM}" == AppleTV* ]]; then
LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} no-async"
fi
# Run Configure
run_configure
# Run make
run_make
# Run make install
set -e
if [ "${LOG_VERBOSE}" == "verbose" ]; then
make install_dev | tee -a "${LOG}"
else
make install_dev >> "${LOG}" 2>&1
fi
# Remove source dir, add references to library files to relevant arrays
# Keep reference to first build target for include file
finish_build_loop
done

40
travis-build.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/sh
# Log script output with prefix
log_output()
{
while read INPUT; do
echo "${1} ${INPUT}"
done
}
# Shut up curl
export CURL_OPTIONS="-s"
# Build 1.0.2 in current directory
./build-libssl.sh --noparallel --verbose-on-error | log_output "ARCHS " &
PID_ARCHS=$!
# Build 1.1.0 in (temporary) subdirectory
mkdir targets
cd targets
cp -r ../include .
../build-libssl.sh --noparallel --verbose-on-error --ec-nistp-64-gcc-128 --version=1.1.0b | log_output "TARGETS" &
PID_TARGETS=$!
echo "SCRIPT Started jobs, waiting for jobs to finish"
wait ${PID_ARCHS}
wait ${PID_TARGETS}
# Verify/prepare 1.1.0 build dir
xcrun -sdk iphoneos lipo -info ./lib/*.a | log_output "TARGETS"
../create-openssl-framework.sh | log_output "TARGETS"
xcrun -sdk iphoneos lipo -info openssl.framework/openssl | log_output "TARGETS"
cp -r ../OpenSSL-for-* .
# Back to main dir
cd ..
xcrun -sdk iphoneos lipo -info ./lib/*.a | log_output "ARCHS "
./create-openssl-framework.sh | log_output "ARCHS "
xcrun -sdk iphoneos lipo -info openssl.framework/openssl | log_output "ARCHS "