forked from libffi/libffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-ios.sh
executable file
·68 lines (58 loc) · 2.2 KB
/
build-ios.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
#!/bin/sh
PLATFORM_IOS=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform
PLATFORM_IOS_SIM=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform
SDK_IOS_VERSION="8.4"
MIN_IOS_VERSION="6.1"
OUTPUT_DIR="universal-ios"
build_target () {
local platform=$1
local sdk=$2
local arch=$3
local triple=$4
local builddir=$5
mkdir -p "${builddir}"
pushd "${builddir}"
export CC="clang"
export CFLAGS="-arch ${arch} -isysroot ${sdk} -miphoneos-version-min=${MIN_IOS_VERSION}"
../configure --host=${triple} && make
popd
}
# Build all targets
# build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv6 arm-apple-darwin10 armv6-ios
build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv7 arm-apple-darwin10 armv7-ios
build_target "${PLATFORM_IOS}" "${PLATFORM_IOS}/Developer/SDKs/iPhoneOS${SDK_IOS_VERSION}.sdk/" armv7s arm-apple-darwin10 armv7s-ios
build_target "${PLATFORM_IOS_SIM}" "${PLATFORM_IOS_SIM}/Developer/SDKs/iPhoneSimulator${SDK_IOS_VERSION}.sdk/" i386 i386-apple-darwin10 i386-ios-sim
# Create universal output directories
mkdir -p "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}/include"
mkdir -p "${OUTPUT_DIR}/include/armv7"
mkdir -p "${OUTPUT_DIR}/include/armv7s"
mkdir -p "${OUTPUT_DIR}/include/i386"
# Create the universal binary
lipo -create armv7-ios/.libs/libffi.a armv7s-ios/.libs/libffi.a i386-ios-sim/.libs/libffi.a -output "${OUTPUT_DIR}/libffi.a"
# Copy in the headers
copy_headers () {
local src=$1
local dest=$2
# Fix non-relative header reference
sed 's/<ffitarget.h>/"ffitarget.h"/' < "${src}/include/ffi.h" > "${dest}/ffi.h"
cp "${src}/include/ffitarget.h" "${dest}"
}
copy_headers armv7-ios "${OUTPUT_DIR}/include/armv7"
copy_headers armv7s-ios "${OUTPUT_DIR}/include/armv7s"
copy_headers i386-ios-sim "${OUTPUT_DIR}/include/i386"
# Create top-level header
(
cat << EOF
#ifdef __arm__
#include <arm/arch.h>
#ifdef _ARM_ARCH_7S
#include "include/armv7s/ffi.h"
#elif defined(_ARM_ARCH_7)
#include "include/armv7/ffi.h"
#endif
#elif defined(__i386__)
#include "include/i386/ffi.h"
#endif
EOF
) > "${OUTPUT_DIR}/ffi.h"