201 lines
5.6 KiB
Bash
Executable file
201 lines
5.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -ex
|
|
|
|
# Configure the following variables according to your needs
|
|
|
|
OPENSSL_TAG_VERSION="OpenSSL_1_1_1g "
|
|
CURL_TAG_VERSION="master "
|
|
JSONC_TAG_VERSION="master"
|
|
IOS_MIN_VERSION="13.0"
|
|
|
|
# Edit below at your own risk
|
|
|
|
XCODE_ROOT="$(xcode-select -p)/Platforms"
|
|
VARIANTS="Simulator OS"
|
|
|
|
get_toolchain() {
|
|
(
|
|
cd deps
|
|
test -d ios-cmake || git clone https://github.com/cristeab/ios-cmake.git
|
|
)
|
|
}
|
|
|
|
make_openssl() {
|
|
(
|
|
cd deps
|
|
test -d openssl || git clone --branch $OPENSSL_TAG_VERSION https://github.com/openssl/openssl.git
|
|
for VARIANT in $VARIANTS; do
|
|
(
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
|
#export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
#export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
|
mkdir -p "$PREFIX"
|
|
cd openssl
|
|
git checkout $OPENSSL_TAG_VERSION
|
|
make clean
|
|
#export CC=clang
|
|
#export PATH="${XCODE_ROOT}/../Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$PATH"
|
|
#export CROSS_TOP=${PLATFORM}/Developer
|
|
#export CROSS_SDK="iPhone${VARIANT}.sdk"
|
|
case $VARIANT in
|
|
OS)
|
|
export TARGET=ios64-xcrun
|
|
;;
|
|
Simulator)
|
|
export TARGET=iossimulator-xcrun
|
|
;;
|
|
esac
|
|
./Configure \
|
|
--prefix="$PREFIX" \
|
|
no-dso \
|
|
no-hw \
|
|
no-engine \
|
|
no-shared \
|
|
$TARGET
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
make install_dev
|
|
)
|
|
done
|
|
)
|
|
}
|
|
|
|
make_curl() {
|
|
(
|
|
cd deps
|
|
test -d curl || git clone --branch $CURL_TAG_VERSION https://github.com/curl/curl.git
|
|
for VARIANT in $VARIANTS; do
|
|
(
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
|
export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
|
case $VARIANT in
|
|
OS)
|
|
export ARCH=arm64
|
|
export HOST=arm-apple-darwin
|
|
break;;
|
|
Simulator)
|
|
export ARCH=x86_64
|
|
export HOST=x86_64-apple-darwin
|
|
break;;
|
|
esac
|
|
export CPPFLAGS="-DCURL_BUILD_IOS"
|
|
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SDK} -miphoneos-version-min=${IOS_MIN_VERSION} -fembed-bitcode"
|
|
export LDFLAGS="-arch ${ARCH} -isysroot ${SDK}"
|
|
mkdir -p "$PREFIX"
|
|
cd curl
|
|
git checkout $CURL_TAG_VERSION
|
|
test -f configure || ./buildconf
|
|
make clean
|
|
./configure \
|
|
--disable-shared \
|
|
--without-zlib \
|
|
--enable-static \
|
|
--enable-ipv6 \
|
|
--host="${HOST}" \
|
|
--with-darwinssl \
|
|
--prefix=${PREFIX}
|
|
#--with-ssl="$PREFIX" \
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
make install
|
|
)
|
|
done
|
|
)
|
|
}
|
|
|
|
make_jsonc() {
|
|
(
|
|
cd deps
|
|
test -d json-c || git clone --branch $JSONC_TAG_VERSION https://github.com/json-c/json-c.git
|
|
for VARIANT in $VARIANTS; do
|
|
(
|
|
export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
|
mkdir -p "$PREFIX"
|
|
cd json-c
|
|
git checkout $JSONC_TAG_VERSION
|
|
if [ -d $VARIANT ]; then
|
|
rm -rf $VARIANT
|
|
fi
|
|
mkdir $VARIANT
|
|
pushd $VARIANT
|
|
cmake \
|
|
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
|
|
-DCMAKE_INCLUDE_PATH=$PREFIX/include \
|
|
-DCMAKE_PREFIX_PATH="${PREFIX};${SDK}/usr" \
|
|
-DCMAKE_IOS_DEVELOPER_ROOT="$PLATFORM" \
|
|
-DCMAKE_IOS_SDK_ROOT="$SDK" \
|
|
-DIOS_PLATFORM=$(echo $VARIANT | tr a-z A-Z) \
|
|
-DCMAKE_TOOLCHAIN_FILE=../../ios-cmake/toolchain/iOS.cmake \
|
|
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-DBUILD_STATIC_LIBS=ON \
|
|
..
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
make install
|
|
)
|
|
done
|
|
)
|
|
}
|
|
|
|
make_pihelper() {
|
|
for VARIANT in $VARIANTS; do
|
|
(
|
|
export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
|
mkdir -p "$PREFIX"
|
|
pushd build
|
|
if [ -d $VARIANT ]; then
|
|
rm -rf $VARIANT
|
|
fi
|
|
mkdir $VARIANT
|
|
pushd $VARIANT
|
|
cmake \
|
|
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
|
|
-DCMAKE_INCLUDE_PATH=$PREFIX/include \
|
|
-DCMAKE_PREFIX_PATH="${PREFIX};${SDK}/usr" \
|
|
-DCMAKE_IOS_DEVELOPER_ROOT="$PLATFORM" \
|
|
-DCMAKE_IOS_SDK_ROOT="$SDK" \
|
|
-DIOS_PLATFORM=$(echo $VARIANT | tr a-z A-Z) \
|
|
-DCMAKE_TOOLCHAIN_FILE=../../deps/ios-cmake/toolchain/iOS.cmake \
|
|
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
|
-DPIHELPER_DEV=ON \
|
|
-DPIHELPER_SHARED=OFF \
|
|
-DPIHELPER_STATIC=ON \
|
|
../..
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
make install
|
|
)
|
|
done
|
|
}
|
|
|
|
package() {
|
|
cd $BUILD_DIR/ios
|
|
cp -r OS/include .
|
|
for LIB in json-c curl ssl crypto pihelper; do
|
|
(
|
|
lipo -create \
|
|
OS/lib/lib${LIB}.a \
|
|
Simulator/lib/lib${LIB}.a \
|
|
-output lib${LIB}.dylib
|
|
)
|
|
done
|
|
}
|
|
|
|
(
|
|
if [ "$(dirname $0)" == "." ]; then
|
|
cd ..
|
|
fi
|
|
test -d deps || mkdir deps
|
|
export BUILD_DIR="$PWD/build"
|
|
test -d "$BUILD_DIR" || mkdir -p "$BUILD_DIR"
|
|
get_toolchain
|
|
make_openssl
|
|
#make_curl
|
|
#make_jsonc
|
|
#make_pihelper
|
|
package
|
|
)
|
|
|