Use one mutator for all bp2build conversion.
Each conversion required defining a separate mutator, which will each operate on _all_ modules and requires each to repeat checks whether the mutator should operator. Instead, we introduce a single mutator and modules can define a ConvertWithBp2build to implement bp2build conversion for that module. Test: bp2build.sh Bug: 183079158 Change-Id: I99d4b51f441c2903879092c5b56313d606d4338d
This commit is contained in:
@@ -39,6 +39,10 @@ type bazelModuleProperties struct {
|
|||||||
// To opt-out a module, set bazel_module: { bp2build_available: false }
|
// To opt-out a module, set bazel_module: { bp2build_available: false }
|
||||||
// To defer the default setting for the directory, do not set the value.
|
// To defer the default setting for the directory, do not set the value.
|
||||||
Bp2build_available *bool
|
Bp2build_available *bool
|
||||||
|
|
||||||
|
// CanConvertToBazel is set via InitBazelModule to indicate that a module type can be converted to
|
||||||
|
// Bazel with Bp2build.
|
||||||
|
CanConvertToBazel bool `blueprint:"mutated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Properties contains common module properties for Bazel migration purposes.
|
// Properties contains common module properties for Bazel migration purposes.
|
||||||
@@ -80,9 +84,10 @@ type Bazelable interface {
|
|||||||
HasHandcraftedLabel() bool
|
HasHandcraftedLabel() bool
|
||||||
HandcraftedLabel() string
|
HandcraftedLabel() string
|
||||||
GetBazelLabel(ctx BazelConversionPathContext, module blueprint.Module) string
|
GetBazelLabel(ctx BazelConversionPathContext, module blueprint.Module) string
|
||||||
ConvertWithBp2build(ctx BazelConversionContext) bool
|
ShouldConvertWithBp2build(ctx BazelConversionContext) bool
|
||||||
convertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool
|
shouldConvertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool
|
||||||
GetBazelBuildFileContents(c Config, path, name string) (string, error)
|
GetBazelBuildFileContents(c Config, path, name string) (string, error)
|
||||||
|
ConvertWithBp2build(ctx TopDownMutatorContext)
|
||||||
|
|
||||||
// namespacedVariableProps is a map from a soong config variable namespace
|
// namespacedVariableProps is a map from a soong config variable namespace
|
||||||
// (e.g. acme, android) to a map of interfaces{}, which are really
|
// (e.g. acme, android) to a map of interfaces{}, which are really
|
||||||
@@ -109,6 +114,7 @@ type BazelModule interface {
|
|||||||
// properties.
|
// properties.
|
||||||
func InitBazelModule(module BazelModule) {
|
func InitBazelModule(module BazelModule) {
|
||||||
module.AddProperties(module.bazelProps())
|
module.AddProperties(module.bazelProps())
|
||||||
|
module.bazelProps().Bazel_module.CanConvertToBazel = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// bazelProps returns the Bazel properties for the given BazelModuleBase.
|
// bazelProps returns the Bazel properties for the given BazelModuleBase.
|
||||||
@@ -147,7 +153,7 @@ func (b *BazelModuleBase) GetBazelLabel(ctx BazelConversionPathContext, module b
|
|||||||
if b.HasHandcraftedLabel() {
|
if b.HasHandcraftedLabel() {
|
||||||
return b.HandcraftedLabel()
|
return b.HandcraftedLabel()
|
||||||
}
|
}
|
||||||
if b.ConvertWithBp2build(ctx) {
|
if b.ShouldConvertWithBp2build(ctx) {
|
||||||
return bp2buildModuleLabel(ctx, module)
|
return bp2buildModuleLabel(ctx, module)
|
||||||
}
|
}
|
||||||
return "" // no label for unconverted module
|
return "" // no label for unconverted module
|
||||||
@@ -436,6 +442,9 @@ var (
|
|||||||
|
|
||||||
"acvp_modulewrapper", // disabled for android x86/x86_64
|
"acvp_modulewrapper", // disabled for android x86/x86_64
|
||||||
"CarHTMLViewer", // depends on unconverted modules android.car-stubs, car-ui-lib
|
"CarHTMLViewer", // depends on unconverted modules android.car-stubs, car-ui-lib
|
||||||
|
|
||||||
|
"libdexfile", // depends on unconverted modules: dexfile_operator_srcs, libartbase, libartpalette,
|
||||||
|
"libdexfiled", // depends on unconverted modules: dexfile_operator_srcs, libartbased, libartpalette
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-module denylist of cc_library modules to only generate the static
|
// Per-module denylist of cc_library modules to only generate the static
|
||||||
@@ -530,32 +539,21 @@ func convertedToBazel(ctx BazelConversionContext, module blueprint.Module) bool
|
|||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return b.convertWithBp2build(ctx, module) || b.HasHandcraftedLabel()
|
return b.shouldConvertWithBp2build(ctx, module) || b.HasHandcraftedLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build.
|
// ShouldConvertWithBp2build returns whether the given BazelModuleBase should be converted with bp2build.
|
||||||
func (b *BazelModuleBase) ConvertWithBp2build(ctx BazelConversionContext) bool {
|
func (b *BazelModuleBase) ShouldConvertWithBp2build(ctx BazelConversionContext) bool {
|
||||||
return b.convertWithBp2build(ctx, ctx.Module())
|
return b.shouldConvertWithBp2build(ctx, ctx.Module())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BazelModuleBase) convertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool {
|
func (b *BazelModuleBase) shouldConvertWithBp2build(ctx BazelConversionContext, module blueprint.Module) bool {
|
||||||
if bp2buildModuleDoNotConvert[module.Name()] {
|
if bp2buildModuleDoNotConvert[module.Name()] {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the module type of this module has a bp2build converter. This
|
if !b.bazelProps().Bazel_module.CanConvertToBazel {
|
||||||
// prevents mixed builds from using auto-converted modules just by matching
|
return false
|
||||||
// the package dir; it also has to have a bp2build mutator as well.
|
|
||||||
if ctx.Config().bp2buildModuleTypeConfig[ctx.OtherModuleType(module)] == false {
|
|
||||||
if b, ok := module.(Bazelable); ok && b.BaseModuleType() != "" {
|
|
||||||
// For modules with custom types from soong_config_module_types,
|
|
||||||
// check that their _base module type_ has a bp2build mutator.
|
|
||||||
if ctx.Config().bp2buildModuleTypeConfig[b.BaseModuleType()] == false {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
packagePath := ctx.OtherModuleDir(module)
|
packagePath := ctx.OtherModuleDir(module)
|
||||||
@@ -629,3 +627,16 @@ func (b *BazelModuleBase) GetBazelBuildFileContents(c Config, path, name string)
|
|||||||
}
|
}
|
||||||
return string(data[:]), nil
|
return string(data[:]), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func registerBp2buildConversionMutator(ctx RegisterMutatorsContext) {
|
||||||
|
ctx.TopDown("bp2build_conversion", convertWithBp2build).Parallel()
|
||||||
|
}
|
||||||
|
|
||||||
|
func convertWithBp2build(ctx TopDownMutatorContext) {
|
||||||
|
bModule, ok := ctx.Module().(Bazelable)
|
||||||
|
if !ok || !bModule.shouldConvertWithBp2build(ctx, ctx.Module()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
bModule.ConvertWithBp2build(ctx)
|
||||||
|
}
|
||||||
|
@@ -157,7 +157,6 @@ type config struct {
|
|||||||
|
|
||||||
runningAsBp2Build bool
|
runningAsBp2Build bool
|
||||||
bp2buildPackageConfig Bp2BuildConfig
|
bp2buildPackageConfig Bp2BuildConfig
|
||||||
bp2buildModuleTypeConfig map[string]bool
|
|
||||||
Bp2buildSoongConfigDefinitions soongconfig.Bp2BuildSoongConfigDefinitions
|
Bp2buildSoongConfigDefinitions soongconfig.Bp2BuildSoongConfigDefinitions
|
||||||
|
|
||||||
// If testAllowNonExistentPaths is true then PathForSource and PathForModuleSrc won't error
|
// If testAllowNonExistentPaths is true then PathForSource and PathForModuleSrc won't error
|
||||||
@@ -353,8 +352,6 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
|
|||||||
|
|
||||||
config.mockFileSystem(bp, fs)
|
config.mockFileSystem(bp, fs)
|
||||||
|
|
||||||
config.bp2buildModuleTypeConfig = map[string]bool{}
|
|
||||||
|
|
||||||
determineBuildOS(config)
|
determineBuildOS(config)
|
||||||
|
|
||||||
return Config{config}
|
return Config{config}
|
||||||
@@ -522,7 +519,6 @@ func NewConfig(moduleListFile string, runGoTests bool, outDir, soongOutDir strin
|
|||||||
|
|
||||||
config.BazelContext, err = NewBazelContext(config)
|
config.BazelContext, err = NewBazelContext(config)
|
||||||
config.bp2buildPackageConfig = bp2buildDefaultConfig
|
config.bp2buildPackageConfig = bp2buildDefaultConfig
|
||||||
config.bp2buildModuleTypeConfig = make(map[string]bool)
|
|
||||||
|
|
||||||
return Config{config}, err
|
return Config{config}, err
|
||||||
}
|
}
|
||||||
|
@@ -173,6 +173,10 @@ func (d *DefaultsModuleBase) productVariableProperties() interface{} {
|
|||||||
func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
|
func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ConvertWithBp2build to fulfill Bazelable interface; however, at this time defaults module are
|
||||||
|
// *NOT* converted with bp2build
|
||||||
|
func (defaultable *DefaultsModuleBase) ConvertWithBp2build(ctx TopDownMutatorContext) {}
|
||||||
|
|
||||||
func InitDefaultsModule(module DefaultsModule) {
|
func InitDefaultsModule(module DefaultsModule) {
|
||||||
commonProperties := &commonProperties{}
|
commonProperties := &commonProperties{}
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterModuleType("filegroup", FileGroupFactory)
|
RegisterModuleType("filegroup", FileGroupFactory)
|
||||||
RegisterBp2BuildMutator("filegroup", FilegroupBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
||||||
@@ -34,12 +33,8 @@ type bazelFilegroupAttributes struct {
|
|||||||
Srcs bazel.LabelListAttribute
|
Srcs bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func FilegroupBp2Build(ctx TopDownMutatorContext) {
|
// ConvertWithBp2build performs bp2build conversion of filegroup
|
||||||
fg, ok := ctx.Module().(*fileGroup)
|
func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) {
|
||||||
if !ok || !fg.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
srcs := bazel.MakeLabelListAttribute(
|
srcs := bazel.MakeLabelListAttribute(
|
||||||
BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))
|
BazelLabelForModuleSrcExcludes(ctx, fg.properties.Srcs, fg.properties.Exclude_srcs))
|
||||||
|
|
||||||
|
@@ -16,7 +16,6 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
|
|
||||||
@@ -34,12 +33,12 @@ import (
|
|||||||
// continue on to GenerateAndroidBuildActions
|
// continue on to GenerateAndroidBuildActions
|
||||||
|
|
||||||
// RegisterMutatorsForBazelConversion is a alternate registration pipeline for bp2build. Exported for testing.
|
// RegisterMutatorsForBazelConversion is a alternate registration pipeline for bp2build. Exported for testing.
|
||||||
func RegisterMutatorsForBazelConversion(ctx *Context, preArchMutators, bp2buildMutators []RegisterMutatorFunc) {
|
func RegisterMutatorsForBazelConversion(ctx *Context, preArchMutators []RegisterMutatorFunc) {
|
||||||
mctx := ®isterMutatorsContext{
|
mctx := ®isterMutatorsContext{
|
||||||
bazelConversionMode: true,
|
bazelConversionMode: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
bp2buildPreArchMutators = append([]RegisterMutatorFunc{
|
bp2buildMutators := append([]RegisterMutatorFunc{
|
||||||
RegisterNamespaceMutator,
|
RegisterNamespaceMutator,
|
||||||
RegisterDefaultsPreArchMutators,
|
RegisterDefaultsPreArchMutators,
|
||||||
// TODO(b/165114590): this is required to resolve deps that are only prebuilts, but we should
|
// TODO(b/165114590): this is required to resolve deps that are only prebuilts, but we should
|
||||||
@@ -47,10 +46,7 @@ func RegisterMutatorsForBazelConversion(ctx *Context, preArchMutators, bp2buildM
|
|||||||
RegisterPrebuiltsPreArchMutators,
|
RegisterPrebuiltsPreArchMutators,
|
||||||
},
|
},
|
||||||
preArchMutators...)
|
preArchMutators...)
|
||||||
|
bp2buildMutators = append(bp2buildMutators, registerBp2buildConversionMutator)
|
||||||
for _, f := range bp2buildPreArchMutators {
|
|
||||||
f(mctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register bp2build mutators
|
// Register bp2build mutators
|
||||||
for _, f := range bp2buildMutators {
|
for _, f := range bp2buildMutators {
|
||||||
@@ -216,10 +212,6 @@ func FinalDepsMutators(f RegisterMutatorFunc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var bp2buildPreArchMutators = []RegisterMutatorFunc{}
|
var bp2buildPreArchMutators = []RegisterMutatorFunc{}
|
||||||
var bp2buildMutators = map[string]RegisterMutatorFunc{}
|
|
||||||
|
|
||||||
// See http://b/192523357
|
|
||||||
var bp2buildLock sync.Mutex
|
|
||||||
|
|
||||||
// A minimal context for Bp2build conversion
|
// A minimal context for Bp2build conversion
|
||||||
type Bp2buildMutatorContext interface {
|
type Bp2buildMutatorContext interface {
|
||||||
@@ -228,21 +220,6 @@ type Bp2buildMutatorContext interface {
|
|||||||
CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
|
CreateBazelTargetModule(bazel.BazelTargetModuleProperties, CommonAttributes, interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterBp2BuildMutator registers specially crafted mutators for
|
|
||||||
// converting Blueprint/Android modules into special modules that can
|
|
||||||
// be code-generated into Bazel BUILD targets.
|
|
||||||
//
|
|
||||||
// TODO(b/178068862): bring this into TestContext.
|
|
||||||
func RegisterBp2BuildMutator(moduleType string, m func(TopDownMutatorContext)) {
|
|
||||||
f := func(ctx RegisterMutatorsContext) {
|
|
||||||
ctx.TopDown(moduleType, m)
|
|
||||||
}
|
|
||||||
// Use a lock to avoid a concurrent map write if RegisterBp2BuildMutator is called in parallel
|
|
||||||
bp2buildLock.Lock()
|
|
||||||
defer bp2buildLock.Unlock()
|
|
||||||
bp2buildMutators[moduleType] = f
|
|
||||||
}
|
|
||||||
|
|
||||||
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
|
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
|
||||||
// into Bazel BUILD targets that should run prior to deps and conversion.
|
// into Bazel BUILD targets that should run prior to deps and conversion.
|
||||||
func PreArchBp2BuildMutators(f RegisterMutatorFunc) {
|
func PreArchBp2BuildMutators(f RegisterMutatorFunc) {
|
||||||
|
@@ -178,13 +178,7 @@ func (ctx *Context) RegisterForBazelConversion() {
|
|||||||
t.register(ctx)
|
t.register(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
bp2buildMutatorList := []RegisterMutatorFunc{}
|
RegisterMutatorsForBazelConversion(ctx, bp2buildPreArchMutators)
|
||||||
for t, f := range bp2buildMutators {
|
|
||||||
ctx.config.bp2buildModuleTypeConfig[t] = true
|
|
||||||
bp2buildMutatorList = append(bp2buildMutatorList, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
RegisterMutatorsForBazelConversion(ctx, bp2buildPreArchMutators, bp2buildMutatorList)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the pipeline of singletons, module types, and mutators for
|
// Register the pipeline of singletons, module types, and mutators for
|
||||||
@@ -196,15 +190,6 @@ func (ctx *Context) Register() {
|
|||||||
t.register(ctx)
|
t.register(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.config.BazelContext.BazelEnabled() {
|
|
||||||
// Hydrate the configuration of bp2build-enabled module types. This is
|
|
||||||
// required as a signal to identify which modules should be deferred to
|
|
||||||
// Bazel in mixed builds, if it is enabled.
|
|
||||||
for t, _ := range bp2buildMutators {
|
|
||||||
ctx.config.bp2buildModuleTypeConfig[t] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mutators := collateGloballyRegisteredMutators()
|
mutators := collateGloballyRegisteredMutators()
|
||||||
mutators.registerAll(ctx)
|
mutators.registerAll(ctx)
|
||||||
|
|
||||||
|
@@ -208,16 +208,6 @@ func (ctx *TestContext) RegisterBp2BuildConfig(config Bp2BuildConfig) {
|
|||||||
ctx.config.bp2buildPackageConfig = config
|
ctx.config.bp2buildPackageConfig = config
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterBp2BuildMutator registers a BazelTargetModule mutator for converting a module
|
|
||||||
// type to the equivalent Bazel target.
|
|
||||||
func (ctx *TestContext) RegisterBp2BuildMutator(moduleType string, m func(TopDownMutatorContext)) {
|
|
||||||
f := func(ctx RegisterMutatorsContext) {
|
|
||||||
ctx.TopDown(moduleType, m)
|
|
||||||
}
|
|
||||||
ctx.config.bp2buildModuleTypeConfig[moduleType] = true
|
|
||||||
ctx.bp2buildMutators = append(ctx.bp2buildMutators, f)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
|
// PreArchBp2BuildMutators adds mutators to be register for converting Android Blueprint modules
|
||||||
// into Bazel BUILD targets that should run prior to deps and conversion.
|
// into Bazel BUILD targets that should run prior to deps and conversion.
|
||||||
func (ctx *TestContext) PreArchBp2BuildMutators(f RegisterMutatorFunc) {
|
func (ctx *TestContext) PreArchBp2BuildMutators(f RegisterMutatorFunc) {
|
||||||
@@ -459,7 +449,7 @@ func (ctx *TestContext) Register() {
|
|||||||
// RegisterForBazelConversion prepares a test context for bp2build conversion.
|
// RegisterForBazelConversion prepares a test context for bp2build conversion.
|
||||||
func (ctx *TestContext) RegisterForBazelConversion() {
|
func (ctx *TestContext) RegisterForBazelConversion() {
|
||||||
ctx.SetRunningAsBp2build()
|
ctx.SetRunningAsBp2build()
|
||||||
RegisterMutatorsForBazelConversion(ctx.Context, ctx.bp2buildPreArch, ctx.bp2buildMutators)
|
RegisterMutatorsForBazelConversion(ctx.Context, ctx.bp2buildPreArch)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
|
func (ctx *TestContext) ParseFileList(rootDir string, filePaths []string) (deps []string, errs []error) {
|
||||||
|
58
apex/apex.go
58
apex/apex.go
@@ -54,8 +54,6 @@ func registerApexBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.PreArchMutators(registerPreArchMutators)
|
ctx.PreArchMutators(registerPreArchMutators)
|
||||||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("apex", ApexBundleBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerPreArchMutators(ctx android.RegisterMutatorsContext) {
|
func registerPreArchMutators(ctx android.RegisterMutatorsContext) {
|
||||||
@@ -3274,72 +3272,62 @@ type bazelApexBundleAttributes struct {
|
|||||||
Prebuilts bazel.LabelListAttribute
|
Prebuilts bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
|
// ConvertWithBp2build performs bp2build conversion of an apex
|
||||||
module, ok := ctx.Module().(*apexBundle)
|
func (a *apexBundle) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
if !ok {
|
// We do not convert apex_test modules at this time
|
||||||
// Not an APEX bundle
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "apex" {
|
if ctx.ModuleType() != "apex" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apexBundleBp2BuildInternal(ctx, module)
|
|
||||||
}
|
|
||||||
|
|
||||||
func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexBundle) {
|
|
||||||
var manifestLabelAttribute bazel.LabelAttribute
|
var manifestLabelAttribute bazel.LabelAttribute
|
||||||
if module.properties.Manifest != nil {
|
if a.properties.Manifest != nil {
|
||||||
manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.Manifest))
|
manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.Manifest))
|
||||||
}
|
}
|
||||||
|
|
||||||
var androidManifestLabelAttribute bazel.LabelAttribute
|
var androidManifestLabelAttribute bazel.LabelAttribute
|
||||||
if module.properties.AndroidManifest != nil {
|
if a.properties.AndroidManifest != nil {
|
||||||
androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *module.properties.AndroidManifest))
|
androidManifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *a.properties.AndroidManifest))
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileContextsLabelAttribute bazel.LabelAttribute
|
var fileContextsLabelAttribute bazel.LabelAttribute
|
||||||
if module.properties.File_contexts != nil {
|
if a.properties.File_contexts != nil {
|
||||||
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.properties.File_contexts))
|
fileContextsLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.properties.File_contexts))
|
||||||
}
|
}
|
||||||
|
|
||||||
var minSdkVersion *string
|
var minSdkVersion *string
|
||||||
if module.properties.Min_sdk_version != nil {
|
if a.properties.Min_sdk_version != nil {
|
||||||
minSdkVersion = module.properties.Min_sdk_version
|
minSdkVersion = a.properties.Min_sdk_version
|
||||||
}
|
}
|
||||||
|
|
||||||
var keyLabelAttribute bazel.LabelAttribute
|
var keyLabelAttribute bazel.LabelAttribute
|
||||||
if module.overridableProperties.Key != nil {
|
if a.overridableProperties.Key != nil {
|
||||||
keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Key))
|
keyLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Key))
|
||||||
}
|
}
|
||||||
|
|
||||||
var certificateLabelAttribute bazel.LabelAttribute
|
var certificateLabelAttribute bazel.LabelAttribute
|
||||||
if module.overridableProperties.Certificate != nil {
|
if a.overridableProperties.Certificate != nil {
|
||||||
certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *module.overridableProperties.Certificate))
|
certificateLabelAttribute.SetValue(android.BazelLabelForModuleDepSingle(ctx, *a.overridableProperties.Certificate))
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeSharedLibs := module.properties.ApexNativeDependencies.Native_shared_libs
|
nativeSharedLibs := a.properties.ApexNativeDependencies.Native_shared_libs
|
||||||
nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs)
|
nativeSharedLibsLabelList := android.BazelLabelForModuleDeps(ctx, nativeSharedLibs)
|
||||||
nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList)
|
nativeSharedLibsLabelListAttribute := bazel.MakeLabelListAttribute(nativeSharedLibsLabelList)
|
||||||
|
|
||||||
prebuilts := module.overridableProperties.Prebuilts
|
prebuilts := a.overridableProperties.Prebuilts
|
||||||
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
|
prebuiltsLabelList := android.BazelLabelForModuleDeps(ctx, prebuilts)
|
||||||
prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
|
prebuiltsLabelListAttribute := bazel.MakeLabelListAttribute(prebuiltsLabelList)
|
||||||
|
|
||||||
binaries := android.BazelLabelForModuleDeps(ctx, module.properties.ApexNativeDependencies.Binaries)
|
binaries := android.BazelLabelForModuleDeps(ctx, a.properties.ApexNativeDependencies.Binaries)
|
||||||
binariesLabelListAttribute := bazel.MakeLabelListAttribute(binaries)
|
binariesLabelListAttribute := bazel.MakeLabelListAttribute(binaries)
|
||||||
|
|
||||||
var updatableAttribute bazel.BoolAttribute
|
var updatableAttribute bazel.BoolAttribute
|
||||||
if module.properties.Updatable != nil {
|
if a.properties.Updatable != nil {
|
||||||
updatableAttribute.Value = module.properties.Updatable
|
updatableAttribute.Value = a.properties.Updatable
|
||||||
}
|
}
|
||||||
|
|
||||||
var installableAttribute bazel.BoolAttribute
|
var installableAttribute bazel.BoolAttribute
|
||||||
if module.properties.Installable != nil {
|
if a.properties.Installable != nil {
|
||||||
installableAttribute.Value = module.properties.Installable
|
installableAttribute.Value = a.properties.Installable
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs := &bazelApexBundleAttributes{
|
attrs := &bazelApexBundleAttributes{
|
||||||
@@ -3361,5 +3349,5 @@ func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexB
|
|||||||
Bzl_load_location: "//build/bazel/rules:apex.bzl",
|
Bzl_load_location: "//build/bazel/rules:apex.bzl",
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: a.Name()}, attrs)
|
||||||
}
|
}
|
||||||
|
19
apex/key.go
19
apex/key.go
@@ -34,8 +34,6 @@ func init() {
|
|||||||
func registerApexKeyBuildComponents(ctx android.RegistrationContext) {
|
func registerApexKeyBuildComponents(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
|
ctx.RegisterModuleType("apex_key", ApexKeyFactory)
|
||||||
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
|
ctx.RegisterSingletonType("apex_keys_text", apexKeysTextFactory)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("apex_key", ApexKeyBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type apexKey struct {
|
type apexKey struct {
|
||||||
@@ -209,20 +207,9 @@ type bazelApexKeyAttributes struct {
|
|||||||
Private_key bazel.LabelAttribute
|
Private_key bazel.LabelAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func ApexKeyBp2Build(ctx android.TopDownMutatorContext) {
|
// ConvertWithBp2build performs conversion apexKey for bp2build
|
||||||
module, ok := ctx.Module().(*apexKey)
|
func (m *apexKey) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
if !ok {
|
apexKeyBp2BuildInternal(ctx, m)
|
||||||
// Not an APEX key
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "apex_key" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
apexKeyBp2BuildInternal(ctx, module)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey) {
|
func apexKeyBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexKey) {
|
||||||
|
@@ -31,11 +31,10 @@ func registerAndroidAppCertificateModuleTypes(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
func TestAndroidAppCertificateSimple(t *testing.T) {
|
func TestAndroidAppCertificateSimple(t *testing.T) {
|
||||||
runAndroidAppCertificateTestCase(t, bp2buildTestCase{
|
runAndroidAppCertificateTestCase(t, bp2buildTestCase{
|
||||||
description: "Android app certificate - simple example",
|
description: "Android app certificate - simple example",
|
||||||
moduleTypeUnderTest: "android_app_certificate",
|
moduleTypeUnderTest: "android_app_certificate",
|
||||||
moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
|
moduleTypeUnderTestFactory: java.AndroidAppCertificateFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: java.AndroidAppCertificateBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: `
|
blueprint: `
|
||||||
android_app_certificate {
|
android_app_certificate {
|
||||||
name: "com.android.apogee.cert",
|
name: "com.android.apogee.cert",
|
||||||
|
@@ -31,10 +31,9 @@ func registerAndroidAppModuleTypes(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
func TestMinimalAndroidApp(t *testing.T) {
|
func TestMinimalAndroidApp(t *testing.T) {
|
||||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||||
description: "Android app - simple example",
|
description: "Android app - simple example",
|
||||||
moduleTypeUnderTest: "android_app",
|
moduleTypeUnderTest: "android_app",
|
||||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: java.AppBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"app.java": "",
|
"app.java": "",
|
||||||
"res/res.png": "",
|
"res/res.png": "",
|
||||||
@@ -58,10 +57,9 @@ android_app {
|
|||||||
|
|
||||||
func TestAndroidAppAllSupportedFields(t *testing.T) {
|
func TestAndroidAppAllSupportedFields(t *testing.T) {
|
||||||
runAndroidAppTestCase(t, bp2buildTestCase{
|
runAndroidAppTestCase(t, bp2buildTestCase{
|
||||||
description: "Android app - all supported fields",
|
description: "Android app - all supported fields",
|
||||||
moduleTypeUnderTest: "android_app",
|
moduleTypeUnderTest: "android_app",
|
||||||
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
moduleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: java.AppBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"app.java": "",
|
"app.java": "",
|
||||||
"resa/res.png": "",
|
"resa/res.png": "",
|
||||||
|
@@ -43,11 +43,10 @@ func registerApexModuleTypes(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
func TestApexBundleSimple(t *testing.T) {
|
func TestApexBundleSimple(t *testing.T) {
|
||||||
runApexTestCase(t, bp2buildTestCase{
|
runApexTestCase(t, bp2buildTestCase{
|
||||||
description: "apex - example with all props",
|
description: "apex - example with all props",
|
||||||
moduleTypeUnderTest: "apex",
|
moduleTypeUnderTest: "apex",
|
||||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: `
|
blueprint: `
|
||||||
apex_key {
|
apex_key {
|
||||||
name: "com.android.apogee.key",
|
name: "com.android.apogee.key",
|
||||||
@@ -147,11 +146,10 @@ apex {
|
|||||||
|
|
||||||
func TestApexBundleDefaultPropertyValues(t *testing.T) {
|
func TestApexBundleDefaultPropertyValues(t *testing.T) {
|
||||||
runApexTestCase(t, bp2buildTestCase{
|
runApexTestCase(t, bp2buildTestCase{
|
||||||
description: "apex - default property values",
|
description: "apex - default property values",
|
||||||
moduleTypeUnderTest: "apex",
|
moduleTypeUnderTest: "apex",
|
||||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: `
|
blueprint: `
|
||||||
apex {
|
apex {
|
||||||
name: "com.android.apogee",
|
name: "com.android.apogee",
|
||||||
@@ -166,11 +164,10 @@ apex {
|
|||||||
|
|
||||||
func TestApexBundleHasBazelModuleProps(t *testing.T) {
|
func TestApexBundleHasBazelModuleProps(t *testing.T) {
|
||||||
runApexTestCase(t, bp2buildTestCase{
|
runApexTestCase(t, bp2buildTestCase{
|
||||||
description: "apex - has bazel module props",
|
description: "apex - has bazel module props",
|
||||||
moduleTypeUnderTest: "apex",
|
moduleTypeUnderTest: "apex",
|
||||||
moduleTypeUnderTestFactory: apex.BundleFactory,
|
moduleTypeUnderTestFactory: apex.BundleFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: `
|
blueprint: `
|
||||||
apex {
|
apex {
|
||||||
name: "apogee",
|
name: "apogee",
|
||||||
|
@@ -31,11 +31,10 @@ func registerApexKeyModuleTypes(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
func TestApexKeySimple(t *testing.T) {
|
func TestApexKeySimple(t *testing.T) {
|
||||||
runApexKeyTestCase(t, bp2buildTestCase{
|
runApexKeyTestCase(t, bp2buildTestCase{
|
||||||
description: "apex key - simple example",
|
description: "apex key - simple example",
|
||||||
moduleTypeUnderTest: "apex_key",
|
moduleTypeUnderTest: "apex_key",
|
||||||
moduleTypeUnderTestFactory: apex.ApexKeyFactory,
|
moduleTypeUnderTestFactory: apex.ApexKeyFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: apex.ApexKeyBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: `
|
blueprint: `
|
||||||
apex_key {
|
apex_key {
|
||||||
name: "com.android.apogee.key",
|
name: "com.android.apogee.key",
|
||||||
|
@@ -245,7 +245,7 @@ func TestGenerateBazelTargetModules(t *testing.T) {
|
|||||||
{
|
{
|
||||||
description: "string props",
|
description: "string props",
|
||||||
blueprint: `custom {
|
blueprint: `custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
string_list_prop: ["a", "b"],
|
string_list_prop: ["a", "b"],
|
||||||
string_ptr_prop: "a",
|
string_ptr_prop: "a",
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
@@ -470,7 +470,7 @@ custom {
|
|||||||
android.FailIfErrored(t, err)
|
android.FailIfErrored(t, err)
|
||||||
|
|
||||||
if actualCount, expectedCount := len(bazelTargets), len(testCase.expectedBazelTargets); actualCount != expectedCount {
|
if actualCount, expectedCount := len(bazelTargets), len(testCase.expectedBazelTargets); actualCount != expectedCount {
|
||||||
t.Errorf("Expected %d bazel target, got %d", expectedCount, actualCount)
|
t.Errorf("Expected %d bazel target (%s),\ngot %d (%s)", expectedCount, testCase.expectedBazelTargets, actualCount, bazelTargets)
|
||||||
} else {
|
} else {
|
||||||
for i, expectedBazelTarget := range testCase.expectedBazelTargets {
|
for i, expectedBazelTarget := range testCase.expectedBazelTargets {
|
||||||
actualBazelTarget := bazelTargets[i]
|
actualBazelTarget := bazelTargets[i]
|
||||||
@@ -596,6 +596,7 @@ func TestGenerateBazelTargetModules_OneToMany_LoadedFromStarlark(t *testing.T) {
|
|||||||
{
|
{
|
||||||
bp: `custom {
|
bp: `custom {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
|
one_to_many_prop: true,
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTarget: `my_library(
|
expectedBazelTarget: `my_library(
|
||||||
@@ -620,7 +621,6 @@ load("//build/bazel/rules:rules.bzl", "my_library")`,
|
|||||||
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
|
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
|
||||||
ctx := android.NewTestContext(config)
|
ctx := android.NewTestContext(config)
|
||||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||||
ctx.RegisterBp2BuildMutator("custom", customBp2BuildMutatorFromStarlark)
|
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
|
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
|
||||||
@@ -658,10 +658,9 @@ load("//build/bazel/rules:rules.bzl", "my_library")`,
|
|||||||
func TestModuleTypeBp2Build(t *testing.T) {
|
func TestModuleTypeBp2Build(t *testing.T) {
|
||||||
testCases := []bp2buildTestCase{
|
testCases := []bp2buildTestCase{
|
||||||
{
|
{
|
||||||
description: "filegroup with does not specify srcs",
|
description: "filegroup with does not specify srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
@@ -671,10 +670,9 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup with no srcs",
|
description: "filegroup with no srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: [],
|
srcs: [],
|
||||||
@@ -685,10 +683,9 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup with srcs",
|
description: "filegroup with srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: ["a", "b"],
|
srcs: ["a", "b"],
|
||||||
@@ -704,10 +701,9 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup with excludes srcs",
|
description: "filegroup with excludes srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: ["a", "b"],
|
srcs: ["a", "b"],
|
||||||
@@ -721,10 +717,9 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup with glob",
|
description: "filegroup with glob",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: ["**/*.txt"],
|
srcs: ["**/*.txt"],
|
||||||
@@ -747,12 +742,10 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup with glob in subdir",
|
description: "filegroup with glob in subdir",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
dir: "other",
|
||||||
blueprint: ``,
|
|
||||||
dir: "other",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"other/Android.bp": `filegroup {
|
"other/Android.bp": `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
@@ -775,10 +768,9 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "depends_on_other_dir_module",
|
description: "depends_on_other_dir_module",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: [
|
srcs: [
|
||||||
@@ -804,26 +796,25 @@ func TestModuleTypeBp2Build(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "depends_on_other_unconverted_module_error",
|
description: "depends_on_other_unconverted_module_error",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
unconvertedDepsMode: errorModulesUnconvertedDeps,
|
||||||
unconvertedDepsMode: errorModulesUnconvertedDeps,
|
|
||||||
filesystem: map[string]string{
|
|
||||||
"other/Android.bp": `filegroup {
|
|
||||||
name: "foo",
|
|
||||||
srcs: ["a", "b"],
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "foobar",
|
||||||
srcs: [
|
srcs: [
|
||||||
":foo",
|
":foo",
|
||||||
"c",
|
"c",
|
||||||
],
|
],
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}`,
|
}`,
|
||||||
expectedErr: fmt.Errorf(`"fg_foo" depends on unconverted modules: foo`),
|
expectedErr: fmt.Errorf(`"foobar" depends on unconverted modules: foo`),
|
||||||
|
filesystem: map[string]string{
|
||||||
|
"other/Android.bp": `filegroup {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["a", "b"],
|
||||||
|
}`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,18 +829,16 @@ type bp2buildMutator = func(android.TopDownMutatorContext)
|
|||||||
|
|
||||||
func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
moduleTypeUnderTest string
|
moduleTypeUnderTest string
|
||||||
moduleTypeUnderTestFactory android.ModuleFactory
|
moduleTypeUnderTestFactory android.ModuleFactory
|
||||||
moduleTypeUnderTestBp2BuildMutator bp2buildMutator
|
bp string
|
||||||
bp string
|
expectedCount int
|
||||||
expectedCount int
|
description string
|
||||||
description string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
description: "explicitly unavailable",
|
description: "explicitly unavailable",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
bp: `filegroup {
|
bp: `filegroup {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a", "b"],
|
srcs: ["a", "b"],
|
||||||
@@ -858,10 +847,9 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
|||||||
expectedCount: 0,
|
expectedCount: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "implicitly unavailable",
|
description: "implicitly unavailable",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
bp: `filegroup {
|
bp: `filegroup {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a", "b"],
|
srcs: ["a", "b"],
|
||||||
@@ -869,10 +857,9 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
|||||||
expectedCount: 0,
|
expectedCount: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "explicitly available",
|
description: "explicitly available",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
bp: `filegroup {
|
bp: `filegroup {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a", "b"],
|
srcs: ["a", "b"],
|
||||||
@@ -881,12 +868,12 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
|||||||
expectedCount: 1,
|
expectedCount: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "generates more than 1 target if needed",
|
description: "generates more than 1 target if needed",
|
||||||
moduleTypeUnderTest: "custom",
|
moduleTypeUnderTest: "custom",
|
||||||
moduleTypeUnderTestFactory: customModuleFactory,
|
moduleTypeUnderTestFactory: customModuleFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: customBp2BuildMutatorFromStarlark,
|
|
||||||
bp: `custom {
|
bp: `custom {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
|
one_to_many_prop: true,
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}`,
|
}`,
|
||||||
expectedCount: 3,
|
expectedCount: 3,
|
||||||
@@ -899,7 +886,6 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
|||||||
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
|
config := android.TestConfig(buildDir, nil, testCase.bp, nil)
|
||||||
ctx := android.NewTestContext(config)
|
ctx := android.NewTestContext(config)
|
||||||
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
||||||
ctx.RegisterBp2BuildMutator(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestBp2BuildMutator)
|
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
|
_, errs := ctx.ParseFileList(dir, []string{"Android.bp"})
|
||||||
@@ -919,20 +905,18 @@ func TestAllowlistingBp2buildTargetsExplicitly(t *testing.T) {
|
|||||||
|
|
||||||
func TestAllowlistingBp2buildTargetsWithConfig(t *testing.T) {
|
func TestAllowlistingBp2buildTargetsWithConfig(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
moduleTypeUnderTest string
|
moduleTypeUnderTest string
|
||||||
moduleTypeUnderTestFactory android.ModuleFactory
|
moduleTypeUnderTestFactory android.ModuleFactory
|
||||||
moduleTypeUnderTestBp2BuildMutator bp2buildMutator
|
expectedCount map[string]int
|
||||||
expectedCount map[string]int
|
description string
|
||||||
description string
|
bp2buildConfig android.Bp2BuildConfig
|
||||||
bp2buildConfig android.Bp2BuildConfig
|
checkDir string
|
||||||
checkDir string
|
fs map[string]string
|
||||||
fs map[string]string
|
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
description: "test bp2build config package and subpackages config",
|
description: "test bp2build config package and subpackages config",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
expectedCount: map[string]int{
|
expectedCount: map[string]int{
|
||||||
"migrated": 1,
|
"migrated": 1,
|
||||||
"migrated/but_not_really": 0,
|
"migrated/but_not_really": 0,
|
||||||
@@ -954,10 +938,9 @@ func TestAllowlistingBp2buildTargetsWithConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "test bp2build config opt-in and opt-out",
|
description: "test bp2build config opt-in and opt-out",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
expectedCount: map[string]int{
|
expectedCount: map[string]int{
|
||||||
"package-opt-in": 2,
|
"package-opt-in": 2,
|
||||||
"package-opt-in/subpackage": 0,
|
"package-opt-in/subpackage": 0,
|
||||||
@@ -1008,7 +991,6 @@ filegroup { name: "opt-out-h", bazel_module: { bp2build_available: false } }
|
|||||||
config := android.TestConfig(buildDir, nil, "", fs)
|
config := android.TestConfig(buildDir, nil, "", fs)
|
||||||
ctx := android.NewTestContext(config)
|
ctx := android.NewTestContext(config)
|
||||||
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
||||||
ctx.RegisterBp2BuildMutator(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestBp2BuildMutator)
|
|
||||||
ctx.RegisterBp2BuildConfig(testCase.bp2buildConfig)
|
ctx.RegisterBp2BuildConfig(testCase.bp2buildConfig)
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
|
|
||||||
@@ -1039,10 +1021,9 @@ filegroup { name: "opt-out-h", bazel_module: { bp2build_available: false } }
|
|||||||
func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
||||||
testCases := []bp2buildTestCase{
|
testCases := []bp2buildTestCase{
|
||||||
{
|
{
|
||||||
description: "filegroup bazel_module.label",
|
description: "filegroup bazel_module.label",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
bazel_module: { label: "//other:fg_foo" },
|
bazel_module: { label: "//other:fg_foo" },
|
||||||
@@ -1055,19 +1036,18 @@ func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "multiple bazel_module.label same BUILD",
|
description: "multiple bazel_module.label same BUILD",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
bazel_module: { label: "//other:fg_foo" },
|
bazel_module: { label: "//other:fg_foo" },
|
||||||
}
|
}
|
||||||
|
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
bazel_module: { label: "//other:foo" },
|
bazel_module: { label: "//other:foo" },
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
`// BUILD file`,
|
`// BUILD file`,
|
||||||
},
|
},
|
||||||
@@ -1076,25 +1056,24 @@ func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup bazel_module.label and bp2build in subdir",
|
description: "filegroup bazel_module.label and bp2build in subdir",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
dir: "other",
|
||||||
dir: "other",
|
blueprint: ``,
|
||||||
blueprint: ``,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"other/Android.bp": `filegroup {
|
"other/Android.bp": `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
bazel_module: {
|
bazel_module: {
|
||||||
bp2build_available: true,
|
bp2build_available: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "fg_bar",
|
name: "fg_bar",
|
||||||
bazel_module: {
|
bazel_module: {
|
||||||
label: "//other:fg_bar"
|
label: "//other:fg_bar"
|
||||||
},
|
},
|
||||||
}`,
|
}`,
|
||||||
"other/BUILD.bazel": `// definition for fg_bar`,
|
"other/BUILD.bazel": `// definition for fg_bar`,
|
||||||
},
|
},
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
@@ -1103,26 +1082,26 @@ func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup bazel_module.label and filegroup bp2build",
|
description: "filegroup bazel_module.label and filegroup bp2build",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"other/BUILD.bazel": `// BUILD file`,
|
"other/BUILD.bazel": `// BUILD file`,
|
||||||
},
|
},
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
bazel_module: {
|
bazel_module: {
|
||||||
label: "//other:fg_foo",
|
label: "//other:fg_foo",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "fg_bar",
|
name: "fg_bar",
|
||||||
bazel_module: {
|
bazel_module: {
|
||||||
bp2build_available: true,
|
bp2build_available: true,
|
||||||
},
|
},
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
makeBazelTarget("filegroup", "fg_bar", map[string]string{}),
|
makeBazelTarget("filegroup", "fg_bar", map[string]string{}),
|
||||||
`// BUILD file`,
|
`// BUILD file`,
|
||||||
@@ -1146,7 +1125,6 @@ func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
|||||||
config := android.TestConfig(buildDir, nil, testCase.blueprint, fs)
|
config := android.TestConfig(buildDir, nil, testCase.blueprint, fs)
|
||||||
ctx := android.NewTestContext(config)
|
ctx := android.NewTestContext(config)
|
||||||
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
ctx.RegisterModuleType(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestFactory)
|
||||||
ctx.RegisterBp2BuildMutator(testCase.moduleTypeUnderTest, testCase.moduleTypeUnderTestBp2BuildMutator)
|
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
|
|
||||||
_, errs := ctx.ParseFileList(dir, toParse)
|
_, errs := ctx.ParseFileList(dir, toParse)
|
||||||
@@ -1192,10 +1170,9 @@ func TestCombineBuildFilesBp2buildTargets(t *testing.T) {
|
|||||||
func TestGlobExcludeSrcs(t *testing.T) {
|
func TestGlobExcludeSrcs(t *testing.T) {
|
||||||
testCases := []bp2buildTestCase{
|
testCases := []bp2buildTestCase{
|
||||||
{
|
{
|
||||||
description: "filegroup top level exclude_srcs",
|
description: "filegroup top level exclude_srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: `filegroup {
|
blueprint: `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
srcs: ["**/*.txt"],
|
srcs: ["**/*.txt"],
|
||||||
@@ -1222,12 +1199,11 @@ func TestGlobExcludeSrcs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "filegroup in subdir exclude_srcs",
|
description: "filegroup in subdir exclude_srcs",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
blueprint: "",
|
||||||
blueprint: "",
|
dir: "dir",
|
||||||
dir: "dir",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"dir/Android.bp": `filegroup {
|
"dir/Android.bp": `filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
@@ -1264,10 +1240,9 @@ func TestGlobExcludeSrcs(t *testing.T) {
|
|||||||
func TestCommonBp2BuildModuleAttrs(t *testing.T) {
|
func TestCommonBp2BuildModuleAttrs(t *testing.T) {
|
||||||
testCases := []bp2buildTestCase{
|
testCases := []bp2buildTestCase{
|
||||||
{
|
{
|
||||||
description: "Required into data test",
|
description: "Required into data test",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: simpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
|
blueprint: simpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
@@ -1281,21 +1256,20 @@ filegroup {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Required via arch into data test",
|
description: "Required via arch into data test",
|
||||||
moduleTypeUnderTest: "python_library",
|
moduleTypeUnderTest: "python_library",
|
||||||
moduleTypeUnderTestFactory: python.PythonLibraryFactory,
|
moduleTypeUnderTestFactory: python.PythonLibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonLibraryBp2Build,
|
|
||||||
blueprint: simpleModuleDoNotConvertBp2build("python_library", "reqdx86") +
|
blueprint: simpleModuleDoNotConvertBp2build("python_library", "reqdx86") +
|
||||||
simpleModuleDoNotConvertBp2build("python_library", "reqdarm") + `
|
simpleModuleDoNotConvertBp2build("python_library", "reqdarm") + `
|
||||||
python_library {
|
python_library {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
arch: {
|
arch: {
|
||||||
arm: {
|
arm: {
|
||||||
required: ["reqdarm"],
|
required: ["reqdarm"],
|
||||||
},
|
},
|
||||||
x86: {
|
x86: {
|
||||||
required: ["reqdx86"],
|
required: ["reqdx86"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: true },
|
||||||
}`,
|
}`,
|
||||||
@@ -1311,10 +1285,9 @@ python_library {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "Required appended to data test",
|
description: "Required appended to data test",
|
||||||
moduleTypeUnderTest: "python_library",
|
moduleTypeUnderTest: "python_library",
|
||||||
moduleTypeUnderTestFactory: python.PythonLibraryFactory,
|
moduleTypeUnderTestFactory: python.PythonLibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"data.bin": "",
|
"data.bin": "",
|
||||||
"src.py": "",
|
"src.py": "",
|
||||||
@@ -1337,10 +1310,9 @@ python_library {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
description: "All props-to-attrs at once together test",
|
description: "All props-to-attrs at once together test",
|
||||||
moduleTypeUnderTest: "filegroup",
|
moduleTypeUnderTest: "filegroup",
|
||||||
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
moduleTypeUnderTestFactory: android.FileGroupFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: android.FilegroupBp2Build,
|
|
||||||
blueprint: simpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
|
blueprint: simpleModuleDoNotConvertBp2build("filegroup", "reqd") + `
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "fg_foo",
|
name: "fg_foo",
|
||||||
|
@@ -100,6 +100,7 @@ custom = rule(
|
|||||||
# nested_props_ptr start
|
# nested_props_ptr start
|
||||||
# "nested_prop": attr.string(),
|
# "nested_prop": attr.string(),
|
||||||
# nested_props_ptr end
|
# nested_props_ptr end
|
||||||
|
"one_to_many_prop": attr.bool(),
|
||||||
"other_embedded_prop": attr.string(),
|
"other_embedded_prop": attr.string(),
|
||||||
"string_list_prop": attr.string_list(),
|
"string_list_prop": attr.string_list(),
|
||||||
"string_prop": attr.string(),
|
"string_prop": attr.string(),
|
||||||
@@ -128,6 +129,7 @@ custom_defaults = rule(
|
|||||||
# nested_props_ptr start
|
# nested_props_ptr start
|
||||||
# "nested_prop": attr.string(),
|
# "nested_prop": attr.string(),
|
||||||
# nested_props_ptr end
|
# nested_props_ptr end
|
||||||
|
"one_to_many_prop": attr.bool(),
|
||||||
"other_embedded_prop": attr.string(),
|
"other_embedded_prop": attr.string(),
|
||||||
"string_list_prop": attr.string_list(),
|
"string_list_prop": attr.string_list(),
|
||||||
"string_prop": attr.string(),
|
"string_prop": attr.string(),
|
||||||
@@ -156,6 +158,7 @@ custom_test_ = rule(
|
|||||||
# nested_props_ptr start
|
# nested_props_ptr start
|
||||||
# "nested_prop": attr.string(),
|
# "nested_prop": attr.string(),
|
||||||
# nested_props_ptr end
|
# nested_props_ptr end
|
||||||
|
"one_to_many_prop": attr.bool(),
|
||||||
"other_embedded_prop": attr.string(),
|
"other_embedded_prop": attr.string(),
|
||||||
"string_list_prop": attr.string_list(),
|
"string_list_prop": attr.string_list(),
|
||||||
"string_prop": attr.string(),
|
"string_prop": attr.string(),
|
||||||
|
@@ -68,14 +68,14 @@ func runCcBinaryTestCase(t *testing.T, tc ccBinaryBp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
moduleTypeUnderTest := "cc_binary"
|
moduleTypeUnderTest := "cc_binary"
|
||||||
testCase := bp2buildTestCase{
|
testCase := bp2buildTestCase{
|
||||||
expectedBazelTargets: generateBazelTargetsForTest(tc.targets),
|
expectedBazelTargets: generateBazelTargetsForTest(tc.targets),
|
||||||
moduleTypeUnderTest: moduleTypeUnderTest,
|
moduleTypeUnderTest: moduleTypeUnderTest,
|
||||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.BinaryBp2build,
|
description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
|
||||||
description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
|
blueprint: binaryReplacer.Replace(tc.blueprint),
|
||||||
blueprint: binaryReplacer.Replace(tc.blueprint),
|
|
||||||
}
|
}
|
||||||
t.Run(testCase.description, func(t *testing.T) {
|
t.Run(testCase.description, func(t *testing.T) {
|
||||||
|
t.Helper()
|
||||||
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, testCase)
|
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, testCase)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -96,12 +96,11 @@ func runCcHostBinaryTestCase(t *testing.T, tc ccBinaryBp2buildTestCase) {
|
|||||||
moduleTypeUnderTest := "cc_binary_host"
|
moduleTypeUnderTest := "cc_binary_host"
|
||||||
t.Run(testCase.description, func(t *testing.T) {
|
t.Run(testCase.description, func(t *testing.T) {
|
||||||
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, bp2buildTestCase{
|
runBp2BuildTestCase(t, registerCcBinaryModuleTypes, bp2buildTestCase{
|
||||||
expectedBazelTargets: generateBazelTargetsForTest(testCase.targets),
|
expectedBazelTargets: generateBazelTargetsForTest(testCase.targets),
|
||||||
moduleTypeUnderTest: moduleTypeUnderTest,
|
moduleTypeUnderTest: moduleTypeUnderTest,
|
||||||
moduleTypeUnderTestFactory: cc.BinaryHostFactory,
|
moduleTypeUnderTestFactory: cc.BinaryHostFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.BinaryHostBp2build,
|
description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
|
||||||
description: fmt.Sprintf("%s %s", moduleTypeUnderTest, tc.description),
|
blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
|
||||||
blueprint: hostBinaryReplacer.Replace(testCase.blueprint),
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -258,11 +257,13 @@ func TestCcBinaryDoNotDistinguishBetweenDepsAndImplementationDeps(t *testing.T)
|
|||||||
genrule {
|
genrule {
|
||||||
name: "generated_hdr",
|
name: "generated_hdr",
|
||||||
cmd: "nothing to see here",
|
cmd: "nothing to see here",
|
||||||
|
bazel_module: { bp2build_available: false },
|
||||||
}
|
}
|
||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "export_generated_hdr",
|
name: "export_generated_hdr",
|
||||||
cmd: "nothing to see here",
|
cmd: "nothing to see here",
|
||||||
|
bazel_module: { bp2build_available: false },
|
||||||
}
|
}
|
||||||
|
|
||||||
{rule_name} {
|
{rule_name} {
|
||||||
|
@@ -19,7 +19,6 @@ import (
|
|||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/cc"
|
"android/soong/cc"
|
||||||
"android/soong/genrule"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var otherCcGenruleBp = map[string]string{
|
var otherCcGenruleBp = map[string]string{
|
||||||
@@ -41,7 +40,6 @@ func runCcGenruleTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "cc_genrule"
|
(&tc).moduleTypeUnderTest = "cc_genrule"
|
||||||
(&tc).moduleTypeUnderTestFactory = cc.GenRuleFactory
|
(&tc).moduleTypeUnderTestFactory = cc.GenRuleFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = genrule.CcGenruleBp2Build
|
|
||||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {}, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,10 +70,9 @@ func registerCcLibraryModuleTypes(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
func TestCcLibrarySimple(t *testing.T) {
|
func TestCcLibrarySimple(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - simple example",
|
description: "cc_library - simple example",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"android.cpp": "",
|
"android.cpp": "",
|
||||||
"bionic.cpp": "",
|
"bionic.cpp": "",
|
||||||
@@ -159,10 +158,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryTrimmedLdAndroid(t *testing.T) {
|
func TestCcLibraryTrimmedLdAndroid(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - trimmed example of //bionic/linker:ld-android",
|
description: "cc_library - trimmed example of //bionic/linker:ld-android",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"ld-android.cpp": "",
|
"ld-android.cpp": "",
|
||||||
"linked_list.h": "",
|
"linked_list.h": "",
|
||||||
@@ -170,8 +168,8 @@ func TestCcLibraryTrimmedLdAndroid(t *testing.T) {
|
|||||||
"linker_block_allocator.h": "",
|
"linker_block_allocator.h": "",
|
||||||
"linker_cfi.h": "",
|
"linker_cfi.h": "",
|
||||||
},
|
},
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble +
|
||||||
cc_library_headers { name: "libc_headers" }
|
simpleModuleDoNotConvertBp2build("cc_library_headers", "libc_headers") + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "fake-ld-android",
|
name: "fake-ld-android",
|
||||||
srcs: ["ld_android.cpp"],
|
srcs: ["ld_android.cpp"],
|
||||||
@@ -228,11 +226,10 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryExcludeSrcs(t *testing.T) {
|
func TestCcLibraryExcludeSrcs(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library exclude_srcs - trimmed example of //external/arm-optimized-routines:libarm-optimized-routines-math",
|
description: "cc_library exclude_srcs - trimmed example of //external/arm-optimized-routines:libarm-optimized-routines-math",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "external",
|
||||||
dir: "external",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"external/math/cosf.c": "",
|
"external/math/cosf.c": "",
|
||||||
"external/math/erf.c": "",
|
"external/math/erf.c": "",
|
||||||
@@ -280,10 +277,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrarySharedStaticProps(t *testing.T) {
|
func TestCcLibrarySharedStaticProps(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library shared/static props",
|
description: "cc_library shared/static props",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"both.cpp": "",
|
"both.cpp": "",
|
||||||
"sharedonly.cpp": "",
|
"sharedonly.cpp": "",
|
||||||
@@ -409,10 +405,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryDeps(t *testing.T) {
|
func TestCcLibraryDeps(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library shared/static props",
|
description: "cc_library shared/static props",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"both.cpp": "",
|
"both.cpp": "",
|
||||||
"sharedonly.cpp": "",
|
"sharedonly.cpp": "",
|
||||||
@@ -537,10 +532,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryWholeStaticLibsAlwaysLink(t *testing.T) {
|
func TestCcLibraryWholeStaticLibsAlwaysLink(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "foo/bar",
|
||||||
dir: "foo/bar",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": `
|
"foo/bar/Android.bp": `
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -584,11 +578,10 @@ cc_prebuilt_library_static { name: "whole_static_lib_for_both" }
|
|||||||
|
|
||||||
func TestCcLibrarySharedStaticPropsInArch(t *testing.T) {
|
func TestCcLibrarySharedStaticPropsInArch(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library shared/static props in arch",
|
description: "cc_library shared/static props in arch",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "foo/bar",
|
||||||
dir: "foo/bar",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/arm.cpp": "",
|
"foo/bar/arm.cpp": "",
|
||||||
"foo/bar/x86.cpp": "",
|
"foo/bar/x86.cpp": "",
|
||||||
@@ -735,11 +728,10 @@ cc_library_static { name: "android_dep_for_shared" }
|
|||||||
|
|
||||||
func TestCcLibrarySharedStaticPropsWithMixedSources(t *testing.T) {
|
func TestCcLibrarySharedStaticPropsWithMixedSources(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library shared/static props with c/cpp/s mixed sources",
|
description: "cc_library shared/static props with c/cpp/s mixed sources",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "foo/bar",
|
||||||
dir: "foo/bar",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/both_source.cpp": "",
|
"foo/bar/both_source.cpp": "",
|
||||||
"foo/bar/both_source.cc": "",
|
"foo/bar/both_source.cc": "",
|
||||||
@@ -868,11 +860,10 @@ filegroup {
|
|||||||
|
|
||||||
func TestCcLibraryNonConfiguredVersionScript(t *testing.T) {
|
func TestCcLibraryNonConfiguredVersionScript(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library non-configured version script",
|
description: "cc_library non-configured version script",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "foo/bar",
|
||||||
dir: "foo/bar",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": `
|
"foo/bar/Android.bp": `
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -896,11 +887,10 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryConfiguredVersionScript(t *testing.T) {
|
func TestCcLibraryConfiguredVersionScript(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library configured version script",
|
description: "cc_library configured version script",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
dir: "foo/bar",
|
||||||
dir: "foo/bar",
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": `
|
"foo/bar/Android.bp": `
|
||||||
cc_library {
|
cc_library {
|
||||||
@@ -940,10 +930,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrarySharedLibs(t *testing.T) {
|
func TestCcLibrarySharedLibs(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library shared_libs",
|
description: "cc_library shared_libs",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "mylib",
|
name: "mylib",
|
||||||
@@ -994,10 +983,9 @@ func TestCcLibraryFeatures(t *testing.T) {
|
|||||||
})...)
|
})...)
|
||||||
|
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library pack_relocations test",
|
description: "cc_library pack_relocations test",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "a",
|
name: "a",
|
||||||
@@ -1036,10 +1024,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrarySpacesInCopts(t *testing.T) {
|
func TestCcLibrarySpacesInCopts(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library spaces in copts",
|
description: "cc_library spaces in copts",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "a",
|
name: "a",
|
||||||
@@ -1059,10 +1046,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
|
func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library cppflags usage",
|
description: "cc_library cppflags usage",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `cc_library {
|
blueprint: soongCcLibraryPreamble + `cc_library {
|
||||||
name: "a",
|
name: "a",
|
||||||
srcs: ["a.cpp"],
|
srcs: ["a.cpp"],
|
||||||
@@ -1104,10 +1090,9 @@ func TestCcLibraryCppFlagsGoesIntoCopts(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryExcludeLibs(t *testing.T) {
|
func TestCcLibraryExcludeLibs(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: soongCcLibraryStaticPreamble + `
|
blueprint: soongCcLibraryStaticPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "foo_static",
|
name: "foo_static",
|
||||||
@@ -1212,10 +1197,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCCLibraryNoCrtTrue(t *testing.T) {
|
func TestCCLibraryNoCrtTrue(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - nocrt: true emits attribute",
|
description: "cc_library - nocrt: true emits attribute",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
@@ -1237,10 +1221,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCCLibraryNoCrtFalse(t *testing.T) {
|
func TestCCLibraryNoCrtFalse(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - nocrt: false - does not emit attribute",
|
description: "cc_library - nocrt: false - does not emit attribute",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
@@ -1260,10 +1243,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCCLibraryNoCrtArchVariant(t *testing.T) {
|
func TestCCLibraryNoCrtArchVariant(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - nocrt in select",
|
description: "cc_library - nocrt in select",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
@@ -1288,15 +1270,12 @@ cc_library {
|
|||||||
|
|
||||||
func TestCCLibraryNoLibCrtTrue(t *testing.T) {
|
func TestCCLibraryNoLibCrtTrue(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - simple example",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library_headers { name: "some-headers" }
|
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "foo-lib",
|
name: "foo-lib",
|
||||||
srcs: ["impl.cpp"],
|
srcs: ["impl.cpp"],
|
||||||
@@ -1337,14 +1316,12 @@ func makeCcLibraryTargets(name string, attrs attrNameToString) []string {
|
|||||||
|
|
||||||
func TestCCLibraryNoLibCrtFalse(t *testing.T) {
|
func TestCCLibraryNoLibCrtFalse(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library_headers { name: "some-headers" }
|
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "foo-lib",
|
name: "foo-lib",
|
||||||
srcs: ["impl.cpp"],
|
srcs: ["impl.cpp"],
|
||||||
@@ -1361,9 +1338,8 @@ cc_library {
|
|||||||
|
|
||||||
func TestCCLibraryNoLibCrtArchVariant(t *testing.T) {
|
func TestCCLibraryNoLibCrtArchVariant(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"impl.cpp": "",
|
"impl.cpp": "",
|
||||||
},
|
},
|
||||||
@@ -1423,10 +1399,9 @@ func TestCcLibraryStrip(t *testing.T) {
|
|||||||
expectedTargets = append(expectedTargets, makeCcLibraryTargets("nothing", attrNameToString{})...)
|
expectedTargets = append(expectedTargets, makeCcLibraryTargets("nothing", attrNameToString{})...)
|
||||||
|
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library strip args",
|
description: "cc_library strip args",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "nothing",
|
name: "nothing",
|
||||||
@@ -1474,10 +1449,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryStripWithArch(t *testing.T) {
|
func TestCcLibraryStripWithArch(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library strip args",
|
description: "cc_library strip args",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "multi-arch",
|
name: "multi-arch",
|
||||||
@@ -1528,10 +1502,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsRootEmpty(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsRootEmpty(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty at root",
|
description: "cc_library system_shared_libs empty at root",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "root_empty",
|
name: "root_empty",
|
||||||
@@ -1548,10 +1521,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsStaticEmpty(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsStaticEmpty(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty for static variant",
|
description: "cc_library system_shared_libs empty for static variant",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "static_empty",
|
name: "static_empty",
|
||||||
@@ -1572,10 +1544,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsSharedEmpty(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsSharedEmpty(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty for shared variant",
|
description: "cc_library system_shared_libs empty for shared variant",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "shared_empty",
|
name: "shared_empty",
|
||||||
@@ -1596,10 +1567,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsSharedBionicEmpty(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsSharedBionicEmpty(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty for shared, bionic variant",
|
description: "cc_library system_shared_libs empty for shared, bionic variant",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "shared_empty",
|
name: "shared_empty",
|
||||||
@@ -1628,10 +1598,9 @@ func TestCcLibrary_SystemSharedLibsLinuxBionicEmpty(t *testing.T) {
|
|||||||
// only for linux_bionic, but `android` had `["libc", "libdl", "libm"].
|
// only for linux_bionic, but `android` had `["libc", "libdl", "libm"].
|
||||||
// b/195791252 tracks the fix.
|
// b/195791252 tracks the fix.
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty for linux_bionic variant",
|
description: "cc_library system_shared_libs empty for linux_bionic variant",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "target_linux_bionic_empty",
|
name: "target_linux_bionic_empty",
|
||||||
@@ -1652,10 +1621,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsBionicEmpty(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsBionicEmpty(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs empty for bionic variant",
|
description: "cc_library system_shared_libs empty for bionic variant",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "target_bionic_empty",
|
name: "target_bionic_empty",
|
||||||
@@ -1676,10 +1644,9 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibrary_SystemSharedLibsSharedAndRoot(t *testing.T) {
|
func TestCcLibrary_SystemSharedLibsSharedAndRoot(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library system_shared_libs set for shared and root",
|
description: "cc_library system_shared_libs set for shared and root",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "libc",
|
name: "libc",
|
||||||
@@ -1715,13 +1682,11 @@ cc_library {
|
|||||||
|
|
||||||
func TestCcLibraryOsSelects(t *testing.T) {
|
func TestCcLibraryOsSelects(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library - selects for all os targets",
|
description: "cc_library - selects for all os targets",
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library_headers { name: "some-headers" }
|
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "foo-lib",
|
name: "foo-lib",
|
||||||
srcs: ["base.cpp"],
|
srcs: ["base.cpp"],
|
||||||
@@ -1861,10 +1826,9 @@ func TestCcLibraryCppStdWithGnuExtensions_ConvertsToFeatureAttr(t *testing.T) {
|
|||||||
|
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
"cc_library with c_std: %s, cpp_std: %s and gnu_extensions: %s", tc.c_std, tc.cpp_std, tc.gnu_extensions),
|
"cc_library with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "%s_full",
|
name: "%s_full",
|
||||||
@@ -1879,10 +1843,9 @@ cc_library {
|
|||||||
|
|
||||||
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
"cc_library_static with c_std: %s, cpp_std: %s and gnu_extensions: %s", tc.c_std, tc.cpp_std, tc.gnu_extensions),
|
"cc_library_static with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "%s_static",
|
name: "%s_static",
|
||||||
@@ -1899,10 +1862,9 @@ cc_library_static {
|
|||||||
|
|
||||||
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
runCcLibrarySharedTestCase(t, bp2buildTestCase{
|
||||||
description: fmt.Sprintf(
|
description: fmt.Sprintf(
|
||||||
"cc_library_shared with c_std: %s, cpp_std: %s and gnu_extensions: %s", tc.c_std, tc.cpp_std, tc.gnu_extensions),
|
"cc_library_shared with cpp_std: %s and gnu_extensions: %s", tc.cpp_std, tc.gnu_extensions),
|
||||||
moduleTypeUnderTest: "cc_library_shared",
|
moduleTypeUnderTest: "cc_library_shared",
|
||||||
moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
moduleTypeUnderTestFactory: cc.LibrarySharedFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibrarySharedBp2Build,
|
|
||||||
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
blueprint: soongCcLibraryPreamble + fmt.Sprintf(`
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
name: "%s_shared",
|
name: "%s_shared",
|
||||||
@@ -1921,9 +1883,8 @@ cc_library_shared {
|
|||||||
|
|
||||||
func TestCcLibraryProtoSimple(t *testing.T) {
|
func TestCcLibraryProtoSimple(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
@@ -1947,9 +1908,8 @@ func TestCcLibraryProtoSimple(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryProtoNoCanonicalPathFromRoot(t *testing.T) {
|
func TestCcLibraryProtoNoCanonicalPathFromRoot(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
@@ -1973,9 +1933,8 @@ func TestCcLibraryProtoNoCanonicalPathFromRoot(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryProtoExplicitCanonicalPathFromRoot(t *testing.T) {
|
func TestCcLibraryProtoExplicitCanonicalPathFromRoot(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
@@ -2000,9 +1959,8 @@ func TestCcLibraryProtoExplicitCanonicalPathFromRoot(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryProtoFull(t *testing.T) {
|
func TestCcLibraryProtoFull(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
@@ -2029,9 +1987,8 @@ func TestCcLibraryProtoFull(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryProtoLite(t *testing.T) {
|
func TestCcLibraryProtoLite(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
@@ -2058,9 +2015,8 @@ func TestCcLibraryProtoLite(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryProtoExportHeaders(t *testing.T) {
|
func TestCcLibraryProtoExportHeaders(t *testing.T) {
|
||||||
runCcLibraryTestCase(t, bp2buildTestCase{
|
runCcLibraryTestCase(t, bp2buildTestCase{
|
||||||
moduleTypeUnderTest: "cc_library",
|
moduleTypeUnderTest: "cc_library",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
|
||||||
blueprint: soongCcProtoPreamble + `cc_library {
|
blueprint: soongCcProtoPreamble + `cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["foo.proto"],
|
srcs: ["foo.proto"],
|
||||||
|
@@ -78,10 +78,9 @@ func runCcLibraryHeadersTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
|
|
||||||
func TestCcLibraryHeadersSimple(t *testing.T) {
|
func TestCcLibraryHeadersSimple(t *testing.T) {
|
||||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_headers test",
|
description: "cc_library_headers test",
|
||||||
moduleTypeUnderTest: "cc_library_headers",
|
moduleTypeUnderTest: "cc_library_headers",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"lib-1/lib1a.h": "",
|
"lib-1/lib1a.h": "",
|
||||||
"lib-1/lib1b.h": "",
|
"lib-1/lib1b.h": "",
|
||||||
@@ -150,11 +149,10 @@ cc_library_headers {
|
|||||||
|
|
||||||
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
|
func TestCcLibraryHeadersOsSpecificHeader(t *testing.T) {
|
||||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_headers test with os-specific header_libs props",
|
description: "cc_library_headers test with os-specific header_libs props",
|
||||||
moduleTypeUnderTest: "cc_library_headers",
|
moduleTypeUnderTest: "cc_library_headers",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library_headers {
|
cc_library_headers {
|
||||||
name: "android-lib",
|
name: "android-lib",
|
||||||
@@ -209,11 +207,10 @@ cc_library_headers {
|
|||||||
|
|
||||||
func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
|
func TestCcLibraryHeadersOsSpecficHeaderLibsExportHeaderLibHeaders(t *testing.T) {
|
||||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
|
description: "cc_library_headers test with os-specific header_libs and export_header_lib_headers props",
|
||||||
moduleTypeUnderTest: "cc_library_headers",
|
moduleTypeUnderTest: "cc_library_headers",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: soongCcLibraryPreamble + `
|
blueprint: soongCcLibraryPreamble + `
|
||||||
cc_library_headers {
|
cc_library_headers {
|
||||||
name: "android-lib",
|
name: "android-lib",
|
||||||
@@ -250,11 +247,10 @@ cc_library_headers {
|
|||||||
|
|
||||||
func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
||||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
|
description: "cc_library_headers test with arch-specific and target-specific export_system_include_dirs props",
|
||||||
moduleTypeUnderTest: "cc_library_headers",
|
moduleTypeUnderTest: "cc_library_headers",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
filesystem: map[string]string{},
|
||||||
filesystem: map[string]string{},
|
|
||||||
blueprint: soongCcLibraryPreamble + `cc_library_headers {
|
blueprint: soongCcLibraryPreamble + `cc_library_headers {
|
||||||
name: "foo_headers",
|
name: "foo_headers",
|
||||||
export_system_include_dirs: [
|
export_system_include_dirs: [
|
||||||
@@ -310,10 +306,9 @@ func TestCcLibraryHeadersArchAndTargetExportSystemIncludes(t *testing.T) {
|
|||||||
|
|
||||||
func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
|
func TestCcLibraryHeadersNoCrtIgnored(t *testing.T) {
|
||||||
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
runCcLibraryHeadersTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_headers test",
|
description: "cc_library_headers test",
|
||||||
moduleTypeUnderTest: "cc_library_headers",
|
moduleTypeUnderTest: "cc_library_headers",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
moduleTypeUnderTestFactory: cc.LibraryHeaderFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryHeadersBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"lib-1/lib1a.h": "",
|
"lib-1/lib1a.h": "",
|
||||||
"lib-1/lib1b.h": "",
|
"lib-1/lib1b.h": "",
|
||||||
|
@@ -40,7 +40,6 @@ func runCcLibrarySharedTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "cc_library_shared"
|
(&tc).moduleTypeUnderTest = "cc_library_shared"
|
||||||
(&tc).moduleTypeUnderTestFactory = cc.LibrarySharedFactory
|
(&tc).moduleTypeUnderTestFactory = cc.LibrarySharedFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = cc.CcLibrarySharedBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
|
runBp2BuildTestCase(t, registerCcLibrarySharedModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,7 +82,6 @@ func runCcLibraryStaticTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
|
|
||||||
(&tc).moduleTypeUnderTest = "cc_library_static"
|
(&tc).moduleTypeUnderTest = "cc_library_static"
|
||||||
(&tc).moduleTypeUnderTestFactory = cc.LibraryStaticFactory
|
(&tc).moduleTypeUnderTestFactory = cc.LibraryStaticFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = cc.CcLibraryStaticBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerCcLibraryStaticModuleTypes, tc)
|
runBp2BuildTestCase(t, registerCcLibraryStaticModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -954,11 +953,13 @@ func TestCcLibraryStaticGeneratedHeadersAllPartitions(t *testing.T) {
|
|||||||
genrule {
|
genrule {
|
||||||
name: "generated_hdr",
|
name: "generated_hdr",
|
||||||
cmd: "nothing to see here",
|
cmd: "nothing to see here",
|
||||||
|
bazel_module: { bp2build_available: false },
|
||||||
}
|
}
|
||||||
|
|
||||||
genrule {
|
genrule {
|
||||||
name: "export_generated_hdr",
|
name: "export_generated_hdr",
|
||||||
cmd: "nothing to see here",
|
cmd: "nothing to see here",
|
||||||
|
bazel_module: { bp2build_available: false },
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
@@ -998,48 +999,17 @@ func TestCcLibraryStaticArchSrcsExcludeSrcsGeneratedFiles(t *testing.T) {
|
|||||||
"for-x86.cpp": "",
|
"for-x86.cpp": "",
|
||||||
"not-for-x86.cpp": "",
|
"not-for-x86.cpp": "",
|
||||||
"not-for-everything.cpp": "",
|
"not-for-everything.cpp": "",
|
||||||
"dep/Android.bp": `
|
"dep/Android.bp": simpleModuleDoNotConvertBp2build("genrule", "generated_src_other_pkg") +
|
||||||
genrule {
|
simpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg") +
|
||||||
name: "generated_src_other_pkg",
|
simpleModuleDoNotConvertBp2build("genrule", "generated_src_other_pkg_x86") +
|
||||||
cmd: "nothing to see here",
|
simpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg_x86") +
|
||||||
}
|
simpleModuleDoNotConvertBp2build("genrule", "generated_hdr_other_pkg_android"),
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_hdr_other_pkg",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_hdr_other_pkg_x86",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_hdr_other_pkg_android",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}`,
|
|
||||||
},
|
},
|
||||||
blueprint: soongCcLibraryStaticPreamble + `
|
blueprint: soongCcLibraryStaticPreamble +
|
||||||
genrule {
|
simpleModuleDoNotConvertBp2build("genrule", "generated_src") +
|
||||||
name: "generated_src",
|
simpleModuleDoNotConvertBp2build("genrule", "generated_src_not_x86") +
|
||||||
cmd: "nothing to see here",
|
simpleModuleDoNotConvertBp2build("genrule", "generated_src_android") +
|
||||||
}
|
simpleModuleDoNotConvertBp2build("genrule", "generated_hdr") + `
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_src_not_x86",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_src_android",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}
|
|
||||||
|
|
||||||
genrule {
|
|
||||||
name: "generated_hdr",
|
|
||||||
cmd: "nothing to see here",
|
|
||||||
}
|
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "foo_static",
|
name: "foo_static",
|
||||||
srcs: ["common.cpp", "not-for-*.cpp"],
|
srcs: ["common.cpp", "not-for-*.cpp"],
|
||||||
@@ -1373,9 +1343,8 @@ cc_library_static {
|
|||||||
func TestStaticLibrary_SystemSharedLibsBionic(t *testing.T) {
|
func TestStaticLibrary_SystemSharedLibsBionic(t *testing.T) {
|
||||||
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_static system_shared_libs set for bionic variant",
|
description: "cc_library_static system_shared_libs set for bionic variant",
|
||||||
blueprint: soongCcLibraryStaticPreamble + `
|
blueprint: soongCcLibraryStaticPreamble +
|
||||||
cc_library{name: "libc"}
|
simpleModuleDoNotConvertBp2build("cc_library", "libc") + `
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "target_bionic",
|
name: "target_bionic",
|
||||||
target: {
|
target: {
|
||||||
@@ -1401,10 +1370,9 @@ cc_library_static {
|
|||||||
func TestStaticLibrary_SystemSharedLibsLinuxRootAndLinuxBionic(t *testing.T) {
|
func TestStaticLibrary_SystemSharedLibsLinuxRootAndLinuxBionic(t *testing.T) {
|
||||||
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
runCcLibraryStaticTestCase(t, bp2buildTestCase{
|
||||||
description: "cc_library_static system_shared_libs set for root and linux_bionic variant",
|
description: "cc_library_static system_shared_libs set for root and linux_bionic variant",
|
||||||
blueprint: soongCcLibraryStaticPreamble + `
|
blueprint: soongCcLibraryStaticPreamble +
|
||||||
cc_library{name: "libc"}
|
simpleModuleDoNotConvertBp2build("cc_library", "libc") +
|
||||||
cc_library{name: "libm"}
|
simpleModuleDoNotConvertBp2build("cc_library", "libm") + `
|
||||||
|
|
||||||
cc_library_static {
|
cc_library_static {
|
||||||
name: "target_linux_bionic",
|
name: "target_linux_bionic",
|
||||||
system_shared_libs: ["libc"],
|
system_shared_libs: ["libc"],
|
||||||
|
@@ -30,7 +30,6 @@ func runCcObjectTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "cc_object"
|
(&tc).moduleTypeUnderTest = "cc_object"
|
||||||
(&tc).moduleTypeUnderTestFactory = cc.ObjectFactory
|
(&tc).moduleTypeUnderTestFactory = cc.ObjectFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = cc.ObjectBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
|
runBp2BuildTestCase(t, registerCcObjectModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,10 +9,9 @@ import (
|
|||||||
func TestSharedPrebuiltLibrary(t *testing.T) {
|
func TestSharedPrebuiltLibrary(t *testing.T) {
|
||||||
runBp2BuildTestCaseSimple(t,
|
runBp2BuildTestCaseSimple(t,
|
||||||
bp2buildTestCase{
|
bp2buildTestCase{
|
||||||
description: "prebuilt library shared simple",
|
description: "prebuilt library shared simple",
|
||||||
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||||
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"libf.so": "",
|
"libf.so": "",
|
||||||
},
|
},
|
||||||
@@ -33,10 +32,9 @@ cc_prebuilt_library_shared {
|
|||||||
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
|
func TestSharedPrebuiltLibraryWithArchVariance(t *testing.T) {
|
||||||
runBp2BuildTestCaseSimple(t,
|
runBp2BuildTestCaseSimple(t,
|
||||||
bp2buildTestCase{
|
bp2buildTestCase{
|
||||||
description: "prebuilt library shared with arch variance",
|
description: "prebuilt library shared with arch variance",
|
||||||
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
moduleTypeUnderTest: "cc_prebuilt_library_shared",
|
||||||
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
moduleTypeUnderTestFactory: cc.PrebuiltSharedLibraryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.PrebuiltLibrarySharedBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"libf.so": "",
|
"libf.so": "",
|
||||||
"libg.so": "",
|
"libg.so": "",
|
||||||
|
@@ -25,7 +25,6 @@ func runFilegroupTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "filegroup"
|
(&tc).moduleTypeUnderTest = "filegroup"
|
||||||
(&tc).moduleTypeUnderTestFactory = android.FileGroupFactory
|
(&tc).moduleTypeUnderTestFactory = android.FileGroupFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = android.FilegroupBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerFilegroupModuleTypes, tc)
|
runBp2BuildTestCase(t, registerFilegroupModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,7 +28,6 @@ func runGenruleTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "genrule"
|
(&tc).moduleTypeUnderTest = "genrule"
|
||||||
(&tc).moduleTypeUnderTestFactory = genrule.GenRuleFactory
|
(&tc).moduleTypeUnderTestFactory = genrule.GenRuleFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = genrule.GenruleBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerGenruleModuleTypes, tc)
|
runBp2BuildTestCase(t, registerGenruleModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,6 @@ func runPrebuiltEtcTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
t.Helper()
|
t.Helper()
|
||||||
(&tc).moduleTypeUnderTest = "prebuilt_etc"
|
(&tc).moduleTypeUnderTest = "prebuilt_etc"
|
||||||
(&tc).moduleTypeUnderTestFactory = etc.PrebuiltEtcFactory
|
(&tc).moduleTypeUnderTestFactory = etc.PrebuiltEtcFactory
|
||||||
(&tc).moduleTypeUnderTestBp2BuildMutator = etc.PrebuiltEtcBp2Build
|
|
||||||
runBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
runBp2BuildTestCase(t, registerPrebuiltEtcModuleTypes, tc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,10 +17,9 @@ func runBp2BuildTestCaseWithPythonLibraries(t *testing.T, tc bp2buildTestCase) {
|
|||||||
|
|
||||||
func TestPythonBinaryHostSimple(t *testing.T) {
|
func TestPythonBinaryHostSimple(t *testing.T) {
|
||||||
runBp2BuildTestCaseWithPythonLibraries(t, bp2buildTestCase{
|
runBp2BuildTestCaseWithPythonLibraries(t, bp2buildTestCase{
|
||||||
description: "simple python_binary_host converts to a native py_binary",
|
description: "simple python_binary_host converts to a native py_binary",
|
||||||
moduleTypeUnderTest: "python_binary_host",
|
moduleTypeUnderTest: "python_binary_host",
|
||||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"a.py": "",
|
"a.py": "",
|
||||||
"b/c.py": "",
|
"b/c.py": "",
|
||||||
@@ -40,7 +39,7 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
|||||||
python_library_host {
|
python_library_host {
|
||||||
name: "bar",
|
name: "bar",
|
||||||
srcs: ["b/e.py"],
|
srcs: ["b/e.py"],
|
||||||
bazel_module: { bp2build_available: true },
|
bazel_module: { bp2build_available: false },
|
||||||
}`,
|
}`,
|
||||||
expectedBazelTargets: []string{
|
expectedBazelTargets: []string{
|
||||||
makeBazelTarget("py_binary", "foo", attrNameToString{
|
makeBazelTarget("py_binary", "foo", attrNameToString{
|
||||||
@@ -59,10 +58,9 @@ func TestPythonBinaryHostSimple(t *testing.T) {
|
|||||||
|
|
||||||
func TestPythonBinaryHostPy2(t *testing.T) {
|
func TestPythonBinaryHostPy2(t *testing.T) {
|
||||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||||
description: "py2 python_binary_host",
|
description: "py2 python_binary_host",
|
||||||
moduleTypeUnderTest: "python_binary_host",
|
moduleTypeUnderTest: "python_binary_host",
|
||||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
|
||||||
blueprint: `python_binary_host {
|
blueprint: `python_binary_host {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.py"],
|
srcs: ["a.py"],
|
||||||
@@ -89,10 +87,9 @@ func TestPythonBinaryHostPy2(t *testing.T) {
|
|||||||
|
|
||||||
func TestPythonBinaryHostPy3(t *testing.T) {
|
func TestPythonBinaryHostPy3(t *testing.T) {
|
||||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||||
description: "py3 python_binary_host",
|
description: "py3 python_binary_host",
|
||||||
moduleTypeUnderTest: "python_binary_host",
|
moduleTypeUnderTest: "python_binary_host",
|
||||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
|
||||||
blueprint: `python_binary_host {
|
blueprint: `python_binary_host {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: ["a.py"],
|
srcs: ["a.py"],
|
||||||
@@ -119,10 +116,9 @@ func TestPythonBinaryHostPy3(t *testing.T) {
|
|||||||
|
|
||||||
func TestPythonBinaryHostArchVariance(t *testing.T) {
|
func TestPythonBinaryHostArchVariance(t *testing.T) {
|
||||||
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
runBp2BuildTestCaseSimple(t, bp2buildTestCase{
|
||||||
description: "test arch variants",
|
description: "test arch variants",
|
||||||
moduleTypeUnderTest: "python_binary_host",
|
moduleTypeUnderTest: "python_binary_host",
|
||||||
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
moduleTypeUnderTestFactory: python.PythonBinaryHostFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: python.PythonBinaryBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"dir/arm.py": "",
|
"dir/arm.py": "",
|
||||||
"dir/x86.py": "",
|
"dir/x86.py": "",
|
||||||
|
@@ -18,7 +18,6 @@ func runPythonLibraryTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library")
|
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library")
|
||||||
testCase.moduleTypeUnderTest = "python_library"
|
testCase.moduleTypeUnderTest = "python_library"
|
||||||
testCase.moduleTypeUnderTestFactory = python.PythonLibraryFactory
|
testCase.moduleTypeUnderTestFactory = python.PythonLibraryFactory
|
||||||
testCase.moduleTypeUnderTestBp2BuildMutator = python.PythonLibraryBp2Build
|
|
||||||
runBp2BuildTestCaseSimple(t, testCase)
|
runBp2BuildTestCaseSimple(t, testCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +28,6 @@ func runPythonLibraryHostTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library_host")
|
testCase.blueprint = fmt.Sprintf(testCase.blueprint, "python_library_host")
|
||||||
testCase.moduleTypeUnderTest = "python_library_host"
|
testCase.moduleTypeUnderTest = "python_library_host"
|
||||||
testCase.moduleTypeUnderTestFactory = python.PythonLibraryHostFactory
|
testCase.moduleTypeUnderTestFactory = python.PythonLibraryHostFactory
|
||||||
testCase.moduleTypeUnderTestBp2BuildMutator = python.PythonLibraryHostBp2Build
|
|
||||||
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
runBp2BuildTestCase(t, func(ctx android.RegistrationContext) {
|
||||||
ctx.RegisterModuleType("python_library", python.PythonLibraryFactory)
|
ctx.RegisterModuleType("python_library", python.PythonLibraryFactory)
|
||||||
},
|
},
|
||||||
|
@@ -55,10 +55,9 @@ func runShBinaryTestCase(t *testing.T, tc bp2buildTestCase) {
|
|||||||
|
|
||||||
func TestShBinarySimple(t *testing.T) {
|
func TestShBinarySimple(t *testing.T) {
|
||||||
runShBinaryTestCase(t, bp2buildTestCase{
|
runShBinaryTestCase(t, bp2buildTestCase{
|
||||||
description: "sh_binary test",
|
description: "sh_binary test",
|
||||||
moduleTypeUnderTest: "sh_binary",
|
moduleTypeUnderTest: "sh_binary",
|
||||||
moduleTypeUnderTestFactory: sh.ShBinaryFactory,
|
moduleTypeUnderTestFactory: sh.ShBinaryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: sh.ShBinaryBp2Build,
|
|
||||||
blueprint: `sh_binary {
|
blueprint: `sh_binary {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
src: "foo.sh",
|
src: "foo.sh",
|
||||||
|
@@ -61,11 +61,10 @@ custom_cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - soong_config_module_type is supported in bp2build",
|
description: "soong config variables - soong_config_module_type is supported in bp2build",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo",
|
name = "foo",
|
||||||
copts = select({
|
copts = select({
|
||||||
@@ -107,10 +106,9 @@ custom_cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - soong_config_module_type_import is supported in bp2build",
|
description: "soong config variables - soong_config_module_type_import is supported in bp2build",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/SoongConfig.bp": configBp,
|
"foo/bar/SoongConfig.bp": configBp,
|
||||||
},
|
},
|
||||||
@@ -161,11 +159,10 @@ custom_cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for string vars",
|
description: "soong config variables - generates selects for string vars",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo",
|
name = "foo",
|
||||||
copts = select({
|
copts = select({
|
||||||
@@ -232,11 +229,10 @@ custom_cc_library_static {
|
|||||||
}`
|
}`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for multiple variable types",
|
description: "soong config variables - generates selects for multiple variable types",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "foo",
|
name = "foo",
|
||||||
copts = select({
|
copts = select({
|
||||||
@@ -298,11 +294,10 @@ cc_library_static { name: "soc_default_static_dep", bazel_module: { bp2build_ava
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for label list attributes",
|
description: "soong config variables - generates selects for label list attributes",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": otherDeps,
|
"foo/bar/Android.bp": otherDeps,
|
||||||
},
|
},
|
||||||
@@ -365,11 +360,10 @@ cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - defaults with a single namespace",
|
description: "soong config variables - defaults with a single namespace",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
copts = select({
|
copts = select({
|
||||||
@@ -445,11 +439,10 @@ cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - multiple defaults with a single namespace",
|
description: "soong config variables - multiple defaults with a single namespace",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
asflags = select({
|
asflags = select({
|
||||||
@@ -561,11 +554,10 @@ cc_library_static {
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - defaults with multiple namespaces",
|
description: "soong config variables - defaults with multiple namespaces",
|
||||||
moduleTypeUnderTest: "cc_library_static",
|
moduleTypeUnderTest: "cc_library_static",
|
||||||
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
moduleTypeUnderTestFactory: cc.LibraryStaticFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryStaticBp2Build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
expectedBazelTargets: []string{`cc_library_static(
|
expectedBazelTargets: []string{`cc_library_static(
|
||||||
name = "lib",
|
name = "lib",
|
||||||
copts = select({
|
copts = select({
|
||||||
@@ -652,11 +644,10 @@ cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for library_linking_strategy",
|
description: "soong config variables - generates selects for library_linking_strategy",
|
||||||
moduleTypeUnderTest: "cc_binary",
|
moduleTypeUnderTest: "cc_binary",
|
||||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.BinaryBp2build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": otherDeps,
|
"foo/bar/Android.bp": otherDeps,
|
||||||
},
|
},
|
||||||
@@ -733,11 +724,10 @@ cc_library { name: "lib_b", bazel_module: { bp2build_available: false } }
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for library_linking_strategy",
|
description: "soong config variables - generates selects for library_linking_strategy",
|
||||||
moduleTypeUnderTest: "cc_binary",
|
moduleTypeUnderTest: "cc_binary",
|
||||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.BinaryBp2build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": otherDeps,
|
"foo/bar/Android.bp": otherDeps,
|
||||||
},
|
},
|
||||||
@@ -821,11 +811,10 @@ cc_library { name: "lib_default", bazel_module: { bp2build_available: false } }
|
|||||||
`
|
`
|
||||||
|
|
||||||
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
runSoongConfigModuleTypeTest(t, bp2buildTestCase{
|
||||||
description: "soong config variables - generates selects for library_linking_strategy",
|
description: "soong config variables - generates selects for library_linking_strategy",
|
||||||
moduleTypeUnderTest: "cc_binary",
|
moduleTypeUnderTest: "cc_binary",
|
||||||
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
moduleTypeUnderTestFactory: cc.BinaryFactory,
|
||||||
moduleTypeUnderTestBp2BuildMutator: cc.BinaryBp2build,
|
blueprint: bp,
|
||||||
blueprint: bp,
|
|
||||||
filesystem: map[string]string{
|
filesystem: map[string]string{
|
||||||
"foo/bar/Android.bp": otherDeps,
|
"foo/bar/Android.bp": otherDeps,
|
||||||
},
|
},
|
||||||
|
@@ -74,16 +74,15 @@ func runBp2BuildTestCaseSimple(t *testing.T, tc bp2buildTestCase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type bp2buildTestCase struct {
|
type bp2buildTestCase struct {
|
||||||
description string
|
description string
|
||||||
moduleTypeUnderTest string
|
moduleTypeUnderTest string
|
||||||
moduleTypeUnderTestFactory android.ModuleFactory
|
moduleTypeUnderTestFactory android.ModuleFactory
|
||||||
moduleTypeUnderTestBp2BuildMutator func(android.TopDownMutatorContext)
|
blueprint string
|
||||||
blueprint string
|
expectedBazelTargets []string
|
||||||
expectedBazelTargets []string
|
filesystem map[string]string
|
||||||
filesystem map[string]string
|
dir string
|
||||||
dir string
|
expectedErr error
|
||||||
expectedErr error
|
unconvertedDepsMode unconvertedDepsMode
|
||||||
unconvertedDepsMode unconvertedDepsMode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc bp2buildTestCase) {
|
func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.RegistrationContext), tc bp2buildTestCase) {
|
||||||
@@ -105,7 +104,6 @@ func runBp2BuildTestCase(t *testing.T, registerModuleTypes func(ctx android.Regi
|
|||||||
registerModuleTypes(ctx)
|
registerModuleTypes(ctx)
|
||||||
ctx.RegisterModuleType(tc.moduleTypeUnderTest, tc.moduleTypeUnderTestFactory)
|
ctx.RegisterModuleType(tc.moduleTypeUnderTest, tc.moduleTypeUnderTestFactory)
|
||||||
ctx.RegisterBp2BuildConfig(bp2buildConfig)
|
ctx.RegisterBp2BuildConfig(bp2buildConfig)
|
||||||
ctx.RegisterBp2BuildMutator(tc.moduleTypeUnderTest, tc.moduleTypeUnderTestBp2BuildMutator)
|
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
|
|
||||||
_, parseErrs := ctx.ParseFileList(dir, toParse)
|
_, parseErrs := ctx.ParseFileList(dir, toParse)
|
||||||
@@ -178,6 +176,9 @@ type customProps struct {
|
|||||||
|
|
||||||
Arch_paths []string `android:"path,arch_variant"`
|
Arch_paths []string `android:"path,arch_variant"`
|
||||||
Arch_paths_exclude []string `android:"path,arch_variant"`
|
Arch_paths_exclude []string `android:"path,arch_variant"`
|
||||||
|
|
||||||
|
// Prop used to indicate this conversion should be 1 module -> multiple targets
|
||||||
|
One_to_many_prop *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type customModule struct {
|
type customModule struct {
|
||||||
@@ -277,71 +278,65 @@ type customBazelModuleAttributes struct {
|
|||||||
Arch_paths bazel.LabelListAttribute
|
Arch_paths bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func customBp2BuildMutator(ctx android.TopDownMutatorContext) {
|
func (m *customModule) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
if m, ok := ctx.Module().(*customModule); ok {
|
paths := bazel.LabelListAttribute{}
|
||||||
if !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
paths := bazel.LabelListAttribute{}
|
if p := m.props.One_to_many_prop; p != nil && *p {
|
||||||
|
customBp2buildOneToMany(ctx, m)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for axis, configToProps := range m.GetArchVariantProperties(ctx, &customProps{}) {
|
for axis, configToProps := range m.GetArchVariantProperties(ctx, &customProps{}) {
|
||||||
for config, props := range configToProps {
|
for config, props := range configToProps {
|
||||||
if archProps, ok := props.(*customProps); ok && archProps.Arch_paths != nil {
|
if archProps, ok := props.(*customProps); ok && archProps.Arch_paths != nil {
|
||||||
paths.SetSelectValue(axis, config, android.BazelLabelForModuleSrcExcludes(ctx, archProps.Arch_paths, archProps.Arch_paths_exclude))
|
paths.SetSelectValue(axis, config, android.BazelLabelForModuleSrcExcludes(ctx, archProps.Arch_paths, archProps.Arch_paths_exclude))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.ResolveExcludes()
|
|
||||||
|
|
||||||
attrs := &customBazelModuleAttributes{
|
|
||||||
String_ptr_prop: m.props.String_ptr_prop,
|
|
||||||
String_list_prop: m.props.String_list_prop,
|
|
||||||
Arch_paths: paths,
|
|
||||||
}
|
|
||||||
attrs.Embedded_attr = m.props.Embedded_prop
|
|
||||||
if m.props.OtherEmbeddedProps != nil {
|
|
||||||
attrs.OtherEmbeddedAttr = &OtherEmbeddedAttr{Other_embedded_attr: m.props.OtherEmbeddedProps.Other_embedded_prop}
|
|
||||||
}
|
|
||||||
|
|
||||||
props := bazel.BazelTargetModuleProperties{
|
|
||||||
Rule_class: "custom",
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
paths.ResolveExcludes()
|
||||||
|
|
||||||
|
attrs := &customBazelModuleAttributes{
|
||||||
|
String_ptr_prop: m.props.String_ptr_prop,
|
||||||
|
String_list_prop: m.props.String_list_prop,
|
||||||
|
Arch_paths: paths,
|
||||||
|
}
|
||||||
|
attrs.Embedded_attr = m.props.Embedded_prop
|
||||||
|
if m.props.OtherEmbeddedProps != nil {
|
||||||
|
attrs.OtherEmbeddedAttr = &OtherEmbeddedAttr{Other_embedded_attr: m.props.OtherEmbeddedProps.Other_embedded_prop}
|
||||||
|
}
|
||||||
|
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "custom",
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// A bp2build mutator that uses load statements and creates a 1:M mapping from
|
// A bp2build mutator that uses load statements and creates a 1:M mapping from
|
||||||
// module to target.
|
// module to target.
|
||||||
func customBp2BuildMutatorFromStarlark(ctx android.TopDownMutatorContext) {
|
func customBp2buildOneToMany(ctx android.TopDownMutatorContext, m *customModule) {
|
||||||
if m, ok := ctx.Module().(*customModule); ok {
|
|
||||||
if !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
baseName := m.Name()
|
baseName := m.Name()
|
||||||
attrs := &customBazelModuleAttributes{}
|
attrs := &customBazelModuleAttributes{}
|
||||||
|
|
||||||
myLibraryProps := bazel.BazelTargetModuleProperties{
|
myLibraryProps := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: "my_library",
|
Rule_class: "my_library",
|
||||||
Bzl_load_location: "//build/bazel/rules:rules.bzl",
|
Bzl_load_location: "//build/bazel/rules:rules.bzl",
|
||||||
}
|
|
||||||
ctx.CreateBazelTargetModule(myLibraryProps, android.CommonAttributes{Name: baseName}, attrs)
|
|
||||||
|
|
||||||
protoLibraryProps := bazel.BazelTargetModuleProperties{
|
|
||||||
Rule_class: "proto_library",
|
|
||||||
Bzl_load_location: "//build/bazel/rules:proto.bzl",
|
|
||||||
}
|
|
||||||
ctx.CreateBazelTargetModule(protoLibraryProps, android.CommonAttributes{Name: baseName + "_proto_library_deps"}, attrs)
|
|
||||||
|
|
||||||
myProtoLibraryProps := bazel.BazelTargetModuleProperties{
|
|
||||||
Rule_class: "my_proto_library",
|
|
||||||
Bzl_load_location: "//build/bazel/rules:proto.bzl",
|
|
||||||
}
|
|
||||||
ctx.CreateBazelTargetModule(myProtoLibraryProps, android.CommonAttributes{Name: baseName + "_my_proto_library_deps"}, attrs)
|
|
||||||
}
|
}
|
||||||
|
ctx.CreateBazelTargetModule(myLibraryProps, android.CommonAttributes{Name: baseName}, attrs)
|
||||||
|
|
||||||
|
protoLibraryProps := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "proto_library",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:proto.bzl",
|
||||||
|
}
|
||||||
|
ctx.CreateBazelTargetModule(protoLibraryProps, android.CommonAttributes{Name: baseName + "_proto_library_deps"}, attrs)
|
||||||
|
|
||||||
|
myProtoLibraryProps := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "my_proto_library",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:proto.bzl",
|
||||||
|
}
|
||||||
|
ctx.CreateBazelTargetModule(myProtoLibraryProps, android.CommonAttributes{Name: baseName + "_my_proto_library_deps"}, attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method for tests to easily access the targets in a dir.
|
// Helper method for tests to easily access the targets in a dir.
|
||||||
@@ -353,7 +348,6 @@ func generateBazelTargetsForDir(codegenCtx *CodegenContext, dir string) (BazelTa
|
|||||||
|
|
||||||
func registerCustomModuleForBp2buildConversion(ctx *android.TestContext) {
|
func registerCustomModuleForBp2buildConversion(ctx *android.TestContext) {
|
||||||
ctx.RegisterModuleType("custom", customModuleFactory)
|
ctx.RegisterModuleType("custom", customModuleFactory)
|
||||||
ctx.RegisterBp2BuildMutator("custom", customBp2BuildMutator)
|
|
||||||
ctx.RegisterForBazelConversion()
|
ctx.RegisterForBazelConversion()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
cc/binary.go
38
cc/binary.go
@@ -69,13 +69,14 @@ func RegisterBinaryBuildComponents(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
// cc_binary produces a binary that is runnable on a device.
|
// cc_binary produces a binary that is runnable on a device.
|
||||||
func BinaryFactory() android.Module {
|
func BinaryFactory() android.Module {
|
||||||
module, _ := NewBinary(android.HostAndDeviceSupported)
|
module, _ := newBinary(android.HostAndDeviceSupported, true)
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
// cc_binary_host produces a binary that is runnable on a host.
|
// cc_binary_host produces a binary that is runnable on a host.
|
||||||
func BinaryHostFactory() android.Module {
|
func BinaryHostFactory() android.Module {
|
||||||
module, _ := NewBinary(android.HostSupported)
|
module, _ := newBinary(android.HostSupported, true)
|
||||||
|
module.bazelable = true
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,6 +194,10 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
// Individual module implementations which comprise a C++ binary should call this function,
|
// Individual module implementations which comprise a C++ binary should call this function,
|
||||||
// set some fields on the result, and then call the Init function.
|
// set some fields on the result, and then call the Init function.
|
||||||
func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
||||||
|
return newBinary(hod, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newBinary(hod android.HostOrDeviceSupported, bazelable bool) (*Module, *binaryDecorator) {
|
||||||
module := newModule(hod, android.MultilibFirst)
|
module := newModule(hod, android.MultilibFirst)
|
||||||
binary := &binaryDecorator{
|
binary := &binaryDecorator{
|
||||||
baseLinker: NewBaseLinker(module.sanitize),
|
baseLinker: NewBaseLinker(module.sanitize),
|
||||||
@@ -201,6 +206,7 @@ func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) {
|
|||||||
module.compiler = NewBaseCompiler()
|
module.compiler = NewBaseCompiler()
|
||||||
module.linker = binary
|
module.linker = binary
|
||||||
module.installer = binary
|
module.installer = binary
|
||||||
|
module.bazelable = bazelable
|
||||||
|
|
||||||
// Allow module to be added as member of an sdk/module_exports.
|
// Allow module to be added as member of an sdk/module_exports.
|
||||||
module.sdkMemberTypes = []android.SdkMemberType{
|
module.sdkMemberTypes = []android.SdkMemberType{
|
||||||
@@ -551,33 +557,7 @@ func (binary *binaryDecorator) verifyHostBionicLinker(ctx ModuleContext, in, lin
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func binaryBp2build(ctx android.TopDownMutatorContext, m *Module, typ string) {
|
||||||
android.RegisterBp2BuildMutator("cc_binary", BinaryBp2build)
|
|
||||||
android.RegisterBp2BuildMutator("cc_binary_host", BinaryHostBp2build)
|
|
||||||
}
|
|
||||||
|
|
||||||
func BinaryBp2build(ctx android.TopDownMutatorContext) {
|
|
||||||
binaryBp2build(ctx, "cc_binary")
|
|
||||||
}
|
|
||||||
|
|
||||||
func BinaryHostBp2build(ctx android.TopDownMutatorContext) {
|
|
||||||
binaryBp2build(ctx, "cc_binary_host")
|
|
||||||
}
|
|
||||||
|
|
||||||
func binaryBp2build(ctx android.TopDownMutatorContext, typ string) {
|
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok {
|
|
||||||
// Not a cc module
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.ModuleType() != typ {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var compatibleWith bazel.StringListAttribute
|
var compatibleWith bazel.StringListAttribute
|
||||||
if typ == "cc_binary_host" {
|
if typ == "cc_binary_host" {
|
||||||
//incompatible with android OS
|
//incompatible with android OS
|
||||||
|
62
cc/cc.go
62
cc/cc.go
@@ -786,8 +786,9 @@ type Module struct {
|
|||||||
Properties BaseProperties
|
Properties BaseProperties
|
||||||
|
|
||||||
// initialize before calling Init
|
// initialize before calling Init
|
||||||
hod android.HostOrDeviceSupported
|
hod android.HostOrDeviceSupported
|
||||||
multilib android.Multilib
|
multilib android.Multilib
|
||||||
|
bazelable bool
|
||||||
|
|
||||||
// Allowable SdkMemberTypes of this module type.
|
// Allowable SdkMemberTypes of this module type.
|
||||||
sdkMemberTypes []android.SdkMemberType
|
sdkMemberTypes []android.SdkMemberType
|
||||||
@@ -1150,7 +1151,9 @@ func (c *Module) Init() android.Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
android.InitAndroidArchModule(c, c.hod, c.multilib)
|
||||||
android.InitBazelModule(c)
|
if c.bazelable {
|
||||||
|
android.InitBazelModule(c)
|
||||||
|
}
|
||||||
android.InitApexModule(c)
|
android.InitApexModule(c)
|
||||||
android.InitSdkAwareModule(c)
|
android.InitSdkAwareModule(c)
|
||||||
android.InitDefaultableModule(c)
|
android.InitDefaultableModule(c)
|
||||||
@@ -3185,6 +3188,24 @@ func (c *Module) testBinary() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Module) benchmarkBinary() bool {
|
||||||
|
if b, ok := c.linker.(interface {
|
||||||
|
benchmarkBinary() bool
|
||||||
|
}); ok {
|
||||||
|
return b.benchmarkBinary()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Module) fuzzBinary() bool {
|
||||||
|
if f, ok := c.linker.(interface {
|
||||||
|
fuzzBinary() bool
|
||||||
|
}); ok {
|
||||||
|
return f.fuzzBinary()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Header returns true if the module is a header-only variant. (See cc/library.go header()).
|
// Header returns true if the module is a header-only variant. (See cc/library.go header()).
|
||||||
func (c *Module) Header() bool {
|
func (c *Module) Header() bool {
|
||||||
if h, ok := c.linker.(interface {
|
if h, ok := c.linker.(interface {
|
||||||
@@ -3430,6 +3451,41 @@ func (c *Module) AlwaysRequiresPlatformApexVariant() bool {
|
|||||||
|
|
||||||
var _ snapshot.RelativeInstallPath = (*Module)(nil)
|
var _ snapshot.RelativeInstallPath = (*Module)(nil)
|
||||||
|
|
||||||
|
// ConvertWithBp2build converts Module to Bazel for bp2build.
|
||||||
|
func (c *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
|
if c.Binary() {
|
||||||
|
binaryBp2build(ctx, c, ctx.ModuleType())
|
||||||
|
} else if c.Object() {
|
||||||
|
objectBp2Build(ctx, c)
|
||||||
|
} else if c.CcLibrary() {
|
||||||
|
if c.hod == android.HostSupported {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
static := c.BuildStaticVariant()
|
||||||
|
shared := c.BuildSharedVariant()
|
||||||
|
prebuilt := c.IsPrebuilt()
|
||||||
|
|
||||||
|
if static && shared {
|
||||||
|
libraryBp2Build(ctx, c)
|
||||||
|
} else if !static && !shared {
|
||||||
|
libraryHeadersBp2Build(ctx, c)
|
||||||
|
} else if static {
|
||||||
|
if prebuilt {
|
||||||
|
prebuiltLibraryStaticBp2Build(ctx, c)
|
||||||
|
} else {
|
||||||
|
sharedOrStaticLibraryBp2Build(ctx, c, true)
|
||||||
|
}
|
||||||
|
} else if shared {
|
||||||
|
if prebuilt {
|
||||||
|
prebuiltLibrarySharedBp2Build(ctx, c)
|
||||||
|
} else {
|
||||||
|
sharedOrStaticLibraryBp2Build(ctx, c, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Defaults
|
// Defaults
|
||||||
//
|
//
|
||||||
|
@@ -52,6 +52,10 @@ type fuzzBinary struct {
|
|||||||
installedSharedDeps []string
|
installedSharedDeps []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fuzz *fuzzBinary) fuzzBinary() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
||||||
props := fuzz.binaryDecorator.linkerProps()
|
props := fuzz.binaryDecorator.linkerProps()
|
||||||
props = append(props, &fuzz.fuzzPackagedModule.FuzzProperties)
|
props = append(props, &fuzz.fuzzPackagedModule.FuzzProperties)
|
||||||
@@ -234,7 +238,7 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewFuzz(hod android.HostOrDeviceSupported) *Module {
|
func NewFuzz(hod android.HostOrDeviceSupported) *Module {
|
||||||
module, binary := NewBinary(hod)
|
module, binary := newBinary(hod, false)
|
||||||
|
|
||||||
binary.baseInstaller = NewFuzzInstaller()
|
binary.baseInstaller = NewFuzzInstaller()
|
||||||
module.sanitize.SetSanitizer(Fuzzer, true)
|
module.sanitize.SetSanitizer(Fuzzer, true)
|
||||||
|
@@ -207,10 +207,6 @@ type FlagExporterProperties struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterLibraryBuildComponents(android.InitRegistrationContext)
|
RegisterLibraryBuildComponents(android.InitRegistrationContext)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("cc_library_static", CcLibraryStaticBp2Build)
|
|
||||||
android.RegisterBp2BuildMutator("cc_library_shared", CcLibrarySharedBp2Build)
|
|
||||||
android.RegisterBp2BuildMutator("cc_library", CcLibraryBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
|
func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
|
||||||
@@ -277,21 +273,12 @@ type stripAttributes struct {
|
|||||||
None bazel.BoolAttribute
|
None bazel.BoolAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.ModuleType() != "cc_library" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// For some cc_library modules, their static variants are ready to be
|
// For some cc_library modules, their static variants are ready to be
|
||||||
// converted, but not their shared variants. For these modules, delegate to
|
// converted, but not their shared variants. For these modules, delegate to
|
||||||
// the cc_library_static bp2build converter temporarily instead.
|
// the cc_library_static bp2build converter temporarily instead.
|
||||||
if android.GenerateCcLibraryStaticOnly(ctx.Module().Name()) {
|
if android.GenerateCcLibraryStaticOnly(ctx.Module().Name()) {
|
||||||
ccSharedOrStaticBp2BuildMutatorInternal(ctx, m, "cc_library_static")
|
sharedOrStaticLibraryBp2Build(ctx, m, true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +408,7 @@ func LibraryFactory() android.Module {
|
|||||||
staticLibrarySdkMemberType,
|
staticLibrarySdkMemberType,
|
||||||
staticAndSharedLibrarySdkMemberType,
|
staticAndSharedLibrarySdkMemberType,
|
||||||
}
|
}
|
||||||
|
module.bazelable = true
|
||||||
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
@@ -430,6 +418,7 @@ func LibraryStaticFactory() android.Module {
|
|||||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||||
library.BuildOnlyStatic()
|
library.BuildOnlyStatic()
|
||||||
module.sdkMemberTypes = []android.SdkMemberType{staticLibrarySdkMemberType}
|
module.sdkMemberTypes = []android.SdkMemberType{staticLibrarySdkMemberType}
|
||||||
|
module.bazelable = true
|
||||||
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
@@ -439,6 +428,7 @@ func LibrarySharedFactory() android.Module {
|
|||||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||||
library.BuildOnlyShared()
|
library.BuildOnlyShared()
|
||||||
module.sdkMemberTypes = []android.SdkMemberType{sharedLibrarySdkMemberType}
|
module.sdkMemberTypes = []android.SdkMemberType{sharedLibrarySdkMemberType}
|
||||||
|
module.bazelable = true
|
||||||
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
module.bazelHandler = &ccLibraryBazelHandler{module: module}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
@@ -2413,25 +2403,7 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu
|
|||||||
return outputFile
|
return outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
func ccSharedOrStaticBp2BuildMutator(ctx android.TopDownMutatorContext, modType string) {
|
func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module, isStatic bool) {
|
||||||
module, ok := ctx.Module().(*Module)
|
|
||||||
if !ok {
|
|
||||||
// Not a cc module
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ccSharedOrStaticBp2BuildMutatorInternal(ctx, module, modType)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext, module *Module, modType string) {
|
|
||||||
if modType != "cc_library_static" && modType != "cc_library_shared" {
|
|
||||||
panic("ccSharedOrStaticBp2BuildMutatorInternal only supports cc_library_{static,shared}")
|
|
||||||
}
|
|
||||||
isStatic := modType == "cc_library_static"
|
|
||||||
|
|
||||||
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
||||||
compilerAttrs := baseAttributes.compilerAttributes
|
compilerAttrs := baseAttributes.compilerAttributes
|
||||||
linkerAttrs := baseAttributes.linkerAttributes
|
linkerAttrs := baseAttributes.linkerAttributes
|
||||||
@@ -2541,6 +2513,12 @@ func ccSharedOrStaticBp2BuildMutatorInternal(ctx android.TopDownMutatorContext,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var modType string
|
||||||
|
if isStatic {
|
||||||
|
modType = "cc_library_static"
|
||||||
|
} else {
|
||||||
|
modType = "cc_library_shared"
|
||||||
|
}
|
||||||
props := bazel.BazelTargetModuleProperties{
|
props := bazel.BazelTargetModuleProperties{
|
||||||
Rule_class: modType,
|
Rule_class: modType,
|
||||||
Bzl_load_location: fmt.Sprintf("//build/bazel/rules:%s.bzl", modType),
|
Bzl_load_location: fmt.Sprintf("//build/bazel/rules:%s.bzl", modType),
|
||||||
@@ -2575,18 +2553,6 @@ type bazelCcLibraryStaticAttributes struct {
|
|||||||
Features bazel.StringListAttribute
|
Features bazel.StringListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
|
|
||||||
isLibraryStatic := ctx.ModuleType() == "cc_library_static"
|
|
||||||
if b, ok := ctx.Module().(android.Bazelable); ok {
|
|
||||||
// This is created by a custom soong config module type, so its ctx.ModuleType() is not
|
|
||||||
// cc_library_static. Check its BaseModuleType.
|
|
||||||
isLibraryStatic = isLibraryStatic || b.BaseModuleType() == "cc_library_static"
|
|
||||||
}
|
|
||||||
if isLibraryStatic {
|
|
||||||
ccSharedOrStaticBp2BuildMutator(ctx, "cc_library_static")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(b/199902614): Can this be factored to share with the other Attributes?
|
// TODO(b/199902614): Can this be factored to share with the other Attributes?
|
||||||
type bazelCcLibrarySharedAttributes struct {
|
type bazelCcLibrarySharedAttributes struct {
|
||||||
staticOrSharedAttributes
|
staticOrSharedAttributes
|
||||||
@@ -2618,15 +2584,3 @@ type bazelCcLibrarySharedAttributes struct {
|
|||||||
|
|
||||||
Features bazel.StringListAttribute
|
Features bazel.StringListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func CcLibrarySharedBp2Build(ctx android.TopDownMutatorContext) {
|
|
||||||
isLibraryShared := ctx.ModuleType() == "cc_library_shared"
|
|
||||||
if b, ok := ctx.Module().(android.Bazelable); ok {
|
|
||||||
// This is created by a custom soong config module type, so its ctx.ModuleType() is not
|
|
||||||
// cc_library_shared. Check its BaseModuleType.
|
|
||||||
isLibraryShared = isLibraryShared || b.BaseModuleType() == "cc_library_shared"
|
|
||||||
}
|
|
||||||
if isLibraryShared {
|
|
||||||
ccSharedOrStaticBp2BuildMutator(ctx, "cc_library_shared")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -25,7 +25,6 @@ func init() {
|
|||||||
// Register sdk member types.
|
// Register sdk member types.
|
||||||
android.RegisterSdkMemberType(headersLibrarySdkMemberType)
|
android.RegisterSdkMemberType(headersLibrarySdkMemberType)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("cc_library_headers", CcLibraryHeadersBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersLibrarySdkMemberType = &librarySdkMemberType{
|
var headersLibrarySdkMemberType = &librarySdkMemberType{
|
||||||
@@ -96,6 +95,7 @@ func LibraryHeaderFactory() android.Module {
|
|||||||
module, library := NewLibrary(android.HostAndDeviceSupported)
|
module, library := NewLibrary(android.HostAndDeviceSupported)
|
||||||
library.HeaderOnly()
|
library.HeaderOnly()
|
||||||
module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType}
|
module.sdkMemberTypes = []android.SdkMemberType{headersLibrarySdkMemberType}
|
||||||
|
module.bazelable = true
|
||||||
module.bazelHandler = &libraryHeaderBazelHander{module: module, library: library}
|
module.bazelHandler = &libraryHeaderBazelHander{module: module, library: library}
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
@@ -117,21 +117,7 @@ type bazelCcLibraryHeadersAttributes struct {
|
|||||||
System_dynamic_deps bazel.LabelListAttribute
|
System_dynamic_deps bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func CcLibraryHeadersBp2Build(ctx android.TopDownMutatorContext) {
|
func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
module, ok := ctx.Module().(*Module)
|
|
||||||
if !ok {
|
|
||||||
// Not a cc module
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.ModuleType() != "cc_library_headers" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
baseAttributes := bp2BuildParseBaseProps(ctx, module)
|
||||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, baseAttributes.includes)
|
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module, baseAttributes.includes)
|
||||||
linkerAttrs := baseAttributes.linkerAttributes
|
linkerAttrs := baseAttributes.linkerAttributes
|
||||||
|
16
cc/object.go
16
cc/object.go
@@ -29,7 +29,6 @@ func init() {
|
|||||||
android.RegisterModuleType("cc_object", ObjectFactory)
|
android.RegisterModuleType("cc_object", ObjectFactory)
|
||||||
android.RegisterSdkMemberType(ccObjectSdkMemberType)
|
android.RegisterSdkMemberType(ccObjectSdkMemberType)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("cc_object", ObjectBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var ccObjectSdkMemberType = &librarySdkMemberType{
|
var ccObjectSdkMemberType = &librarySdkMemberType{
|
||||||
@@ -117,6 +116,7 @@ func ObjectFactory() android.Module {
|
|||||||
|
|
||||||
module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType}
|
module.sdkMemberTypes = []android.SdkMemberType{ccObjectSdkMemberType}
|
||||||
|
|
||||||
|
module.bazelable = true
|
||||||
return module.Init()
|
return module.Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,19 +135,9 @@ type bazelObjectAttributes struct {
|
|||||||
Linker_script bazel.LabelAttribute
|
Linker_script bazel.LabelAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
// ObjectBp2Build is the bp2build converter from cc_object modules to the
|
// objectBp2Build is the bp2build converter from cc_object modules to the
|
||||||
// Bazel equivalent target, plus any necessary include deps for the cc_object.
|
// Bazel equivalent target, plus any necessary include deps for the cc_object.
|
||||||
func ObjectBp2Build(ctx android.TopDownMutatorContext) {
|
func objectBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// a Module can be something other than a cc_object.
|
|
||||||
if ctx.ModuleType() != "cc_object" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.compiler == nil {
|
if m.compiler == nil {
|
||||||
// a cc_object must have access to the compiler decorator for its props.
|
// a cc_object must have access to the compiler decorator for its props.
|
||||||
ctx.ModuleErrorf("compiler must not be nil for a cc_object module")
|
ctx.ModuleErrorf("compiler must not be nil for a cc_object module")
|
||||||
|
@@ -32,8 +32,6 @@ func RegisterPrebuiltBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("cc_prebuilt_test_library_shared", PrebuiltSharedTestLibraryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_test_library_shared", PrebuiltSharedTestLibraryFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
|
ctx.RegisterModuleType("cc_prebuilt_object", prebuiltObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
ctx.RegisterModuleType("cc_prebuilt_binary", prebuiltBinaryFactory)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("cc_prebuilt_library_shared", PrebuiltLibrarySharedBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type prebuiltLinkerInterface interface {
|
type prebuiltLinkerInterface interface {
|
||||||
@@ -299,6 +297,7 @@ func PrebuiltSharedTestLibraryFactory() android.Module {
|
|||||||
func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
func NewPrebuiltSharedLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
||||||
module, library := NewPrebuiltLibrary(hod, "srcs")
|
module, library := NewPrebuiltLibrary(hod, "srcs")
|
||||||
library.BuildOnlyShared()
|
library.BuildOnlyShared()
|
||||||
|
module.bazelable = true
|
||||||
|
|
||||||
// Prebuilt shared libraries can be included in APEXes
|
// Prebuilt shared libraries can be included in APEXes
|
||||||
android.InitApexModule(module)
|
android.InitApexModule(module)
|
||||||
@@ -316,31 +315,41 @@ func PrebuiltStaticLibraryFactory() android.Module {
|
|||||||
func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
func NewPrebuiltStaticLibrary(hod android.HostOrDeviceSupported) (*Module, *libraryDecorator) {
|
||||||
module, library := NewPrebuiltLibrary(hod, "srcs")
|
module, library := NewPrebuiltLibrary(hod, "srcs")
|
||||||
library.BuildOnlyStatic()
|
library.BuildOnlyStatic()
|
||||||
|
module.bazelable = true
|
||||||
module.bazelHandler = &prebuiltStaticLibraryBazelHandler{module: module, library: library}
|
module.bazelHandler = &prebuiltStaticLibraryBazelHandler{module: module, library: library}
|
||||||
return module, library
|
return module, library
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type bazelPrebuiltLibraryStaticAttributes struct {
|
||||||
|
Static_library bazel.LabelAttribute
|
||||||
|
Export_includes bazel.StringListAttribute
|
||||||
|
Export_system_includes bazel.StringListAttribute
|
||||||
|
}
|
||||||
|
|
||||||
|
func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
|
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module)
|
||||||
|
exportedIncludes := Bp2BuildParseExportedIncludesForPrebuiltLibrary(ctx, module)
|
||||||
|
|
||||||
|
attrs := &bazelPrebuiltLibraryStaticAttributes{
|
||||||
|
Static_library: prebuiltAttrs.Src,
|
||||||
|
Export_includes: exportedIncludes.Includes,
|
||||||
|
Export_system_includes: exportedIncludes.SystemIncludes,
|
||||||
|
}
|
||||||
|
|
||||||
|
props := bazel.BazelTargetModuleProperties{
|
||||||
|
Rule_class: "prebuilt_library_static",
|
||||||
|
Bzl_load_location: "//build/bazel/rules:prebuilt_library_static.bzl",
|
||||||
|
}
|
||||||
|
|
||||||
|
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
|
||||||
|
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
|
||||||
|
}
|
||||||
|
|
||||||
type bazelPrebuiltLibrarySharedAttributes struct {
|
type bazelPrebuiltLibrarySharedAttributes struct {
|
||||||
Shared_library bazel.LabelAttribute
|
Shared_library bazel.LabelAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext) {
|
func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||||
module, ok := ctx.Module().(*Module)
|
|
||||||
if !ok {
|
|
||||||
// Not a cc module
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "cc_prebuilt_library_shared" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
prebuiltLibrarySharedBp2BuildInternal(ctx, module)
|
|
||||||
}
|
|
||||||
|
|
||||||
func prebuiltLibrarySharedBp2BuildInternal(ctx android.TopDownMutatorContext, module *Module) {
|
|
||||||
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module)
|
prebuiltAttrs := Bp2BuildParsePrebuiltLibraryProps(ctx, module)
|
||||||
|
|
||||||
attrs := &bazelPrebuiltLibrarySharedAttributes{
|
attrs := &bazelPrebuiltLibrarySharedAttributes{
|
||||||
|
@@ -461,7 +461,7 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
func NewTest(hod android.HostOrDeviceSupported) *Module {
|
||||||
module, binary := NewBinary(hod)
|
module, binary := newBinary(hod, false)
|
||||||
module.multilib = android.MultilibBoth
|
module.multilib = android.MultilibBoth
|
||||||
binary.baseInstaller = NewTestInstaller()
|
binary.baseInstaller = NewTestInstaller()
|
||||||
|
|
||||||
@@ -551,6 +551,10 @@ type benchmarkDecorator struct {
|
|||||||
testConfig android.Path
|
testConfig android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (benchmark *benchmarkDecorator) benchmarkBinary() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
func (benchmark *benchmarkDecorator) linkerInit(ctx BaseModuleContext) {
|
||||||
runpath := "../../lib"
|
runpath := "../../lib"
|
||||||
if ctx.toolchain().Is64Bit() {
|
if ctx.toolchain().Is64Bit() {
|
||||||
@@ -588,7 +592,7 @@ func (benchmark *benchmarkDecorator) install(ctx ModuleContext, file android.Pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
|
func NewBenchmark(hod android.HostOrDeviceSupported) *Module {
|
||||||
module, binary := NewBinary(hod)
|
module, binary := newBinary(hod, false)
|
||||||
module.multilib = android.MultilibBoth
|
module.multilib = android.MultilibBoth
|
||||||
binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData)
|
binary.baseInstaller = NewBaseInstaller("benchmarktest", "benchmarktest64", InstallInData)
|
||||||
|
|
||||||
|
@@ -63,7 +63,6 @@ func RegisterPrebuiltEtcBuildComponents(ctx android.RegistrationContext) {
|
|||||||
|
|
||||||
ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
|
ctx.RegisterModuleType("prebuilt_defaults", defaultsFactory)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("prebuilt_etc", PrebuiltEtcBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
|
var PrepareForTestWithPrebuiltEtc = android.FixtureRegisterWithContext(RegisterPrebuiltEtcBuildComponents)
|
||||||
@@ -663,20 +662,14 @@ type bazelPrebuiltEtcAttributes struct {
|
|||||||
Installable bazel.BoolAttribute
|
Installable bazel.BoolAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrebuiltEtcBp2Build(ctx android.TopDownMutatorContext) {
|
// ConvertWithBp2build performs bp2build conversion of PrebuiltEtc
|
||||||
module, ok := ctx.Module().(*PrebuiltEtc)
|
func (p *PrebuiltEtc) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
if !ok {
|
// All prebuilt_* modules are PrebuiltEtc, but at this time, we only convert prebuilt_etc modules.
|
||||||
// Not an prebuilt_etc
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "prebuilt_etc" {
|
if ctx.ModuleType() != "prebuilt_etc" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
prebuiltEtcBp2BuildInternal(ctx, module)
|
prebuiltEtcBp2BuildInternal(ctx, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *PrebuiltEtc) {
|
func prebuiltEtcBp2BuildInternal(ctx android.TopDownMutatorContext, module *PrebuiltEtc) {
|
||||||
|
@@ -67,13 +67,6 @@ func RegisterGenruleBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
ctx.FinalDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||||
ctx.BottomUp("genrule_tool_deps", toolDepsMutator).Parallel()
|
ctx.BottomUp("genrule_tool_deps", toolDepsMutator).Parallel()
|
||||||
})
|
})
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("genrule", GenruleBp2Build)
|
|
||||||
android.RegisterBp2BuildMutator("cc_genrule", CcGenruleBp2Build)
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterGenruleBp2BuildDeps(ctx android.RegisterMutatorsContext) {
|
|
||||||
ctx.BottomUp("genrule_tool_deps", toolDepsMutator)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -833,38 +826,8 @@ type bazelGenruleAttributes struct {
|
|||||||
Cmd string
|
Cmd string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CcGenruleBp2Build is for cc_genrule.
|
// ConvertWithBp2build converts a Soong module -> Bazel target.
|
||||||
func CcGenruleBp2Build(ctx android.TopDownMutatorContext) {
|
func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.ModuleType() != "cc_genrule" {
|
|
||||||
// Not a cc_genrule.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
genruleBp2Build(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GenruleBp2Build is used for genrule.
|
|
||||||
func GenruleBp2Build(ctx android.TopDownMutatorContext) {
|
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if ctx.ModuleType() != "genrule" {
|
|
||||||
// Not a regular genrule.
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
genruleBp2Build(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func genruleBp2Build(ctx android.TopDownMutatorContext) {
|
|
||||||
m, _ := ctx.Module().(*Module)
|
|
||||||
// Bazel only has the "tools" attribute.
|
// Bazel only has the "tools" attribute.
|
||||||
tools_prop := android.BazelLabelForModuleDeps(ctx, m.properties.Tools)
|
tools_prop := android.BazelLabelForModuleDeps(ctx, m.properties.Tools)
|
||||||
tool_files_prop := android.BazelLabelForModuleSrc(ctx, m.properties.Tool_files)
|
tool_files_prop := android.BazelLabelForModuleSrc(ctx, m.properties.Tool_files)
|
||||||
|
34
java/app.go
34
java/app.go
@@ -43,9 +43,6 @@ func RegisterAppBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
|
ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory)
|
||||||
ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
|
ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory)
|
||||||
ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
|
ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("android_app_certificate", AndroidAppCertificateBp2Build)
|
|
||||||
android.RegisterBp2BuildMutator("android_app", AppBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AndroidManifest.xml merging
|
// AndroidManifest.xml merging
|
||||||
@@ -945,6 +942,7 @@ func AndroidAppFactory() android.Module {
|
|||||||
android.InitDefaultableModule(module)
|
android.InitDefaultableModule(module)
|
||||||
android.InitOverridableModule(module, &module.appProperties.Overrides)
|
android.InitOverridableModule(module, &module.appProperties.Overrides)
|
||||||
android.InitApexModule(module)
|
android.InitApexModule(module)
|
||||||
|
android.InitBazelModule(module)
|
||||||
|
|
||||||
return module
|
return module
|
||||||
}
|
}
|
||||||
@@ -1407,23 +1405,11 @@ type bazelAndroidAppCertificateAttributes struct {
|
|||||||
Certificate string
|
Certificate string
|
||||||
}
|
}
|
||||||
|
|
||||||
func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) {
|
func (m *AndroidAppCertificate) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
module, ok := ctx.Module().(*AndroidAppCertificate)
|
androidAppCertificateBp2Build(ctx, m)
|
||||||
if !ok {
|
|
||||||
// Not an Android app certificate
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !module.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "android_app_certificate" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
androidAppCertificateBp2BuildInternal(ctx, module)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) {
|
func androidAppCertificateBp2Build(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) {
|
||||||
var certificate string
|
var certificate string
|
||||||
if module.properties.Certificate != nil {
|
if module.properties.Certificate != nil {
|
||||||
certificate = *module.properties.Certificate
|
certificate = *module.properties.Certificate
|
||||||
@@ -1448,16 +1434,8 @@ type bazelAndroidAppAttributes struct {
|
|||||||
Resource_files bazel.LabelListAttribute
|
Resource_files bazel.LabelListAttribute
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppBp2Build is used for android_app.
|
// ConvertWithBp2build is used to convert android_app to Bazel.
|
||||||
func AppBp2Build(ctx android.TopDownMutatorContext) {
|
func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
a, ok := ctx.Module().(*AndroidApp)
|
|
||||||
if !ok || !a.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if ctx.ModuleType() != "android_app" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO(b/209577426): Support multiple arch variants
|
//TODO(b/209577426): Support multiple arch variants
|
||||||
srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Srcs, a.properties.Exclude_srcs))
|
srcs := bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrcExcludes(ctx, a.properties.Srcs, a.properties.Exclude_srcs))
|
||||||
|
|
||||||
|
@@ -27,7 +27,6 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registerPythonBinaryComponents(android.InitRegistrationContext)
|
registerPythonBinaryComponents(android.InitRegistrationContext)
|
||||||
android.RegisterBp2BuildMutator("python_binary_host", PythonBinaryBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerPythonBinaryComponents(ctx android.RegistrationContext) {
|
func registerPythonBinaryComponents(ctx android.RegistrationContext) {
|
||||||
@@ -41,17 +40,7 @@ type bazelPythonBinaryAttributes struct {
|
|||||||
Python_version *string
|
Python_version *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func PythonBinaryBp2Build(ctx android.TopDownMutatorContext) {
|
func pythonBinaryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// a Module can be something other than a python_binary_host
|
|
||||||
if ctx.ModuleType() != "python_binary_host" {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var main *string
|
var main *string
|
||||||
for _, propIntf := range m.GetProperties() {
|
for _, propIntf := range m.GetProperties() {
|
||||||
if props, ok := propIntf.(*BinaryProperties); ok {
|
if props, ok := propIntf.(*BinaryProperties); ok {
|
||||||
|
@@ -17,8 +17,6 @@ package python
|
|||||||
// This file contains the module types for building Python library.
|
// This file contains the module types for building Python library.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
|
|
||||||
@@ -27,8 +25,6 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registerPythonLibraryComponents(android.InitRegistrationContext)
|
registerPythonLibraryComponents(android.InitRegistrationContext)
|
||||||
android.RegisterBp2BuildMutator("python_library_host", PythonLibraryHostBp2Build)
|
|
||||||
android.RegisterBp2BuildMutator("python_library", PythonLibraryBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerPythonLibraryComponents(ctx android.RegistrationContext) {
|
func registerPythonLibraryComponents(ctx android.RegistrationContext) {
|
||||||
@@ -50,25 +46,7 @@ type bazelPythonLibraryAttributes struct {
|
|||||||
Srcs_version *string
|
Srcs_version *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func PythonLibraryHostBp2Build(ctx android.TopDownMutatorContext) {
|
func pythonLibBp2Build(ctx android.TopDownMutatorContext, m *Module) {
|
||||||
pythonLibBp2Build(ctx, "python_library_host")
|
|
||||||
}
|
|
||||||
|
|
||||||
func PythonLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|
||||||
pythonLibBp2Build(ctx, "python_library")
|
|
||||||
}
|
|
||||||
|
|
||||||
func pythonLibBp2Build(ctx android.TopDownMutatorContext, modType string) {
|
|
||||||
m, ok := ctx.Module().(*Module)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// a Module can be something other than a `modType`
|
|
||||||
if ctx.ModuleType() != modType {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(b/182306917): this doesn't fully handle all nested props versioned
|
// TODO(b/182306917): this doesn't fully handle all nested props versioned
|
||||||
// by the python version, which would have been handled by the version split
|
// by the python version, which would have been handled by the version split
|
||||||
// mutator. This is sufficient for very simple python_library modules under
|
// mutator. This is sufficient for very simple python_library modules under
|
||||||
@@ -81,9 +59,7 @@ func pythonLibBp2Build(ctx android.TopDownMutatorContext, modType string) {
|
|||||||
} else if !py2Enabled && py3Enabled {
|
} else if !py2Enabled && py3Enabled {
|
||||||
python_version = &pyVersion3
|
python_version = &pyVersion3
|
||||||
} else if !py2Enabled && !py3Enabled {
|
} else if !py2Enabled && !py3Enabled {
|
||||||
panic(fmt.Errorf(
|
ctx.ModuleErrorf("bp2build converter doesn't understand having neither py2 nor py3 enabled")
|
||||||
"error for '%s' module: bp2build's %s converter doesn't understand having "+
|
|
||||||
"neither py2 nor py3 enabled", m.Name(), modType))
|
|
||||||
} else {
|
} else {
|
||||||
// do nothing, since python_version defaults to PY2ANDPY3
|
// do nothing, since python_version defaults to PY2ANDPY3
|
||||||
}
|
}
|
||||||
|
@@ -23,6 +23,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/bazel"
|
"android/soong/bazel"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
|
|
||||||
@@ -667,18 +668,25 @@ func (p *Module) createSrcsZip(ctx android.ModuleContext, pkgPath string) androi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isPythonLibModule returns whether the given module is a Python library Module or not
|
// isPythonLibModule returns whether the given module is a Python library Module or not
|
||||||
// This is distinguished by the fact that Python libraries are not installable, while other Python
|
|
||||||
// modules are.
|
|
||||||
func isPythonLibModule(module blueprint.Module) bool {
|
func isPythonLibModule(module blueprint.Module) bool {
|
||||||
if m, ok := module.(*Module); ok {
|
if m, ok := module.(*Module); ok {
|
||||||
// Python library has no bootstrapper or installer
|
return m.isLibrary()
|
||||||
if m.bootstrapper == nil && m.installer == nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is distinguished by the fact that Python libraries are not installable, while other Python
|
||||||
|
// modules are.
|
||||||
|
func (p *Module) isLibrary() bool {
|
||||||
|
// Python library has no bootstrapper or installer
|
||||||
|
return p.bootstrapper == nil && p.installer == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Module) isBinary() bool {
|
||||||
|
_, ok := p.bootstrapper.(*binaryDecorator)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// collectPathsFromTransitiveDeps checks for source/data files for duplicate paths
|
// collectPathsFromTransitiveDeps checks for source/data files for duplicate paths
|
||||||
// for module and its transitive dependencies and collects list of data/source file
|
// for module and its transitive dependencies and collects list of data/source file
|
||||||
// zips for transitive dependencies.
|
// zips for transitive dependencies.
|
||||||
@@ -752,6 +760,14 @@ func (p *Module) InstallInData() bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
|
if p.isLibrary() {
|
||||||
|
pythonLibBp2Build(ctx, p)
|
||||||
|
} else if p.isBinary() {
|
||||||
|
pythonBinaryBp2Build(ctx, p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var Bool = proptools.Bool
|
var Bool = proptools.Bool
|
||||||
var BoolDefault = proptools.BoolDefault
|
var BoolDefault = proptools.BoolDefault
|
||||||
var String = proptools.String
|
var String = proptools.String
|
||||||
|
@@ -42,8 +42,6 @@ func init() {
|
|||||||
pctx.Import("android/soong/android")
|
pctx.Import("android/soong/android")
|
||||||
|
|
||||||
registerShBuildComponents(android.InitRegistrationContext)
|
registerShBuildComponents(android.InitRegistrationContext)
|
||||||
|
|
||||||
android.RegisterBp2BuildMutator("sh_binary", ShBinaryBp2Build)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerShBuildComponents(ctx android.RegistrationContext) {
|
func registerShBuildComponents(ctx android.RegistrationContext) {
|
||||||
@@ -540,12 +538,7 @@ type bazelShBinaryAttributes struct {
|
|||||||
// visibility
|
// visibility
|
||||||
}
|
}
|
||||||
|
|
||||||
func ShBinaryBp2Build(ctx android.TopDownMutatorContext) {
|
func (m *ShBinary) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||||
m, ok := ctx.Module().(*ShBinary)
|
|
||||||
if !ok || !m.ConvertWithBp2build(ctx) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
srcs := bazel.MakeLabelListAttribute(
|
srcs := bazel.MakeLabelListAttribute(
|
||||||
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
android.BazelLabelForModuleSrc(ctx, []string{*m.properties.Src}))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user