aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2018-07-24 14:47:35 +0200
committerGravatar Jan Tattermusch <jtattermusch@google.com>2018-07-24 14:47:35 +0200
commit5aa2a0e376b22f35babf095ab1bc83078a7bf51b (patch)
treef332f6a7941b2ec0ad16dda5a9f277f5fa36b465
parent527d87add53b0ac7f13799facf0115c38846a23d (diff)
build fat binary for ios
-rwxr-xr-xsrc/csharp/experimental/build_native_ext_for_ios.sh65
-rwxr-xr-xtools/run_tests/artifacts/build_artifact_csharp_ios.sh2
2 files changed, 42 insertions, 25 deletions
diff --git a/src/csharp/experimental/build_native_ext_for_ios.sh b/src/csharp/experimental/build_native_ext_for_ios.sh
index 518390ea63..69c9cdf021 100755
--- a/src/csharp/experimental/build_native_ext_for_ios.sh
+++ b/src/csharp/experimental/build_native_ext_for_ios.sh
@@ -19,27 +19,44 @@ set -ex
cd "$(dirname "$0")/../../.."
-# <iphoneos|iphonesimulator>
-SDK="iphoneos"
-# <arm64|x86_64|...>
-ARCH="arm64"
-
-PATH_AR="$(xcrun --sdk $SDK --find ar)"
-PATH_CC="$(xcrun --sdk $SDK --find clang)"
-PATH_CXX="$(xcrun --sdk $SDK --find clang++)"
-
-# TODO(jtattermusch): add -mios-version-min=6.0 and -Wl,ios_version_min=6.0
-CPPFLAGS="-O2 -Wframe-larger-than=16384 -arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path) -DPB_NO_PACKED_STRUCTS=1"
-LDFLAGS="-arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path)"
-
-# TODO(jtattermusch): revisit the build arguments
-make -j4 static_csharp \
- VALID_CONFIG_ios_$ARCH="1" \
- CC_ios_$ARCH="$PATH_CC" \
- CXX_ios_$ARCH="$PATH_CXX" \
- LD_ios_$ARCH="$PATH_CC" \
- LDXX_ios_$ARCH="$PATH_CXX" \
- CPPFLAGS_ios_$ARCH="$CPPFLAGS" \
- LDFLAGS_ios_$ARCH="$LDFLAGS" \
- DEFINES_ios_$ARCH="NDEBUG" \
- CONFIG="ios_$ARCH"
+# Usage: build <iphoneos|iphonesimulator> <arm64|x86_64|...>
+function build {
+ SDK="$1"
+ ARCH="$2"
+
+ PATH_AR="$(xcrun --sdk $SDK --find ar)"
+ PATH_CC="$(xcrun --sdk $SDK --find clang)"
+ PATH_CXX="$(xcrun --sdk $SDK --find clang++)"
+
+ # TODO(jtattermusch): add -mios-version-min=6.0 and -Wl,ios_version_min=6.0
+ CPPFLAGS="-O2 -Wframe-larger-than=16384 -arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path) -DPB_NO_PACKED_STRUCTS=1"
+ LDFLAGS="-arch $ARCH -isysroot $(xcrun --sdk $SDK --show-sdk-path)"
+
+ # TODO(jtattermusch): revisit the build arguments
+ make -j4 static_csharp \
+ VALID_CONFIG_ios_$ARCH="1" \
+ CC_ios_$ARCH="$PATH_CC" \
+ CXX_ios_$ARCH="$PATH_CXX" \
+ LD_ios_$ARCH="$PATH_CC" \
+ LDXX_ios_$ARCH="$PATH_CXX" \
+ CPPFLAGS_ios_$ARCH="$CPPFLAGS" \
+ LDFLAGS_ios_$ARCH="$LDFLAGS" \
+ DEFINES_ios_$ARCH="NDEBUG" \
+ CONFIG="ios_$ARCH"
+}
+
+# Usage: fatten <grpc_csharp_ext|...>
+function fatten {
+ LIB_NAME="$1"
+
+ mkdir -p libs/ios
+ lipo -create -output libs/ios/lib$LIB_NAME.a \
+ libs/ios_arm64/lib$LIB_NAME.a \
+ libs/ios_x86_64/lib$LIB_NAME.a
+}
+
+build iphoneos arm64
+build iphonesimulator x86_64
+
+fatten grpc
+fatten grpc_csharp_ext
diff --git a/tools/run_tests/artifacts/build_artifact_csharp_ios.sh b/tools/run_tests/artifacts/build_artifact_csharp_ios.sh
index 8b3c7a17b3..0d0a9c86da 100755
--- a/tools/run_tests/artifacts/build_artifact_csharp_ios.sh
+++ b/tools/run_tests/artifacts/build_artifact_csharp_ios.sh
@@ -20,4 +20,4 @@ cd "$(dirname "$0")/../../.."
src/csharp/experimental/build_native_ext_for_ios.sh
mkdir -p "${ARTIFACTS_OUT}"
-cp libs/ios_arm64/libgrpc_csharp_ext.a libs/ios_arm64/libgrpc.a "${ARTIFACTS_OUT}"
+cp libs/ios/libgrpc_csharp_ext.a libs/ios/libgrpc.a "${ARTIFACTS_OUT}"