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 {
|
type baseCompiler struct {
|
||||||
Properties BaseCompilerProperties
|
Properties BaseCompilerProperties
|
||||||
|
deps android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ compiler = (*baseCompiler)(nil)
|
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 {
|
func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) android.Paths {
|
||||||
pathDeps := deps.GeneratedHeaders
|
pathDeps := deps.GeneratedHeaders
|
||||||
pathDeps = append(pathDeps, ndkPathDeps(ctx)...)
|
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
|
// Compile files listed in c.Properties.Srcs into objects
|
||||||
objFiles := compileObjs(ctx, flags, "",
|
objFiles := compileObjs(ctx, buildFlags, "", srcs, compiler.deps)
|
||||||
compiler.Properties.Srcs, compiler.Properties.Exclude_srcs,
|
|
||||||
deps.GeneratedSources, pathDeps)
|
|
||||||
|
|
||||||
if ctx.Failed() {
|
if ctx.Failed() {
|
||||||
return nil
|
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
|
// Compile a list of source files into objects a specified subdirectory
|
||||||
func compileObjs(ctx android.ModuleContext, flags Flags,
|
func compileObjs(ctx android.ModuleContext, flags builderFlags,
|
||||||
subdir string, srcFiles, excludes []string, extraSrcs, deps android.Paths) android.Paths {
|
subdir string, srcFiles, deps android.Paths) android.Paths {
|
||||||
|
|
||||||
buildFlags := flagsToBuilderFlags(flags)
|
return TransformSourceToObj(ctx, subdir, srcFiles, flags, deps)
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,8 @@ import (
|
||||||
|
|
||||||
type LibraryProperties struct {
|
type LibraryProperties struct {
|
||||||
Static struct {
|
Static struct {
|
||||||
Srcs []string `android:"arch_variant"`
|
Srcs []string `android:"arch_variant"`
|
||||||
Exclude_srcs []string `android:"arch_variant"`
|
Cflags []string `android:"arch_variant"`
|
||||||
Cflags []string `android:"arch_variant"`
|
|
||||||
|
|
||||||
Enabled *bool `android:"arch_variant"`
|
Enabled *bool `android:"arch_variant"`
|
||||||
Whole_static_libs []string `android:"arch_variant"`
|
Whole_static_libs []string `android:"arch_variant"`
|
||||||
|
@ -35,9 +34,8 @@ type LibraryProperties struct {
|
||||||
Shared_libs []string `android:"arch_variant"`
|
Shared_libs []string `android:"arch_variant"`
|
||||||
} `android:"arch_variant"`
|
} `android:"arch_variant"`
|
||||||
Shared struct {
|
Shared struct {
|
||||||
Srcs []string `android:"arch_variant"`
|
Srcs []string `android:"arch_variant"`
|
||||||
Exclude_srcs []string `android:"arch_variant"`
|
Cflags []string `android:"arch_variant"`
|
||||||
Cflags []string `android:"arch_variant"`
|
|
||||||
|
|
||||||
Enabled *bool `android:"arch_variant"`
|
Enabled *bool `android:"arch_variant"`
|
||||||
Whole_static_libs []string `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)
|
objFiles = library.baseCompiler.compile(ctx, flags, deps)
|
||||||
library.reuseObjFiles = objFiles
|
library.reuseObjFiles = objFiles
|
||||||
|
buildFlags := flagsToBuilderFlags(flags)
|
||||||
pathDeps := deps.GeneratedHeaders
|
|
||||||
pathDeps = append(pathDeps, ndkPathDeps(ctx)...)
|
|
||||||
|
|
||||||
if library.static() {
|
if library.static() {
|
||||||
objFiles = append(objFiles, compileObjs(ctx, flags, android.DeviceStaticLibrary,
|
srcs := android.PathsForModuleSrc(ctx, library.Properties.Static.Srcs)
|
||||||
library.Properties.Static.Srcs, library.Properties.Static.Exclude_srcs,
|
objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceStaticLibrary,
|
||||||
nil, pathDeps)...)
|
srcs, library.baseCompiler.deps)...)
|
||||||
} else {
|
} else {
|
||||||
objFiles = append(objFiles, compileObjs(ctx, flags, android.DeviceSharedLibrary,
|
srcs := android.PathsForModuleSrc(ctx, library.Properties.Shared.Srcs)
|
||||||
library.Properties.Shared.Srcs, library.Properties.Shared.Exclude_srcs,
|
objFiles = append(objFiles, compileObjs(ctx, buildFlags, android.DeviceSharedLibrary,
|
||||||
nil, pathDeps)...)
|
srcs, library.baseCompiler.deps)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return objFiles
|
return objFiles
|
||||||
|
|
|
@ -227,12 +227,8 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) a
|
||||||
)
|
)
|
||||||
|
|
||||||
subdir := ""
|
subdir := ""
|
||||||
srcs := []string{}
|
srcs := []android.Path{stubSrcPath}
|
||||||
excludeSrcs := []string{}
|
return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil)
|
||||||
extraSrcs := []android.Path{stubSrcPath}
|
|
||||||
extraDeps := []android.Path{}
|
|
||||||
return compileObjs(ctx, flags, subdir, srcs, excludeSrcs,
|
|
||||||
extraSrcs, extraDeps)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (linker *stubDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
func (linker *stubDecorator) linkerDeps(ctx BaseModuleContext, deps Deps) Deps {
|
||||||
|
|
Loading…
Reference in a new issue