From f21dd65c0836d3505425485eee522337c30fcf5d Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 17 Apr 2024 05:22:37 +0000 Subject: [PATCH] Revert^2 "Use Module interface in addRequiredDeps" This reverts commit bbcdaa0c32498d212e2af65984b0180bfbf3925b. Reason for revert: relanding with a forward fix Change-Id: I14b83010a4b8d9cb9cb317f2aa07875c17f6cdaa --- android/module.go | 24 ++++++++++++------------ filesystem/filesystem_test.go | 10 ++++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/android/module.go b/android/module.go index 89c4ddde9..8752a62ab 100644 --- a/android/module.go +++ b/android/module.go @@ -1043,12 +1043,12 @@ func (m *ModuleBase) baseDepsMutator(ctx BottomUpMutatorContext) { pv := ctx.Config().productVariables fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil if fullManifest { - m.addRequiredDeps(ctx) + addRequiredDeps(ctx) } } // 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) { if !ctx.OtherModuleExists(depName) { if ctx.Config().AllowMissingDependencies() { @@ -1061,9 +1061,9 @@ func (m *ModuleBase) 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 := m.Device() && target.Os.Class == Device - nativeArch := InList(m.Arch().ArchType.Multilib, []string{"lib32", "lib64"}) - sameBitness := m.Arch().ArchType.Multilib == target.Arch.ArchType.Multilib + 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 if bothInAndroid && nativeArch && !sameBitness { return } @@ -1082,31 +1082,31 @@ func (m *ModuleBase) addRequiredDeps(ctx BottomUpMutatorContext) { hostTargets = append(hostTargets, ctx.Config().Targets[ctx.Config().BuildOS]...) hostTargets = append(hostTargets, ctx.Config().BuildOSCommonTarget) - if m.Device() { - for _, depName := range m.RequiredModuleNames() { + if ctx.Device() { + for _, depName := range ctx.Module().RequiredModuleNames() { for _, target := range deviceTargets { addDep(target, depName) } } - for _, depName := range m.HostRequiredModuleNames() { + for _, depName := range ctx.Module().HostRequiredModuleNames() { for _, target := range hostTargets { addDep(target, depName) } } } - if m.Host() { - for _, depName := range m.RequiredModuleNames() { + if ctx.Host() { + for _, depName := range ctx.Module().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 m.Target().HostCross != target.HostCross { + if ctx.Target().HostCross != target.HostCross { continue } addDep(target, depName) } } - for _, depName := range m.TargetRequiredModuleNames() { + for _, depName := range ctx.Module().TargetRequiredModuleNames() { for _, target := range deviceTargets { addDep(target, depName) } diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go index f4ecad46c..3a5071d34 100644 --- a/filesystem/filesystem_test.go +++ b/filesystem/filesystem_test.go @@ -84,12 +84,21 @@ 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: [ @@ -120,6 +129,7 @@ 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 {