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

Commit a8166862 authored by Paul Duffin's avatar Paul Duffin Committed by Gerrit Code Review
Browse files

Merge "Add support for multiple os types"

parents a8e37b98 a04c107b
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -596,7 +596,7 @@ var BuildOs = func() OsType {
}()

var (
	osTypeList      []OsType
	OsTypeList      []OsType
	commonTargetMap = make(map[string]Target)

	NoOsType    OsType
@@ -672,7 +672,7 @@ func NewOsType(name string, class OsClass, defDisabled bool) OsType {

		DefaultDisabled: defDisabled,
	}
	osTypeList = append(osTypeList, os)
	OsTypeList = append(OsTypeList, os)

	if _, found := commonTargetMap[name]; found {
		panic(fmt.Errorf("Found Os type duplicate during OsType registration: %q", name))
@@ -684,7 +684,7 @@ func NewOsType(name string, class OsClass, defDisabled bool) OsType {
}

func osByName(name string) OsType {
	for _, os := range osTypeList {
	for _, os := range OsTypeList {
		if os.Name == name {
			return os
		}
@@ -750,7 +750,7 @@ func osMutator(mctx BottomUpMutatorContext) {

	var moduleOSList []OsType

	for _, os := range osTypeList {
	for _, os := range OsTypeList {
		supportedClass := false
		for _, osClass := range osClasses {
			if os.Class == osClass {
@@ -1071,7 +1071,7 @@ func createArchPropTypeDesc(props reflect.Type) []archPropTypeDesc {
			"Arm_on_x86",
			"Arm_on_x86_64",
		}
		for _, os := range osTypeList {
		for _, os := range OsTypeList {
			targets = append(targets, os.Field)

			for _, archType := range osArchTypeMap[os] {
+20 −1
Original line number Diff line number Diff line
@@ -448,10 +448,29 @@ func RegisterSdkMemberType(memberType SdkMemberType) {

// Base structure for all implementations of SdkMemberProperties.
//
// Contains common properties that apply across many different member types.
// Contains common properties that apply across many different member types. These
// are not affected by the optimization to extract common values.
type SdkMemberPropertiesBase struct {
	// The setting to use for the compile_multilib property.
	Compile_multilib string

	// The number of unique os types supported by the member variants.
	Os_count int

	// The os type for which these properties refer.
	Os OsType
}

// The os prefix to use for any file paths in the sdk.
//
// Is an empty string if the member only provides variants for a single os type, otherwise
// is the OsType.Name.
func (b *SdkMemberPropertiesBase) OsPrefix() string {
	if b.Os_count == 1 {
		return ""
	} else {
		return b.Os.Name
	}
}

func (b *SdkMemberPropertiesBase) Base() *SdkMemberPropertiesBase {
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ const (

// path to the native binary. Relative to <sdk_root>/<api_dir>
func nativeBinaryPathFor(lib nativeBinaryInfoProperties) string {
	return filepath.Join(lib.archType,
	return filepath.Join(lib.OsPrefix(), lib.archType,
		nativeBinaryDir, lib.outputFile.Base())
}

+1 −1
Original line number Diff line number Diff line
@@ -254,7 +254,7 @@ const (

// path to the native library. Relative to <sdk_root>/<api_dir>
func nativeLibraryPathFor(lib *nativeLibInfoProperties) string {
	return filepath.Join(lib.archType,
	return filepath.Join(lib.OsPrefix(), lib.archType,
		nativeStubDir, lib.outputFile.Base())
}

+20 −3
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
	ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
}

func GatherRequiredDepsForTest(os android.OsType) string {
func GatherRequiredDepsForTest(oses ...android.OsType) string {
	ret := `
		toolchain_library {
			name: "libatomic",
@@ -341,6 +341,7 @@ func GatherRequiredDepsForTest(os android.OsType) string {
		}
	`

	for _, os := range oses {
		if os == android.Fuchsia {
			ret += `
		cc_library {
@@ -353,6 +354,22 @@ func GatherRequiredDepsForTest(os android.OsType) string {
		}
		`
		}
		if os == android.Windows {
			ret += `
		toolchain_library {
			name: "libwinpthread",
			host_supported: true,
			enabled: false,
			target: {
				windows: {
					enabled: true,
				},
			},
			src: "",
		}
		`
		}
	}
	return ret
}

Loading