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
This commit is contained in:
Dan Willemsen 2017-09-22 12:28:24 -07:00
parent 1596e6ee11
commit 866b563d4c
4 changed files with 75 additions and 8 deletions

View file

@ -243,7 +243,11 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
} }
if host { 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") fmt.Fprintln(&data.preamble, "LOCAL_IS_HOST_MODULE := true")
} }

View file

@ -192,7 +192,7 @@ var (
commonTargetMap = make(map[string]Target) commonTargetMap = make(map[string]Target)
NoOsType OsType NoOsType OsType
Linux = NewOsType("linux", Host, false) Linux = NewOsType("linux_glibc", Host, false)
Darwin = NewOsType("darwin", Host, false) Darwin = NewOsType("darwin", Host, false)
LinuxBionic = NewOsType("linux_bionic", Host, true) LinuxBionic = NewOsType("linux_bionic", Host, true)
Windows = NewOsType("windows", HostCross, true) Windows = NewOsType("windows", HostCross, true)
@ -242,6 +242,14 @@ func (os OsType) String() string {
return os.Name 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 { func NewOsType(name string, class OsClass, defDisabled bool) OsType {
os := OsType{ os := OsType{
Name: name, Name: name,
@ -459,6 +467,8 @@ func createArchType(props reflect.Type) reflect.Type {
"Host", "Host",
"Android64", "Android64",
"Android32", "Android32",
"Bionic",
"Linux",
"Not_windows", "Not_windows",
"Arm_on_x86", "Arm_on_x86",
"Arm_on_x86_64", "Arm_on_x86_64",
@ -468,6 +478,19 @@ func createArchType(props reflect.Type) reflect.Type {
for _, archType := range osArchTypeMap[os] { for _, archType := range osArchTypeMap[os] {
targets = append(targets, os.Field+"_"+archType.Name) 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) 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: // Handle target OS properties in the form:
// target: { // target: {
// linux: { // linux_glibc: {
// key: value, // key: value,
// }, // },
// not_windows: { // not_windows: {
// key: value, // key: value,
// }, // },
// linux_x86: { // linux_glibc_x86: {
// key: value, // key: value,
// }, // },
// linux_arm: { // linux_glibc_arm: {
// key: value, // key: value,
// }, // },
// android { // android {
@ -687,7 +739,6 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
// key: value, // key: value,
// }, // },
// }, // },
// },
field = os.Field field = os.Field
prefix = "target." + os.Name prefix = "target." + os.Name
a.appendProperties(ctx, genProps, targetProp, field, prefix) a.appendProperties(ctx, genProps, targetProp, field, prefix)

View file

@ -714,7 +714,15 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
} }
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition} outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition}
} else { } 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() { if ctx.Debug() {
outPaths = append([]string{"debug"}, outPaths...) outPaths = append([]string{"debug"}, outPaths...)

View file

@ -155,7 +155,11 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
} }
if host { 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") fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
} else if ctx.vndk() { } else if ctx.vndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true")