forked from aspect-build/toolchains_protoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0001-bazel-Remove-hardcoded-dependency-on-protoc-from-lan.patch
More file actions
89 lines (81 loc) · 2.94 KB
/
0001-bazel-Remove-hardcoded-dependency-on-protoc-from-lan.patch
File metadata and controls
89 lines (81 loc) · 2.94 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 755aafd6fa3de6ea507be6a7e5790c6b53e0e5f9 Mon Sep 17 00:00:00 2001
From: Fabian Meumertzheim <fabian@meumertzhe.im>
Date: Mon, 16 Dec 2024 15:55:24 +0100
Subject: [PATCH 1/2] bazel: Remove hardcoded dependency on `//:protoc` from
language runtimes
Without this change, language runtimes still result in a build of `//:protoc` even with a prebuilt `proto_toolchain` registered or `--proto_compiler` set to a precompiled protoc.
---
bazel/private/BUILD | 6 ++++++
protobuf.bzl | 13 +++++--------
2 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/bazel/private/BUILD b/bazel/private/BUILD
index 8c1c94ac8..a5b3abeda 100644
--- a/bazel/private/BUILD
+++ b/bazel/private/BUILD
@@ -1,4 +1,5 @@
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
+load(":current_protoc.bzl", "current_protoc")
load(":native_bool_flag.bzl", "native_bool_flag")
package(default_applicable_licenses = ["//:license"])
@@ -28,6 +29,11 @@ toolchain_type(
visibility = ["//visibility:public"],
)
+current_protoc(
+ name = "current_protoc",
+ visibility = ["//:__subpackages__"],
+)
+
bzl_library(
name = "upb_proto_library_internal_bzl",
srcs = [
diff --git a/protobuf.bzl b/protobuf.bzl
index fdf09bd6b..736cc19cf 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -2,6 +2,7 @@ load("@bazel_skylib//lib:versions.bzl", "versions")
load("@rules_cc//cc:defs.bzl", "objc_library")
load("@rules_python//python:defs.bzl", "py_library")
load("//bazel/common:proto_info.bzl", "ProtoInfo")
+load("//bazel/private:current_protoc.bzl", "ProtocFilesToRun")
def _GetPath(ctx, path):
if ctx.label.workspace_root:
@@ -310,7 +311,7 @@ def _internal_gen_well_known_protos_java_impl(ctx):
args.add_all([src.path[offset:] for src in dep.direct_sources])
ctx.actions.run(
- executable = ctx.executable._protoc,
+ executable = ctx.attr._protoc[ProtocFilesToRun].files_to_run,
inputs = descriptors,
outputs = [srcjar],
arguments = [args],
@@ -335,9 +336,7 @@ internal_gen_well_known_protos_java = rule(
default = False,
),
"_protoc": attr.label(
- executable = True,
- cfg = "exec",
- default = "//:protoc",
+ default = "//bazel/private:current_protoc",
),
},
)
@@ -373,7 +372,7 @@ def _internal_gen_kt_protos(ctx):
args.add_all([src.path[offset:] for src in dep.direct_sources])
ctx.actions.run(
- executable = ctx.executable._protoc,
+ executable = ctx.attr._protoc[ProtocFilesToRun].files_to_run,
inputs = descriptors,
outputs = [srcjar],
arguments = [args],
@@ -398,9 +397,7 @@ internal_gen_kt_protos = rule(
default = False,
),
"_protoc": attr.label(
- executable = True,
- cfg = "exec",
- default = "//:protoc",
+ default = "//bazel/private:current_protoc",
),
},
)
--
2.49.0