Merge "Include static lib information for the snapshot modules" am: 503e3a10b2

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1751245

Change-Id: I96414fa69aa86706d20433540f5b13033a559a58
This commit is contained in:
Treehugger Robot
2021-07-02 00:19:24 +00:00
committed by Automerger Merge Worker
6 changed files with 41 additions and 2 deletions

View File

@@ -337,6 +337,7 @@ type BaseProperties struct {
// Used by vendor snapshot to record dependencies from snapshot modules. // Used by vendor snapshot to record dependencies from snapshot modules.
SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotSharedLibs []string `blueprint:"mutated"`
SnapshotStaticLibs []string `blueprint:"mutated"`
SnapshotRuntimeLibs []string `blueprint:"mutated"` SnapshotRuntimeLibs []string `blueprint:"mutated"`
Installable *bool Installable *bool
@@ -2830,6 +2831,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
c.Properties.AndroidMkStaticLibs = append( c.Properties.AndroidMkStaticLibs = append(
c.Properties.AndroidMkStaticLibs, makeLibName) c.Properties.AndroidMkStaticLibs, makeLibName)
} }
// Record BaseLibName for snapshots.
c.Properties.SnapshotStaticLibs = append(c.Properties.SnapshotStaticLibs, BaseLibName(depName))
} }
} else if !c.IsStubs() { } else if !c.IsStubs() {
// Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies. // Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies.
@@ -3153,6 +3156,13 @@ func (c *Module) Binary() bool {
return false return false
} }
func (c *Module) StaticExecutable() bool {
if b, ok := c.linker.(*binaryDecorator); ok {
return b.static()
}
return false
}
func (c *Module) Object() bool { func (c *Module) Object() bool {
if o, ok := c.linker.(interface { if o, ok := c.linker.(interface {
object() bool object() bool

View File

@@ -94,6 +94,9 @@ type Snapshottable interface {
// SnapshotSharedLibs returns the list of shared library dependencies for this module. // SnapshotSharedLibs returns the list of shared library dependencies for this module.
SnapshotSharedLibs() []string SnapshotSharedLibs() []string
// SnapshotStaticLibs returns the list of static library dependencies for this module.
SnapshotStaticLibs() []string
// IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt. // IsSnapshotPrebuilt returns true if this module is a snapshot prebuilt.
IsSnapshotPrebuilt() bool IsSnapshotPrebuilt() bool
} }
@@ -226,6 +229,9 @@ type LinkableInterface interface {
// Header returns true if this is a library headers module. // Header returns true if this is a library headers module.
Header() bool Header() bool
// StaticExecutable returns true if this is a binary module with "static_executable: true".
StaticExecutable() bool
// EverInstallable returns true if the module is ever installable // EverInstallable returns true if the module is ever installable
EverInstallable() bool EverInstallable() bool

View File

@@ -53,6 +53,10 @@ func (m *Module) SnapshotSharedLibs() []string {
return m.Properties.SnapshotSharedLibs return m.Properties.SnapshotSharedLibs
} }
func (m *Module) SnapshotStaticLibs() []string {
return m.Properties.SnapshotStaticLibs
}
// snapshotLibraryInterface is an interface for libraries captured to VNDK / vendor snapshots. // snapshotLibraryInterface is an interface for libraries captured to VNDK / vendor snapshots.
type snapshotLibraryInterface interface { type snapshotLibraryInterface interface {
libraryInterface libraryInterface

View File

@@ -242,10 +242,12 @@ type snapshotJsonFlags struct {
SanitizeUbsanDep bool `json:",omitempty"` SanitizeUbsanDep bool `json:",omitempty"`
// binary flags // binary flags
Symlinks []string `json:",omitempty"` Symlinks []string `json:",omitempty"`
StaticExecutable bool `json:",omitempty"`
// dependencies // dependencies
SharedLibs []string `json:",omitempty"` SharedLibs []string `json:",omitempty"`
StaticLibs []string `json:",omitempty"`
RuntimeLibs []string `json:",omitempty"` RuntimeLibs []string `json:",omitempty"`
Required []string `json:",omitempty"` Required []string `json:",omitempty"`
@@ -381,6 +383,8 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
if m.Shared() { if m.Shared() {
prop.SharedLibs = m.SnapshotSharedLibs() prop.SharedLibs = m.SnapshotSharedLibs()
} }
// static libs dependencies are required to collect the NOTICE files.
prop.StaticLibs = m.SnapshotStaticLibs()
if sanitizable, ok := m.(PlatformSanitizeable); ok { if sanitizable, ok := m.(PlatformSanitizeable); ok {
if sanitizable.Static() && sanitizable.SanitizePropDefined() { if sanitizable.Static() && sanitizable.SanitizePropDefined() {
prop.SanitizeMinimalDep = sanitizable.MinimalRuntimeDep() || sanitizable.MinimalRuntimeNeeded() prop.SanitizeMinimalDep = sanitizable.MinimalRuntimeDep() || sanitizable.MinimalRuntimeNeeded()
@@ -426,8 +430,10 @@ func (c *snapshotSingleton) GenerateBuildActions(ctx android.SingletonContext) {
} else if m.Binary() { } else if m.Binary() {
// binary flags // binary flags
prop.Symlinks = m.Symlinks() prop.Symlinks = m.Symlinks()
prop.StaticExecutable = m.StaticExecutable()
prop.SharedLibs = m.SnapshotSharedLibs() prop.SharedLibs = m.SnapshotSharedLibs()
// static libs dependencies are required to collect the NOTICE files.
prop.StaticLibs = m.SnapshotStaticLibs()
// install bin // install bin
binPath := m.OutputFile().Path() binPath := m.OutputFile().Path()
snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base()) snapshotBinOut := filepath.Join(snapshotArchDir, targetArch, "binary", binPath.Base())

View File

@@ -87,6 +87,7 @@ type BaseProperties struct {
// Used by vendor snapshot to record dependencies from snapshot modules. // Used by vendor snapshot to record dependencies from snapshot modules.
SnapshotSharedLibs []string `blueprint:"mutated"` SnapshotSharedLibs []string `blueprint:"mutated"`
SnapshotStaticLibs []string `blueprint:"mutated"`
// Make this module available when building for vendor ramdisk. // Make this module available when building for vendor ramdisk.
// On device without a dedicated recovery partition, the module is only // On device without a dedicated recovery partition, the module is only
@@ -259,6 +260,13 @@ func (mod *Module) Binary() bool {
return false return false
} }
func (mod *Module) StaticExecutable() bool {
if !mod.Binary() {
return false
}
return Bool(mod.compiler.(*binaryDecorator).Properties.Static_executable)
}
func (mod *Module) Object() bool { func (mod *Module) Object() bool {
// Rust has no modules which produce only object files. // Rust has no modules which produce only object files.
return false return false
@@ -1097,6 +1105,7 @@ func (mod *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// Record baseLibName for snapshots. // Record baseLibName for snapshots.
mod.Properties.SnapshotSharedLibs = append(mod.Properties.SnapshotSharedLibs, cc.BaseLibName(depName)) mod.Properties.SnapshotSharedLibs = append(mod.Properties.SnapshotSharedLibs, cc.BaseLibName(depName))
mod.Properties.SnapshotStaticLibs = append(mod.Properties.SnapshotStaticLibs, cc.BaseLibName(depName))
mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, makeLibName) mod.Properties.AndroidMkSharedLibs = append(mod.Properties.AndroidMkSharedLibs, makeLibName)
exportDep = true exportDep = true

View File

@@ -57,6 +57,10 @@ func (mod *Module) SnapshotSharedLibs() []string {
return mod.Properties.SnapshotSharedLibs return mod.Properties.SnapshotSharedLibs
} }
func (mod *Module) SnapshotStaticLibs() []string {
return mod.Properties.SnapshotStaticLibs
}
func (mod *Module) Symlinks() []string { func (mod *Module) Symlinks() []string {
// TODO update this to return the list of symlinks when Rust supports defining symlinks // TODO update this to return the list of symlinks when Rust supports defining symlinks
return nil return nil