From 5cb580f407d2b1b639d7aeea8e1310740e55fe1c Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Mon, 26 Sep 2016 17:33:01 -0700 Subject: Start using "struct Objects" to store object Paths So that we can represent other files that get generated along with the objects, like the gcno coverage information, and per-file clang-tidy runs. Test: Soong's build.ninja identical before/after Change-Id: I5c553a153c436d5403549f62c73fe79c5f101779 --- cc/library.go | 56 +++++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'cc/library.go') diff --git a/cc/library.go b/cc/library.go index 99a9b488..db19d665 100644 --- a/cc/library.go +++ b/cc/library.go @@ -160,7 +160,7 @@ type libraryDecorator struct { Properties LibraryProperties // For reusing static library objects for shared library - reuseObjFiles android.Paths + reuseObjects Objects // table-of-contents file to optimize out relinking when possible tocFile android.OptionalPath @@ -173,7 +173,7 @@ type libraryDecorator struct { wholeStaticMissingDeps []string // For whole_static_libs - objFiles android.Paths + objects Objects // Uses the module's name if empty, but can be overridden. Does not include // shlib suffix. @@ -251,31 +251,29 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla return flags } -func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths { - var objFiles android.Paths - - objFiles = library.baseCompiler.compile(ctx, flags, deps) - library.reuseObjFiles = objFiles +func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { + objs := library.baseCompiler.compile(ctx, flags, deps) + library.reuseObjects = objs buildFlags := flagsToBuilderFlags(flags) if library.static() { srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs) - objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, - srcs, library.baseCompiler.deps)...) + objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, + srcs, library.baseCompiler.deps)) } else { srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs) - objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, - srcs, library.baseCompiler.deps)...) + objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, + srcs, library.baseCompiler.deps)) } - return objFiles + return objs } type libraryInterface interface { getWholeStaticMissingDeps() []string static() bool - objs() android.Paths - reuseObjs() android.Paths + objs() Objects + reuseObjs() Objects toc() android.OptionalPath // Returns true if the build options for the module have selected a static or shared build @@ -340,18 +338,18 @@ func (library *libraryDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) De } func (library *libraryDecorator) linkStatic(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { - library.objFiles = append(android.Paths{}, deps.WholeStaticLibObjFiles...) - library.objFiles = append(library.objFiles, objFiles...) + library.objects = deps.WholeStaticLibObjs.Copy() + library.objects = library.objects.Append(objs) outputFile := android.PathForModuleOut(ctx, ctx.ModuleName()+library.Properties.VariantName+staticLibraryExtension) if ctx.Darwin() { - TransformDarwinObjToStaticLib(ctx, library.objFiles, flagsToBuilderFlags(flags), outputFile) + TransformDarwinObjToStaticLib(ctx, library.objects.objFiles, flagsToBuilderFlags(flags), outputFile) } else { - TransformObjToStaticLib(ctx, library.objFiles, flagsToBuilderFlags(flags), outputFile) + TransformObjToStaticLib(ctx, library.objects.objFiles, flagsToBuilderFlags(flags), outputFile) } library.wholeStaticMissingDeps = ctx.GetMissingDependencies() @@ -362,7 +360,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext, } func (library *libraryDecorator) linkShared(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { var linkerDeps android.Paths @@ -455,7 +453,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, linkerDeps = append(linkerDeps, deps.SharedLibsDeps...) linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...) - TransformObjToDynamicBinary(ctx, objFiles, sharedLibs, + TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile) @@ -463,15 +461,15 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, } func (library *libraryDecorator) link(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { - objFiles = append(objFiles, deps.ObjFiles...) + objs = objs.Append(deps.Objs) var out android.Path if library.static() { - out = library.linkStatic(ctx, flags, deps, objFiles) + out = library.linkStatic(ctx, flags, deps, objs) } else { - out = library.linkShared(ctx, flags, deps, objFiles) + out = library.linkShared(ctx, flags, deps, objs) } library.exportIncludes(ctx, "-I") @@ -505,12 +503,12 @@ func (library *libraryDecorator) getWholeStaticMissingDeps() []string { return library.wholeStaticMissingDeps } -func (library *libraryDecorator) objs() android.Paths { - return library.objFiles +func (library *libraryDecorator) objs() Objects { + return library.objects } -func (library *libraryDecorator) reuseObjs() android.Paths { - return library.reuseObjFiles +func (library *libraryDecorator) reuseObjs() Objects { + return library.reuseObjects } func (library *libraryDecorator) toc() android.OptionalPath { -- cgit v1.2.3