2020-07-07 02:16:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-12-01 22:26:33 +00:00
|
|
|
set -ex
|
|
|
|
|
2020-07-07 02:16:38 +00:00
|
|
|
# Configure the following variables according to your needs
|
|
|
|
|
|
|
|
OPENSSL_TAG_VERSION="OpenSSL_1_1_1g "
|
|
|
|
CURL_TAG_VERSION="master "
|
|
|
|
JSONC_TAG_VERSION="master"
|
2020-12-01 22:26:33 +00:00
|
|
|
IOS_MIN_VERSION="13.0"
|
2020-07-07 02:16:38 +00:00
|
|
|
|
|
|
|
# Edit below at your own risk
|
|
|
|
|
2020-12-01 22:26:33 +00:00
|
|
|
XCODE_ROOT="$(xcode-select -p)/Platforms"
|
|
|
|
VARIANTS="Simulator OS"
|
2020-07-07 02:16:38 +00:00
|
|
|
|
|
|
|
get_toolchain() {
|
2020-12-01 22:26:33 +00:00
|
|
|
(
|
2020-07-07 02:16:38 +00:00
|
|
|
cd deps
|
|
|
|
test -d ios-cmake || git clone https://github.com/cristeab/ios-cmake.git
|
2020-12-01 22:26:33 +00:00
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_openssl() {
|
2020-12-01 22:26:33 +00:00
|
|
|
(
|
2020-07-07 02:16:38 +00:00
|
|
|
cd deps
|
|
|
|
test -d openssl || git clone --branch $OPENSSL_TAG_VERSION https://github.com/openssl/openssl.git
|
2020-12-01 22:26:33 +00:00
|
|
|
for VARIANT in $VARIANTS; do
|
2020-07-07 02:16:38 +00:00
|
|
|
(
|
|
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
2020-12-01 22:26:33 +00:00
|
|
|
#export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
|
|
#export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
2020-07-07 02:16:38 +00:00
|
|
|
mkdir -p "$PREFIX"
|
|
|
|
cd openssl
|
|
|
|
git checkout $OPENSSL_TAG_VERSION
|
|
|
|
make clean
|
2020-12-01 22:26:33 +00:00
|
|
|
#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
|
2020-07-07 02:16:38 +00:00
|
|
|
./Configure \
|
|
|
|
--prefix="$PREFIX" \
|
2020-12-01 22:26:33 +00:00
|
|
|
no-dso \
|
|
|
|
no-hw \
|
|
|
|
no-engine \
|
2020-07-07 02:16:38 +00:00
|
|
|
no-shared \
|
2020-12-01 22:26:33 +00:00
|
|
|
$TARGET
|
|
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
2020-07-07 02:16:38 +00:00
|
|
|
make install_dev
|
|
|
|
)
|
|
|
|
done
|
2020-12-01 22:26:33 +00:00
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_curl() {
|
2020-12-01 22:26:33 +00:00
|
|
|
(
|
2020-07-07 02:16:38 +00:00
|
|
|
cd deps
|
|
|
|
test -d curl || git clone --branch $CURL_TAG_VERSION https://github.com/curl/curl.git
|
2020-12-01 22:26:33 +00:00
|
|
|
for VARIANT in $VARIANTS; do
|
2020-07-07 02:16:38 +00:00
|
|
|
(
|
|
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
2020-12-01 22:26:33 +00:00
|
|
|
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}"
|
2020-07-07 02:16:38 +00:00
|
|
|
mkdir -p "$PREFIX"
|
|
|
|
cd curl
|
|
|
|
git checkout $CURL_TAG_VERSION
|
|
|
|
test -f configure || ./buildconf
|
|
|
|
make clean
|
2020-12-01 22:26:33 +00:00
|
|
|
./configure \
|
2020-07-07 02:16:38 +00:00
|
|
|
--disable-shared \
|
2020-12-01 22:26:33 +00:00
|
|
|
--without-zlib \
|
|
|
|
--enable-static \
|
|
|
|
--enable-ipv6 \
|
|
|
|
--host="${HOST}" \
|
|
|
|
--with-darwinssl \
|
|
|
|
--prefix=${PREFIX}
|
|
|
|
#--with-ssl="$PREFIX" \
|
|
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
2020-07-07 02:16:38 +00:00
|
|
|
make install
|
|
|
|
)
|
|
|
|
done
|
2020-12-01 22:26:33 +00:00
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_jsonc() {
|
2020-12-01 22:26:33 +00:00
|
|
|
(
|
2020-07-07 02:16:38 +00:00
|
|
|
cd deps
|
|
|
|
test -d json-c || git clone --branch $JSONC_TAG_VERSION https://github.com/json-c/json-c.git
|
2020-12-01 22:26:33 +00:00
|
|
|
for VARIANT in $VARIANTS; do
|
2020-07-07 02:16:38 +00:00
|
|
|
(
|
2020-12-01 22:26:33 +00:00
|
|
|
export PLATFORM="${XCODE_ROOT}/iPhone${VARIANT}.platform"
|
|
|
|
export SDK="${PLATFORM}/Developer/SDKs/iPhone${VARIANT}.sdk"
|
|
|
|
export PREFIX="$BUILD_DIR/ios/$VARIANT"
|
2020-07-07 02:16:38 +00:00
|
|
|
mkdir -p "$PREFIX"
|
|
|
|
cd json-c
|
|
|
|
git checkout $JSONC_TAG_VERSION
|
2020-12-01 22:26:33 +00:00
|
|
|
if [ -d $VARIANT ]; then
|
|
|
|
rm -rf $VARIANT
|
|
|
|
fi
|
2020-07-07 02:16:38 +00:00
|
|
|
mkdir $VARIANT
|
|
|
|
pushd $VARIANT
|
|
|
|
cmake \
|
2020-12-01 22:26:33 +00:00
|
|
|
-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 \
|
2020-07-07 02:16:38 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
|
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
|
|
-DBUILD_STATIC_LIBS=ON \
|
|
|
|
..
|
2020-12-01 22:26:33 +00:00
|
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
|
|
make install
|
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
done
|
2020-12-01 22:26:33 +00:00
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
make_pihelper() {
|
2020-12-01 22:26:33 +00:00
|
|
|
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"
|
2020-07-07 02:16:38 +00:00
|
|
|
mkdir -p "$PREFIX"
|
2020-12-01 22:26:33 +00:00
|
|
|
pushd build
|
|
|
|
if [ -d $VARIANT ]; then
|
|
|
|
rm -rf $VARIANT
|
|
|
|
fi
|
|
|
|
mkdir $VARIANT
|
|
|
|
pushd $VARIANT
|
2020-07-07 02:16:38 +00:00
|
|
|
cmake \
|
|
|
|
-DCMAKE_FIND_ROOT_PATH=$PREFIX \
|
|
|
|
-DCMAKE_INCLUDE_PATH=$PREFIX/include \
|
2020-12-01 22:26:33 +00:00
|
|
|
-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 \
|
2020-07-07 02:16:38 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX=$PREFIX \
|
2020-12-01 22:26:33 +00:00
|
|
|
-DPIHELPER_DEV=ON \
|
2020-07-07 02:16:38 +00:00
|
|
|
-DPIHELPER_SHARED=OFF \
|
|
|
|
-DPIHELPER_STATIC=ON \
|
|
|
|
../..
|
2020-12-01 22:26:33 +00:00
|
|
|
make -j $(sysctl -n hw.logicalcpu_max)
|
|
|
|
make install
|
|
|
|
)
|
2020-07-07 02:16:38 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
package() {
|
2020-12-01 22:26:33 +00:00
|
|
|
cd $BUILD_DIR/ios
|
|
|
|
cp -r OS/include .
|
|
|
|
for LIB in json-c curl ssl crypto pihelper; do
|
2020-07-07 02:16:38 +00:00
|
|
|
(
|
2020-12-01 22:26:33 +00:00
|
|
|
lipo -create \
|
|
|
|
OS/lib/lib${LIB}.a \
|
|
|
|
Simulator/lib/lib${LIB}.a \
|
|
|
|
-output lib${LIB}.dylib
|
2020-07-07 02:16:38 +00:00
|
|
|
)
|
|
|
|
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
|
2020-12-01 22:26:33 +00:00
|
|
|
make_openssl
|
2020-07-07 02:16:38 +00:00
|
|
|
#make_curl
|
2020-12-01 22:26:33 +00:00
|
|
|
#make_jsonc
|
2020-07-07 02:16:38 +00:00
|
|
|
#make_pihelper
|
|
|
|
package
|
|
|
|
)
|
|
|
|
|