Merge "Add native_bridge target to Android.bp"
This commit is contained in:
@@ -444,6 +444,7 @@ toolchain_library {
|
|||||||
defaults: ["linux_bionic_supported"],
|
defaults: ["linux_bionic_supported"],
|
||||||
vendor_available: true,
|
vendor_available: true,
|
||||||
recovery_available: true,
|
recovery_available: true,
|
||||||
|
native_bridge_supported: true,
|
||||||
|
|
||||||
arch: {
|
arch: {
|
||||||
arm: {
|
arm: {
|
||||||
@@ -466,6 +467,7 @@ toolchain_library {
|
|||||||
defaults: ["linux_bionic_supported"],
|
defaults: ["linux_bionic_supported"],
|
||||||
vendor_available: true,
|
vendor_available: true,
|
||||||
recovery_available: true,
|
recovery_available: true,
|
||||||
|
native_bridge_supported: true,
|
||||||
|
|
||||||
arch: {
|
arch: {
|
||||||
arm: {
|
arm: {
|
||||||
|
@@ -28,6 +28,10 @@ import (
|
|||||||
"github.com/google/blueprint/bootstrap"
|
"github.com/google/blueprint/bootstrap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
NativeBridgeSuffix = ".native_bridge"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterSingletonType("androidmk", AndroidMkSingleton)
|
RegisterSingletonType("androidmk", AndroidMkSingleton)
|
||||||
}
|
}
|
||||||
@@ -161,6 +165,10 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if amod.Target().NativeBridge {
|
||||||
|
a.SubName += NativeBridgeSuffix
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Fprintln(&a.header, "\ninclude $(CLEAR_VARS)")
|
fmt.Fprintln(&a.header, "\ninclude $(CLEAR_VARS)")
|
||||||
|
|
||||||
// Collect make variable assignment entries.
|
// Collect make variable assignment entries.
|
||||||
@@ -190,8 +198,23 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
|||||||
case Device:
|
case Device:
|
||||||
// Make cannot identify LOCAL_MODULE_TARGET_ARCH:= common.
|
// Make cannot identify LOCAL_MODULE_TARGET_ARCH:= common.
|
||||||
if archStr != "common" {
|
if archStr != "common" {
|
||||||
|
if amod.Target().NativeBridge {
|
||||||
|
// TODO: Unhardcode these rules.
|
||||||
|
guestArchStr := archStr
|
||||||
|
hostArchStr := ""
|
||||||
|
if guestArchStr == "arm" {
|
||||||
|
hostArchStr = "x86"
|
||||||
|
} else if guestArchStr == "arm64" {
|
||||||
|
hostArchStr = "x86_64"
|
||||||
|
}
|
||||||
|
|
||||||
|
if hostArchStr != "" {
|
||||||
|
a.SetString("LOCAL_MODULE_TARGET_ARCH", hostArchStr)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
a.SetString("LOCAL_MODULE_TARGET_ARCH", archStr)
|
a.SetString("LOCAL_MODULE_TARGET_ARCH", archStr)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
a.AddStrings("LOCAL_INIT_RC", amod.commonProperties.Init_rc...)
|
a.AddStrings("LOCAL_INIT_RC", amod.commonProperties.Init_rc...)
|
||||||
a.AddStrings("LOCAL_VINTF_FRAGMENTS", amod.commonProperties.Vintf_fragments...)
|
a.AddStrings("LOCAL_VINTF_FRAGMENTS", amod.commonProperties.Vintf_fragments...)
|
||||||
|
@@ -683,13 +683,25 @@ func osByName(name string) OsType {
|
|||||||
return NoOsType
|
return NoOsType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NativeBridgeSupport bool
|
||||||
|
|
||||||
|
const (
|
||||||
|
NativeBridgeDisabled NativeBridgeSupport = false
|
||||||
|
NativeBridgeEnabled NativeBridgeSupport = true
|
||||||
|
)
|
||||||
|
|
||||||
type Target struct {
|
type Target struct {
|
||||||
Os OsType
|
Os OsType
|
||||||
Arch Arch
|
Arch Arch
|
||||||
|
NativeBridge NativeBridgeSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
func (target Target) String() string {
|
func (target Target) String() string {
|
||||||
return target.Os.String() + "_" + target.Arch.String()
|
variant := ""
|
||||||
|
if target.NativeBridge {
|
||||||
|
variant = "native_bridge_"
|
||||||
|
}
|
||||||
|
return target.Os.String() + "_" + variant + target.Arch.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// archMutator splits a module into a variant for each Target requested by the module. Target selection
|
// archMutator splits a module into a variant for each Target requested by the module. Target selection
|
||||||
@@ -750,6 +762,18 @@ func archMutator(mctx BottomUpMutatorContext) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filter NativeBridge targets unless they are explicitly supported
|
||||||
|
if os == Android && !Bool(base.commonProperties.Native_bridge_supported) {
|
||||||
|
var targets []Target
|
||||||
|
for _, t := range osTargets {
|
||||||
|
if !t.NativeBridge {
|
||||||
|
targets = append(targets, t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
osTargets = targets
|
||||||
|
}
|
||||||
|
|
||||||
// only the primary arch in the recovery partition
|
// only the primary arch in the recovery partition
|
||||||
if os == Android && module.InstallInRecovery() {
|
if os == Android && module.InstallInRecovery() {
|
||||||
osTargets = []Target{osTargets[0]}
|
osTargets = []Target{osTargets[0]}
|
||||||
@@ -1378,7 +1402,8 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
targets := make(map[OsType][]Target)
|
targets := make(map[OsType][]Target)
|
||||||
var targetErr error
|
var targetErr error
|
||||||
|
|
||||||
addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi []string) {
|
addTarget := func(os OsType, archName string, archVariant, cpuVariant *string, abi []string,
|
||||||
|
nativeBridgeEnabled NativeBridgeSupport) {
|
||||||
if targetErr != nil {
|
if targetErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1393,6 +1418,7 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
Target{
|
Target{
|
||||||
Os: os,
|
Os: os,
|
||||||
Arch: arch,
|
Arch: arch,
|
||||||
|
NativeBridge: nativeBridgeEnabled,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1400,14 +1426,14 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
return nil, fmt.Errorf("No host primary architecture set")
|
return nil, fmt.Errorf("No host primary architecture set")
|
||||||
}
|
}
|
||||||
|
|
||||||
addTarget(BuildOs, *variables.HostArch, nil, nil, nil)
|
addTarget(BuildOs, *variables.HostArch, nil, nil, nil, NativeBridgeDisabled)
|
||||||
|
|
||||||
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
||||||
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil)
|
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil, NativeBridgeDisabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(config.Host_bionic) {
|
if Bool(config.Host_bionic) {
|
||||||
addTarget(LinuxBionic, "x86_64", nil, nil, nil)
|
addTarget(LinuxBionic, "x86_64", nil, nil, nil, NativeBridgeDisabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
if String(variables.CrossHost) != "" {
|
if String(variables.CrossHost) != "" {
|
||||||
@@ -1420,10 +1446,10 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
return nil, fmt.Errorf("No cross-host primary architecture set")
|
return nil, fmt.Errorf("No cross-host primary architecture set")
|
||||||
}
|
}
|
||||||
|
|
||||||
addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil)
|
addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil, NativeBridgeDisabled)
|
||||||
|
|
||||||
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
|
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
|
||||||
addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil)
|
addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil, NativeBridgeDisabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1434,18 +1460,32 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTarget(target, *variables.DeviceArch, variables.DeviceArchVariant,
|
addTarget(target, *variables.DeviceArch, variables.DeviceArchVariant,
|
||||||
variables.DeviceCpuVariant, variables.DeviceAbi)
|
variables.DeviceCpuVariant, variables.DeviceAbi, NativeBridgeDisabled)
|
||||||
|
|
||||||
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
|
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" {
|
||||||
addTarget(Android, *variables.DeviceSecondaryArch,
|
addTarget(Android, *variables.DeviceSecondaryArch,
|
||||||
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
|
variables.DeviceSecondaryArchVariant, variables.DeviceSecondaryCpuVariant,
|
||||||
variables.DeviceSecondaryAbi)
|
variables.DeviceSecondaryAbi, NativeBridgeDisabled)
|
||||||
|
|
||||||
deviceArches := targets[Android]
|
deviceArches := targets[Android]
|
||||||
if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
|
if deviceArches[0].Arch.ArchType.Multilib == deviceArches[1].Arch.ArchType.Multilib {
|
||||||
deviceArches[1].Arch.Native = false
|
deviceArches[1].Arch.Native = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if variables.NativeBridgeArch != nil && *variables.NativeBridgeArch != "" {
|
||||||
|
addTarget(Android, *variables.NativeBridgeArch,
|
||||||
|
variables.NativeBridgeArchVariant, variables.NativeBridgeCpuVariant,
|
||||||
|
variables.NativeBridgeAbi, NativeBridgeEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" &&
|
||||||
|
variables.NativeBridgeSecondaryArch != nil && *variables.NativeBridgeSecondaryArch != "" {
|
||||||
|
addTarget(Android, *variables.NativeBridgeSecondaryArch,
|
||||||
|
variables.NativeBridgeSecondaryArchVariant,
|
||||||
|
variables.NativeBridgeSecondaryCpuVariant,
|
||||||
|
variables.NativeBridgeSecondaryAbi, NativeBridgeEnabled)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetErr != nil {
|
if targetErr != nil {
|
||||||
|
@@ -234,16 +234,36 @@ func TestConfig(buildDir string, env map[string]string) Config {
|
|||||||
return Config{config}
|
return Config{config}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestArchConfigNativeBridge(buildDir string, env map[string]string) Config {
|
||||||
|
testConfig := TestConfig(buildDir, env)
|
||||||
|
config := testConfig.config
|
||||||
|
|
||||||
|
config.Targets = map[OsType][]Target{
|
||||||
|
Android: []Target{
|
||||||
|
{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled},
|
||||||
|
{Android, Arch{ArchType: X86, ArchVariant: "silvermont", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled},
|
||||||
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled},
|
||||||
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled},
|
||||||
|
},
|
||||||
|
BuildOs: []Target{
|
||||||
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled},
|
||||||
|
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
return testConfig
|
||||||
|
}
|
||||||
|
|
||||||
func TestArchConfigFuchsia(buildDir string, env map[string]string) Config {
|
func TestArchConfigFuchsia(buildDir string, env map[string]string) Config {
|
||||||
testConfig := TestConfig(buildDir, env)
|
testConfig := TestConfig(buildDir, env)
|
||||||
config := testConfig.config
|
config := testConfig.config
|
||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Fuchsia: []Target{
|
Fuchsia: []Target{
|
||||||
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Native: true}},
|
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Native: true}, NativeBridgeDisabled},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,12 +277,12 @@ func TestArchConfig(buildDir string, env map[string]string) Config {
|
|||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Android: []Target{
|
Android: []Target{
|
||||||
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}},
|
{Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled},
|
||||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled},
|
||||||
{BuildOs, Arch{ArchType: X86}},
|
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -290,6 +290,9 @@ type commonProperties struct {
|
|||||||
// Whether this module is installed to recovery partition
|
// Whether this module is installed to recovery partition
|
||||||
Recovery *bool
|
Recovery *bool
|
||||||
|
|
||||||
|
// Whether this module is built for non-native architecures (also known as native bridge binary)
|
||||||
|
Native_bridge_supported *bool `android:"arch_variant"`
|
||||||
|
|
||||||
// init.rc files to be installed if this module is installed
|
// init.rc files to be installed if this module is installed
|
||||||
Init_rc []string `android:"path"`
|
Init_rc []string `android:"path"`
|
||||||
|
|
||||||
|
@@ -165,6 +165,16 @@ type productVariables struct {
|
|||||||
DeviceSecondaryCpuVariant *string `json:",omitempty"`
|
DeviceSecondaryCpuVariant *string `json:",omitempty"`
|
||||||
DeviceSecondaryAbi []string `json:",omitempty"`
|
DeviceSecondaryAbi []string `json:",omitempty"`
|
||||||
|
|
||||||
|
NativeBridgeArch *string `json:",omitempty"`
|
||||||
|
NativeBridgeArchVariant *string `json:",omitempty"`
|
||||||
|
NativeBridgeCpuVariant *string `json:",omitempty"`
|
||||||
|
NativeBridgeAbi []string `json:",omitempty"`
|
||||||
|
|
||||||
|
NativeBridgeSecondaryArch *string `json:",omitempty"`
|
||||||
|
NativeBridgeSecondaryArchVariant *string `json:",omitempty"`
|
||||||
|
NativeBridgeSecondaryCpuVariant *string `json:",omitempty"`
|
||||||
|
NativeBridgeSecondaryAbi []string `json:",omitempty"`
|
||||||
|
|
||||||
HostArch *string `json:",omitempty"`
|
HostArch *string `json:",omitempty"`
|
||||||
HostSecondaryArch *string `json:",omitempty"`
|
HostSecondaryArch *string `json:",omitempty"`
|
||||||
|
|
||||||
|
2
cc/cc.go
2
cc/cc.go
@@ -1804,6 +1804,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||||||
return libName + vendorPublicLibrarySuffix
|
return libName + vendorPublicLibrarySuffix
|
||||||
} else if ccDep.inRecovery() && !ccDep.onlyInRecovery() {
|
} else if ccDep.inRecovery() && !ccDep.onlyInRecovery() {
|
||||||
return libName + recoverySuffix
|
return libName + recoverySuffix
|
||||||
|
} else if ccDep.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||||
|
return libName + android.NativeBridgeSuffix
|
||||||
} else {
|
} else {
|
||||||
return libName
|
return libName
|
||||||
}
|
}
|
||||||
|
@@ -66,7 +66,7 @@ func (installer *baseInstaller) installDir(ctx ModuleContext) android.OutputPath
|
|||||||
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
if ctx.toolchain().Is64Bit() && installer.dir64 != "" {
|
||||||
dir = installer.dir64
|
dir = installer.dir64
|
||||||
}
|
}
|
||||||
if !ctx.Host() && !ctx.Arch().Native {
|
if (!ctx.Host() && !ctx.Arch().Native) || ctx.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||||
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
||||||
}
|
}
|
||||||
if installer.location == InstallInData && ctx.useVndk() {
|
if installer.location == InstallInData && ctx.useVndk() {
|
||||||
|
@@ -111,8 +111,10 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
|
|||||||
if len(archs) == 0 {
|
if len(archs) == 0 {
|
||||||
// assume this is a java library, dexpreopt for all arches for now
|
// assume this is a java library, dexpreopt for all arches for now
|
||||||
for _, target := range ctx.Config().Targets[android.Android] {
|
for _, target := range ctx.Config().Targets[android.Android] {
|
||||||
|
if target.NativeBridge == android.NativeBridgeDisabled {
|
||||||
archs = append(archs, target.Arch.ArchType)
|
archs = append(archs, target.Arch.ArchType)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if inList(ctx.ModuleName(), global.SystemServerJars) && !d.isSDKLibrary {
|
if inList(ctx.ModuleName(), global.SystemServerJars) && !d.isSDKLibrary {
|
||||||
// If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
|
// If the module is not an SDK library and it's a system server jar, only preopt the primary arch.
|
||||||
archs = archs[:1]
|
archs = archs[:1]
|
||||||
|
@@ -197,10 +197,12 @@ func buildBootImage(ctx android.SingletonContext, config bootImageConfig) *bootI
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, target := range targets {
|
for _, target := range targets {
|
||||||
|
if target.NativeBridge == android.NativeBridgeDisabled {
|
||||||
files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
|
files := buildBootImageRuleForArch(ctx, image, target.Arch.ArchType, profile, missingDeps)
|
||||||
allFiles = append(allFiles, files.Paths()...)
|
allFiles = append(allFiles, files.Paths()...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if image.zip != nil {
|
if image.zip != nil {
|
||||||
rule := android.NewRuleBuilder()
|
rule := android.NewRuleBuilder()
|
||||||
|
Reference in New Issue
Block a user