Skip to content

Commit c08cc9f

Browse files
authored
Fix label references when consumed as a library (#403)
* Fix label references when consumed as a library * Use remote java runtime * buildifier: fix
1 parent 5fd4992 commit c08cc9f

File tree

5 files changed

+9
-12
lines changed

5 files changed

+9
-12
lines changed

.bazelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ build --incompatible_strict_action_env
1515
# Don't use legacy repository rules.
1616
build --incompatible_disable_native_repo_rules
1717

18+
# Use a download java runtime
19+
build --java_runtime_version=remotejdk_21
20+
1821
# C++17 for protobuf compatibility
1922
build --host_cxxopt=-std=c++17 --cxxopt=-std=c++17
2023

BUILD.bazel

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("@//rules:proto_gazelle.bzl", "proto_gazelle")
21
load("@bazel_gazelle//:def.bzl", "gazelle_binary")
2+
load("@build_stack_rules_proto//rules:proto_gazelle.bzl", "proto_gazelle")
33
load("@npm_ts_proto//:defs.bzl", "npm_link_all_packages")
44

55
exports_files([
@@ -29,9 +29,9 @@ gazelle_binary(
2929

3030
proto_gazelle(
3131
name = "gazelle",
32-
cfgs = [":rules_proto_config.yaml"],
32+
cfgs = ["//:rules_proto_config.yaml"],
3333
external = "static",
34-
gazelle = ":gazelle-protobuf",
34+
gazelle = "//:gazelle-protobuf",
3535
imports = [
3636
"@googleapis//:imports.csv",
3737
"@protobufapis//:imports.csv",

MODULE.bazel

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
module(
44
name = "build_stack_rules_proto",
5-
version = "0.0.0",
65
compatibility_level = 1,
76
)
87

98
# -------------------------------------------------------------------
109
# Bazel Dependencies
1110
# -------------------------------------------------------------------
1211

13-
PROTOBUF_VERSION = "32.0"
14-
1512
bazel_dep(name = "zlib", version = "1.3.1.bcr.6")
1613
bazel_dep(name = "rules_shell", version = "0.6.1")
1714
bazel_dep(name = "rules_scala", version = "7.0.0", repo_name = "io_bazel_rules_scala")
@@ -24,7 +21,7 @@ bazel_dep(name = "rules_java", version = "8.15.1")
2421
bazel_dep(name = "rules_go", version = "0.57.0", repo_name = "io_bazel_rules_go")
2522
bazel_dep(name = "rules_foreign_cc", version = "0.15.0") # specified to ensure more recent version than @grpc/@opencensus-cpp/@google_benchmark
2623
bazel_dep(name = "rules_cc", version = "0.2.0")
27-
bazel_dep(name = "protobuf", version = PROTOBUF_VERSION, repo_name = "com_google_protobuf")
24+
bazel_dep(name = "protobuf", version = "32.0", repo_name = "com_google_protobuf")
2825
bazel_dep(name = "package_metadata", version = "0.0.5")
2926
bazel_dep(name = "grpc", version = "1.74.1", repo_name = "com_github_grpc_grpc")
3027
bazel_dep(name = "grpc-java", version = "1.71.0", repo_name = "io_grpc_grpc_java")
@@ -318,7 +315,7 @@ proto_repository.archive(
318315
] + proto_language_directives,
319316
build_file_generation = "clean",
320317
build_file_proto_mode = "file",
321-
cfgs = ["@//:rules_proto_config.yaml"],
318+
cfgs = ["//:rules_proto_config.yaml"],
322319
deleted_files = [
323320
"google/protobuf/*test*.proto",
324321
"google/protobuf/*unittest*.proto",

rules/proto_compile.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,6 @@ def _proto_compile_impl(ctx):
369369
for c in commands:
370370
# buildifier: disable=print
371371
print("COMMAND:", c)
372-
for f in tools:
373-
# buildifier: disable=print
374-
print("TOOL:", f.path)
375372
for a in replaced_args:
376373
# buildifier: disable=print
377374
print("ARG:", a)

rules/proto_gazelle.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ _gazelle_runner = rule(
111111
implementation = _gazelle_runner_impl,
112112
attrs = {
113113
"gazelle": attr.label(
114-
default = "@build_stack_rules_proto//cmd/gazelle",
114+
default = str(Label("@build_stack_rules_proto//cmd/gazelle")),
115115
executable = True,
116116
cfg = "exec",
117117
),

0 commit comments

Comments
 (0)