Propagate missing dependencies when using whole_static_libs

Currently, whole_static_libs with missing dependencies are silently
ignored. Instead, when getting the object files from the other module,
add its missing dependencies to the current module.

Change-Id: I12472dede2dfafdded56268bfd37f60063b637c4
This commit is contained in:
Dan Willemsen 2016-03-10 18:14:25 -08:00
parent eb371e51d9
commit 6553f5ef57
2 changed files with 26 additions and 0 deletions

View file

@ -791,6 +791,13 @@ func (c *CCBase) depsToPaths(ctx common.AndroidModuleContext, depNames CCDeps) C
for _, m := range wholeStaticLibModules { for _, m := range wholeStaticLibModules {
if staticLib, ok := m.(ccLibraryInterface); ok && staticLib.static() { if staticLib, ok := m.(ccLibraryInterface); ok && staticLib.static() {
if missingDeps := staticLib.getWholeStaticMissingDeps(); missingDeps != nil {
postfix := " (required by " + ctx.OtherModuleName(m) + ")"
for i := range missingDeps {
missingDeps[i] += postfix
}
ctx.AddMissingDependencies(missingDeps)
}
depPaths.WholeStaticLibObjFiles = depPaths.WholeStaticLibObjFiles =
append(depPaths.WholeStaticLibObjFiles, staticLib.allObjFiles()...) append(depPaths.WholeStaticLibObjFiles, staticLib.allObjFiles()...)
} else { } else {
@ -1136,6 +1143,10 @@ type CCLibrary struct {
out common.Path out common.Path
systemLibs []string systemLibs []string
// If we're used as a whole_static_lib, our missing dependencies need
// to be given
wholeStaticMissingDeps []string
LibraryProperties CCLibraryProperties LibraryProperties CCLibraryProperties
} }
@ -1154,6 +1165,7 @@ type ccLibraryInterface interface {
getReuseFrom() ccLibraryInterface getReuseFrom() ccLibraryInterface
getReuseObjFiles() common.Paths getReuseObjFiles() common.Paths
allObjFiles() common.Paths allObjFiles() common.Paths
getWholeStaticMissingDeps() []string
} }
var _ ccLibraryInterface = (*CCLibrary)(nil) var _ ccLibraryInterface = (*CCLibrary)(nil)
@ -1224,6 +1236,10 @@ func (c *CCLibrary) allObjFiles() common.Paths {
return c.objFiles return c.objFiles
} }
func (c *CCLibrary) getWholeStaticMissingDeps() []string {
return c.wholeStaticMissingDeps
}
func (c *CCLibrary) exportedFlags() []string { func (c *CCLibrary) exportedFlags() []string {
return c.exportFlags return c.exportFlags
} }
@ -1294,6 +1310,8 @@ func (c *CCLibrary) compileStaticLibrary(ctx common.AndroidModuleContext,
TransformObjToStaticLib(ctx, objFiles, ccFlagsToBuilderFlags(flags), outputFile) TransformObjToStaticLib(ctx, objFiles, ccFlagsToBuilderFlags(flags), outputFile)
} }
c.wholeStaticMissingDeps = ctx.GetMissingDependencies()
c.objFiles = objFiles c.objFiles = objFiles
c.out = outputFile c.out = outputFile

View file

@ -79,6 +79,8 @@ type AndroidModuleContext interface {
InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path InstallFile(installPath OutputPath, srcPath Path, deps ...Path) Path
InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) Path InstallFileName(installPath OutputPath, name string, srcPath Path, deps ...Path) Path
CheckbuildFile(srcPath Path) CheckbuildFile(srcPath Path)
AddMissingDependencies(deps []string)
} }
type AndroidModule interface { type AndroidModule interface {
@ -482,6 +484,12 @@ func (a *androidModuleContext) GetMissingDependencies() []string {
return a.missingDeps return a.missingDeps
} }
func (a *androidModuleContext) AddMissingDependencies(deps []string) {
if deps != nil {
a.missingDeps = append(a.missingDeps, deps...)
}
}
func (a *androidBaseContextImpl) Arch() Arch { func (a *androidBaseContextImpl) Arch() Arch {
return a.arch return a.arch
} }