Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d36865d9 authored by Dan Albert's avatar Dan Albert Committed by Gerrit Code Review
Browse files

Merge "Stop dumping/diffing preview ABIs." into main

parents f5755e17 499c92ea
Loading
Loading
Loading
Loading
+56 −42
Original line number Diff line number Diff line
@@ -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,15 +439,27 @@ func (this *stubDecorator) diffAbi(ctx ModuleContext) {
				"non-current API level %s", this.apiLevel))
		}

		// "current" ABI is not tracked.
		if !nextApiLevel.IsCurrent() {
		// 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")
			nextAbiDump := this.findPrebuiltAbiDump(ctx, *nextApiLevel)

		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,
@@ -469,7 +484,6 @@ func (this *stubDecorator) diffAbi(ctx ModuleContext) {
		this.abiDiffPaths = append(this.abiDiffPaths, nextAbiDiffPath)
	}
}
}

func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
	if !strings.HasSuffix(String(c.properties.Symbol_file), ".map.txt") {
@@ -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)
		}
	}