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 $?
|
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 for error status
|
||||||
check_status()
|
check_status()
|
||||||
{
|
{
|
||||||
|
@ -109,6 +128,57 @@ check_status()
|
||||||
fi
|
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
|
# Init optional command line vars
|
||||||
ARCHS=""
|
ARCHS=""
|
||||||
BRANCH=""
|
BRANCH=""
|
||||||
|
@ -403,20 +473,8 @@ do
|
||||||
export BUILD_TOOLS="${DEVELOPER}"
|
export BUILD_TOOLS="${DEVELOPER}"
|
||||||
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
|
export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
|
||||||
|
|
||||||
# Prepare target dir
|
# Prepare TARGETDIR and SOURCEDIR
|
||||||
TARGETDIR="${CURRENTPATH}/bin/${PLATFORM}${SDKVERSION}-${ARCH}.sdk"
|
prepare_target_source_dirs
|
||||||
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
|
# Add optional enable-ec_nistp_64_gcc_128 configure option for 64 bit builds
|
||||||
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
|
LOCAL_CONFIG_OPTIONS="${CONFIG_OPTIONS}"
|
||||||
|
@ -453,16 +511,7 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run Configure
|
# Run Configure
|
||||||
echo " Configure..."
|
run_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"
|
|
||||||
|
|
||||||
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
|
# Only required for Darwin64 builds (-isysroot is automatically added by iphoneos-cross target)
|
||||||
if [ "${ARCH}" == "x86_64" ]; then
|
if [ "${ARCH}" == "x86_64" ]; then
|
||||||
|
@ -484,15 +533,7 @@ do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run make
|
# Run make
|
||||||
echo " Make (using ${BUILD_THREADS} thread(s))..."
|
run_make
|
||||||
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
|
# Run make install
|
||||||
set -e
|
set -e
|
||||||
|
@ -502,23 +543,9 @@ do
|
||||||
make install_sw >> "${LOG}" 2>&1
|
make install_sw >> "${LOG}" 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Return to ${CURRENTPATH} and remove source dir
|
# Remove source dir, add references to library files to relevant arrays
|
||||||
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
|
# Keep reference to first build target for include file
|
||||||
if [ -z "${INCLUDE_DIR}" ]; then
|
finish_build_loop
|
||||||
INCLUDE_DIR="${TARGETDIR}/include/openssl"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Build iOS library if selected for build
|
# Build iOS library if selected for build
|
||||||
|
|
Loading…
Reference in New Issue