mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Merge pull request #7025 from bandi13/universalScriptSimplify
Massively simplify apple-universal script
This commit is contained in:
@ -20,7 +20,6 @@
|
|||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
||||||
|
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
WOLFSSL_DIR=$(pwd)/../../
|
WOLFSSL_DIR=$(pwd)/../../
|
||||||
@ -28,12 +27,9 @@ OUTDIR=$(pwd)/artifacts
|
|||||||
LIPODIR=${OUTDIR}/lib
|
LIPODIR=${OUTDIR}/lib
|
||||||
SDK_OUTPUT_DIR=${OUTDIR}/xcframework
|
SDK_OUTPUT_DIR=${OUTDIR}/xcframework
|
||||||
|
|
||||||
|
|
||||||
CFLAGS_COMMON=""
|
CFLAGS_COMMON=""
|
||||||
# Optional configure flags passed in by user through -c argument
|
|
||||||
CONF_OPTS_EXTRA=""
|
|
||||||
# Base configure flags
|
# Base configure flags
|
||||||
CONF_OPTS_COMMON="--disable-shared --enable-static"
|
CONF_OPTS="--disable-shared --enable-static"
|
||||||
|
|
||||||
helpFunction()
|
helpFunction()
|
||||||
{
|
{
|
||||||
@ -47,7 +43,7 @@ helpFunction()
|
|||||||
while getopts ":c:" opt; do
|
while getopts ":c:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
c)
|
c)
|
||||||
CONF_OPTS_EXTRA="$OPTARG"
|
CONF_OPTS+=" $OPTARG"
|
||||||
;;
|
;;
|
||||||
\?)
|
\?)
|
||||||
echo "Invalid option: -$OPTARG" >&2; helpFunction
|
echo "Invalid option: -$OPTARG" >&2; helpFunction
|
||||||
@ -55,279 +51,60 @@ while getopts ":c:" opt; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Amalgamate extra CLI options with base options
|
|
||||||
CONF_OPTS="${CONF_OPTS_COMMON} ${CONF_OPTS_EXTRA}"
|
|
||||||
|
|
||||||
rm -rf $OUTDIR
|
rm -rf $OUTDIR
|
||||||
mkdir -p $LIPODIR
|
mkdir -p $LIPODIR
|
||||||
mkdir -p $SDK_OUTPUT_DIR
|
mkdir -p $SDK_OUTPUT_DIR
|
||||||
|
|
||||||
|
build() { # <ARCH=arm64|x86_64> <TYPE=iphonesimulator|iphoneos|macosx|watchos|watchsimulator|appletvos|appletvsimulator>
|
||||||
buildIOSSim()
|
|
||||||
{
|
|
||||||
set -x
|
set -x
|
||||||
pushd .
|
pushd .
|
||||||
cd $WOLFSSL_DIR
|
cd $WOLFSSL_DIR
|
||||||
|
|
||||||
ARCH=$1
|
ARCH=$1
|
||||||
HOST="${ARCH}-apple-darwin"
|
HOST="${ARCH}-apple-darwin"
|
||||||
SDK_ROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)
|
TYPE=$2
|
||||||
|
SDK_ROOT=$(xcrun --sdk ${TYPE} --show-sdk-path)
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-ios-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
./configure -prefix=${OUTDIR}/wolfssl-${TYPE}-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
||||||
make -j
|
make -j src/libwolfssl.la
|
||||||
make install
|
make install
|
||||||
|
|
||||||
popd
|
popd
|
||||||
set +x
|
set +x
|
||||||
}
|
}
|
||||||
|
|
||||||
buildIOS()
|
XCFRAMEWORKS=
|
||||||
{
|
for type in iphonesimulator macosx appletvsimulator watchsimulator ; do
|
||||||
set -x
|
build arm64 ${type}
|
||||||
pushd .
|
build x86_64 ${type}
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=$1
|
# Create universal binaries from architecture-specific static libraries
|
||||||
HOST="${ARCH}-apple-darwin"
|
lipo \
|
||||||
SDK_ROOT=$(xcrun --sdk iphoneos --show-sdk-path)
|
"$OUTDIR/wolfssl-${type}-x86_64/lib/libwolfssl.a" \
|
||||||
|
"$OUTDIR/wolfssl-${type}-arm64/lib/libwolfssl.a" \
|
||||||
|
-create -output $LIPODIR/libwolfssl-${type}.a
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-ios-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
echo "Checking libraries"
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
xcrun -sdk ${type} lipo -info $LIPODIR/libwolfssl-${type}.a
|
||||||
make -j
|
XCFRAMEWORKS+=" -library ${LIPODIR}/libwolfssl-${type}.a -headers ${OUTDIR}/wolfssl-${type}-arm64/include"
|
||||||
make install
|
done
|
||||||
|
|
||||||
popd
|
for type in iphoneos appletvos ; do
|
||||||
set +x
|
build arm64 ${type}
|
||||||
}
|
|
||||||
|
|
||||||
buildMacOS()
|
# Create universal binaries from architecture-specific static libraries
|
||||||
{
|
lipo \
|
||||||
set -x
|
"$OUTDIR/wolfssl-${type}-arm64/lib/libwolfssl.a" \
|
||||||
pushd .
|
-create -output $LIPODIR/libwolfssl-${type}.a
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
HOST="${ARCH}-apple-darwin"
|
|
||||||
SDK_ROOT=$(xcrun --sdk macosx --show-sdk-path)
|
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-macos-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
|
||||||
make -j
|
|
||||||
make install
|
|
||||||
|
|
||||||
popd
|
|
||||||
set +x
|
|
||||||
}
|
|
||||||
|
|
||||||
buildWatchOS()
|
|
||||||
{
|
|
||||||
set -x
|
|
||||||
pushd .
|
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
HOST="${ARCH}-apple-darwin"
|
|
||||||
SDK_ROOT=$(xcrun --sdk watchos --show-sdk-path)
|
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-watchos-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
|
||||||
make -j
|
|
||||||
make install
|
|
||||||
|
|
||||||
popd
|
|
||||||
set +x
|
|
||||||
}
|
|
||||||
|
|
||||||
buildWatchOSSim()
|
|
||||||
{
|
|
||||||
set -x
|
|
||||||
pushd .
|
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
HOST="${ARCH}-apple-darwin"
|
|
||||||
SDK_ROOT=$(xcrun --sdk watchsimulator --show-sdk-path)
|
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-watchos-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
|
||||||
make -j
|
|
||||||
make install
|
|
||||||
|
|
||||||
popd
|
|
||||||
set +x
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTVOS()
|
|
||||||
{
|
|
||||||
set -x
|
|
||||||
pushd .
|
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=arm64
|
|
||||||
HOST="${ARCH}-apple-darwin"
|
|
||||||
SDK_ROOT=$(xcrun --sdk appletvos --show-sdk-path)
|
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-tvos-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
|
||||||
make -j
|
|
||||||
make install
|
|
||||||
|
|
||||||
popd
|
|
||||||
set +x
|
|
||||||
}
|
|
||||||
|
|
||||||
buildTVOSSim()
|
|
||||||
{
|
|
||||||
set -x
|
|
||||||
pushd .
|
|
||||||
cd $WOLFSSL_DIR
|
|
||||||
|
|
||||||
ARCH=$1
|
|
||||||
HOST="${ARCH}-apple-darwin"
|
|
||||||
SDK_ROOT=$(xcrun --sdk appletvsimulator --show-sdk-path)
|
|
||||||
|
|
||||||
./configure -prefix=${OUTDIR}/wolfssl-tvos-simulator-${ARCH} ${CONF_OPTS} --host=${HOST} \
|
|
||||||
CFLAGS="${CFLAGS_COMMON} -arch ${ARCH} -isysroot ${SDK_ROOT}"
|
|
||||||
make -j
|
|
||||||
make install
|
|
||||||
|
|
||||||
popd
|
|
||||||
set +x
|
|
||||||
}
|
|
||||||
|
|
||||||
buildCatalyst()
|
|
||||||
{
|
|
||||||
echo "TBD"
|
|
||||||
}
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# IOS Simulator ############################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildIOSSim arm64
|
|
||||||
buildIOSSim x86_64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-ios-simulator-x86_64/lib/libwolfssl.a" \
|
|
||||||
"$OUTDIR/wolfssl-ios-simulator-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-ios-simulator.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk iphonesimulator lipo -info $LIPODIR/libwolfssl-ios-simulator.a
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# IOS ######################################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildIOS arm64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-ios-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-ios.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk iphoneos lipo -info $LIPODIR/libwolfssl-ios.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# MacOS ####################################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildMacOS arm64
|
|
||||||
buildMacOS x86_64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-macos-x86_64/lib/libwolfssl.a" \
|
|
||||||
"$OUTDIR/wolfssl-macos-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-macos.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk macosx lipo -info $LIPODIR/libwolfssl-macos.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# tvOS Simulator ###########################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildTVOSSim arm64
|
|
||||||
buildTVOSSim x86_64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-tvos-simulator-x86_64/lib/libwolfssl.a" \
|
|
||||||
"$OUTDIR/wolfssl-tvos-simulator-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-tvos-simulator.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk appletvsimulator lipo -info $LIPODIR/libwolfssl-tvos-simulator.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# tvOS #####################################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildTVOS arm64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-tvos-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-tvos.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk appletvos lipo -info $LIPODIR/libwolfssl-tvos.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# watchOS Simulator ########################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildWatchOSSim arm64
|
|
||||||
buildWatchOSSim x86_64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-watchos-simulator-arm64/lib/libwolfssl.a" \
|
|
||||||
"$OUTDIR/wolfssl-watchos-simulator-x86_64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-watchos-simulator.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk watchsimulator lipo -info $LIPODIR/libwolfssl-watchos-simulator.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# watchOS ##################################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
buildWatchOS arm64
|
|
||||||
|
|
||||||
# Create universal binaries from architecture-specific static libraries
|
|
||||||
lipo \
|
|
||||||
"$OUTDIR/wolfssl-watchos-arm64/lib/libwolfssl.a" \
|
|
||||||
-create -output $LIPODIR/libwolfssl-watchos.a
|
|
||||||
|
|
||||||
echo "Checking libraries"
|
|
||||||
xcrun -sdk watchos lipo -info $LIPODIR/libwolfssl-watchos.a
|
|
||||||
|
|
||||||
|
|
||||||
############################################################################################################################################
|
|
||||||
# Catalyst #################################################################################################################################
|
|
||||||
############################################################################################################################################
|
|
||||||
|
|
||||||
|
echo "Checking libraries"
|
||||||
|
xcrun -sdk ${type} lipo -info $LIPODIR/libwolfssl-${type}.a
|
||||||
|
XCFRAMEWORKS+=" -library ${LIPODIR}/libwolfssl-${type}.a -headers ${OUTDIR}/wolfssl-${type}-arm64/include"
|
||||||
|
done
|
||||||
|
|
||||||
############################################################################################################################################
|
############################################################################################################################################
|
||||||
# ********** BUILD FRAMEWORK
|
# ********** BUILD FRAMEWORK
|
||||||
############################################################################################################################################
|
############################################################################################################################################
|
||||||
|
|
||||||
xcodebuild -create-xcframework \
|
xcodebuild -create-xcframework ${XCFRAMEWORKS} -output ${SDK_OUTPUT_DIR}/libwolfssl.xcframework
|
||||||
-library ${LIPODIR}/libwolfssl-ios-simulator.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-ios-simulator-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-ios.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-ios-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-macos.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-macos-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-tvos.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-tvos-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-tvos-simulator.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-tvos-simulator-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-watchos.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-watchos-arm64/include \
|
|
||||||
-library ${LIPODIR}/libwolfssl-watchos-simulator.a \
|
|
||||||
-headers ${OUTDIR}/wolfssl-watchos-simulator-arm64/include \
|
|
||||||
-output ${SDK_OUTPUT_DIR}/libwolfssl.xcframework
|
|
||||||
|
Reference in New Issue
Block a user