This commit is contained in:
Bochun Bai 2017-02-08 11:30:57 -08:00
parent ee1633ce46
commit bd046a6f9b
3 changed files with 69 additions and 11 deletions

View file

@ -6,15 +6,33 @@ Bitcode support.
OpenSSL and Darwin native ssl support. OpenSSL and Darwin native ssl support.
Script only, please download libcurl from here: http://curl.haxx.se/download.html Script only, please download libcurl from here: http://curl.haxx.se/download.html
Tested Xcode 7.3(7D175) on OSX 10.11.4 Tested Xcode 8.1 on macOS 10.12
Tested curl 7.44.0 and 7.47.1 and 7.48.0 Tested curl 7.52.1
curl-7.52.1 issue
=================
7.52.1 is the latest release but have an issue to build with darwinssl
https://github.com/curl/curl/issues/1172
https://github.com/curl/curl/commit/8db3afe16c0916ea5acf6aed6e7cf02f06cc8677
The fix have commited to curl just one day after release, which should be avaliable for the next patch release.
Workaround for this issue is:
- patch it with the commit (See darwinssl-fix-iOS-build.patch extacted)
- Or, use openssl with: ```
../build_libcurl_dist.sh openssl
```
Usage Usage
================= =================
``` ```
curl -O http://curl.haxx.se/download/curl-7.47.1.tar.gz curl -O http://curl.haxx.se/download/curl-7.52.1.tar.gz
tar xf curl-7.47.1.tar.gz tar xf curl-7.52.1.tar.gz
cd curl-7.47.1 cd curl-7.52.1
curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/darwinssl-fix-iOS-build.patch
patch -p1 < darwinssl-fix-iOS-build.patch
curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_libcurl_dist.sh |bash curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_libcurl_dist.sh |bash
...... ......
``` ```
@ -28,8 +46,10 @@ To use OpenSSL, use https://github.com/sinofool/build-openssl-ios/ to build Open
curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_libcurl_dist.sh openssl |bash curl https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/build_libcurl_dist.sh openssl |bash
``` ```
Binary Binary (Not updated yet)
================= =================
Following binary is curl-7.47.1, I will release 7.52.1 binaries after a longer test.
You can find a prebuild binary (with OpenSSL) here: https://sinofool.net/dl/libcurl-ios-dist.tar.bz2 You can find a prebuild binary (with OpenSSL) here: https://sinofool.net/dl/libcurl-ios-dist.tar.bz2
Double check the binary file before use: Double check the binary file before use:

View file

@ -9,6 +9,13 @@ echo "#include \"include/curl/curlver.h\"
#if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 40 #if LIBCURL_VERSION_MAJOR < 7 || LIBCURL_VERSION_MINOR < 40
#error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html #error Required curl 7.40.0+; See http://curl.haxx.se/docs/adv_20150108A.html
#endif"|gcc -c -o /dev/null -xc -||exit 9 #endif"|gcc -c -o /dev/null -xc -||exit 9
echo "#include \"include/curl/curlver.h\"
#if LIBCURL_VERSION_MAJOR == 7 && LIBCURL_VERSION_MINOR <= 52 && LIBCURL_VERSION_PATCH <= 1
#warning curl 7.52.1 have an issue build with darwinssl; See patch here: https://github.com/curl/curl/commit/8db3afe16c0916ea5acf6aed6e7cf02f06cc8677
#warning For 7.52.1 is the latest release version, the patch commited just one day later than release cut. I can't automatically apply the patch for you.
#warning Please patch it with: patch -p1 < darwinssl-fix-iOS-build.patch
#endif"|gcc -c -o /dev/null -xc -||exit 9
} }
function build_for_arch() { function build_for_arch() {
@ -18,7 +25,7 @@ function build_for_arch() {
PREFIX=$4 PREFIX=$4
IPHONEOS_DEPLOYMENT_TARGET="6.0" IPHONEOS_DEPLOYMENT_TARGET="6.0"
export PATH="${DEVROOT}/usr/bin/:${PATH}" export PATH="${DEVROOT}/usr/bin/:${PATH}"
export CFLAGS="-arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode" export CFLAGS="-DCURL_BUILD_IOS -arch ${ARCH} -pipe -Os -gdwarf-2 -isysroot ${SYSROOT} -miphoneos-version-min=${IPHONEOS_DEPLOYMENT_TARGET} -fembed-bitcode"
export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}" export LDFLAGS="-arch ${ARCH} -isysroot ${SYSROOT}"
./configure --disable-shared --enable-static --enable-ipv6 ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install ./configure --disable-shared --enable-static --enable-ipv6 ${SSL_FLAG} --host="${HOST}" --prefix=${PREFIX} && make -j8 && make install
} }
@ -38,21 +45,22 @@ fi
TMP_DIR=/tmp/build_libcurl_$$ TMP_DIR=/tmp/build_libcurl_$$
build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1 #build_for_arch i386 i386-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/i386 || exit 1
build_for_arch x86_64 x86_64-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/x86_64 || exit 2 build_for_arch x86_64 x86_64-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk ${TMP_DIR}/x86_64 || exit 2
build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 3 build_for_arch arm64 arm-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/arm64 || exit 3
build_for_arch armv7s armv7s-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7s || exit 4 build_for_arch armv7s armv7s-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7s || exit 4
build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 5 #build_for_arch armv7 armv7-apple-darwin /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk ${TMP_DIR}/armv7 || exit 5
mkdir -p ${TMP_DIR}/lib/ mkdir -p ${TMP_DIR}/lib/
${DEVROOT}/usr/bin/lipo \ ${DEVROOT}/usr/bin/lipo \
-arch i386 ${TMP_DIR}/i386/lib/libcurl.a \
-arch x86_64 ${TMP_DIR}/x86_64/lib/libcurl.a \ -arch x86_64 ${TMP_DIR}/x86_64/lib/libcurl.a \
-arch armv7 ${TMP_DIR}/armv7/lib/libcurl.a \
-arch armv7s ${TMP_DIR}/armv7s/lib/libcurl.a \ -arch armv7s ${TMP_DIR}/armv7s/lib/libcurl.a \
-arch arm64 ${TMP_DIR}/arm64/lib/libcurl.a \ -arch arm64 ${TMP_DIR}/arm64/lib/libcurl.a \
-output ${TMP_DIR}/lib/libcurl.a -create -output ${TMP_DIR}/lib/libcurl.a -create
# -arch armv7 ${TMP_DIR}/armv7/lib/libcurl.a \
# -arch i386 ${TMP_DIR}/i386/lib/libcurl.a \
cp -r ${TMP_DIR}/armv7s/include ${TMP_DIR}/ cp -r ${TMP_DIR}/armv7s/include ${TMP_DIR}/
curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch curl -O https://raw.githubusercontent.com/sinofool/build-libcurl-ios/master/patch-include.patch
patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch patch ${TMP_DIR}/include/curl/curlbuild.h < patch-include.patch

View file

@ -0,0 +1,30 @@
From 8db3afe16c0916ea5acf6aed6e7cf02f06cc8677 Mon Sep 17 00:00:00 2001
From: Chris Araman <chris-araman@users.noreply.github.com>
Date: Thu, 22 Dec 2016 18:27:17 -0800
Subject: [PATCH] darwinssl: fix iOS build
Reviewed-by: Nick Zitzmann
Fixes #1172
---
lib/vtls/darwinssl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/vtls/darwinssl.c b/lib/vtls/darwinssl.c
index a43e391..2146b56 100644
--- a/lib/vtls/darwinssl.c
+++ b/lib/vtls/darwinssl.c
@@ -936,7 +936,11 @@ static OSStatus CopyIdentityWithLabel(char *label,
(SecIdentityRef) CFArrayGetValueAtIndex(keys_list, i);
err = SecIdentityCopyCertificate(*out_cert_and_key, &cert);
if(err == noErr) {
+#if CURL_BUILD_IOS
+ common_name = SecCertificateCopySubjectSummary(cert);
+#else // CURL_BUILD_MAC_10_7
SecCertificateCopyCommonName(cert, &common_name);
+#endif
if(CFStringCompare(common_name, label_cf, 0) == kCFCompareEqualTo) {
CFRelease(cert);
CFRelease(common_name);
--
2.10.1 (Apple Git-78)