Merge "Make relative path for native_bridge binaries configurable"
This commit is contained in:
@@ -191,15 +191,7 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
|||||||
// 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 {
|
if amod.Target().NativeBridge {
|
||||||
// TODO: Unhardcode these rules.
|
hostArchStr := amod.Target().NativeBridgeHostArchName
|
||||||
guestArchStr := archStr
|
|
||||||
hostArchStr := ""
|
|
||||||
if guestArchStr == "arm" {
|
|
||||||
hostArchStr = "x86"
|
|
||||||
} else if guestArchStr == "arm64" {
|
|
||||||
hostArchStr = "x86_64"
|
|
||||||
}
|
|
||||||
|
|
||||||
if hostArchStr != "" {
|
if hostArchStr != "" {
|
||||||
a.SetString("LOCAL_MODULE_TARGET_ARCH", hostArchStr)
|
a.SetString("LOCAL_MODULE_TARGET_ARCH", hostArchStr)
|
||||||
}
|
}
|
||||||
|
@@ -694,6 +694,8 @@ type Target struct {
|
|||||||
Os OsType
|
Os OsType
|
||||||
Arch Arch
|
Arch Arch
|
||||||
NativeBridge NativeBridgeSupport
|
NativeBridge NativeBridgeSupport
|
||||||
|
NativeBridgeHostArchName string
|
||||||
|
NativeBridgeRelativePath string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (target Target) String() string {
|
func (target Target) String() string {
|
||||||
@@ -1403,7 +1405,8 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
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) {
|
nativeBridgeEnabled NativeBridgeSupport, nativeBridgeHostArchName *string,
|
||||||
|
nativeBridgeRelativePath *string) {
|
||||||
if targetErr != nil {
|
if targetErr != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1413,12 +1416,21 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
targetErr = err
|
targetErr = err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
nativeBridgeRelativePathStr := String(nativeBridgeRelativePath)
|
||||||
|
nativeBridgeHostArchNameStr := String(nativeBridgeHostArchName)
|
||||||
|
|
||||||
|
// Use guest arch as relative install path by default
|
||||||
|
if nativeBridgeEnabled && nativeBridgeRelativePathStr == "" {
|
||||||
|
nativeBridgeRelativePathStr = arch.ArchType.String()
|
||||||
|
}
|
||||||
|
|
||||||
targets[os] = append(targets[os],
|
targets[os] = append(targets[os],
|
||||||
Target{
|
Target{
|
||||||
Os: os,
|
Os: os,
|
||||||
Arch: arch,
|
Arch: arch,
|
||||||
NativeBridge: nativeBridgeEnabled,
|
NativeBridge: nativeBridgeEnabled,
|
||||||
|
NativeBridgeHostArchName: nativeBridgeHostArchNameStr,
|
||||||
|
NativeBridgeRelativePath: nativeBridgeRelativePathStr,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1426,14 +1438,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, NativeBridgeDisabled)
|
addTarget(BuildOs, *variables.HostArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
|
|
||||||
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
if variables.HostSecondaryArch != nil && *variables.HostSecondaryArch != "" {
|
||||||
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil, NativeBridgeDisabled)
|
addTarget(BuildOs, *variables.HostSecondaryArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(config.Host_bionic) {
|
if Bool(config.Host_bionic) {
|
||||||
addTarget(LinuxBionic, "x86_64", nil, nil, nil, NativeBridgeDisabled)
|
addTarget(LinuxBionic, "x86_64", nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
if String(variables.CrossHost) != "" {
|
if String(variables.CrossHost) != "" {
|
||||||
@@ -1446,10 +1458,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, NativeBridgeDisabled)
|
addTarget(crossHostOs, *variables.CrossHostArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
|
|
||||||
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
|
if variables.CrossHostSecondaryArch != nil && *variables.CrossHostSecondaryArch != "" {
|
||||||
addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil, NativeBridgeDisabled)
|
addTarget(crossHostOs, *variables.CrossHostSecondaryArch, nil, nil, nil, NativeBridgeDisabled, nil, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1460,12 +1472,12 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addTarget(target, *variables.DeviceArch, variables.DeviceArchVariant,
|
addTarget(target, *variables.DeviceArch, variables.DeviceArchVariant,
|
||||||
variables.DeviceCpuVariant, variables.DeviceAbi, NativeBridgeDisabled)
|
variables.DeviceCpuVariant, variables.DeviceAbi, NativeBridgeDisabled, nil, nil)
|
||||||
|
|
||||||
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, NativeBridgeDisabled)
|
variables.DeviceSecondaryAbi, NativeBridgeDisabled, nil, nil)
|
||||||
|
|
||||||
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 {
|
||||||
@@ -1476,7 +1488,8 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
if variables.NativeBridgeArch != nil && *variables.NativeBridgeArch != "" {
|
if variables.NativeBridgeArch != nil && *variables.NativeBridgeArch != "" {
|
||||||
addTarget(Android, *variables.NativeBridgeArch,
|
addTarget(Android, *variables.NativeBridgeArch,
|
||||||
variables.NativeBridgeArchVariant, variables.NativeBridgeCpuVariant,
|
variables.NativeBridgeArchVariant, variables.NativeBridgeCpuVariant,
|
||||||
variables.NativeBridgeAbi, NativeBridgeEnabled)
|
variables.NativeBridgeAbi, NativeBridgeEnabled, variables.DeviceArch,
|
||||||
|
variables.NativeBridgeRelativePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" &&
|
if variables.DeviceSecondaryArch != nil && *variables.DeviceSecondaryArch != "" &&
|
||||||
@@ -1484,7 +1497,10 @@ func decodeTargetProductVariables(config *config) (map[OsType][]Target, error) {
|
|||||||
addTarget(Android, *variables.NativeBridgeSecondaryArch,
|
addTarget(Android, *variables.NativeBridgeSecondaryArch,
|
||||||
variables.NativeBridgeSecondaryArchVariant,
|
variables.NativeBridgeSecondaryArchVariant,
|
||||||
variables.NativeBridgeSecondaryCpuVariant,
|
variables.NativeBridgeSecondaryCpuVariant,
|
||||||
variables.NativeBridgeSecondaryAbi, NativeBridgeEnabled)
|
variables.NativeBridgeSecondaryAbi,
|
||||||
|
NativeBridgeEnabled,
|
||||||
|
variables.DeviceSecondaryArch,
|
||||||
|
variables.NativeBridgeSecondaryRelativePath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -240,10 +240,10 @@ func TestArchConfigNativeBridge(buildDir string, env map[string]string) Config {
|
|||||||
config := testConfig.config
|
config := testConfig.config
|
||||||
|
|
||||||
config.Targets[Android] = []Target{
|
config.Targets[Android] = []Target{
|
||||||
{Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled},
|
{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: 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: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled, "x86_64", "arm64"},
|
||||||
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled, "x86", "arm"},
|
||||||
}
|
}
|
||||||
|
|
||||||
return testConfig
|
return testConfig
|
||||||
@@ -255,10 +255,10 @@ func TestArchConfigFuchsia(buildDir string, env map[string]string) Config {
|
|||||||
|
|
||||||
config.Targets = map[OsType][]Target{
|
config.Targets = map[OsType][]Target{
|
||||||
Fuchsia: []Target{
|
Fuchsia: []Target{
|
||||||
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Native: true}, NativeBridgeDisabled},
|
{Fuchsia, Arch{ArchType: Arm64, ArchVariant: "", Native: true}, NativeBridgeDisabled, "", ""},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,12 +272,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"}}, NativeBridgeDisabled},
|
{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"}}, NativeBridgeDisabled},
|
{Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled, "", ""},
|
||||||
},
|
},
|
||||||
BuildOs: []Target{
|
BuildOs: []Target{
|
||||||
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled},
|
{BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled, "", ""},
|
||||||
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled},
|
{BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled, "", ""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -169,11 +169,13 @@ type productVariables struct {
|
|||||||
NativeBridgeArchVariant *string `json:",omitempty"`
|
NativeBridgeArchVariant *string `json:",omitempty"`
|
||||||
NativeBridgeCpuVariant *string `json:",omitempty"`
|
NativeBridgeCpuVariant *string `json:",omitempty"`
|
||||||
NativeBridgeAbi []string `json:",omitempty"`
|
NativeBridgeAbi []string `json:",omitempty"`
|
||||||
|
NativeBridgeRelativePath *string `json:",omitempty"`
|
||||||
|
|
||||||
NativeBridgeSecondaryArch *string `json:",omitempty"`
|
NativeBridgeSecondaryArch *string `json:",omitempty"`
|
||||||
NativeBridgeSecondaryArchVariant *string `json:",omitempty"`
|
NativeBridgeSecondaryArchVariant *string `json:",omitempty"`
|
||||||
NativeBridgeSecondaryCpuVariant *string `json:",omitempty"`
|
NativeBridgeSecondaryCpuVariant *string `json:",omitempty"`
|
||||||
NativeBridgeSecondaryAbi []string `json:",omitempty"`
|
NativeBridgeSecondaryAbi []string `json:",omitempty"`
|
||||||
|
NativeBridgeSecondaryRelativePath *string `json:",omitempty"`
|
||||||
|
|
||||||
HostArch *string `json:",omitempty"`
|
HostArch *string `json:",omitempty"`
|
||||||
HostSecondaryArch *string `json:",omitempty"`
|
HostSecondaryArch *string `json:",omitempty"`
|
||||||
|
@@ -656,8 +656,10 @@ func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fil
|
|||||||
dirInApex = "lib64"
|
dirInApex = "lib64"
|
||||||
}
|
}
|
||||||
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
|
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
|
||||||
if cc.Target().NativeBridge == android.NativeBridgeEnabled || !cc.Arch().Native {
|
if !cc.Arch().Native {
|
||||||
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
|
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
|
||||||
|
} else if cc.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||||
|
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
|
||||||
}
|
}
|
||||||
if handleSpecialLibs {
|
if handleSpecialLibs {
|
||||||
switch cc.Name() {
|
switch cc.Name() {
|
||||||
@@ -681,8 +683,10 @@ func getCopyManifestForNativeLibrary(cc *cc.Module, handleSpecialLibs bool) (fil
|
|||||||
|
|
||||||
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
|
func getCopyManifestForExecutable(cc *cc.Module) (fileToCopy android.Path, dirInApex string) {
|
||||||
dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
|
dirInApex = filepath.Join("bin", cc.RelativeInstallPath())
|
||||||
if cc.Target().NativeBridge == android.NativeBridgeEnabled || !cc.Arch().Native {
|
if !cc.Arch().Native {
|
||||||
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
|
dirInApex = filepath.Join(dirInApex, cc.Arch().ArchType.String())
|
||||||
|
} else if cc.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||||
|
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
|
||||||
}
|
}
|
||||||
fileToCopy = cc.OutputFile().Path()
|
fileToCopy = cc.OutputFile().Path()
|
||||||
return
|
return
|
||||||
|
@@ -66,9 +66,12 @@ 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) || ctx.Target().NativeBridge == android.NativeBridgeEnabled {
|
if !ctx.Host() && !ctx.Arch().Native {
|
||||||
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
dir = filepath.Join(dir, ctx.Arch().ArchType.String())
|
||||||
}
|
}
|
||||||
|
if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||||
|
dir = filepath.Join(dir, ctx.Target().NativeBridgeRelativePath)
|
||||||
|
}
|
||||||
if installer.location == InstallInData && ctx.useVndk() {
|
if installer.location == InstallInData && ctx.useVndk() {
|
||||||
dir = filepath.Join(dir, "vendor")
|
dir = filepath.Join(dir, "vendor")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user