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:
@@ -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)
|
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ 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"`
|
||||||
@@ -36,7 +35,6 @@ type LibraryProperties struct {
|
|||||||
} `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"`
|
||||||
@@ -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 {
|
||||||
|
Reference in New Issue
Block a user