Merge "Stripped rust bin/libs are included in APEX"

This commit is contained in:
Jiyong Park
2021-04-07 17:51:32 +00:00
committed by Gerrit Code Review
3 changed files with 25 additions and 16 deletions

View File

@@ -50,7 +50,7 @@ func (mod *Module) AndroidMkEntries() []android.AndroidMkEntries {
} }
ret := android.AndroidMkEntries{ ret := android.AndroidMkEntries{
OutputFile: mod.outputFile, OutputFile: mod.unstrippedOutputFile,
Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_rust_prebuilt.mk",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {

View File

@@ -272,6 +272,10 @@ func (compiler *baseCompiler) isDependencyRoot() bool {
return false return false
} }
func (compiler *baseCompiler) strippedOutputFilePath() android.OptionalPath {
return compiler.strippedOutputFile
}
func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...) deps.Rlibs = append(deps.Rlibs, compiler.Properties.Rlibs...)
deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...) deps.Dylibs = append(deps.Dylibs, compiler.Properties.Dylibs...)
@@ -337,10 +341,7 @@ func (compiler *baseCompiler) nativeCoverage() bool {
} }
func (compiler *baseCompiler) install(ctx ModuleContext) { func (compiler *baseCompiler) install(ctx ModuleContext) {
path := ctx.RustModule().outputFile path := ctx.RustModule().OutputFile()
if compiler.strippedOutputFile.Valid() {
path = compiler.strippedOutputFile
}
compiler.path = ctx.InstallFile(compiler.installDir(ctx), path.Path().Base(), path.Path()) compiler.path = ctx.InstallFile(compiler.installDir(ctx), path.Path().Base(), path.Path())
} }

View File

@@ -114,7 +114,10 @@ type Module struct {
sourceProvider SourceProvider sourceProvider SourceProvider
subAndroidMkOnce map[SubAndroidMkProvider]bool subAndroidMkOnce map[SubAndroidMkProvider]bool
outputFile android.OptionalPath // Unstripped output. This is usually used when this module is linked to another module
// as a library. The stripped output which is used for installation can be found via
// compiler.strippedOutputFile if it exists.
unstrippedOutputFile android.OptionalPath
hideApexVariantFromMake bool hideApexVariantFromMake bool
} }
@@ -163,8 +166,8 @@ func (mod *Module) OutputFiles(tag string) (android.Paths, error) {
if mod.sourceProvider != nil && (mod.compiler == nil || mod.compiler.Disabled()) { if mod.sourceProvider != nil && (mod.compiler == nil || mod.compiler.Disabled()) {
return mod.sourceProvider.Srcs(), nil return mod.sourceProvider.Srcs(), nil
} else { } else {
if mod.outputFile.Valid() { if mod.OutputFile().Valid() {
return android.Paths{mod.outputFile.Path()}, nil return android.Paths{mod.OutputFile().Path()}, nil
} }
return android.Paths{}, nil return android.Paths{}, nil
} }
@@ -346,6 +349,8 @@ type compiler interface {
stdLinkage(ctx *depsContext) RustLinkage stdLinkage(ctx *depsContext) RustLinkage
isDependencyRoot() bool isDependencyRoot() bool
strippedOutputFilePath() android.OptionalPath
} }
type exportedFlagsProducer interface { type exportedFlagsProducer interface {
@@ -523,7 +528,10 @@ func (mod *Module) Module() android.Module {
} }
func (mod *Module) OutputFile() android.OptionalPath { func (mod *Module) OutputFile() android.OptionalPath {
return mod.outputFile if mod.compiler != nil && mod.compiler.strippedOutputFilePath().Valid() {
return mod.compiler.strippedOutputFilePath()
}
return mod.unstrippedOutputFile
} }
func (mod *Module) CoverageFiles() android.Paths { func (mod *Module) CoverageFiles() android.Paths {
@@ -540,7 +548,7 @@ func (mod *Module) installable(apexInfo android.ApexInfo) bool {
return false return false
} }
return mod.outputFile.Valid() && !mod.Properties.PreventInstall return mod.OutputFile().Valid() && !mod.Properties.PreventInstall
} }
var _ cc.LinkableInterface = (*Module)(nil) var _ cc.LinkableInterface = (*Module)(nil)
@@ -721,9 +729,9 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if mod.compiler != nil && !mod.compiler.Disabled() { if mod.compiler != nil && !mod.compiler.Disabled() {
mod.compiler.initialize(ctx) mod.compiler.initialize(ctx)
outputFile := mod.compiler.compile(ctx, flags, deps) unstrippedOutputFile := mod.compiler.compile(ctx, flags, deps)
mod.outputFile = android.OptionalPathForPath(outputFile) mod.unstrippedOutputFile = android.OptionalPathForPath(unstrippedOutputFile)
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo) apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if mod.installable(apexInfo) { if mod.installable(apexInfo) {
@@ -882,7 +890,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
} }
if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag { if depTag == dylibDepTag || depTag == rlibDepTag || depTag == procMacroDepTag {
linkFile := rustDep.outputFile linkFile := rustDep.unstrippedOutputFile
if !linkFile.Valid() { if !linkFile.Valid() {
ctx.ModuleErrorf("Invalid output file when adding dep %q to %q", ctx.ModuleErrorf("Invalid output file when adding dep %q to %q",
depName, ctx.ModuleName()) depName, ctx.ModuleName())
@@ -978,15 +986,15 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
var rlibDepFiles RustLibraries var rlibDepFiles RustLibraries
for _, dep := range directRlibDeps { for _, dep := range directRlibDeps {
rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()}) rlibDepFiles = append(rlibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
} }
var dylibDepFiles RustLibraries var dylibDepFiles RustLibraries
for _, dep := range directDylibDeps { for _, dep := range directDylibDeps {
dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()}) dylibDepFiles = append(dylibDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
} }
var procMacroDepFiles RustLibraries var procMacroDepFiles RustLibraries
for _, dep := range directProcMacroDeps { for _, dep := range directProcMacroDeps {
procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.outputFile.Path(), CrateName: dep.CrateName()}) procMacroDepFiles = append(procMacroDepFiles, RustLibrary{Path: dep.unstrippedOutputFile.Path(), CrateName: dep.CrateName()})
} }
var staticLibDepFiles android.Paths var staticLibDepFiles android.Paths