Skip to content

Commit c3f3f3c

Browse files
committed
Provide bazelrc preset definition
1 parent fd1e09f commit c3f3f3c

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
PROTOC_TOOLCHAIN_FLAGS = {
2+
"incompatible_enable_proto_toolchain_resolution": struct(
3+
default = True,
4+
description = """\
5+
Bazel 7 introduced this flag to allow us fetch `protoc` rather than re-build it!
6+
That flag ALSO decouples how each built-in language rule (Java, Python, C++, etc.) locates the runtime.
7+
""",
8+
),
9+
"per_file_copt": struct(
10+
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
11+
description = "Make sure protobuf is not built from source",
12+
),
13+
"host_per_file_copt": struct(
14+
default = "external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT",
15+
description = "Make sure protobuf is not built from source",
16+
),
17+
"per_file_copt_grpc": struct(
18+
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
19+
description = "Make sure grpc is not built from source",
20+
),
21+
"host_per_file_copt_grpc": struct(
22+
default = "external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT",
23+
description = "Make sure grpc is not built from source",
24+
),
25+
}

0 commit comments

Comments
 (0)