Skip to content

Commit 4ef6589

Browse files
authored
Provide bazelrc preset definition (#84)
* Provide bazelrc preset definition * Apply suggestion from @hofbi * Apply suggestion from @hofbi * Update protoc/flags.bzl
1 parent fd1e09f commit 4ef6589

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
2929
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
3030
```
3131

32+
or if you are using [bazelrc-preset.bzl](https://github.com/bazel-contrib/bazelrc-preset.bzl), you can extend your presets using the `PROTOC_TOOLCHAIN_FLAGS` preset defined in this repository.
33+
34+
```starlark
35+
load("@bazelrc-preset.bzl", "bazelrc_preset")
36+
load("@toolchains_protoc//protoc:flags.bzl", "PROTOC_TOOLCHAIN_FLAGS")
37+
38+
bazelrc_preset(
39+
name = "preset",
40+
extra_presets = PROTOC_TOOLCHAIN_FLAGS,
41+
)
42+
```
43+
44+
Once you update your presets, all necessary flags will be added to your preset bazelrc.
45+
3246
## Support matrix
3347

3448
Minimum versions:

protoc/flags.bzl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""bazelrc presets for https://github.com/bazel-contrib/bazelrc-preset.bzl"""
2+
3+
PROTOC_TOOLCHAIN_FLAGS = {
4+
"incompatible_enable_proto_toolchain_resolution": struct(
5+
default = True,
6+
description = """\
7+
Bazel 7 introduced this flag to allow us fetch `protoc` rather than re-build it!
8+
That flag ALSO decouples how each built-in language rule (Java, Python, C++, etc.) locates the runtime.
9+
""",
10+
),
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+
),
27+
}

0 commit comments

Comments
 (0)