Merge "Add -D__ANDROID_NATIVE_BRIDGE__ to native_bridge targets"

This commit is contained in:
Victor Khimenko
2020-09-17 19:09:03 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 30 deletions

View File

@@ -1434,20 +1434,15 @@ func (m *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
// key: value, // key: value,
// }, // },
// }, // },
// TODO(ccross): is this still necessary with native bridge?
if os.Class == Device { if os.Class == Device {
if (arch.ArchType == X86 && (hasArmAbi(arch) || if arch.ArchType == X86 && (hasArmAbi(arch) ||
hasArmAndroidArch(ctx.Config().Targets[Android]))) || hasArmAndroidArch(ctx.Config().Targets[Android])) {
(arch.ArchType == Arm &&
hasX86AndroidArch(ctx.Config().Targets[Android])) {
field := "Arm_on_x86" field := "Arm_on_x86"
prefix := "target.arm_on_x86" prefix := "target.arm_on_x86"
m.appendProperties(ctx, genProps, targetProp, field, prefix) m.appendProperties(ctx, genProps, targetProp, field, prefix)
} }
if (arch.ArchType == X86_64 && (hasArmAbi(arch) || if arch.ArchType == X86_64 && (hasArmAbi(arch) ||
hasArmAndroidArch(ctx.Config().Targets[Android]))) || hasArmAndroidArch(ctx.Config().Targets[Android])) {
(arch.ArchType == Arm &&
hasX8664AndroidArch(ctx.Config().Targets[Android])) {
field := "Arm_on_x86_64" field := "Arm_on_x86_64"
prefix := "target.arm_on_x86_64" prefix := "target.arm_on_x86_64"
m.appendProperties(ctx, genProps, targetProp, field, prefix) m.appendProperties(ctx, genProps, targetProp, field, prefix)
@@ -1594,27 +1589,7 @@ func hasArmAbi(arch Arch) bool {
// hasArmArch returns true if targets has at least non-native_bridge arm Android arch // hasArmArch returns true if targets has at least non-native_bridge arm Android arch
func hasArmAndroidArch(targets []Target) bool { func hasArmAndroidArch(targets []Target) bool {
for _, target := range targets { for _, target := range targets {
if target.Os == Android && target.Arch.ArchType == Arm && target.NativeBridge == NativeBridgeDisabled { if target.Os == Android && target.Arch.ArchType == Arm {
return true
}
}
return false
}
// hasX86Arch returns true if targets has at least x86 Android arch
func hasX86AndroidArch(targets []Target) bool {
for _, target := range targets {
if target.Os == Android && target.Arch.ArchType == X86 {
return true
}
}
return false
}
// hasX8664Arch returns true if targets has at least x86_64 Android arch
func hasX8664AndroidArch(targets []Target) bool {
for _, target := range targets {
if target.Os == Android && target.Arch.ArchType == X86_64 {
return true return true
} }
} }

View File

@@ -358,6 +358,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
} }
} }
if ctx.Target().NativeBridge == android.NativeBridgeEnabled {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_NATIVE_BRIDGE__")
}
instructionSet := String(compiler.Properties.Instruction_set) instructionSet := String(compiler.Properties.Instruction_set)
if flags.RequiredInstructionSet != "" { if flags.RequiredInstructionSet != "" {
instructionSet = flags.RequiredInstructionSet instructionSet = flags.RequiredInstructionSet