From 866b563d4cc490a4cfa0a3e0611b05539f736dc2 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Fri, 22 Sep 2017 12:28:24 -0700 Subject: [PATCH] Add target.linux_glibc and target.bionic target.linux_glibc will apply to host builds with glibc, which is identical to the current target.linux. In a future change, target.linux will change to affect all targets using the Linux kernel (android, linux_bionic, and linux_glibc). target.bionic will apply to all OS variants using Bionic. Bug: 31559095 Test: Add target.linux_glibc, target.bionic sections to an Android.bp, build Test: m host Change-Id: I677a67c22fba148fec264132311e355283f9d88d --- android/androidmk.go | 6 ++++- android/arch.go | 61 ++++++++++++++++++++++++++++++++++++++++---- android/paths.go | 10 +++++++- cc/androidmk.go | 6 ++++- 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 319f7118f..5ce486da3 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -243,7 +243,11 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b } if host { - fmt.Fprintln(&data.preamble, "LOCAL_MODULE_HOST_OS :=", amod.Os().String()) + makeOs := amod.Os().String() + if amod.Os() == Linux || amod.Os() == LinuxBionic { + makeOs = "linux" + } + fmt.Fprintln(&data.preamble, "LOCAL_MODULE_HOST_OS :=", makeOs) fmt.Fprintln(&data.preamble, "LOCAL_IS_HOST_MODULE := true") } diff --git a/android/arch.go b/android/arch.go index 05887a185..3fe034579 100644 --- a/android/arch.go +++ b/android/arch.go @@ -192,7 +192,7 @@ var ( commonTargetMap = make(map[string]Target) NoOsType OsType - Linux = NewOsType("linux", Host, false) + Linux = NewOsType("linux_glibc", Host, false) Darwin = NewOsType("darwin", Host, false) LinuxBionic = NewOsType("linux_bionic", Host, true) Windows = NewOsType("windows", HostCross, true) @@ -242,6 +242,14 @@ func (os OsType) String() string { return os.Name } +func (os OsType) Bionic() bool { + return os == Android || os == LinuxBionic +} + +func (os OsType) Linux() bool { + return os == Android || os == Linux || os == LinuxBionic +} + func NewOsType(name string, class OsClass, defDisabled bool) OsType { os := OsType{ Name: name, @@ -459,6 +467,8 @@ func createArchType(props reflect.Type) reflect.Type { "Host", "Android64", "Android32", + "Bionic", + "Linux", "Not_windows", "Arm_on_x86", "Arm_on_x86_64", @@ -468,6 +478,19 @@ func createArchType(props reflect.Type) reflect.Type { for _, archType := range osArchTypeMap[os] { targets = append(targets, os.Field+"_"+archType.Name) + + if os == Linux { // TODO(dwillemsen): os.Linux() + target := "Linux_" + archType.Name + if !inList(target, targets) { + targets = append(targets, target) + } + } + if os.Bionic() { + target := "Bionic_" + archType.Name + if !inList(target, targets) { + targets = append(targets, target) + } + } } } @@ -663,18 +686,47 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) { a.appendProperties(ctx, genProps, targetProp, field, prefix) } + // Handle target OS generalities of the form: + // target: { + // bionic: { + // key: value, + // }, + // bionic_x86: { + // key: value, + // }, + // } + if os == Linux { // TODO(dwillemsen): os.Linux() + field = "Linux" + prefix = "target.linux" + a.appendProperties(ctx, genProps, targetProp, field, prefix) + + field = "Linux_" + t.Name + prefix = "target.linux_" + t.Name + a.appendProperties(ctx, genProps, targetProp, field, prefix) + } + + if os.Bionic() { + field = "Bionic" + prefix = "target.bionic" + a.appendProperties(ctx, genProps, targetProp, field, prefix) + + field = "Bionic_" + t.Name + prefix = "target.bionic_" + t.Name + a.appendProperties(ctx, genProps, targetProp, field, prefix) + } + // Handle target OS properties in the form: // target: { - // linux: { + // linux_glibc: { // key: value, // }, // not_windows: { // key: value, // }, - // linux_x86: { + // linux_glibc_x86: { // key: value, // }, - // linux_arm: { + // linux_glibc_arm: { // key: value, // }, // android { @@ -687,7 +739,6 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) { // key: value, // }, // }, - // }, field = os.Field prefix = "target." + os.Name a.appendProperties(ctx, genProps, targetProp, field, prefix) diff --git a/android/paths.go b/android/paths.go index 9c8e93a4b..4a49d556a 100644 --- a/android/paths.go +++ b/android/paths.go @@ -714,7 +714,15 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string } outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition} } else { - outPaths = []string{"host", ctx.Os().String() + "-x86"} + switch ctx.Os() { + case Linux: + outPaths = []string{"host", "linux-x86"} + case LinuxBionic: + // TODO: should this be a separate top level, or shared with linux-x86? + outPaths = []string{"host", "linux_bionic-x86"} + default: + outPaths = []string{"host", ctx.Os().String() + "-x86"} + } } if ctx.Debug() { outPaths = append([]string{"debug"}, outPaths...) diff --git a/cc/androidmk.go b/cc/androidmk.go index 2db9d86bb..eb6306539 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -155,7 +155,11 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An } if host { - fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", ctx.Target().Os.String()) + makeOs := ctx.Target().Os.String() + if ctx.Target().Os == android.Linux || ctx.Target().Os == android.LinuxBionic { + makeOs = "linux" + } + fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs) fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") } else if ctx.vndk() { fmt.Fprintln(w, "LOCAL_USE_VNDK := true")