Skip to content

Commit 78d8f78

Browse files
authored
fix: break protobuf and grpc building from source (#54)
1 parent cb688bf commit 78d8f78

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ Using Protocol Buffers with Bazel has always been difficult.
1515
This makes it difficult to migrate to a monorepo, allowing some applications to move from their separate repo without
1616
changing their dependency versions.
1717

18+
## Ensure protobuf and gRPC never built
19+
20+
You can ensure that protobuf and grpc is never built from source by breaking the CC compilation.
21+
22+
Simply drop this in your `.bazelrc`
23+
24+
```
25+
# Ensure that we don't accidentally build protobuf or gRPC
26+
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
27+
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
28+
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
29+
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
30+
```
31+
1832
## Support matrix
1933

2034
Minimum versions:

examples/.bazelrc

+6
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ common --@aspect_rules_py//py:interpreter_version=3.9.18
66
common --host_platform=//tools:no_cgo_host_platform
77
common --@aspect_rules_ts//ts:skipLibCheck=always
88
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
9+
10+
# Ensure that we don't accidentally build protobuf or gRPC
11+
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
12+
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
13+
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
14+
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT

0 commit comments

Comments
 (0)