Simplify compileObjs

None of the direct users of compileObjs were using any of its
complexity (generated sources, excluded sources, extra sources).  Move
the complexity back in to baseCompiler.compile.

Test: m -j
Change-Id: I2e59d216682c00dd12a1395cf2448827d1c48023
This commit is contained in:
Colin Cross 2016-10-26 10:03:47 -07:00
parent 46974e2457
commit 2f33635542
3 changed files with 31 additions and 36 deletions

View file

@ -100,6 +100,7 @@ func NewBaseCompiler() *baseCompiler {
type baseCompiler struct {
Properties BaseCompilerProperties
deps android.Paths
}
var _ compiler = (*baseCompiler)(nil)
@ -337,10 +338,21 @@ func ndkPathDeps(ctx ModuleContext) android.Paths {
func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths {
pathDeps := deps.GeneratedHeaders
pathDeps = append(pathDeps, ndkPathDeps(ctx)...)
srcs := ctx.ExpandSources(compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
srcs = append(srcs, deps.GeneratedSources...)
buildFlags := flagsToBuilderFlags(flags)
srcs, genDeps := genSources(ctx, srcs, buildFlags)
pathDeps = append(pathDeps, genDeps...)
pathDeps = append(pathDeps, flags.CFlagsDeps...)
compiler.deps = pathDeps
// Compile files listed in c.Properties.Srcs into objects
objFiles := compileObjs(ctx, flags, "",
compiler.Properties.Srcs, compiler.Properties.Exclude_srcs,
deps.GeneratedSources, pathDeps)
objFiles := compileObjs(ctx, buildFlags, "", srcs, compiler.deps)
if ctx.Failed() {
return nil
@ -350,17 +362,8 @@ func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathD
}
// Compile a list of source files into objects a specified subdirectory
func compileObjs(ctx android.ModuleContext, flags Flags,
subdir string, srcFiles, excludes []string, extraSrcs, deps android.Paths) android.Paths {
func compileObjs(ctx android.ModuleContext, flags builderFlags,
subdir string, srcFiles, deps android.Paths) android.Paths {
buildFlags := flagsToBuilderFlags(flags)
inputFiles := ctx.ExpandSources(srcFiles, excludes)
inputFiles = append(inputFiles, extraSrcs...)
srcPaths, gendeps := genSources(ctx, inputFiles, buildFlags)
deps = append(deps, gendeps...)
deps = append(deps, flags.CFlagsDeps...)
return TransformSourceToObj(ctx, subdir, srcPaths, buildFlags, deps)
return TransformSourceToObj(ctx, subdir, srcFiles, flags, deps)
}

View file

@ -25,9 +25,8 @@ import (
type LibraryProperties struct {
Static struct {
Srcs []string `android:"arch_variant"`
Exclude_srcs []string `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Srcs []string `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
@ -35,9 +34,8 @@ type LibraryProperties struct {
Shared_libs []string `android:"arch_variant"`
} `android:"arch_variant"`
Shared struct {
Srcs []string `android:"arch_variant"`
Exclude_srcs []string `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Srcs []string `android:"arch_variant"`
Cflags []string `android:"arch_variant"`
Enabled *bool `android:"arch_variant"`
Whole_static_libs []string `android:"arch_variant"`
@ -253,18 +251,16 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
objFiles = library.baseCompiler.compile(ctx, flags, deps)
library.reuseObjFiles = objFiles
pathDeps := deps.GeneratedHeaders
pathDeps = append(pathDeps, ndkPathDeps(ctx)...)
buildFlags := flagsToBuilderFlags(flags)
if library.static() {
objFiles = append(objFiles, compileObjs(ctx, flags, android.DeviceStaticLibrary,
library.Properties.Static.Srcs, library.Properties.Static.Exclude_srcs,
nil, pathDeps)...)
srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
srcs, library.baseCompiler.deps)...)
} else {
objFiles = append(objFiles, compileObjs(ctx, flags, android.DeviceSharedLibrary,
library.Properties.Shared.Srcs, library.Properties.Shared.Exclude_srcs,
nil, pathDeps)...)
srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
srcs, library.baseCompiler.deps)...)
}
return objFiles

View file

@ -227,12 +227,8 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) a
)
subdir := ""
srcs := []string{}
excludeSrcs := []string{}
extraSrcs := []android.Path{stubSrcPath}
extraDeps := []android.Path{}
return compileObjs(ctx, flags, subdir, srcs, excludeSrcs,
extraSrcs, extraDeps)
srcs := []android.Path{stubSrcPath}
return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil)
}
func (linker *stubDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {