Merge "Clean up some bp2build technical debt" am: 5bec8d41ea
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2075729 Change-Id: I29733bcd49c36590c134862013a1efe5264a9d70 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
d5c19f1eb9
10 changed files with 9 additions and 50 deletions
|
@ -2462,7 +2462,7 @@ type baseModuleContext struct {
|
|||
bazelConversionMode bool
|
||||
}
|
||||
|
||||
func (b *baseModuleContext) BazelConversionMode() bool {
|
||||
func (b *baseModuleContext) isBazelConversionMode() bool {
|
||||
return b.bazelConversionMode
|
||||
}
|
||||
func (b *baseModuleContext) OtherModuleName(m blueprint.Module) string {
|
||||
|
@ -2851,7 +2851,7 @@ func (b *baseModuleContext) GetDirectDep(name string) (blueprint.Module, bluepri
|
|||
}
|
||||
|
||||
func (b *baseModuleContext) ModuleFromName(name string) (blueprint.Module, bool) {
|
||||
if !b.BazelConversionMode() {
|
||||
if !b.isBazelConversionMode() {
|
||||
panic("cannot call ModuleFromName if not in bazel conversion mode")
|
||||
}
|
||||
if moduleName, _ := SrcIsModuleWithTag(name); moduleName != "" {
|
||||
|
|
|
@ -232,9 +232,6 @@ type BaseMutatorContext interface {
|
|||
// Rename all variants of a module. The new name is not visible to calls to ModuleName,
|
||||
// AddDependency or OtherModuleName until after this mutator pass is complete.
|
||||
Rename(name string)
|
||||
|
||||
// BazelConversionMode returns whether this mutator is being run as part of Bazel Conversion.
|
||||
BazelConversionMode() bool
|
||||
}
|
||||
|
||||
type TopDownMutator func(TopDownMutatorContext)
|
||||
|
@ -626,28 +623,11 @@ func (b *bottomUpMutatorContext) SetDefaultDependencyVariation(variation *string
|
|||
|
||||
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
|
||||
names ...string) []blueprint.Module {
|
||||
if b.bazelConversionMode {
|
||||
_, noSelfDeps := RemoveFromList(b.ModuleName(), names)
|
||||
if len(noSelfDeps) == 0 {
|
||||
return []blueprint.Module(nil)
|
||||
}
|
||||
// In Bazel conversion mode, mutators should not have created any variants. So, when adding a
|
||||
// dependency, the variations would not exist and the dependency could not be added, by
|
||||
// specifying no variations, we will allow adding the dependency to succeed.
|
||||
return b.bp.AddFarVariationDependencies(nil, tag, noSelfDeps...)
|
||||
}
|
||||
|
||||
return b.bp.AddVariationDependencies(variations, tag, names...)
|
||||
}
|
||||
|
||||
func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
|
||||
tag blueprint.DependencyTag, names ...string) []blueprint.Module {
|
||||
if b.bazelConversionMode {
|
||||
// In Bazel conversion mode, mutators should not have created any variants. So, when adding a
|
||||
// dependency, the variations would not exist and the dependency could not be added, by
|
||||
// specifying no variations, we will allow adding the dependency to succeed.
|
||||
return b.bp.AddFarVariationDependencies(nil, tag, names...)
|
||||
}
|
||||
|
||||
return b.bp.AddFarVariationDependencies(variations, tag, names...)
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|||
}
|
||||
}
|
||||
|
||||
if !binary.static() && inList("libc", deps.StaticLibs) && !ctx.BazelConversionMode() {
|
||||
if !binary.static() && inList("libc", deps.StaticLibs) {
|
||||
ctx.ModuleErrorf("statically linking libc to dynamic executable, please remove libc\n" +
|
||||
"from static libs or set static_executable: true")
|
||||
}
|
||||
|
|
6
cc/cc.go
6
cc/cc.go
|
@ -2059,12 +2059,6 @@ func (c *Module) deps(ctx DepsContext) Deps {
|
|||
deps.HeaderLibs = android.LastUniqueStrings(deps.HeaderLibs)
|
||||
deps.RuntimeLibs = android.LastUniqueStrings(deps.RuntimeLibs)
|
||||
|
||||
// In Bazel conversion mode, we dependency and build validations will occur in Bazel, so there is
|
||||
// no need to do so in Soong.
|
||||
if ctx.BazelConversionMode() {
|
||||
return deps
|
||||
}
|
||||
|
||||
for _, lib := range deps.ReexportSharedLibHeaders {
|
||||
if !inList(lib, deps.SharedLibs) {
|
||||
ctx.PropertyErrorf("export_shared_lib_headers", "Shared library not in shared_libs: '%s'", lib)
|
||||
|
|
|
@ -36,19 +36,10 @@ type toolchainContext interface {
|
|||
Arch() android.Arch
|
||||
}
|
||||
|
||||
type conversionContext interface {
|
||||
BazelConversionMode() bool
|
||||
}
|
||||
|
||||
func FindToolchainWithContext(ctx toolchainContext) Toolchain {
|
||||
t, err := findToolchain(ctx.Os(), ctx.Arch())
|
||||
if err != nil {
|
||||
if c, ok := ctx.(conversionContext); ok && c.BazelConversionMode() {
|
||||
// TODO(b/179123288): determine conversion for toolchain
|
||||
return &toolchainX86_64{}
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
|
|
@ -389,9 +389,7 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
|
|||
}
|
||||
|
||||
deps.SystemSharedLibs = linker.Properties.System_shared_libs
|
||||
// In Bazel conversion mode, variations have not been specified, so SystemSharedLibs may
|
||||
// inaccuarately appear unset, which can cause issues with circular dependencies.
|
||||
if deps.SystemSharedLibs == nil && !ctx.BazelConversionMode() {
|
||||
if deps.SystemSharedLibs == nil {
|
||||
// Provide a default system_shared_libs if it is unspecified. Note: If an
|
||||
// empty list [] is specified, it implies that the module declines the
|
||||
// default system_shared_libs.
|
||||
|
|
|
@ -1247,10 +1247,10 @@ func (j *Binary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
}
|
||||
|
||||
func (j *Binary) DepsMutator(ctx android.BottomUpMutatorContext) {
|
||||
if ctx.Arch().ArchType == android.Common || ctx.BazelConversionMode() {
|
||||
if ctx.Arch().ArchType == android.Common {
|
||||
j.deps(ctx)
|
||||
}
|
||||
if ctx.Arch().ArchType != android.Common || ctx.BazelConversionMode() {
|
||||
if ctx.Arch().ArchType != android.Common {
|
||||
// These dependencies ensure the host installation rules will install the jar file and
|
||||
// the jni libraries when the wrapper is installed.
|
||||
ctx.AddVariationDependencies(nil, jniInstallTag, j.binaryProperties.Jni_libs...)
|
||||
|
|
|
@ -91,7 +91,7 @@ func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
|
|||
case "lite", unspecifiedProtobufPluginType:
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-lite")
|
||||
case "full":
|
||||
if ctx.Host() || ctx.BazelConversionMode() {
|
||||
if ctx.Host() {
|
||||
ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-full")
|
||||
} else {
|
||||
ctx.PropertyErrorf("proto.type", "full java protos only supported on the host")
|
||||
|
|
|
@ -246,10 +246,6 @@ func (library *libraryDecorator) autoDep(ctx android.BottomUpMutatorContext) aut
|
|||
return rlibAutoDep
|
||||
} else if library.dylib() || library.shared() {
|
||||
return dylibAutoDep
|
||||
} else if ctx.BazelConversionMode() {
|
||||
// In Bazel conversion mode, we are currently ignoring the deptag, so we just need to supply a
|
||||
// compatible tag in order to add the dependency.
|
||||
return rlibAutoDep
|
||||
} else {
|
||||
panic(fmt.Errorf("autoDep called on library %q that has no enabled variants.", ctx.ModuleName()))
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ func (s *ShTest) DepsMutator(ctx android.BottomUpMutatorContext) {
|
|||
ctx.AddFarVariationDependencies(ctx.Target().Variations(), shTestDataBinsTag, s.testProperties.Data_bins...)
|
||||
ctx.AddFarVariationDependencies(append(ctx.Target().Variations(), sharedLibVariations...),
|
||||
shTestDataLibsTag, s.testProperties.Data_libs...)
|
||||
if (ctx.Target().Os.Class == android.Host || ctx.BazelConversionMode()) && len(ctx.Config().Targets[android.Android]) > 0 {
|
||||
if ctx.Target().Os.Class == android.Host && len(ctx.Config().Targets[android.Android]) > 0 {
|
||||
deviceVariations := ctx.Config().AndroidFirstDeviceTarget.Variations()
|
||||
ctx.AddFarVariationDependencies(deviceVariations, shTestDataDeviceBinsTag, s.testProperties.Data_device_bins...)
|
||||
ctx.AddFarVariationDependencies(append(deviceVariations, sharedLibVariations...),
|
||||
|
|
Loading…
Reference in a new issue