Merge "Revert^2 "Use Module interface in addRequiredDeps"" into main

This commit is contained in:
Treehugger Robot 2024-04-17 22:37:56 +00:00 committed by Gerrit Code Review
commit e25cc5c909
2 changed files with 22 additions and 12 deletions

View file

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

View file

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