Revert "Use Module interface in addRequiredDeps"

This reverts commit de18a3d55a.

Reason for revert: b/335332155

Change-Id: Ib5b74b1704c1446713466e8617c42b212c960d49
This commit is contained in:
Daren Liao 2024-04-17 03:07:53 +00:00 committed by Gerrit Code Review
parent de18a3d55a
commit bbcdaa0c32
2 changed files with 12 additions and 22 deletions

View file

@ -1043,12 +1043,12 @@ func (m *ModuleBase) baseDepsMutator(ctx BottomUpMutatorContext) {
pv := ctx.Config().productVariables
fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil
if fullManifest {
addRequiredDeps(ctx)
m.addRequiredDeps(ctx)
}
}
// addRequiredDeps adds required, target_required, and host_required as dependencies.
func addRequiredDeps(ctx BottomUpMutatorContext) {
func (m *ModuleBase) addRequiredDeps(ctx BottomUpMutatorContext) {
addDep := func(target Target, depName string) {
if !ctx.OtherModuleExists(depName) {
if ctx.Config().AllowMissingDependencies() {
@ -1061,9 +1061,9 @@ func addRequiredDeps(ctx BottomUpMutatorContext) {
// in build/make/core/main.mk.
// TODO(jiyong): the Make-side does this only when the required module is a shared
// library or a native test.
bothInAndroid := ctx.Device() && target.Os.Class == Device
nativeArch := InList(ctx.Arch().ArchType.Multilib, []string{"lib32", "lib64"})
sameBitness := ctx.Arch().ArchType.Multilib == target.Arch.ArchType.Multilib
bothInAndroid := m.Device() && target.Os.Class == Device
nativeArch := InList(m.Arch().ArchType.Multilib, []string{"lib32", "lib64"})
sameBitness := m.Arch().ArchType.Multilib == target.Arch.ArchType.Multilib
if bothInAndroid && nativeArch && !sameBitness {
return
}
@ -1082,31 +1082,31 @@ func addRequiredDeps(ctx BottomUpMutatorContext) {
hostTargets = append(hostTargets, ctx.Config().Targets[ctx.Config().BuildOS]...)
hostTargets = append(hostTargets, ctx.Config().BuildOSCommonTarget)
if ctx.Device() {
for _, depName := range ctx.Module().RequiredModuleNames() {
if m.Device() {
for _, depName := range m.RequiredModuleNames() {
for _, target := range deviceTargets {
addDep(target, depName)
}
}
for _, depName := range ctx.Module().HostRequiredModuleNames() {
for _, depName := range m.HostRequiredModuleNames() {
for _, target := range hostTargets {
addDep(target, depName)
}
}
}
if ctx.Host() {
for _, depName := range ctx.Module().RequiredModuleNames() {
if m.Host() {
for _, depName := range m.RequiredModuleNames() {
for _, target := range hostTargets {
// When a host module requires another host module, don't make a
// dependency if they have different OSes (i.e. hostcross).
if ctx.Target().HostCross != target.HostCross {
if m.Target().HostCross != target.HostCross {
continue
}
addDep(target, depName)
}
}
for _, depName := range ctx.Module().TargetRequiredModuleNames() {
for _, depName := range m.TargetRequiredModuleNames() {
for _, target := range deviceTargets {
addDep(target, depName)
}

View file

@ -84,21 +84,12 @@ func TestFileSystemDeps(t *testing.T) {
cc_library {
name: "libbar",
required: ["libbaz"],
target: {
platform: {
required: ["lib_platform_only"],
},
},
}
cc_library {
name: "libbaz",
}
cc_library {
name: "lib_platform_only",
}
phony {
name: "phony",
required: [
@ -129,7 +120,6 @@ func TestFileSystemDeps(t *testing.T) {
"lib64/libbar.so",
"lib64/libbaz.so",
"lib64/libquz.so",
"lib64/lib_platform_only.so",
"etc/bpf/bpf.o",
}
for _, e := range expected {