Skip to content

Commit ce62f16

Browse files
authored
grpc-native: Add support for iOS (#458)
* grpc-native: Add support for iOS Signed-off-by: Johannes Zottele <[email protected]> * protobuf-native: Add support for iOS/arm64 Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Add support for iOS/arm64 Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Finish iOS support Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Add build_all_targets.sh Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Add ios/x64 support Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: One build task per platform target Signed-off-by: Johannes Zottele <[email protected]> --------- Signed-off-by: Johannes Zottele <[email protected]>
1 parent 8ac469e commit ce62f16

File tree

14 files changed

+165
-51
lines changed

14 files changed

+165
-51
lines changed

cinterop-c/.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# we build the cc_static library bundled with all dependencies
2-
build --experimental_cc_static_library
2+
build --experimental_cc_static_library --experimental_platform_in_output_dir
33

44
build:release --compilation_mode=opt --strip=always

cinterop-c/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
/.aswb/
1313
/.clwb/
1414
.idea/
15+
16+
out/

cinterop-c/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cc_library(
1515
includes = ["include"],
1616
visibility = ["//visibility:public"],
1717
deps = [
18-
"@com_github_grpc_grpc//:grpc"
18+
"@com_github_grpc_grpc//:grpc",
1919
],
2020
)
2121

cinterop-c/MODULE.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ bazel_dep(
99
version = "0.1.1",
1010
)
1111

12+
# required to build for apple targets (like iOS)
13+
bazel_dep(name = "apple_support", version = "1.22.1", repo_name = "build_bazel_apple_support")
14+
1215
# Protobuf
1316
bazel_dep(
1417
name = "protobuf",
@@ -19,6 +22,6 @@ bazel_dep(
1922
# gRPC library
2023
bazel_dep(
2124
name = "grpc",
22-
version = "1.73.1",
25+
version = "1.74.1",
2326
repo_name = "com_github_grpc_grpc",
2427
)

cinterop-c/MODULE.bazel.lock

Lines changed: 23 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cinterop-c/build_target.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
4+
#
5+
6+
set -Eeuo pipefail
7+
trap 'echo "ERROR: Build failed at ${BASH_SOURCE}:${LINENO}" >&2' ERR
8+
9+
# Builds a static library for a specific platform (os/arch).
10+
#
11+
# Usage:
12+
# ./build_target.sh //path:libtarget out_dir <platform> <short> <os>
13+
# Example:
14+
# ./build_target.sh :protowire_static out @build_bazel_apple_support//platforms:ios_arm64 ios_arm64 ios
15+
#
16+
# The example will produce ./out/libprotowire_static.ios_arm64.a
17+
18+
LABEL="${1:?need bazel target label}"
19+
DST="${2:?need output destination}"
20+
PLATFORM="${3:?need a platform for bazel build command}"
21+
OS="${4:?need the operating system of the target platform}"
22+
23+
CONFIG=release
24+
25+
mkdir -p $(dirname "$DST")
26+
27+
echo "==> Building $LABEL to $DST" >&2
28+
bazel build "$LABEL" --platforms="$PLATFORM" --apple_platform_type="$OS" --config="$CONFIG" --announce_rc >/dev/null
29+
30+
# Ask Bazel what file(s) this target produced under this platform
31+
out="$(bazel cquery "$LABEL" --platforms="$PLATFORM" --apple_platform_type="$OS" --config="$CONFIG" --output=files | head -n1)"
32+
[[ -n "$out" ]] || { echo "No output for $LABEL ($SHORT)"; exit 1; }
33+
34+
cp -f "$out" "$DST"
35+
36+
echo "Done. Binary written to: $DST"

0 commit comments

Comments
 (0)