forked from kunliao/build-curl-openssl-zlib-android-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-ios-curl.sh
executable file
·89 lines (59 loc) · 2.17 KB
/
build-ios-curl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/sh
source ./build-ios-env.sh
ARCHIVE=curl-7.88.0.tar.xz
DIR=curl-7.88.0
VERSION=7.88.0
INSTALL_DIR=$BUILD_DIR/curl
if [ -d $INSTALL_DIR ]; then
rm -rf "$INSTALL_DIR"*
fi
mkdir -p $INSTALL_DIR
if [ -d $DIR ];then
rm -rf $DIR
fi
tar xzf $ARCHIVE
cd $DIR
function build() {
ARCH=$1
HOST=$2
SDK=$3
SDKDIR=$(xcrun --sdk $SDK --show-sdk-path)
export CC=$(xcrun -find -sdk $SDK gcc)
export CFLAGS="-arch $ARCH -pipe -Os -gdwarf-2 -isysroot $SDKDIR -m$SDK-version-min=$IOS_MIN_SDK_VERSION"
export LDFLAGS="-arch $ARCH -isysroot $SDKDIR"
./configure \
--host="$HOST-apple-darwin" \
--disable-shared \
--with-zlib=$SDKDIR/usr \
--with-openssl=$BUILD_DIR/openssl/"$ARCH"_"$SDK" \
--prefix=$INSTALL_DIR/"$ARCH"_"$SDK"
make -j`sysctl -n hw.logicalcpu_max`
make install
make clean
}
build arm64 arm iphoneos
build arm64 arm iphonesimulator
build x86_64 x86_64 iphonesimulator
lipo \
-arch arm64 $INSTALL_DIR/arm64_iphonesimulator/lib/libcurl.a \
-arch x86_64 $INSTALL_DIR/x86_64_iphonesimulator/lib/libcurl.a \
-create -output $INSTALL_DIR/libcurl.a
mkdir -p $INSTALL_DIR/iphoneos/curl.framework/Headers
mkdir -p $INSTALL_DIR/iphonesimulator/curl.framework/Headers
libtool -no_warning_for_no_symbols -static -o $INSTALL_DIR/iphoneos/curl.framework/curl $INSTALL_DIR/arm64_iphoneos/lib/libcurl.a
cp -r $INSTALL_DIR/arm64_iphoneos/include/curl/ $INSTALL_DIR/iphoneos/curl.framework/Headers
libtool -no_warning_for_no_symbols -static -o $INSTALL_DIR/iphonesimulator/curl.framework/curl $INSTALL_DIR/libcurl.a
cp -r $INSTALL_DIR/arm64_iphonesimulator/include/curl/ $INSTALL_DIR/iphonesimulator/curl.framework/Headers
if [ -d $BUILD_DIR/curl.xcframework ];then
rm -rf $BUILD_DIR/curl.xcframework
fi
xcodebuild -create-xcframework \
-framework $INSTALL_DIR/iphoneos/curl.framework \
-framework $INSTALL_DIR/iphonesimulator/curl.framework \
-output $BUILD_DIR/curl.xcframework
plutil -insert CFBundleVersion -string $VERSION $BUILD_DIR/curl.xcframework/Info.plist
rm -rf $INSTALL_DIR/iphoneos
rm -rf $INSTALL_DIR/iphonesimulator
rm $INSTALL_DIR/libcurl.a
cd ..
rm -rf $DIR