diff options
| -rw-r--r-- | cc/ndk_library.go | 98 |
1 files changed, 56 insertions, 42 deletions
diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 01551ab49..0db5b7614 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -144,11 +144,9 @@ func (stub *stubDecorator) implementationModuleName(name string) string { } func ndkLibraryVersions(ctx android.BaseModuleContext, from android.ApiLevel) []string { - var versions []android.ApiLevel versionStrs := []string{} - for _, version := range ctx.Config().AllSupportedApiLevels() { + for _, version := range ctx.Config().FinalApiLevels() { if version.GreaterThanOrEqualTo(from) { - versions = append(versions, version) versionStrs = append(versionStrs, version.String()) } } @@ -330,6 +328,12 @@ func (this *stubDecorator) findPrebuiltAbiDump(ctx ModuleContext, return android.ExistentPathForSource(ctx, subpath) } +func (this *stubDecorator) builtAbiDumpLocation(ctx ModuleContext, apiLevel android.ApiLevel) android.OutputPath { + return getNdkAbiDumpInstallBase(ctx).Join(ctx, + apiLevel.String(), ctx.Arch().ArchType.String(), + this.libraryName(ctx), "abi.stg") +} + // Feature flag. func (this *stubDecorator) canDumpAbi(ctx ModuleContext) bool { if runtime.GOOS == "darwin" { @@ -345,25 +349,24 @@ func (this *stubDecorator) canDumpAbi(ctx ModuleContext) bool { return false } - if this.apiLevel.IsCurrent() { - // "current" (AKA 10000) is not tracked. - return false - } - // http://b/156513478 return ctx.Config().ReleaseNdkAbiMonitored() } // Feature flag to disable diffing against prebuilts. -func canDiffAbi(config android.Config) bool { +func (this *stubDecorator) canDiffAbi(config android.Config) bool { + if this.apiLevel.IsCurrent() { + // Diffs are performed from this to next, and there's nothing after + // current. + return false + } + return config.ReleaseNdkAbiMonitored() } func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) { implementationLibrary := this.findImplementationLibrary(ctx) - this.abiDumpPath = getNdkAbiDumpInstallBase(ctx).Join(ctx, - this.apiLevel.String(), ctx.Arch().ArchType.String(), - this.libraryName(ctx), "abi.stg") + this.abiDumpPath = this.builtAbiDumpLocation(ctx, this.apiLevel) this.hasAbiDump = true headersList := getNdkABIHeadersFile(ctx) ctx.Build(pctx, android.BuildParams{ @@ -383,7 +386,7 @@ func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) { } func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.ApiLevel { - apiLevels := append(ctx.Config().AllSupportedApiLevels(), + apiLevels := append(ctx.Config().FinalApiLevels(), android.FutureApiLevel) for _, api := range apiLevels { if api.GreaterThan(apiLevel) { @@ -436,38 +439,49 @@ func (this *stubDecorator) diffAbi(ctx ModuleContext) { "non-current API level %s", this.apiLevel)) } - // "current" ABI is not tracked. - if !nextApiLevel.IsCurrent() { - nextAbiDiffPath := android.PathForModuleOut(ctx, - "abidiff_next.timestamp") - nextAbiDump := this.findPrebuiltAbiDump(ctx, *nextApiLevel) + // Preview ABI levels are not recording in prebuilts. ABI compatibility + // for preview APIs is still monitored via "current" so we have early + // warning rather than learning about an ABI break during finalization, + // but is only checked against the "current" API dumps in the out + // directory. + nextAbiDiffPath := android.PathForModuleOut(ctx, + "abidiff_next.timestamp") + + var nextAbiDump android.OptionalPath + if nextApiLevel.IsCurrent() { + nextAbiDump = android.OptionalPathForPath( + this.builtAbiDumpLocation(ctx, *nextApiLevel), + ) + } else { + nextAbiDump = this.findPrebuiltAbiDump(ctx, *nextApiLevel) + } + + if !nextAbiDump.Valid() { missingNextPrebuiltError := fmt.Sprintf( missingPrebuiltErrorTemplate, this.libraryName(ctx), nextAbiDump.InvalidReason()) - if !nextAbiDump.Valid() { - ctx.Build(pctx, android.BuildParams{ - Rule: android.ErrorRule, - Output: nextAbiDiffPath, - Args: map[string]string{ - "error": missingNextPrebuiltError, - }, - }) - } else { - ctx.Build(pctx, android.BuildParams{ - Rule: stgdiff, - Description: fmt.Sprintf( - "Comparing ABI to the next API level %s %s", - prebuiltAbiDump, nextAbiDump), - Output: nextAbiDiffPath, - Inputs: android.Paths{ - prebuiltAbiDump.Path(), nextAbiDump.Path()}, - Args: map[string]string{ - "args": "--format=small --ignore=interface_addition", - }, - }) - } - this.abiDiffPaths = append(this.abiDiffPaths, nextAbiDiffPath) + ctx.Build(pctx, android.BuildParams{ + Rule: android.ErrorRule, + Output: nextAbiDiffPath, + Args: map[string]string{ + "error": missingNextPrebuiltError, + }, + }) + } else { + ctx.Build(pctx, android.BuildParams{ + Rule: stgdiff, + Description: fmt.Sprintf( + "Comparing ABI to the next API level %s %s", + prebuiltAbiDump, nextAbiDump), + Output: nextAbiDiffPath, + Inputs: android.Paths{ + prebuiltAbiDump.Path(), nextAbiDump.Path()}, + Args: map[string]string{ + "args": "--format=small --ignore=interface_addition", + }, + }) } + this.abiDiffPaths = append(this.abiDiffPaths, nextAbiDiffPath) } } @@ -492,7 +506,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O c.versionScriptPath = nativeAbiResult.versionScript if c.canDumpAbi(ctx) { c.dumpAbi(ctx, nativeAbiResult.symbolList) - if canDiffAbi(ctx.Config()) { + if c.canDiffAbi(ctx.Config()) { c.diffAbi(ctx) } } |