Simplify compileObjs
am: 2f33635542
Change-Id: I5766b8964fc1da175d74408c2ffe089f989305c7
This commit is contained in:
commit
dc90f3bd71
3 changed files with 31 additions and 36 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
type LibraryProperties struct {
|
||||
Static struct {
|
||||
Srcs []string `android:"arch_variant"`
|
||||
Exclude_srcs []string `android:"arch_variant"`
|
||||
Cflags []string `android:"arch_variant"`
|
||||
|
||||
Enabled *bool `android:"arch_variant"`
|
||||
|
@ -36,7 +35,6 @@ type LibraryProperties struct {
|
|||
} `android:"arch_variant"`
|
||||
Shared struct {
|
||||
Srcs []string `android:"arch_variant"`
|
||||
Exclude_srcs []string `android:"arch_variant"`
|
||||
Cflags []string `android:"arch_variant"`
|
||||
|
||||
Enabled *bool `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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue