Merge changes Id11f4fb1,Id573d970,Ia94a0b5c am: a3bd963988
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1878086 Change-Id: Ia4ae8723342e8114b25326c5259065be32d32c58
This commit is contained in:
@@ -60,8 +60,8 @@ type Bazelable interface {
|
||||
HasHandcraftedLabel() bool
|
||||
HandcraftedLabel() string
|
||||
GetBazelLabel(ctx BazelConversionPathContext, module blueprint.Module) string
|
||||
ConvertWithBp2build(ctx BazelConversionPathContext) bool
|
||||
convertWithBp2build(ctx BazelConversionPathContext, module blueprint.Module) bool
|
||||
ConvertWithBp2build(ctx BazelConversionContext) bool
|
||||
convertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool
|
||||
GetBazelBuildFileContents(c Config, path, name string) (string, error)
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ func (b *BazelModuleBase) MixedBuildsEnabled(ctx BazelConversionPathContext) boo
|
||||
}
|
||||
|
||||
// ConvertedToBazel returns whether this module has been converted (with bp2build or manually) to Bazel.
|
||||
func convertedToBazel(ctx BazelConversionPathContext, module blueprint.Module) bool {
|
||||
func convertedToBazel(ctx BazelConversionContext, module blueprint.Module) bool {
|
||||
b, ok := module.(Bazelable)
|
||||
if !ok {
|
||||
return false
|
||||
@@ -386,11 +386,11 @@ func convertedToBazel(ctx BazelConversionPathContext, module blueprint.Module) b
|
||||
}
|
||||
|
||||
// ConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build.
|
||||
func (b *BazelModuleBase) ConvertWithBp2build(ctx BazelConversionPathContext) bool {
|
||||
func (b *BazelModuleBase) ConvertWithBp2build(ctx BazelConversionContext) bool {
|
||||
return b.convertWithBp2build(ctx, ctx.Module())
|
||||
}
|
||||
|
||||
func (b *BazelModuleBase) convertWithBp2build(ctx BazelConversionPathContext, module blueprint.Module) bool {
|
||||
func (b *BazelModuleBase) convertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool {
|
||||
if bp2buildModuleDoNotConvert[module.Name()] {
|
||||
return false
|
||||
}
|
||||
|
@@ -68,24 +68,36 @@ import (
|
||||
// cannot be resolved,the function will panic. This is often due to the dependency not being added
|
||||
// via an AddDependency* method.
|
||||
|
||||
// A subset of the ModuleContext methods which are sufficient to resolve references to paths/deps in
|
||||
// order to form a Bazel-compatible label for conversion.
|
||||
type BazelConversionPathContext interface {
|
||||
EarlyModulePathContext
|
||||
// A minimal context interface to check if a module should be converted by bp2build,
|
||||
// with functions containing information to match against allowlists and denylists.
|
||||
// If a module is deemed to be convertible by bp2build, then it should rely on a
|
||||
// BazelConversionPathContext for more functions for dep/path features.
|
||||
type BazelConversionContext interface {
|
||||
Config() Config
|
||||
|
||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||
ModuleFromName(name string) (blueprint.Module, bool)
|
||||
Module() Module
|
||||
OtherModuleType(m blueprint.Module) string
|
||||
OtherModuleName(m blueprint.Module) string
|
||||
OtherModuleDir(m blueprint.Module) string
|
||||
}
|
||||
|
||||
// A subset of the ModuleContext methods which are sufficient to resolve references to paths/deps in
|
||||
// order to form a Bazel-compatible label for conversion.
|
||||
type BazelConversionPathContext interface {
|
||||
EarlyModulePathContext
|
||||
BazelConversionContext
|
||||
|
||||
ModuleErrorf(fmt string, args ...interface{})
|
||||
PropertyErrorf(property, fmt string, args ...interface{})
|
||||
GetDirectDep(name string) (blueprint.Module, blueprint.DependencyTag)
|
||||
ModuleFromName(name string) (blueprint.Module, bool)
|
||||
AddUnconvertedBp2buildDep(string)
|
||||
}
|
||||
|
||||
// BazelLabelForModuleDeps expects a list of reference to other modules, ("<module>"
|
||||
// or ":<module>") and returns a Bazel-compatible label which corresponds to dependencies on the
|
||||
// module within the given ctx.
|
||||
func BazelLabelForModuleDeps(ctx TopDownMutatorContext, modules []string) bazel.LabelList {
|
||||
func BazelLabelForModuleDeps(ctx BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||
return BazelLabelForModuleDepsWithFn(ctx, modules, BazelModuleLabel)
|
||||
}
|
||||
|
||||
@@ -95,15 +107,15 @@ func BazelLabelForModuleDeps(ctx TopDownMutatorContext, modules []string) bazel.
|
||||
// list which corresponds to dependencies on the module within the given ctx, and the excluded
|
||||
// dependencies. Prebuilt dependencies will be appended with _alwayslink so they can be handled as
|
||||
// whole static libraries.
|
||||
func BazelLabelForModuleDepsExcludes(ctx TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
|
||||
func BazelLabelForModuleDepsExcludes(ctx BazelConversionPathContext, modules, excludes []string) bazel.LabelList {
|
||||
return BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, BazelModuleLabel)
|
||||
}
|
||||
|
||||
// BazelLabelForModuleDepsWithFn expects a list of reference to other modules, ("<module>"
|
||||
// or ":<module>") and applies moduleToLabelFn to determine and return a Bazel-compatible label
|
||||
// which corresponds to dependencies on the module within the given ctx.
|
||||
func BazelLabelForModuleDepsWithFn(ctx TopDownMutatorContext, modules []string,
|
||||
moduleToLabelFn func(TopDownMutatorContext, blueprint.Module) string) bazel.LabelList {
|
||||
func BazelLabelForModuleDepsWithFn(ctx BazelConversionPathContext, modules []string,
|
||||
moduleToLabelFn func(BazelConversionPathContext, blueprint.Module) string) bazel.LabelList {
|
||||
var labels bazel.LabelList
|
||||
// In some cases, a nil string list is different than an explicitly empty list.
|
||||
if len(modules) == 0 && modules != nil {
|
||||
@@ -131,8 +143,8 @@ func BazelLabelForModuleDepsWithFn(ctx TopDownMutatorContext, modules []string,
|
||||
// to other modules, ("<module>" or ":<module>"). It applies moduleToLabelFn to determine and return a
|
||||
// Bazel-compatible label list which corresponds to dependencies on the module within the given ctx, and
|
||||
// the excluded dependencies.
|
||||
func BazelLabelForModuleDepsExcludesWithFn(ctx TopDownMutatorContext, modules, excludes []string,
|
||||
moduleToLabelFn func(TopDownMutatorContext, blueprint.Module) string) bazel.LabelList {
|
||||
func BazelLabelForModuleDepsExcludesWithFn(ctx BazelConversionPathContext, modules, excludes []string,
|
||||
moduleToLabelFn func(BazelConversionPathContext, blueprint.Module) string) bazel.LabelList {
|
||||
moduleLabels := BazelLabelForModuleDepsWithFn(ctx, RemoveListFromList(modules, excludes), moduleToLabelFn)
|
||||
if len(excludes) == 0 {
|
||||
return moduleLabels
|
||||
@@ -144,11 +156,11 @@ func BazelLabelForModuleDepsExcludesWithFn(ctx TopDownMutatorContext, modules, e
|
||||
}
|
||||
}
|
||||
|
||||
func BazelLabelForModuleSrcSingle(ctx TopDownMutatorContext, path string) bazel.Label {
|
||||
func BazelLabelForModuleSrcSingle(ctx BazelConversionPathContext, path string) bazel.Label {
|
||||
return BazelLabelForModuleSrcExcludes(ctx, []string{path}, []string(nil)).Includes[0]
|
||||
}
|
||||
|
||||
func BazelLabelForModuleDepSingle(ctx TopDownMutatorContext, path string) bazel.Label {
|
||||
func BazelLabelForModuleDepSingle(ctx BazelConversionPathContext, path string) bazel.Label {
|
||||
return BazelLabelForModuleDepsExcludes(ctx, []string{path}, []string(nil)).Includes[0]
|
||||
}
|
||||
|
||||
@@ -158,7 +170,7 @@ func BazelLabelForModuleDepSingle(ctx TopDownMutatorContext, path string) bazel.
|
||||
// relative if within the same package).
|
||||
// Properties must have been annotated with struct tag `android:"path"` so that dependencies modules
|
||||
// will have already been handled by the path_deps mutator.
|
||||
func BazelLabelForModuleSrc(ctx TopDownMutatorContext, paths []string) bazel.LabelList {
|
||||
func BazelLabelForModuleSrc(ctx BazelConversionPathContext, paths []string) bazel.LabelList {
|
||||
return BazelLabelForModuleSrcExcludes(ctx, paths, []string(nil))
|
||||
}
|
||||
|
||||
@@ -168,7 +180,7 @@ func BazelLabelForModuleSrc(ctx TopDownMutatorContext, paths []string) bazel.Lab
|
||||
// (absolute if in a different package or relative if within the same package).
|
||||
// Properties must have been annotated with struct tag `android:"path"` so that dependencies modules
|
||||
// will have already been handled by the path_deps mutator.
|
||||
func BazelLabelForModuleSrcExcludes(ctx TopDownMutatorContext, paths, excludes []string) bazel.LabelList {
|
||||
func BazelLabelForModuleSrcExcludes(ctx BazelConversionPathContext, paths, excludes []string) bazel.LabelList {
|
||||
excludeLabels := expandSrcsForBazel(ctx, excludes, []string(nil))
|
||||
excluded := make([]string, 0, len(excludeLabels.Includes))
|
||||
for _, e := range excludeLabels.Includes {
|
||||
@@ -288,7 +300,7 @@ func transformSubpackagePaths(ctx BazelConversionPathContext, paths bazel.LabelL
|
||||
// Properties passed as the paths or excludes argument must have been annotated with struct tag
|
||||
// `android:"path"` so that dependencies on other modules will have already been handled by the
|
||||
// path_deps mutator.
|
||||
func expandSrcsForBazel(ctx TopDownMutatorContext, paths, expandedExcludes []string) bazel.LabelList {
|
||||
func expandSrcsForBazel(ctx BazelConversionPathContext, paths, expandedExcludes []string) bazel.LabelList {
|
||||
if paths == nil {
|
||||
return bazel.LabelList{}
|
||||
}
|
||||
@@ -336,8 +348,8 @@ func expandSrcsForBazel(ctx TopDownMutatorContext, paths, expandedExcludes []str
|
||||
// getOtherModuleLabel returns a bazel.Label for the given dependency/tag combination for the
|
||||
// module. The label will be relative to the current directory if appropriate. The dependency must
|
||||
// already be resolved by either deps mutator or path deps mutator.
|
||||
func getOtherModuleLabel(ctx TopDownMutatorContext, dep, tag string,
|
||||
labelFromModule func(TopDownMutatorContext, blueprint.Module) string) bazel.Label {
|
||||
func getOtherModuleLabel(ctx BazelConversionPathContext, dep, tag string,
|
||||
labelFromModule func(BazelConversionPathContext, blueprint.Module) string) bazel.Label {
|
||||
m, _ := ctx.ModuleFromName(dep)
|
||||
if m == nil {
|
||||
panic(fmt.Errorf("No module named %q found, but was a direct dep of %q", dep, ctx.Module().Name()))
|
||||
@@ -359,7 +371,7 @@ func getOtherModuleLabel(ctx TopDownMutatorContext, dep, tag string,
|
||||
}
|
||||
}
|
||||
|
||||
func BazelModuleLabel(ctx TopDownMutatorContext, module blueprint.Module) string {
|
||||
func BazelModuleLabel(ctx BazelConversionPathContext, module blueprint.Module) string {
|
||||
// TODO(b/165114590): Convert tag (":name{.tag}") to corresponding Bazel implicit output targets.
|
||||
if !convertedToBazel(ctx, module) {
|
||||
return bp2buildModuleLabel(ctx, module)
|
||||
@@ -370,11 +382,17 @@ func BazelModuleLabel(ctx TopDownMutatorContext, module blueprint.Module) string
|
||||
|
||||
func bazelShortLabel(label string) string {
|
||||
i := strings.Index(label, ":")
|
||||
if i == -1 {
|
||||
panic(fmt.Errorf("Could not find the ':' character in '%s', expected a fully qualified label.", label))
|
||||
}
|
||||
return label[i:]
|
||||
}
|
||||
|
||||
func bazelPackage(label string) string {
|
||||
i := strings.Index(label, ":")
|
||||
if i == -1 {
|
||||
panic(fmt.Errorf("Could not find the ':' character in '%s', expected a fully qualified label.", label))
|
||||
}
|
||||
return label[0:i]
|
||||
}
|
||||
|
||||
@@ -382,7 +400,7 @@ func samePackage(label1, label2 string) bool {
|
||||
return bazelPackage(label1) == bazelPackage(label2)
|
||||
}
|
||||
|
||||
func bp2buildModuleLabel(ctx BazelConversionPathContext, module blueprint.Module) string {
|
||||
func bp2buildModuleLabel(ctx BazelConversionContext, module blueprint.Module) string {
|
||||
moduleName := ctx.OtherModuleName(module)
|
||||
moduleDir := ctx.OtherModuleDir(module)
|
||||
return fmt.Sprintf("//%s:%s", moduleDir, moduleName)
|
||||
|
@@ -498,7 +498,7 @@ type ProductConfigProperties map[string]map[string]ProductConfigProperty
|
||||
|
||||
// ProductVariableProperties returns a ProductConfigProperties containing only the properties which
|
||||
// have been set for the module in the given context.
|
||||
func ProductVariableProperties(ctx BaseMutatorContext) ProductConfigProperties {
|
||||
func ProductVariableProperties(ctx BazelConversionPathContext) ProductConfigProperties {
|
||||
module := ctx.Module()
|
||||
moduleBase := module.base()
|
||||
|
||||
|
@@ -534,9 +534,13 @@ func (lla *LabelListAttribute) ResolveExcludes() {
|
||||
lla.ConfigurableValues[axis][config] = SubtractBazelLabelList(val, lla.Value)
|
||||
}
|
||||
|
||||
// Now that the Value list is finalized for this axis, compare it with the original
|
||||
// list, and put the difference into the default condition for the axis.
|
||||
lla.ConfigurableValues[axis][ConditionsDefaultConfigKey] = SubtractBazelLabelList(baseLabels, lla.Value)
|
||||
// Now that the Value list is finalized for this axis, compare it with
|
||||
// the original list, and union the difference with the default
|
||||
// condition for the axis.
|
||||
difference := SubtractBazelLabelList(baseLabels, lla.Value)
|
||||
existingDefaults := lla.ConfigurableValues[axis][ConditionsDefaultConfigKey]
|
||||
existingDefaults.Append(difference)
|
||||
lla.ConfigurableValues[axis][ConditionsDefaultConfigKey] = FirstUniqueBazelLabelList(existingDefaults)
|
||||
|
||||
// if everything ends up without includes, just delete the axis
|
||||
if !lla.ConfigurableValues[axis].HasConfigurableValues() {
|
||||
|
@@ -236,8 +236,9 @@ func TestResolveExcludes(t *testing.T) {
|
||||
),
|
||||
ConfigurableValues: configurableLabelLists{
|
||||
ArchConfigurationAxis: labelListSelectValues{
|
||||
"arm": makeLabelList([]string{}, []string{"arm_exclude"}),
|
||||
"x86": makeLabelList([]string{"x86_include"}, []string{}),
|
||||
"arm": makeLabelList([]string{}, []string{"arm_exclude"}),
|
||||
"x86": makeLabelList([]string{"x86_include"}, []string{}),
|
||||
ConditionsDefaultConfigKey: makeLabelList([]string{"default_include"}, []string{}),
|
||||
},
|
||||
OsConfigurationAxis: labelListSelectValues{
|
||||
"android": makeLabelList([]string{}, []string{"android_exclude"}),
|
||||
@@ -246,7 +247,13 @@ func TestResolveExcludes(t *testing.T) {
|
||||
OsArchConfigurationAxis: labelListSelectValues{
|
||||
"linux_x86": makeLabelList([]string{"linux_x86_include"}, []string{}),
|
||||
},
|
||||
ProductVariableConfigurationAxis("a"): labelListSelectValues{
|
||||
ProductVariableConfigurationAxis("product_with_defaults"): labelListSelectValues{
|
||||
"a": makeLabelList([]string{}, []string{"not_in_value"}),
|
||||
"b": makeLabelList([]string{"b_val"}, []string{}),
|
||||
"c": makeLabelList([]string{"c_val"}, []string{}),
|
||||
ConditionsDefaultConfigKey: makeLabelList([]string{"c_val", "default", "default2"}, []string{}),
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_only_with_excludes"): labelListSelectValues{
|
||||
"a": makeLabelList([]string{}, []string{"not_in_value"}),
|
||||
},
|
||||
},
|
||||
@@ -254,25 +261,31 @@ func TestResolveExcludes(t *testing.T) {
|
||||
|
||||
attr.ResolveExcludes()
|
||||
|
||||
expectedBaseIncludes := []Label{Label{Label: "all_include"}}
|
||||
expectedBaseIncludes := []Label{{Label: "all_include"}}
|
||||
if !reflect.DeepEqual(expectedBaseIncludes, attr.Value.Includes) {
|
||||
t.Errorf("Expected Value includes %q, got %q", attr.Value.Includes, expectedBaseIncludes)
|
||||
}
|
||||
var nilLabels []Label
|
||||
expectedConfiguredIncludes := map[ConfigurationAxis]map[string][]Label{
|
||||
ArchConfigurationAxis: map[string][]Label{
|
||||
"arm": nilLabels,
|
||||
"x86": makeLabels("arm_exclude", "x86_include"),
|
||||
"conditions_default": makeLabels("arm_exclude"),
|
||||
ArchConfigurationAxis: {
|
||||
"arm": nilLabels,
|
||||
"x86": makeLabels("arm_exclude", "x86_include"),
|
||||
ConditionsDefaultConfigKey: makeLabels("arm_exclude", "default_include"),
|
||||
},
|
||||
OsConfigurationAxis: map[string][]Label{
|
||||
"android": nilLabels,
|
||||
"linux": makeLabels("android_exclude", "linux_include"),
|
||||
"conditions_default": makeLabels("android_exclude"),
|
||||
OsConfigurationAxis: {
|
||||
"android": nilLabels,
|
||||
"linux": makeLabels("android_exclude", "linux_include"),
|
||||
ConditionsDefaultConfigKey: makeLabels("android_exclude"),
|
||||
},
|
||||
OsArchConfigurationAxis: map[string][]Label{
|
||||
"linux_x86": makeLabels("linux_x86_include"),
|
||||
"conditions_default": nilLabels,
|
||||
OsArchConfigurationAxis: {
|
||||
"linux_x86": makeLabels("linux_x86_include"),
|
||||
ConditionsDefaultConfigKey: nilLabels,
|
||||
},
|
||||
ProductVariableConfigurationAxis("product_with_defaults"): {
|
||||
"a": nilLabels,
|
||||
"b": makeLabels("b_val"),
|
||||
"c": makeLabels("c_val"),
|
||||
ConditionsDefaultConfigKey: makeLabels("c_val", "default", "default2"),
|
||||
},
|
||||
}
|
||||
for _, axis := range attr.SortedConfigurationAxes() {
|
||||
@@ -288,7 +301,7 @@ func TestResolveExcludes(t *testing.T) {
|
||||
for config, value := range gotForAxis {
|
||||
if expected, ok := expectedForAxis[config]; ok {
|
||||
if !reflect.DeepEqual(expected, value.Includes) {
|
||||
t.Errorf("For %s, expected: %#v, got %#v", axis, expected, value.Includes)
|
||||
t.Errorf("For %s,\nexpected: %#v\ngot %#v", axis, expected, value.Includes)
|
||||
}
|
||||
} else {
|
||||
t.Errorf("Got unexpected config %q for %s", config, axis)
|
||||
|
@@ -50,7 +50,7 @@ type staticOrSharedAttributes struct {
|
||||
System_dynamic_deps bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelListAttribute) bazel.PartitionToLabelListAttribute {
|
||||
func groupSrcsByExtension(ctx android.BazelConversionPathContext, srcs bazel.LabelListAttribute) bazel.PartitionToLabelListAttribute {
|
||||
// Check that a module is a filegroup type named <label>.
|
||||
isFilegroupNamed := func(m android.Module, fullLabel string) bool {
|
||||
if ctx.OtherModuleType(m) != "filegroup" {
|
||||
@@ -93,7 +93,7 @@ func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelLis
|
||||
}
|
||||
|
||||
// bp2BuildParseLibProps returns the attributes for a variant of a cc_library.
|
||||
func bp2BuildParseLibProps(ctx android.TopDownMutatorContext, module *Module, isStatic bool) staticOrSharedAttributes {
|
||||
func bp2BuildParseLibProps(ctx android.BazelConversionPathContext, module *Module, isStatic bool) staticOrSharedAttributes {
|
||||
lib, ok := module.compiler.(*libraryDecorator)
|
||||
if !ok {
|
||||
return staticOrSharedAttributes{}
|
||||
@@ -102,12 +102,12 @@ func bp2BuildParseLibProps(ctx android.TopDownMutatorContext, module *Module, is
|
||||
}
|
||||
|
||||
// bp2buildParseSharedProps returns the attributes for the shared variant of a cc_library.
|
||||
func bp2BuildParseSharedProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
|
||||
func bp2BuildParseSharedProps(ctx android.BazelConversionPathContext, module *Module) staticOrSharedAttributes {
|
||||
return bp2BuildParseLibProps(ctx, module, false)
|
||||
}
|
||||
|
||||
// bp2buildParseStaticProps returns the attributes for the static variant of a cc_library.
|
||||
func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) staticOrSharedAttributes {
|
||||
func bp2BuildParseStaticProps(ctx android.BazelConversionPathContext, module *Module) staticOrSharedAttributes {
|
||||
return bp2BuildParseLibProps(ctx, module, true)
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ type depsPartition struct {
|
||||
implementation bazel.LabelList
|
||||
}
|
||||
|
||||
type bazelLabelForDepsFn func(android.TopDownMutatorContext, []string) bazel.LabelList
|
||||
type bazelLabelForDepsFn func(android.BazelConversionPathContext, []string) bazel.LabelList
|
||||
|
||||
func maybePartitionExportedAndImplementationsDeps(ctx android.TopDownMutatorContext, exportsDeps bool, allDeps, exportedDeps []string, fn bazelLabelForDepsFn) depsPartition {
|
||||
func maybePartitionExportedAndImplementationsDeps(ctx android.BazelConversionPathContext, exportsDeps bool, allDeps, exportedDeps []string, fn bazelLabelForDepsFn) depsPartition {
|
||||
if !exportsDeps {
|
||||
return depsPartition{
|
||||
implementation: fn(ctx, allDeps),
|
||||
@@ -133,9 +133,9 @@ func maybePartitionExportedAndImplementationsDeps(ctx android.TopDownMutatorCont
|
||||
}
|
||||
}
|
||||
|
||||
type bazelLabelForDepsExcludesFn func(android.TopDownMutatorContext, []string, []string) bazel.LabelList
|
||||
type bazelLabelForDepsExcludesFn func(android.BazelConversionPathContext, []string, []string) bazel.LabelList
|
||||
|
||||
func maybePartitionExportedAndImplementationsDepsExcludes(ctx android.TopDownMutatorContext, exportsDeps bool, allDeps, excludes, exportedDeps []string, fn bazelLabelForDepsExcludesFn) depsPartition {
|
||||
func maybePartitionExportedAndImplementationsDepsExcludes(ctx android.BazelConversionPathContext, exportsDeps bool, allDeps, excludes, exportedDeps []string, fn bazelLabelForDepsExcludesFn) depsPartition {
|
||||
if !exportsDeps {
|
||||
return depsPartition{
|
||||
implementation: fn(ctx, allDeps, excludes),
|
||||
@@ -149,7 +149,7 @@ func maybePartitionExportedAndImplementationsDepsExcludes(ctx android.TopDownMut
|
||||
}
|
||||
}
|
||||
|
||||
func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
|
||||
func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
|
||||
attrs := staticOrSharedAttributes{}
|
||||
|
||||
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
|
||||
@@ -204,7 +204,7 @@ type prebuiltAttributes struct {
|
||||
}
|
||||
|
||||
// NOTE: Used outside of Soong repo project, in the clangprebuilts.go bootstrap_go_package
|
||||
func Bp2BuildParsePrebuiltLibraryProps(ctx android.TopDownMutatorContext, module *Module) prebuiltAttributes {
|
||||
func Bp2BuildParsePrebuiltLibraryProps(ctx android.BazelConversionPathContext, module *Module) prebuiltAttributes {
|
||||
var srcLabelAttribute bazel.LabelAttribute
|
||||
|
||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &prebuiltLinkerProperties{}) {
|
||||
@@ -269,7 +269,7 @@ func parseCommandLineFlags(soongFlags []string) []string {
|
||||
return result
|
||||
}
|
||||
|
||||
func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutatorContext, axis bazel.ConfigurationAxis, config string, props *BaseCompilerProperties) {
|
||||
func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis, config string, props *BaseCompilerProperties) {
|
||||
// If there's arch specific srcs or exclude_srcs, generate a select entry for it.
|
||||
// TODO(b/186153868): do this for OS specific srcs and exclude_srcs too.
|
||||
if srcsList, ok := parseSrcs(ctx, props); ok {
|
||||
@@ -295,7 +295,7 @@ func (ca *compilerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutato
|
||||
ca.rtti.SetSelectValue(axis, config, props.Rtti)
|
||||
}
|
||||
|
||||
func (ca *compilerAttributes) convertStlProps(ctx android.TopDownMutatorContext, module *Module) {
|
||||
func (ca *compilerAttributes) convertStlProps(ctx android.ArchVariantContext, module *Module) {
|
||||
stlPropsByArch := module.GetArchVariantProperties(ctx, &StlProperties{})
|
||||
for _, configToProps := range stlPropsByArch {
|
||||
for _, props := range configToProps {
|
||||
@@ -313,7 +313,7 @@ func (ca *compilerAttributes) convertStlProps(ctx android.TopDownMutatorContext,
|
||||
}
|
||||
}
|
||||
|
||||
func (ca *compilerAttributes) convertProductVariables(ctx android.TopDownMutatorContext, productVariableProps android.ProductConfigProperties) {
|
||||
func (ca *compilerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
||||
productVarPropNameToAttribute := map[string]*bazel.StringListAttribute{
|
||||
"Cflags": &ca.copts,
|
||||
"Asflags": &ca.asFlags,
|
||||
@@ -333,7 +333,7 @@ func (ca *compilerAttributes) convertProductVariables(ctx android.TopDownMutator
|
||||
}
|
||||
}
|
||||
|
||||
func (ca *compilerAttributes) finalize(ctx android.TopDownMutatorContext, implementationHdrs bazel.LabelListAttribute) {
|
||||
func (ca *compilerAttributes) finalize(ctx android.BazelConversionPathContext, implementationHdrs bazel.LabelListAttribute) {
|
||||
ca.srcs.ResolveExcludes()
|
||||
partitionedSrcs := groupSrcsByExtension(ctx, ca.srcs)
|
||||
|
||||
@@ -355,7 +355,7 @@ func (ca *compilerAttributes) finalize(ctx android.TopDownMutatorContext, implem
|
||||
}
|
||||
|
||||
// Parse srcs from an arch or OS's props value.
|
||||
func parseSrcs(ctx android.TopDownMutatorContext, props *BaseCompilerProperties) (bazel.LabelList, bool) {
|
||||
func parseSrcs(ctx android.BazelConversionPathContext, props *BaseCompilerProperties) (bazel.LabelList, bool) {
|
||||
anySrcs := false
|
||||
// Add srcs-like dependencies such as generated files.
|
||||
// First create a LabelList containing these dependencies, then merge the values with srcs.
|
||||
@@ -392,7 +392,7 @@ func bp2buildResolveCppStdValue(cpp_std *string, gnu_extensions *bool) *string {
|
||||
}
|
||||
|
||||
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
|
||||
func bp2BuildParseBaseProps(ctx android.TopDownMutatorContext, module *Module) baseAttributes {
|
||||
func bp2BuildParseBaseProps(ctx android.BazelConversionPathContext, module *Module) baseAttributes {
|
||||
archVariantCompilerProps := module.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
|
||||
archVariantLinkerProps := module.GetArchVariantProperties(ctx, &BaseLinkerProperties{})
|
||||
|
||||
@@ -475,7 +475,7 @@ type linkerAttributes struct {
|
||||
features bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutatorContext, isBinary bool, axis bazel.ConfigurationAxis, config string, props *BaseLinkerProperties) {
|
||||
func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversionPathContext, isBinary bool, axis bazel.ConfigurationAxis, config string, props *BaseLinkerProperties) {
|
||||
// Use a single variable to capture usage of nocrt in arch variants, so there's only 1 error message for this module
|
||||
var axisFeatures []string
|
||||
|
||||
@@ -548,7 +548,7 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.TopDownMutatorC
|
||||
}
|
||||
}
|
||||
|
||||
func (la *linkerAttributes) convertStripProps(ctx android.TopDownMutatorContext, module *Module) {
|
||||
func (la *linkerAttributes) convertStripProps(ctx android.BazelConversionPathContext, module *Module) {
|
||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &StripProperties{}) {
|
||||
for config, props := range configToProps {
|
||||
if stripProperties, ok := props.(*StripProperties); ok {
|
||||
@@ -562,7 +562,7 @@ func (la *linkerAttributes) convertStripProps(ctx android.TopDownMutatorContext,
|
||||
}
|
||||
}
|
||||
|
||||
func (la *linkerAttributes) convertProductVariables(ctx android.TopDownMutatorContext, productVariableProps android.ProductConfigProperties) {
|
||||
func (la *linkerAttributes) convertProductVariables(ctx android.BazelConversionPathContext, productVariableProps android.ProductConfigProperties) {
|
||||
|
||||
type productVarDep struct {
|
||||
// the name of the corresponding excludes field, if one exists
|
||||
@@ -570,14 +570,14 @@ func (la *linkerAttributes) convertProductVariables(ctx android.TopDownMutatorCo
|
||||
// reference to the bazel attribute that should be set for the given product variable config
|
||||
attribute *bazel.LabelListAttribute
|
||||
|
||||
depResolutionFunc func(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList
|
||||
depResolutionFunc func(ctx android.BazelConversionPathContext, modules, excludes []string) bazel.LabelList
|
||||
}
|
||||
|
||||
productVarToDepFields := map[string]productVarDep{
|
||||
// product variables do not support exclude_shared_libs
|
||||
"Shared_libs": productVarDep{attribute: &la.implementationDynamicDeps, depResolutionFunc: bazelLabelForSharedDepsExcludes},
|
||||
"Static_libs": productVarDep{"Exclude_static_libs", &la.implementationDeps, bazelLabelForStaticDepsExcludes},
|
||||
"Whole_static_libs": productVarDep{"Exclude_static_libs", &la.wholeArchiveDeps, bazelLabelForWholeDepsExcludes},
|
||||
"Shared_libs": {attribute: &la.implementationDynamicDeps, depResolutionFunc: bazelLabelForSharedDepsExcludes},
|
||||
"Static_libs": {"Exclude_static_libs", &la.implementationDeps, bazelLabelForStaticDepsExcludes},
|
||||
"Whole_static_libs": {"Exclude_static_libs", &la.wholeArchiveDeps, bazelLabelForWholeDepsExcludes},
|
||||
}
|
||||
|
||||
for name, dep := range productVarToDepFields {
|
||||
@@ -655,14 +655,14 @@ type BazelIncludes struct {
|
||||
SystemIncludes bazel.StringListAttribute
|
||||
}
|
||||
|
||||
func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) BazelIncludes {
|
||||
func bp2BuildParseExportedIncludes(ctx android.BazelConversionPathContext, module *Module) BazelIncludes {
|
||||
libraryDecorator := module.linker.(*libraryDecorator)
|
||||
return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
|
||||
}
|
||||
|
||||
// Bp2buildParseExportedIncludesForPrebuiltLibrary returns a BazelIncludes with Bazel-ified values
|
||||
// to export includes from the underlying module's properties.
|
||||
func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.TopDownMutatorContext, module *Module) BazelIncludes {
|
||||
func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.BazelConversionPathContext, module *Module) BazelIncludes {
|
||||
prebuiltLibraryLinker := module.linker.(*prebuiltLibraryLinker)
|
||||
libraryDecorator := prebuiltLibraryLinker.libraryDecorator
|
||||
return bp2BuildParseExportedIncludesHelper(ctx, module, libraryDecorator)
|
||||
@@ -670,7 +670,7 @@ func Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx android.TopDownMutatorC
|
||||
|
||||
// bp2BuildParseExportedIncludes creates a string list attribute contains the
|
||||
// exported included directories of a module.
|
||||
func bp2BuildParseExportedIncludesHelper(ctx android.TopDownMutatorContext, module *Module, libraryDecorator *libraryDecorator) BazelIncludes {
|
||||
func bp2BuildParseExportedIncludesHelper(ctx android.BazelConversionPathContext, module *Module, libraryDecorator *libraryDecorator) BazelIncludes {
|
||||
exported := BazelIncludes{}
|
||||
for axis, configToProps := range module.GetArchVariantProperties(ctx, &FlagExporterProperties{}) {
|
||||
for config, props := range configToProps {
|
||||
@@ -690,7 +690,7 @@ func bp2BuildParseExportedIncludesHelper(ctx android.TopDownMutatorContext, modu
|
||||
return exported
|
||||
}
|
||||
|
||||
func bazelLabelForStaticModule(ctx android.TopDownMutatorContext, m blueprint.Module) string {
|
||||
func bazelLabelForStaticModule(ctx android.BazelConversionPathContext, m blueprint.Module) string {
|
||||
label := android.BazelModuleLabel(ctx, m)
|
||||
if aModule, ok := m.(android.Module); ok {
|
||||
if ctx.OtherModuleType(aModule) == "cc_library" && !android.GenerateCcLibraryStaticOnly(m.Name()) {
|
||||
@@ -700,13 +700,13 @@ func bazelLabelForStaticModule(ctx android.TopDownMutatorContext, m blueprint.Mo
|
||||
return label
|
||||
}
|
||||
|
||||
func bazelLabelForSharedModule(ctx android.TopDownMutatorContext, m blueprint.Module) string {
|
||||
func bazelLabelForSharedModule(ctx android.BazelConversionPathContext, m blueprint.Module) string {
|
||||
// cc_library, at it's root name, propagates the shared library, which depends on the static
|
||||
// library.
|
||||
return android.BazelModuleLabel(ctx, m)
|
||||
}
|
||||
|
||||
func bazelLabelForStaticWholeModuleDeps(ctx android.TopDownMutatorContext, m blueprint.Module) string {
|
||||
func bazelLabelForStaticWholeModuleDeps(ctx android.BazelConversionPathContext, m blueprint.Module) string {
|
||||
label := bazelLabelForStaticModule(ctx, m)
|
||||
if aModule, ok := m.(android.Module); ok {
|
||||
if android.IsModulePrebuilt(aModule) {
|
||||
@@ -716,33 +716,33 @@ func bazelLabelForStaticWholeModuleDeps(ctx android.TopDownMutatorContext, m blu
|
||||
return label
|
||||
}
|
||||
|
||||
func bazelLabelForWholeDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
|
||||
func bazelLabelForWholeDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticWholeModuleDeps)
|
||||
}
|
||||
|
||||
func bazelLabelForWholeDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
|
||||
func bazelLabelForWholeDepsExcludes(ctx android.BazelConversionPathContext, modules, excludes []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForStaticWholeModuleDeps)
|
||||
}
|
||||
|
||||
func bazelLabelForStaticDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
|
||||
func bazelLabelForStaticDepsExcludes(ctx android.BazelConversionPathContext, modules, excludes []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForStaticModule)
|
||||
}
|
||||
|
||||
func bazelLabelForStaticDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
|
||||
func bazelLabelForStaticDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForStaticModule)
|
||||
}
|
||||
|
||||
func bazelLabelForSharedDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
|
||||
func bazelLabelForSharedDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsWithFn(ctx, modules, bazelLabelForSharedModule)
|
||||
}
|
||||
|
||||
func bazelLabelForHeaderDeps(ctx android.TopDownMutatorContext, modules []string) bazel.LabelList {
|
||||
func bazelLabelForHeaderDeps(ctx android.BazelConversionPathContext, modules []string) bazel.LabelList {
|
||||
// This is not elegant, but bp2build's shared library targets only propagate
|
||||
// their header information as part of the normal C++ provider.
|
||||
return bazelLabelForSharedDeps(ctx, modules)
|
||||
}
|
||||
|
||||
func bazelLabelForSharedDepsExcludes(ctx android.TopDownMutatorContext, modules, excludes []string) bazel.LabelList {
|
||||
func bazelLabelForSharedDepsExcludes(ctx android.BazelConversionPathContext, modules, excludes []string) bazel.LabelList {
|
||||
return android.BazelLabelForModuleDepsExcludesWithFn(ctx, modules, excludes, bazelLabelForSharedModule)
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ type binaryLinkerAttrs struct {
|
||||
Linkshared *bool
|
||||
}
|
||||
|
||||
func bp2buildBinaryLinkerProps(ctx android.TopDownMutatorContext, m *Module) binaryLinkerAttrs {
|
||||
func bp2buildBinaryLinkerProps(ctx android.BazelConversionPathContext, m *Module) binaryLinkerAttrs {
|
||||
attrs := binaryLinkerAttrs{}
|
||||
archVariantProps := m.GetArchVariantProperties(ctx, &BinaryLinkerProperties{})
|
||||
for axis, configToProps := range archVariantProps {
|
||||
|
Reference in New Issue
Block a user