Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e25cc5c9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents 7bfe1377 f21dd65c
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -1042,12 +1042,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() {
@@ -1060,9 +1060,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
		}
@@ -1081,31 +1081,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)
			}
+10 −0
Original line number Diff line number Diff line
@@ -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 {