From 2c8075cd6fc9cf3e7347e1747e751389c8d148e5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 16 Feb 2022 21:53:13 -0800 Subject: [PATCH] Add an __ANDROID_RAMDISK__ preprocessor define. There is no easy way to inform C++ targets whether they're building "not in normal Android". In the past we used __ANDROID_RECOVERY__, but this isn't defined for ramdisk targets, or for vendor_boot. Furthermore there's no "target.ramdisk.cflags" option to add it. Add a new __ANDROID_RAMDISK__ define that will be set in any ramdisk or recovery target (since recovery by definition is in a ramdisk). Bug: 205987817 Test: mm bootimage, vendorbootimage, recovery Change-Id: If3cd34b07fe0e20abc5108cb338a56698d33e42e --- cc/compiler.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cc/compiler.go b/cc/compiler.go index 2e62b0002..dca6a3c96 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -403,6 +403,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RECOVERY__") } + if ctx.inRecovery() || ctx.inRamdisk() || ctx.inVendorRamdisk() { + flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RAMDISK__") + } + if ctx.apexVariationName() != "" { flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__") if ctx.Device() {