diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/binary.go | 4 | ||||
-rw-r--r-- | cc/builder.go | 24 | ||||
-rw-r--r-- | cc/cc.go | 22 | ||||
-rw-r--r-- | cc/compiler.go | 10 | ||||
-rw-r--r-- | cc/library.go | 56 | ||||
-rw-r--r-- | cc/linker.go | 2 | ||||
-rw-r--r-- | cc/ndk_library.go | 6 | ||||
-rw-r--r-- | cc/ndk_prebuilt.go | 6 | ||||
-rw-r--r-- | cc/object.go | 10 | ||||
-rw-r--r-- | cc/prebuilt.go | 2 | ||||
-rw-r--r-- | cc/toolchain_library.go | 6 |
11 files changed, 81 insertions, 67 deletions
diff --git a/cc/binary.go b/cc/binary.go index e7d22c1f..1e923a4f 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -250,7 +250,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags } func (binary *binaryDecorator) link(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { fileName := binary.getStem(ctx) + flags.Toolchain.ExecutableSuffix() outputFile := android.PathForModuleOut(ctx, fileName) @@ -283,7 +283,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext, linkerDeps = append(linkerDeps, deps.SharedLibsDeps...) linkerDeps = append(linkerDeps, deps.LateSharedLibsDeps...) - TransformObjToDynamicBinary(ctx, objFiles, sharedLibs, deps.StaticLibs, + TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true, builderFlags, outputFile) diff --git a/cc/builder.go b/cc/builder.go index 60aad0b4..0006ed36 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -182,11 +182,27 @@ type builderFlags struct { stripAddGnuDebuglink bool } +type Objects struct { + objFiles android.Paths +} + +func (a Objects) Copy() Objects { + return Objects{ + objFiles: append(android.Paths{}, a.objFiles...), + } +} + +func (a Objects) Append(b Objects) Objects { + return Objects{ + objFiles: append(a.objFiles, b.objFiles...), + } +} + // Generate rules for compiling multiple .c, .cpp, or .S files to individual .o files func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles android.Paths, - flags builderFlags, deps android.Paths) (objFiles android.Paths) { + flags builderFlags, deps android.Paths) Objects { - objFiles = make(android.Paths, len(srcFiles)) + objFiles := make(android.Paths, len(srcFiles)) cflags := flags.globalFlags + " " + flags.cFlags + " " + flags.conlyFlags cppflags := flags.globalFlags + " " + flags.cFlags + " " + flags.cppFlags @@ -250,7 +266,9 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and }) } - return objFiles + return Objects{ + objFiles: objFiles, + } } // Generate a rule for compiling multiple .o files to a static library (.a) @@ -76,8 +76,8 @@ type PathDeps struct { StaticLibs, LateStaticLibs, WholeStaticLibs android.Paths // Paths to .o files - ObjFiles android.Paths - WholeStaticLibObjFiles android.Paths + Objs Objects + WholeStaticLibObjs Objects // Paths to generated source files GeneratedSources android.Paths @@ -174,7 +174,7 @@ type compiler interface { appendCflags([]string) appendAsflags([]string) - compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths + compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects } type linker interface { @@ -183,7 +183,7 @@ type linker interface { linkerFlags(ctx ModuleContext, flags Flags) Flags linkerProps() []interface{} - link(ctx ModuleContext, flags Flags, deps PathDeps, objFiles android.Paths) android.Path + link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path appendLdflags([]string) } @@ -440,16 +440,16 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...) - var objFiles android.Paths + var objs Objects if c.compiler != nil { - objFiles = c.compiler.compile(ctx, flags, deps) + objs = c.compiler.compile(ctx, flags, deps) if ctx.Failed() { return } } if c.linker != nil { - outputFile := c.linker.link(ctx, flags, deps, objFiles) + outputFile := c.linker.link(ctx, flags, deps, objs) if ctx.Failed() { return } @@ -813,8 +813,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } if tag == reuseObjTag { - depPaths.ObjFiles = append(depPaths.ObjFiles, - cc.compiler.(libraryInterface).reuseObjs()...) + depPaths.Objs = depPaths.Objs.Append(cc.compiler.(libraryInterface).reuseObjs()) return } @@ -868,10 +867,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } ctx.AddMissingDependencies(missingDeps) } - depPaths.WholeStaticLibObjFiles = - append(depPaths.WholeStaticLibObjFiles, staticLib.objs()...) + depPaths.WholeStaticLibObjs = depPaths.WholeStaticLibObjs.Append(staticLib.objs()) case objDepTag: - ptr = &depPaths.ObjFiles + depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path()) case crtBeginDepTag: depPaths.CrtBegin = linkFile case crtEndDepTag: diff --git a/cc/compiler.go b/cc/compiler.go index 0184ee9f..454be5e3 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -350,7 +350,7 @@ func ndkPathDeps(ctx ModuleContext) android.Paths { return nil } -func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths { +func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { pathDeps := deps.GeneratedHeaders pathDeps = append(pathDeps, ndkPathDeps(ctx)...) @@ -367,18 +367,18 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD compiler.deps = pathDeps // Compile files listed in c.Properties.Srcs into objects - objFiles := compileObjs(ctx, buildFlags, "", srcs, compiler.deps) + objs := compileObjs(ctx, buildFlags, "", srcs, compiler.deps) if ctx.Failed() { - return nil + return Objects{} } - return objFiles + return objs } // Compile a list of source files into objects a specified subdirectory func compileObjs(ctx android.ModuleContext, flags builderFlags, - subdir string, srcFiles, deps android.Paths) android.Paths { + subdir string, srcFiles, deps android.Paths) Objects { return TransformSourceToObj(ctx, subdir, srcFiles, flags, deps) } 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 { diff --git a/cc/linker.go b/cc/linker.go index 09233385..28572c69 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -197,6 +197,6 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { } func (linker *baseLinker) link(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { panic(fmt.Errorf("baseLinker doesn't know how to link")) } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 6b0c325e..48fbf4dd 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -189,7 +189,7 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { ndkMigratedLibs = append(ndkMigratedLibs, name) } -func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths { +func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { arch := ctx.Arch().ArchType.String() if !strings.HasSuffix(ctx.ModuleName(), ndkLibrarySuffix) { @@ -242,11 +242,11 @@ func (stub *stubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { } func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, - objFiles android.Paths) android.Path { + objs Objects) android.Path { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) - return stub.libraryDecorator.link(ctx, flags, deps, objFiles) + return stub.libraryDecorator.link(ctx, flags, deps, objs) } func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) { diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go index 106c9b51..46b383b9 100644 --- a/cc/ndk_prebuilt.go +++ b/cc/ndk_prebuilt.go @@ -79,7 +79,7 @@ func ndkPrebuiltObjectFactory() (blueprint.Module, []interface{}) { } func (c *ndkPrebuiltObjectLinker) link(ctx ModuleContext, flags Flags, - deps PathDeps, objFiles android.Paths) android.Path { + deps PathDeps, objs Objects) android.Path { // A null build step, but it sets up the output path. if !strings.HasPrefix(ctx.ModuleName(), "ndk_crt") { ctx.ModuleErrorf("NDK prebuilts must have an ndk_crt prefixed name") @@ -115,7 +115,7 @@ func ndkPrebuiltLibraryFactory() (blueprint.Module, []interface{}) { } func (ndk *ndkPrebuiltLibraryLinker) link(ctx ModuleContext, flags Flags, - deps PathDeps, objFiles android.Paths) android.Path { + deps PathDeps, objs Objects) android.Path { // A null build step, but it sets up the output path. ndk.exportIncludes(ctx, "-isystem") @@ -181,7 +181,7 @@ func getNdkStlLibDir(ctx android.ModuleContext, toolchain config.Toolchain, stl } func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags, - deps PathDeps, objFiles android.Paths) android.Path { + deps PathDeps, objs Objects) android.Path { // A null build step, but it sets up the output path. if !strings.HasPrefix(ctx.ModuleName(), "ndk_lib") { ctx.ModuleErrorf("NDK prebuilts must have an ndk_lib prefixed name") diff --git a/cc/object.go b/cc/object.go index 72fd55bd..57cc8b05 100644 --- a/cc/object.go +++ b/cc/object.go @@ -70,16 +70,16 @@ func (*objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { } func (object *objectLinker) 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 outputFile android.Path - if len(objFiles) == 1 { - outputFile = objFiles[0] + if len(objs.objFiles) == 1 { + outputFile = objs.objFiles[0] } else { output := android.PathForModuleOut(ctx, ctx.ModuleName()+objectExtension) - TransformObjsToObj(ctx, objFiles, flagsToBuilderFlags(flags), output) + TransformObjsToObj(ctx, objs.objFiles, flagsToBuilderFlags(flags), output) outputFile = output } diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 55775b69..4328df8a 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -46,7 +46,7 @@ func (p *prebuiltLibraryLinker) linkerProps() []interface{} { } func (p *prebuiltLibraryLinker) link(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { // TODO(ccross): verify shared library dependencies if len(p.Prebuilt.Properties.Srcs) > 0 { p.libraryDecorator.exportIncludes(ctx, "-I") diff --git a/cc/toolchain_library.go b/cc/toolchain_library.go index 0097ca3e..2f3c9a1a 100644 --- a/cc/toolchain_library.go +++ b/cc/toolchain_library.go @@ -53,12 +53,12 @@ func toolchainLibraryFactory() (blueprint.Module, []interface{}) { } func (library *toolchainLibraryDecorator) compile(ctx ModuleContext, flags Flags, - deps PathDeps) android.Paths { - return nil + deps PathDeps) Objects { + return Objects{} } func (library *toolchainLibraryDecorator) link(ctx ModuleContext, - flags Flags, deps PathDeps, objFiles android.Paths) android.Path { + flags Flags, deps PathDeps, objs Objects) android.Path { libName := ctx.ModuleName() + staticLibraryExtension outputFile := android.PathForModuleOut(ctx, libName) |