Skip to content

Commit

Permalink
Move 1.0 (archs) build loop to separate file and add 1.1 (targets) bu…
Browse files Browse the repository at this point in the history
…ild loop
  • Loading branch information
oneton committed Nov 6, 2016
1 parent da61c4b commit 8a0cc68
Show file tree
Hide file tree
Showing 3 changed files with 218 additions and 102 deletions.
108 changes: 6 additions & 102 deletions build-libssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -449,108 +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 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
# 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
Expand Down
123 changes: 123 additions & 0 deletions scripts/build-loop-archs.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 89 additions & 0 deletions scripts/build-loop-targets.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8a0cc68

Please sign in to comment.