Bugfixes for proto_library (proto.include_dirs)
The fixes are - Dedupe the dir list. Since we partition the proto srcs per pacakge and then iterate the map, a single include directory was being listed multiple times - Drop target_compatible_with from these proto_library targets. The compatibility will be enforced at the top-level <lang>_proto_library. Test: Added a unit test Change-Id: Ia18c0f8c495585010fd4e372092afe80c5d8290c
This commit is contained in:
@@ -330,7 +330,8 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz
|
||||
Label: l,
|
||||
})
|
||||
}
|
||||
protoLibrariesInIncludeDir := createProtoLibraryTargetsForIncludeDirs(ctx, protoIncludeDirs)
|
||||
// Partitioning by packages can create dupes of protoIncludeDirs, so dedupe it first.
|
||||
protoLibrariesInIncludeDir := createProtoLibraryTargetsForIncludeDirs(ctx, SortedUniqueStrings(protoIncludeDirs))
|
||||
transitiveProtoLibraries.Append(protoLibrariesInIncludeDir)
|
||||
}
|
||||
|
||||
@@ -401,7 +402,13 @@ func createProtoLibraryTargetsForIncludeDirs(ctx Bp2buildMutatorContext, include
|
||||
if rel != "." {
|
||||
attrs.Import_prefix = proptools.StringPtr(rel)
|
||||
}
|
||||
ctx.CreateBazelTargetModule(
|
||||
|
||||
// If a specific directory is listed in proto.include_dirs of two separate modules (one host-specific and another device-specific),
|
||||
// we do not want to create the proto_library with target_compatible_with of the first visited of these two modules
|
||||
// As a workarounds, delete `target_compatible_with`
|
||||
alwaysEnabled := bazel.BoolAttribute{}
|
||||
alwaysEnabled.Value = proptools.BoolPtr(true)
|
||||
ctx.CreateBazelTargetModuleWithRestrictions(
|
||||
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
|
||||
CommonAttributes{
|
||||
Name: label,
|
||||
@@ -411,6 +418,7 @@ func createProtoLibraryTargetsForIncludeDirs(ctx Bp2buildMutatorContext, include
|
||||
Tags: bazel.MakeStringListAttribute([]string{"manual"}),
|
||||
},
|
||||
&attrs,
|
||||
alwaysEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user