Add __ANDROID_APEX_<NAME>__ for apex variants
With __ANDROID_APEX_<NAME>__ definition, native modules may have different behavior when it is built for a specific apex module. Previously, the name is passed as value of definition __ANDROID_APEX__ like -D__ANDROID_APEX__=com.android.foo. But it is difficult to do conditional compilation with it. Now, since the name is incorporated into definition itself, it gets easier to set #ifdef condition. Bug: 142582178 Test: m (soong test added) Change-Id: I3c90c789fa692a19addf2e5a7c8d4cc571cde112
This commit is contained in:
@@ -321,7 +321,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
||||
}
|
||||
|
||||
if ctx.apexName() != "" {
|
||||
// TODO(b/142582178): remove the value for __ANDROID_APEX__
|
||||
flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_APEX__="+ctx.apexName())
|
||||
flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexName())+"__")
|
||||
}
|
||||
|
||||
instructionSet := String(compiler.Properties.Instruction_set)
|
||||
@@ -529,6 +531,12 @@ func (compiler *baseCompiler) hasSrcExt(ext string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// makeDefineString transforms a name of an APEX module into a value to be used as value for C define
|
||||
// For example, com.android.foo => COM_ANDROID_FOO
|
||||
func makeDefineString(name string) string {
|
||||
return strings.ReplaceAll(strings.ToUpper(name), ".", "_")
|
||||
}
|
||||
|
||||
var gnuToCReplacer = strings.NewReplacer("gnu", "c")
|
||||
|
||||
func ndkPathDeps(ctx ModuleContext) android.Paths {
|
||||
|
Reference in New Issue
Block a user