Fix target_compatible_with non-determinism for proto.include_dirs

A single proto providing directory can be used by multiple soong modules. Some of these
can be
1. Host specific
2. Device specific
3. Both host and device

Since the generated proto_library can have 1:many mapping, it should
have an empty target_compatible_with. Compatiblity will be enforced at
the top-level {cc|java|python}_proto_library.

(This is a followup to aosp/2727054 which did not handle this correctly)

Test: Added a unit test

Change-Id: I09b3def70e3d043fd8ba0d1eb4ffff1910f097d1
This commit is contained in:
Spandan Das
2023-09-01 19:43:56 +00:00
parent 08e1792144
commit ab29f57ce6
3 changed files with 44 additions and 1 deletions

View File

@@ -408,6 +408,11 @@ func createProtoLibraryTargetsForIncludeDirs(ctx Bp2buildMutatorContext, include
// As a workarounds, delete `target_compatible_with`
alwaysEnabled := bazel.BoolAttribute{}
alwaysEnabled.Value = proptools.BoolPtr(true)
// Add android and linux explicitly so that fillcommonbp2buildmoduleattrs can override these configs
// When we extend b support for other os'es (darwin/windows), we should add those configs here as well
alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid, proptools.BoolPtr(true))
alwaysEnabled.SetSelectValue(bazel.OsConfigurationAxis, bazel.OsLinux, proptools.BoolPtr(true))
ctx.CreateBazelTargetModuleWithRestrictions(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
CommonAttributes{