Handle excludes_{shared,static}_libs

Bug: 188497994
Test: bp2build.sh
Change-Id: I4a5ea40cbd804e8542fe33143e4926abc0c6164f
This commit is contained in:
Liz Kammer
2021-06-02 16:02:22 -04:00
parent 74deed445b
commit 47535c51fa
4 changed files with 252 additions and 36 deletions

View File

@@ -100,6 +100,22 @@ func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) b
return labels
}
// BazelLabelForModuleDeps expects two lists: modules (containing modules to include in the list),
// and excludes (modules to exclude from the list). Both of these should contain references to other
// modules, ("<module>" or ":<module>"). It returns a Bazel-compatible label list which corresponds
// to dependencies on the module within the given ctx, and the excluded dependencies.
func BazelLabelForModuleDepsExcludes(ctx BazelConversionPathContext, modules, excludes []string) bazel.LabelList {
moduleLabels := BazelLabelForModuleDeps(ctx, RemoveListFromList(modules, excludes))
if len(excludes) == 0 {
return moduleLabels
}
excludeLabels := BazelLabelForModuleDeps(ctx, excludes)
return bazel.LabelList{
Includes: moduleLabels.Includes,
Excludes: excludeLabels.Includes,
}
}
func BazelLabelForModuleSrcSingle(ctx BazelConversionPathContext, path string) bazel.Label {
return BazelLabelForModuleSrcExcludes(ctx, []string{path}, []string(nil)).Includes[0]
}