-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bazel_to_cmake: Improve handling of .proto files in multiple targets
There are a number of issues with the older mechanism: 1. The mechanism used by btc_protobuf.cmake to collect sources collected INTERFACE sources during proto generation, which could invoke protoc on dependencies multiple times. 2. Some .proto files are included in multiple different proto_library() rules. This would again cause the protoc compiler to be invoked multiple times, and could lead to duplicate identical outputs and/or problems locating the appropriate generated file. That bazel_to_cmake appeared to work appears to be somewhat of an accident; Protoc was invoked on .proto files more than necessary, and include directories were over-specified, so by luck the dependency mechanism in ninja/make appeared to build the correct target in many of these cases. Now, however, these accidents are improved with the following fixes: 1. Invoke protoc directly using generator expressions to collect the correct imports only from the proto_library(deps=) targets. Also declares outputs and proto inputs explicitly. 2. Instead of invoking the protoc compiler rules for each proto_library(), target, invoke protoc for each file target included by a proto_library() 3. Generalize dependency handling to collect matching providers in a 'ProviderCollector' to better specify target_link_libraries vs. add_dependencies. This solves some cases of bad aliasing that was potentially generated (i.e. an alias to an alias). This includes a bunch of other changes that move some code around and rework using StringIO buffers and other fixes as well. See bug report: #197 PiperOrigin-RevId: 676089562 Change-Id: I64eba6e9e232af354a2b35d1b11e7c8b185aa1bc
- Loading branch information
1 parent
87f2a4d
commit 012fd80
Showing
38 changed files
with
2,926 additions
and
1,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.