Merge "Append whole_static_libs deps from .a files instead of the list of objects." am: 5b79950e99
am: d9b1282918
Change-Id: I9095dfd6ea2baaf523c15a5d931e0192f8b98981
This commit is contained in:
commit
09dce92ece
3 changed files with 54 additions and 16 deletions
|
@ -99,6 +99,15 @@ var (
|
|||
},
|
||||
"arCmd", "arFlags")
|
||||
|
||||
arWithLibs = pctx.AndroidStaticRule("arWithLibs",
|
||||
blueprint.RuleParams{
|
||||
Command: "rm -f ${out} && $arCmd $arObjFlags $out @${out}.rsp && $arCmd $arLibFlags $out $arLibs",
|
||||
CommandDeps: []string{"$arCmd"},
|
||||
Rspfile: "${out}.rsp",
|
||||
RspfileContent: "${arObjs}",
|
||||
},
|
||||
"arCmd", "arObjFlags", "arObjs", "arLibFlags", "arLibs")
|
||||
|
||||
darwinStrip = pctx.AndroidStaticRule("darwinStrip",
|
||||
blueprint.RuleParams{
|
||||
Command: "${config.MacStripPath} -u -r -o $out $in",
|
||||
|
@ -609,26 +618,45 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
|
|||
}
|
||||
|
||||
// Generate a rule for compiling multiple .o files to a static library (.a)
|
||||
func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths,
|
||||
func TransformObjToStaticLib(ctx android.ModuleContext,
|
||||
objFiles android.Paths, wholeStaticLibs android.Paths,
|
||||
flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths) {
|
||||
|
||||
arCmd := "${config.ClangBin}/llvm-ar"
|
||||
arFlags := "crsPD"
|
||||
arFlags := ""
|
||||
if !ctx.Darwin() {
|
||||
arFlags += " -format=gnu"
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: ar,
|
||||
Description: "static link " + outputFile.Base(),
|
||||
Output: outputFile,
|
||||
Inputs: objFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"arFlags": arFlags,
|
||||
"arCmd": arCmd,
|
||||
},
|
||||
})
|
||||
if len(wholeStaticLibs) == 0 {
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: ar,
|
||||
Description: "static link " + outputFile.Base(),
|
||||
Output: outputFile,
|
||||
Inputs: objFiles,
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"arFlags": "crsPD" + arFlags,
|
||||
"arCmd": arCmd,
|
||||
},
|
||||
})
|
||||
|
||||
} else {
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: arWithLibs,
|
||||
Description: "static link " + outputFile.Base(),
|
||||
Output: outputFile,
|
||||
Inputs: append(objFiles, wholeStaticLibs...),
|
||||
Implicits: deps,
|
||||
Args: map[string]string{
|
||||
"arCmd": arCmd,
|
||||
"arObjFlags": "crsPD" + arFlags,
|
||||
"arObjs": strings.Join(objFiles.Strings(), " "),
|
||||
"arLibFlags": "cqsL" + arFlags,
|
||||
"arLibs": strings.Join(wholeStaticLibs.Strings(), " "),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries,
|
||||
|
|
14
cc/cc.go
14
cc/cc.go
|
@ -124,10 +124,16 @@ type PathDeps struct {
|
|||
StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths
|
||||
|
||||
// Paths to .o files
|
||||
Objs Objects
|
||||
Objs Objects
|
||||
// Paths to .o files in dependencies that provide them. Note that these lists
|
||||
// aren't complete since prebuilt modules don't provide the .o files.
|
||||
StaticLibObjs Objects
|
||||
WholeStaticLibObjs Objects
|
||||
|
||||
// Paths to .a files in prebuilts. Complements WholeStaticLibObjs to contain
|
||||
// the libs from all whole_static_lib dependencies.
|
||||
WholeStaticLibsFromPrebuilts android.Paths
|
||||
|
||||
// Paths to generated source files
|
||||
GeneratedSources android.Paths
|
||||
GeneratedHeaders android.Paths
|
||||
|
@ -2482,7 +2488,11 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
}
|
||||
ctx.AddMissingDependencies(missingDeps)
|
||||
}
|
||||
depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
|
||||
if _, ok := ccWholeStaticLib.linker.(prebuiltLinkerInterface); ok {
|
||||
depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path())
|
||||
} else {
|
||||
depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs())
|
||||
}
|
||||
} else {
|
||||
ctx.ModuleErrorf(
|
||||
"non-cc.Modules cannot be included as whole static libraries.", depName)
|
||||
|
|
|
@ -874,7 +874,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext,
|
|||
}
|
||||
}
|
||||
|
||||
TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
|
||||
TransformObjToStaticLib(ctx, library.objects.objFiles, deps.WholeStaticLibsFromPrebuilts, builderFlags, outputFile, objs.tidyFiles)
|
||||
|
||||
library.coverageOutputFile = TransformCoverageFilesToZip(ctx, library.objects, ctx.ModuleName())
|
||||
|
||||
|
|
Loading…
Reference in a new issue