Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cinterop-c/.bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# we build the cc_static library bundled with all dependencies
build --experimental_cc_static_library
build --experimental_cc_static_library --experimental_platform_in_output_dir

build:release --compilation_mode=opt --strip=always
2 changes: 2 additions & 0 deletions cinterop-c/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
/.aswb/
/.clwb/
.idea/

out/
2 changes: 1 addition & 1 deletion cinterop-c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cc_library(
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
"@com_github_grpc_grpc//:grpc"
"@com_github_grpc_grpc//:grpc",
],
)

Expand Down
5 changes: 4 additions & 1 deletion cinterop-c/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ bazel_dep(
version = "0.1.1",
)

# required to build for apple targets (like iOS)
bazel_dep(name = "apple_support", version = "1.22.1", repo_name = "build_bazel_apple_support")

# Protobuf
bazel_dep(
name = "protobuf",
Expand All @@ -19,6 +22,6 @@ bazel_dep(
# gRPC library
bazel_dep(
name = "grpc",
version = "1.73.1",
version = "1.74.1",
repo_name = "com_github_grpc_grpc",
)
34 changes: 23 additions & 11 deletions cinterop-c/MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions cinterop-c/build_target.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
#

set -Eeuo pipefail
trap 'echo "ERROR: Build failed at ${BASH_SOURCE}:${LINENO}" >&2' ERR

# Builds a static library for a specific platform (os/arch).
#
# Usage:
# ./build_target.sh //path:libtarget out_dir <platform> <short> <os>
# Example:
# ./build_target.sh :protowire_static out @build_bazel_apple_support//platforms:ios_arm64 ios_arm64 ios
#
# The example will produce ./out/libprotowire_static.ios_arm64.a

LABEL="${1:?need bazel target label}"
DST="${2:?need output destination}"
PLATFORM="${3:?need a platform for bazel build command}"
OS="${4:?need the operating system of the target platform}"

CONFIG=release

mkdir -p $(dirname "$DST")

echo "==> Building $LABEL to $DST" >&2
bazel build "$LABEL" --platforms="$PLATFORM" --apple_platform_type="$OS" --config="$CONFIG" --announce_rc >/dev/null

# Ask Bazel what file(s) this target produced under this platform
out="$(bazel cquery "$LABEL" --platforms="$PLATFORM" --apple_platform_type="$OS" --config="$CONFIG" --output=files | head -n1)"
[[ -n "$out" ]] || { echo "No output for $LABEL ($SHORT)"; exit 1; }

cp -f "$out" "$DST"

echo "Done. Binary written to: $DST"
Loading
Loading