Skip to content

Commit

Permalink
[ObjC] build universal binary for grpc_proto_plugin on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahShiSFB committed Jan 3, 2025
1 parent f39cd0f commit 1065f6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion bazel/grpc_build_system.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Contains macros used throughout the repo.
"""

load("@build_bazel_apple_support//rules:universal_binary.bzl", "universal_binary")
load("@build_bazel_rules_apple//apple:ios.bzl", "ios_unit_test")
load("@build_bazel_rules_apple//apple/testing/default_runner:ios_test_runner.bzl", "ios_test_runner")
load("@com_google_protobuf//bazel:upb_proto_library.bzl", "upb_proto_library", "upb_proto_reflection_library")
Expand Down Expand Up @@ -237,10 +238,24 @@ def grpc_cc_library(

def grpc_proto_plugin(name, srcs = [], deps = []):
native.cc_binary(
name = name,
name = name + "_native",
srcs = srcs,
deps = deps,
)
universal_binary(
name = name + "_universal",
binary = name + "_native",
)
native.genrule(
name = name,
srcs = select({
"@platforms//os:macos": [name + "_universal"],
"//conditions:default": [name + "_native"],
}),
outs = [name],
cmd = "cp $< $@",
executable = True,
)

def grpc_internal_proto_library(
name,
Expand Down
1 change: 1 addition & 0 deletions tools/buildgen/extract_metadata_from_bazel_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ def _extract_rules_from_bazel_xml(xml_tree):
"upb_proto_reflection_library",
"alias",
"bind",
"genrule",
]:
if rule_name in result:
raise Exception("Rule %s already present" % rule_name)
Expand Down

0 comments on commit 1065f6b

Please sign in to comment.