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

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

Merge changes I0885e493,Ic37c8db9

* changes:
  linux_bionic_arm64 is added when Host_bionic_arm64 is true
  HostCross is an attribute of a Target, not OsType
parents 8bd50953 22101981
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -304,15 +304,16 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
	host := false
	switch amod.Os().Class {
	case Host:
		if amod.Target().HostCross {
			// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
			if amod.Arch().ArchType != Common {
				a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
			}
		} else {
			// Make cannot identify LOCAL_MODULE_HOST_ARCH:= common.
			if amod.Arch().ArchType != Common {
				a.SetString("LOCAL_MODULE_HOST_ARCH", archStr)
			}
		host = true
	case HostCross:
		// Make cannot identify LOCAL_MODULE_HOST_CROSS_ARCH:= common.
		if amod.Arch().ArchType != Common {
			a.SetString("LOCAL_MODULE_HOST_CROSS_ARCH", archStr)
		}
		host = true
	case Device:
@@ -359,9 +360,11 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
	if amod.ArchSpecific() {
		switch amod.Os().Class {
		case Host:
			prefix = "HOST_"
		case HostCross:
			if amod.Target().HostCross {
				prefix = "HOST_CROSS_"
			} else {
				prefix = "HOST_"
			}
		case Device:
			prefix = "TARGET_"

@@ -563,9 +566,11 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
	if amod.ArchSpecific() {
		switch amod.Os().Class {
		case Host:
			prefix = "HOST_"
		case HostCross:
			if amod.Target().HostCross {
				prefix = "HOST_CROSS_"
			} else {
				prefix = "HOST_"
			}
		case Device:
			prefix = "TARGET_"

+60 −26
Original line number Diff line number Diff line
@@ -590,7 +590,7 @@ var (
	Linux       = NewOsType("linux_glibc", Host, false)
	Darwin      = NewOsType("darwin", Host, false)
	LinuxBionic = NewOsType("linux_bionic", Host, false)
	Windows     = NewOsType("windows", HostCross, true)
	Windows     = NewOsType("windows", Host, true)
	Android     = NewOsType("android", Device, false)
	Fuchsia     = NewOsType("fuchsia", Device, false)

@@ -621,7 +621,6 @@ const (
	Generic OsClass = iota
	Device
	Host
	HostCross
)

func (class OsClass) String() string {
@@ -632,8 +631,6 @@ func (class OsClass) String() string {
		return "device"
	case Host:
		return "host"
	case HostCross:
		return "host cross"
	default:
		panic(fmt.Errorf("unknown class %d", class))
	}
@@ -693,6 +690,11 @@ type Target struct {
	NativeBridge             NativeBridgeSupport
	NativeBridgeHostArchName string
	NativeBridgeRelativePath string

	// HostCross is true when the target cannot run natively on the current build host.
	// For example, linux_glibc_x86 returns true on a regular x86/i686/Linux machines, but returns false
	// on Mac (different OS), or on 64-bit only i686/Linux machines (unsupported arch).
	HostCross bool
}

func (target Target) String() string {
@@ -751,26 +753,15 @@ func osMutator(bpctx blueprint.BottomUpMutatorContext) {
		return
	}

	osClasses := base.OsClassSupported()

	var moduleOSList []OsType

	for _, os := range OsTypeList {
		supportedClass := false
		for _, osClass := range osClasses {
			if os.Class == osClass {
				supportedClass = true
		for _, t := range mctx.Config().Targets[os] {
			if base.supportsTarget(t, mctx.Config()) {
				moduleOSList = append(moduleOSList, os)
				break
			}
		}
		if !supportedClass {
			continue
		}

		if len(mctx.Config().Targets[os]) == 0 {
			continue
		}

		moduleOSList = append(moduleOSList, os)
	}

	if len(moduleOSList) == 0 {
@@ -925,7 +916,7 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {

	prefer32 := false
	if base.prefer32 != nil {
		prefer32 = base.prefer32(mctx, base, os.Class)
		prefer32 = base.prefer32(mctx, base, os)
	}

	multilib, extraMultilib := decodeMultilib(base, os.Class)
@@ -976,7 +967,7 @@ func decodeMultilib(base *ModuleBase, class OsClass) (multilib, extraMultilib st
	switch class {
	case Device:
		multilib = String(base.commonProperties.Target.Android.Compile_multilib)
	case Host, HostCross:
	case Host:
		multilib = String(base.commonProperties.Target.Host.Compile_multilib)
	}
	if multilib == "" {
@@ -1252,7 +1243,7 @@ func (m *ModuleBase) setOSProperties(ctx BottomUpMutatorContext) {
			//         key: value,
			//     },
			// },
			if os.Class == Host || os.Class == HostCross {
			if os.Class == Host {
				field := "Host"
				prefix := "target.host"
				m.appendProperties(ctx, genProps, targetProp, field, prefix)
@@ -1292,7 +1283,7 @@ func (m *ModuleBase) setOSProperties(ctx BottomUpMutatorContext) {
			prefix := "target." + os.Name
			m.appendProperties(ctx, genProps, targetProp, field, prefix)

			if (os.Class == Host || os.Class == HostCross) && os != Windows {
			if os.Class == Host && os != Windows {
				field := "Not_windows"
				prefix := "target.not_windows"
				m.appendProperties(ctx, genProps, targetProp, field, prefix)
@@ -1520,6 +1511,36 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
			nativeBridgeRelativePathStr = arch.ArchType.String()
		}

		// A target is considered as HostCross if it's a host target which can't run natively on
		// the currently configured build machine (either because the OS is different or because of
		// the unsupported arch)
		hostCross := false
		if os.Class == Host {
			var osSupported bool
			if os == BuildOs {
				osSupported = true
			} else if BuildOs.Linux() && os.Linux() {
				// LinuxBionic and Linux are compatible
				osSupported = true
			} else {
				osSupported = false
			}

			var archSupported bool
			if arch.ArchType == Common {
				archSupported = true
			} else if arch.ArchType.Name == *variables.HostArch {
				archSupported = true
			} else if variables.HostSecondaryArch != nil && arch.ArchType.Name == *variables.HostSecondaryArch {
				archSupported = true
			} else {
				archSupported = false
			}
			if !osSupported || !archSupported {
				hostCross = true
			}
		}

		targets[os] = append(targets[os],
			Target{
				Os:                       os,
@@ -1527,6 +1548,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
				NativeBridge:             nativeBridgeEnabled,
				NativeBridgeHostArchName: nativeBridgeHostArchNameStr,
				NativeBridgeRelativePath: nativeBridgeRelativePathStr,
				HostCross:                hostCross,
			})
	}

@@ -1543,6 +1565,9 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
	if Bool(config.Host_bionic) {
		addTarget(LinuxBionic, "x86_64", nil, nil, nil, NativeBridgeDisabled, nil, nil)
	}
	if Bool(config.Host_bionic_arm64) {
		addTarget(LinuxBionic, "arm64", nil, nil, nil, NativeBridgeDisabled, nil, nil)
	}

	if String(variables.CrossHost) != "" {
		crossHostOs := osByName(*variables.CrossHost)
@@ -1783,13 +1808,22 @@ func getCommonTargets(targets []Target) []Target {
}

func firstTarget(targets []Target, filters ...string) []Target {
	// find the first target from each OS
	var ret []Target
	hasHost := false
	set := make(map[OsType]bool)

	for _, filter := range filters {
		buildTargets := filterMultilibTargets(targets, filter)
		if len(buildTargets) > 0 {
			return buildTargets[:1]
		for _, t := range buildTargets {
			if _, found := set[t.Os]; !found {
				hasHost = hasHost || (t.Os.Class == Host)
				set[t.Os] = true
				ret = append(ret, t)
			}
		}
	return nil
	}
	return ret
}

// Use the module multilib setting to select one or more targets from a target list
+13 −12
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ const productVariablesFileName = "soong.variables"
type FileConfigurableOptions struct {
	Mega_device       *bool `json:",omitempty"`
	Host_bionic       *bool `json:",omitempty"`
	Host_bionic_arm64 *bool `json:",omitempty"`
}

func (f *FileConfigurableOptions) SetDefaultConfig() {
@@ -267,10 +268,10 @@ func TestArchConfigNativeBridge(buildDir string, env map[string]string, bp strin
	config := testConfig.config

	config.Targets[Android] = []Target{
		{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
		{Android, Arch{ArchType: X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", ""},
		{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled, "x86_64", "arm64"},
		{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled, "x86", "arm"},
		{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
		{Android, Arch{ArchType: X86, ArchVariant: "silvermont", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
		{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled, "x86_64", "arm64", false},
		{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled, "x86", "arm", false},
	}

	return testConfig
@@ -282,10 +283,10 @@ func TestArchConfigFuchsia(buildDir string, env map[string]string, bp string, fs

	config.Targets = map[OsType][]Target{
		Fuchsia: []Target{
			{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
			{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
		},
		BuildOs: []Target{
			{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
			{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
		},
	}

@@ -299,12 +300,12 @@ func TestArchConfig(buildDir string, env map[string]string, bp string, fs map[st

	config.Targets = map[OsType][]Target{
		Android: []Target{
			{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", ""},
			{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", ""},
			{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled, "", "", false},
			{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", "", false},
		},
		BuildOs: []Target{
			{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
			{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", ""},
			{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", false},
			{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", "", false},
		},
	}

+27 −21
Original line number Diff line number Diff line
@@ -948,7 +948,7 @@ type ModuleBase struct {
	initRcPaths         Paths
	vintfFragmentsPaths Paths

	prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool
	prefer32 func(ctx BaseModuleContext, base *ModuleBase, os OsType) bool
}

func (m *ModuleBase) ComponentDepsMutator(BottomUpMutatorContext) {}
@@ -975,7 +975,7 @@ func (m *ModuleBase) VariablesForTests() map[string]string {
	return m.variables
}

func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, class OsClass) bool) {
func (m *ModuleBase) Prefer32(prefer32 func(ctx BaseModuleContext, base *ModuleBase, os OsType) bool) {
	m.prefer32 = prefer32
}

@@ -1071,7 +1071,7 @@ func (m *ModuleBase) Os() OsType {
}

func (m *ModuleBase) Host() bool {
	return m.Os().Class == Host || m.Os().Class == HostCross
	return m.Os().Class == Host
}

func (m *ModuleBase) Device() bool {
@@ -1091,28 +1091,28 @@ func (m *ModuleBase) IsCommonOSVariant() bool {
	return m.commonProperties.CommonOSVariant
}

func (m *ModuleBase) OsClassSupported() []OsClass {
func (m *ModuleBase) supportsTarget(target Target, config Config) bool {
	switch m.commonProperties.HostOrDeviceSupported {
	case HostSupported:
		return []OsClass{Host, HostCross}
		return target.Os.Class == Host
	case HostSupportedNoCross:
		return []OsClass{Host}
		return target.Os.Class == Host && !target.HostCross
	case DeviceSupported:
		return []OsClass{Device}
		return target.Os.Class == Device
	case HostAndDeviceSupported, HostAndDeviceDefault:
		var supported []OsClass
		supported := false
		if Bool(m.hostAndDeviceProperties.Host_supported) ||
			(m.commonProperties.HostOrDeviceSupported == HostAndDeviceDefault &&
				m.hostAndDeviceProperties.Host_supported == nil) {
			supported = append(supported, Host, HostCross)
			supported = supported || target.Os.Class == Host
		}
		if m.hostAndDeviceProperties.Device_supported == nil ||
			*m.hostAndDeviceProperties.Device_supported {
			supported = append(supported, Device)
			supported = supported || target.Os.Class == Device
		}
		return supported
	default:
		return nil
		return false
	}
}

@@ -2115,7 +2115,7 @@ func (b *baseModuleContext) Os() OsType {
}

func (b *baseModuleContext) Host() bool {
	return b.os.Class == Host || b.os.Class == HostCross
	return b.os.Class == Host
}

func (b *baseModuleContext) Device() bool {
@@ -2575,30 +2575,36 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
	}

	// Create (host|host-cross|target)-<OS> phony rules to build a reduced checkbuild.
	osDeps := map[OsType]Paths{}
	type osAndCross struct {
		os        OsType
		hostCross bool
	}
	osDeps := map[osAndCross]Paths{}
	ctx.VisitAllModules(func(module Module) {
		if module.Enabled() {
			os := module.Target().Os
			osDeps[os] = append(osDeps[os], module.base().checkbuildFiles...)
			key := osAndCross{os: module.Target().Os, hostCross: module.Target().HostCross}
			osDeps[key] = append(osDeps[key], module.base().checkbuildFiles...)
		}
	})

	osClass := make(map[string]Paths)
	for os, deps := range osDeps {
	for key, deps := range osDeps {
		var className string

		switch os.Class {
		switch key.os.Class {
		case Host:
			className = "host"
		case HostCross:
			if key.hostCross {
				className = "host-cross"
			} else {
				className = "host"
			}
		case Device:
			className = "target"
		default:
			continue
		}

		name := className + "-" + os.Name
		name := className + "-" + key.os.Name
		osClass[className] = append(osClass[className], PathForPhony(ctx, name))

		ctx.Phony(name, deps...)
+1 −1
Original line number Diff line number Diff line
@@ -285,7 +285,7 @@ func TestPrebuilts(t *testing.T) {
				t.Errorf("windows is assumed to be disabled by default")
			}
			config.config.Targets[Windows] = []Target{
				{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
				{Windows, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", "", true},
			}

			ctx := NewTestArchContext()
Loading