Fix flags presets (#96)
- Fixes https://github.com/aspect-build/toolchains_protoc/issues/85
- Closes https://github.com/aspect-build/toolchains_protoc/pull/93
diff --git a/MODULE.bazel b/MODULE.bazel
index c98de63..ddaa68c 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -12,6 +12,7 @@
bazel_dep(name = "aspect_bazel_lib", version = "2.8.1", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)
+bazel_dep(name = "bazelrc-preset.bzl", version = "1.2.0", dev_dependency = True)
protoc = use_extension("@toolchains_protoc//protoc:extensions.bzl", "protoc")
protoc.toolchain(
diff --git a/protoc/flags.bzl b/protoc/flags.bzl
index 88bc01c..23eaed4 100644
--- a/protoc/flags.bzl
+++ b/protoc/flags.bzl
@@ -8,20 +8,26 @@
That flag ALSO decouples how each built-in language rule (Java, Python, C++, etc.) locates the runtime.
""",
),
- "per_file_copt": struct(
- default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
- description = "Make sure protobuf is not built from source",
- ),
- "host_per_file_copt": struct(
- default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
- description = "Make sure protobuf is not built from source",
- ),
- "per_file_copt": struct(
- default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
- description = "Make sure grpc is not built from source",
- ),
- "host_per_file_copt": struct(
- default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
- description = "Make sure grpc is not built from source",
- ),
+ "per_file_copt": [
+ struct(
+ default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
+ description = "Make sure protobuf is not built from source",
+ ),
+ struct(
+ default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
+ description = "Make sure grpc is not built from source",
+ allow_repeated = True,
+ ),
+ ],
+ "host_per_file_copt": [
+ struct(
+ default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
+ description = "Make sure protobuf is not built from source",
+ ),
+ struct(
+ default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
+ description = "Make sure grpc is not built from source",
+ allow_repeated = True,
+ ),
+ ],
}
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel
new file mode 100644
index 0000000..09a9d15
--- /dev/null
+++ b/tests/BUILD.bazel
@@ -0,0 +1,7 @@
+load("@bazelrc-preset.bzl", "bazelrc_preset_test")
+load("//protoc:flags.bzl", "PROTOC_TOOLCHAIN_FLAGS")
+
+bazelrc_preset_test(
+ name = "test_protoc_toolchain_flags",
+ extra_presets = PROTOC_TOOLCHAIN_FLAGS,
+)