Special case the stubgen args for bionic libs
IsNdk and NotInPlatform can return incorrect values in minimal branches
that do not contain the source bionic libraries. (e.g. in
aosp-master-art)
Bug: 275273834
Test: presbumits (which will build aosp-master-art)
Change-Id: I5e9216a40c0fd2d077bb6c53ba6628e311d99737
diff --git a/cc/library.go b/cc/library.go
index fef83f6..011de36 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -676,6 +676,15 @@
!strings.Contains(ctx.ModuleName(), "libclang_rt") {
flag = flag + " --no-ndk"
}
+ // TODO(b/361303067): Remove this special case if bionic/ projects are added to ART development branches.
+ if isBionic(ctx.baseModuleName()) {
+ // set the flags explicitly for bionic libs.
+ // this is necessary for development in minimal branches which does not contain bionic/*.
+ // In such minimal branches, e.g. on the prebuilt libc stubs
+ // 1. IsNdk will return false (since the ndk_library definition for libc does not exist)
+ // 2. NotInPlatform will return true (since the source com.android.runtime does not exist)
+ flag = "--apex"
+ }
nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile,
android.ApiLevelOrPanic(ctx, library.MutatedProperties.StubsVersion), flag)
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)