Move generic parts of build loop to functions
This commit is contained in:
parent
c683e1b3d8
commit
8709045b25
125
build-libssl.sh
125
build-libssl.sh
|
@ -87,6 +87,25 @@ spinner()
|
|||
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()
|
||||
{
|
||||
|
@ -109,6 +128,57 @@ 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=""
|
||||
|
@ -403,20 +473,8 @@ do
|
|||
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
|
||||
# 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}"
|
||||
|
@ -453,16 +511,7 @@ do
|
|||
fi
|
||||
|
||||
# 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_configure
|
||||
|
||||
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
|
||||
if [ "${ARCH}" == "x86_64" ]; then
|
||||
|
@ -484,15 +533,7 @@ do
|
|||
fi
|
||||
|
||||
# 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"
|
||||
run_make
|
||||
|
||||
# Run make install
|
||||
set -e
|
||||
|
@ -502,23 +543,9 @@ do
|
|||
make install_sw >> "${LOG}" 2>&1
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# Remove source dir, add references to library files to relevant arrays
|
||||
# Keep reference to first build target for include file
|
||||
if [ -z "${INCLUDE_DIR}" ]; then
|
||||
INCLUDE_DIR="${TARGETDIR}/include/openssl"
|
||||
fi
|
||||
finish_build_loop
|
||||
done
|
||||
|
||||
# Build iOS library if selected for build
|
||||
|
|
Loading…
Reference in New Issue