Merge changes Ideaa9908,Ie45cb7da into main
* changes: NDK library: extract ABI representations with STG NDK library: switch abi diffing to STG
This commit is contained in:
@@ -31,9 +31,9 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pctx.HostBinToolVariable("ndkStubGenerator", "ndkstubgen")
|
pctx.HostBinToolVariable("ndkStubGenerator", "ndkstubgen")
|
||||||
pctx.HostBinToolVariable("abidiff", "abidiff")
|
|
||||||
pctx.HostBinToolVariable("abidw", "abidw")
|
pctx.HostBinToolVariable("abidw", "abidw")
|
||||||
pctx.HostBinToolVariable("stg", "stg")
|
pctx.HostBinToolVariable("stg", "stg")
|
||||||
|
pctx.HostBinToolVariable("stgdiff", "stgdiff")
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -44,6 +44,7 @@ var (
|
|||||||
CommandDeps: []string{"$ndkStubGenerator"},
|
CommandDeps: []string{"$ndkStubGenerator"},
|
||||||
}, "arch", "apiLevel", "apiMap", "flags")
|
}, "arch", "apiLevel", "apiMap", "flags")
|
||||||
|
|
||||||
|
// TODO(b/156513478): remove once migration to STG is complete
|
||||||
abidw = pctx.AndroidStaticRule("abidw",
|
abidw = pctx.AndroidStaticRule("abidw",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$abidw --type-id-style hash --no-corpus-path " +
|
Command: "$abidw --type-id-style hash --no-corpus-path " +
|
||||||
@@ -52,20 +53,27 @@ var (
|
|||||||
CommandDeps: []string{"$abidw"},
|
CommandDeps: []string{"$abidw"},
|
||||||
}, "symbolList")
|
}, "symbolList")
|
||||||
|
|
||||||
|
stg = pctx.AndroidStaticRule("stg",
|
||||||
|
blueprint.RuleParams{
|
||||||
|
Command: "$stg -S :$symbolList --elf $in -o $out",
|
||||||
|
CommandDeps: []string{"$stg"},
|
||||||
|
}, "symbolList")
|
||||||
|
|
||||||
|
// TODO(b/156513478): remove once migration to STG is complete
|
||||||
xml2stg = pctx.AndroidStaticRule("xml2stg",
|
xml2stg = pctx.AndroidStaticRule("xml2stg",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Command: "$stg --abi -i $in -o $out",
|
Command: "$stg --abi -i $in -o $out",
|
||||||
CommandDeps: []string{"$stg"},
|
CommandDeps: []string{"$stg"},
|
||||||
})
|
})
|
||||||
|
|
||||||
abidiff = pctx.AndroidStaticRule("abidiff",
|
stgdiff = pctx.AndroidStaticRule("stgdiff",
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
// Need to create *some* output for ninja. We don't want to use tee
|
// Need to create *some* output for ninja. We don't want to use tee
|
||||||
// because we don't want to spam the build output with "nothing
|
// because we don't want to spam the build output with "nothing
|
||||||
// changed" messages, so redirect output message to $out, and if
|
// changed" messages, so redirect output message to $out, and if
|
||||||
// changes were detected print the output and fail.
|
// changes were detected print the output and fail.
|
||||||
Command: "$abidiff $args $in > $out || (cat $out && false)",
|
Command: "$stgdiff $args --stg $in -o $out || (cat $out && false)",
|
||||||
CommandDeps: []string{"$abidiff"},
|
CommandDeps: []string{"$stgdiff"},
|
||||||
}, "args")
|
}, "args")
|
||||||
|
|
||||||
ndkLibrarySuffix = ".ndk"
|
ndkLibrarySuffix = ".ndk"
|
||||||
@@ -109,6 +117,10 @@ type libraryProperties struct {
|
|||||||
|
|
||||||
// Headers presented by this library to the Public API Surface
|
// Headers presented by this library to the Public API Surface
|
||||||
Export_header_libs []string
|
Export_header_libs []string
|
||||||
|
|
||||||
|
// TODO(b/156513478): remove once migration to STG is complete
|
||||||
|
// Fall back to the legacy abidw ABI extraction pipeline
|
||||||
|
Legacy_use_abidw *bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type stubDecorator struct {
|
type stubDecorator struct {
|
||||||
@@ -351,7 +363,8 @@ func canDiffAbi() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) {
|
// TODO(b/156513478): remove once migration to STG is complete
|
||||||
|
func (this *stubDecorator) dumpAbiLegacy(ctx ModuleContext, symbolList android.Path) {
|
||||||
implementationLibrary := this.findImplementationLibrary(ctx)
|
implementationLibrary := this.findImplementationLibrary(ctx)
|
||||||
abiRawPath := getNdkAbiDumpInstallBase(ctx).Join(ctx,
|
abiRawPath := getNdkAbiDumpInstallBase(ctx).Join(ctx,
|
||||||
this.apiLevel.String(), ctx.Arch().ArchType.String(),
|
this.apiLevel.String(), ctx.Arch().ArchType.String(),
|
||||||
@@ -378,6 +391,23 @@ func (this *stubDecorator) dumpAbi(ctx ModuleContext, symbolList android.Path) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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")
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: stg,
|
||||||
|
Description: fmt.Sprintf("stg %s", implementationLibrary),
|
||||||
|
Input: implementationLibrary,
|
||||||
|
Implicit: symbolList,
|
||||||
|
Output: this.abiDumpPath,
|
||||||
|
Args: map[string]string{
|
||||||
|
"symbolList": symbolList.String(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.ApiLevel {
|
func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.ApiLevel {
|
||||||
apiLevels := append(ctx.Config().AllSupportedApiLevels(),
|
apiLevels := append(ctx.Config().AllSupportedApiLevels(),
|
||||||
android.FutureApiLevel)
|
android.FutureApiLevel)
|
||||||
@@ -392,7 +422,7 @@ func findNextApiLevel(ctx ModuleContext, apiLevel android.ApiLevel) *android.Api
|
|||||||
func (this *stubDecorator) diffAbi(ctx ModuleContext) {
|
func (this *stubDecorator) diffAbi(ctx ModuleContext) {
|
||||||
// Catch any ABI changes compared to the checked-in definition of this API
|
// Catch any ABI changes compared to the checked-in definition of this API
|
||||||
// level.
|
// level.
|
||||||
abiDiffPath := android.PathForModuleOut(ctx, "abidiff.timestamp")
|
abiDiffPath := android.PathForModuleOut(ctx, "stgdiff.timestamp")
|
||||||
prebuiltAbiDump := this.findPrebuiltAbiDump(ctx, this.apiLevel)
|
prebuiltAbiDump := this.findPrebuiltAbiDump(ctx, this.apiLevel)
|
||||||
missingPrebuiltError := fmt.Sprintf(
|
missingPrebuiltError := fmt.Sprintf(
|
||||||
"Did not find prebuilt ABI dump for %q (%q). Generate with "+
|
"Did not find prebuilt ABI dump for %q (%q). Generate with "+
|
||||||
@@ -408,11 +438,14 @@ func (this *stubDecorator) diffAbi(ctx ModuleContext) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: abidiff,
|
Rule: stgdiff,
|
||||||
Description: fmt.Sprintf("abidiff %s %s", prebuiltAbiDump,
|
Description: fmt.Sprintf("Comparing ABI %s %s", prebuiltAbiDump,
|
||||||
this.abiDumpPath),
|
this.abiDumpPath),
|
||||||
Output: abiDiffPath,
|
Output: abiDiffPath,
|
||||||
Inputs: android.Paths{prebuiltAbiDump.Path(), this.abiDumpPath},
|
Inputs: android.Paths{prebuiltAbiDump.Path(), this.abiDumpPath},
|
||||||
|
Args: map[string]string{
|
||||||
|
"args": "--format=small",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.abiDiffPaths = append(this.abiDiffPaths, abiDiffPath)
|
this.abiDiffPaths = append(this.abiDiffPaths, abiDiffPath)
|
||||||
@@ -439,13 +472,13 @@ func (this *stubDecorator) diffAbi(ctx ModuleContext) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: abidiff,
|
Rule: stgdiff,
|
||||||
Description: fmt.Sprintf("abidiff %s %s", this.abiDumpPath,
|
Description: fmt.Sprintf("abidiff %s %s", this.abiDumpPath,
|
||||||
nextAbiDump),
|
nextAbiDump),
|
||||||
Output: nextAbiDiffPath,
|
Output: nextAbiDiffPath,
|
||||||
Inputs: android.Paths{this.abiDumpPath, nextAbiDump.Path()},
|
Inputs: android.Paths{this.abiDumpPath, nextAbiDump.Path()},
|
||||||
Args: map[string]string{
|
Args: map[string]string{
|
||||||
"args": "--no-added-syms",
|
"args": "--format=small --ignore=interface_addition",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -473,7 +506,11 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
|
|||||||
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
|
objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
|
||||||
c.versionScriptPath = nativeAbiResult.versionScript
|
c.versionScriptPath = nativeAbiResult.versionScript
|
||||||
if canDumpAbi(ctx.Config()) {
|
if canDumpAbi(ctx.Config()) {
|
||||||
|
if proptools.BoolDefault(c.properties.Legacy_use_abidw, false) {
|
||||||
|
c.dumpAbiLegacy(ctx, nativeAbiResult.symbolList)
|
||||||
|
} else {
|
||||||
c.dumpAbi(ctx, nativeAbiResult.symbolList)
|
c.dumpAbi(ctx, nativeAbiResult.symbolList)
|
||||||
|
}
|
||||||
if canDiffAbi() {
|
if canDiffAbi() {
|
||||||
c.diffAbi(ctx)
|
c.diffAbi(ctx)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user