Skip to content

Commit ecf62fb

Browse files
authored
Fix flags presets (#96)
- Fixes #85 - Closes #93
1 parent 48a32e6 commit ecf62fb

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bazel_dep(name = "platforms", version = "0.0.10")
1212

1313
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1", dev_dependency = True)
1414
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)
15+
bazel_dep(name = "bazelrc-preset.bzl", version = "1.2.0", dev_dependency = True)
1516

1617
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
1718
protoc.toolchain(

protoc/flags.bzl

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ PROTOC_TOOLCHAIN_FLAGS = {
88
That flag ALSO decouples how each built-in language rule (Java, Python, C++, etc.) locates the runtime.
99
""",
1010
),
11-
"per_file_copt": struct(
12-
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
13-
description = "Make sure protobuf is not built from source",
14-
),
15-
"host_per_file_copt": struct(
16-
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
17-
description = "Make sure protobuf is not built from source",
18-
),
19-
"per_file_copt": struct(
20-
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
21-
description = "Make sure grpc is not built from source",
22-
),
23-
"host_per_file_copt": struct(
24-
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
25-
description = "Make sure grpc is not built from source",
26-
),
11+
"per_file_copt": [
12+
struct(
13+
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
14+
description = "Make sure protobuf is not built from source",
15+
),
16+
struct(
17+
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
18+
description = "Make sure grpc is not built from source",
19+
allow_repeated = True,
20+
),
21+
],
22+
"host_per_file_copt": [
23+
struct(
24+
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
25+
description = "Make sure protobuf is not built from source",
26+
),
27+
struct(
28+
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
29+
description = "Make sure grpc is not built from source",
30+
allow_repeated = True,
31+
),
32+
],
2733
}

tests/BUILD.bazel

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@bazelrc-preset.bzl", "bazelrc_preset_test")
2+
load("//protoc:flags.bzl", "PROTOC_TOOLCHAIN_FLAGS")
3+
4+
bazelrc_preset_test(
5+
name = "test_protoc_toolchain_flags",
6+
extra_presets = PROTOC_TOOLCHAIN_FLAGS,
7+
)

0 commit comments

Comments
 (0)