Make the srcs and exclude_srcs properties configurable
Bug: 358377461 Bug: 342006386 Test: Presubmits Change-Id: I21c20254a3ad3e75dd401ab807eb57ddbbeac047
This commit is contained in:
@@ -244,6 +244,8 @@ func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier Pr
|
|||||||
p.srcsPropertyName = srcsPropertyName
|
p.srcsPropertyName = srcsPropertyName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitPrebuiltModule is the same as InitPrebuiltModuleWithSrcSupplier, but uses the
|
||||||
|
// provided list of strings property as the source provider.
|
||||||
func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) {
|
func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) {
|
||||||
if srcs == nil {
|
if srcs == nil {
|
||||||
panic(fmt.Errorf("srcs must not be nil"))
|
panic(fmt.Errorf("srcs must not be nil"))
|
||||||
@@ -256,6 +258,20 @@ func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) {
|
|||||||
InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitConfigurablePrebuiltModule is the same as InitPrebuiltModule, but uses a
|
||||||
|
// Configurable list of strings property instead of a regular list of strings.
|
||||||
|
func InitConfigurablePrebuiltModule(module PrebuiltInterface, srcs *proptools.Configurable[[]string]) {
|
||||||
|
if srcs == nil {
|
||||||
|
panic(fmt.Errorf("srcs must not be nil"))
|
||||||
|
}
|
||||||
|
|
||||||
|
srcsSupplier := func(ctx BaseModuleContext, _ Module) []string {
|
||||||
|
return srcs.GetOrDefault(ctx, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
InitPrebuiltModuleWithSrcSupplier(module, srcsSupplier, "srcs")
|
||||||
|
}
|
||||||
|
|
||||||
func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface{}, srcField string) {
|
func InitSingleSourcePrebuiltModule(module PrebuiltInterface, srcProps interface{}, srcField string) {
|
||||||
srcPropsValue := reflect.ValueOf(srcProps).Elem()
|
srcPropsValue := reflect.ValueOf(srcProps).Elem()
|
||||||
srcStructField, _ := srcPropsValue.Type().FieldByName(srcField)
|
srcStructField, _ := srcPropsValue.Type().FieldByName(srcField)
|
||||||
|
44
cc/cc.go
44
cc/cc.go
@@ -906,19 +906,17 @@ type Module struct {
|
|||||||
logtagsPaths android.Paths
|
logtagsPaths android.Paths
|
||||||
|
|
||||||
WholeRustStaticlib bool
|
WholeRustStaticlib bool
|
||||||
|
|
||||||
|
hasAidl bool
|
||||||
|
hasLex bool
|
||||||
|
hasProto bool
|
||||||
|
hasRenderscript bool
|
||||||
|
hasSysprop bool
|
||||||
|
hasWinMsg bool
|
||||||
|
hasYacc bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) AddJSONData(d *map[string]interface{}) {
|
func (c *Module) AddJSONData(d *map[string]interface{}) {
|
||||||
var hasAidl, hasLex, hasProto, hasRenderscript, hasSysprop, hasWinMsg, hasYacc bool
|
|
||||||
if b, ok := c.compiler.(*baseCompiler); ok {
|
|
||||||
hasAidl = b.hasSrcExt(".aidl")
|
|
||||||
hasLex = b.hasSrcExt(".l") || b.hasSrcExt(".ll")
|
|
||||||
hasProto = b.hasSrcExt(".proto")
|
|
||||||
hasRenderscript = b.hasSrcExt(".rscript") || b.hasSrcExt(".fs")
|
|
||||||
hasSysprop = b.hasSrcExt(".sysprop")
|
|
||||||
hasWinMsg = b.hasSrcExt(".mc")
|
|
||||||
hasYacc = b.hasSrcExt(".y") || b.hasSrcExt(".yy")
|
|
||||||
}
|
|
||||||
c.AndroidModuleBase().AddJSONData(d)
|
c.AndroidModuleBase().AddJSONData(d)
|
||||||
(*d)["Cc"] = map[string]interface{}{
|
(*d)["Cc"] = map[string]interface{}{
|
||||||
"SdkVersion": c.SdkVersion(),
|
"SdkVersion": c.SdkVersion(),
|
||||||
@@ -948,14 +946,14 @@ func (c *Module) AddJSONData(d *map[string]interface{}) {
|
|||||||
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
|
"IsVendorPublicLibrary": c.IsVendorPublicLibrary(),
|
||||||
"ApexSdkVersion": c.apexSdkVersion,
|
"ApexSdkVersion": c.apexSdkVersion,
|
||||||
"TestFor": c.TestFor(),
|
"TestFor": c.TestFor(),
|
||||||
"AidlSrcs": hasAidl,
|
"AidlSrcs": c.hasAidl,
|
||||||
"LexSrcs": hasLex,
|
"LexSrcs": c.hasLex,
|
||||||
"ProtoSrcs": hasProto,
|
"ProtoSrcs": c.hasProto,
|
||||||
"RenderscriptSrcs": hasRenderscript,
|
"RenderscriptSrcs": c.hasRenderscript,
|
||||||
"SyspropSrcs": hasSysprop,
|
"SyspropSrcs": c.hasSysprop,
|
||||||
"WinMsgSrcs": hasWinMsg,
|
"WinMsgSrcs": c.hasWinMsg,
|
||||||
"YaccSrsc": hasYacc,
|
"YaccSrsc": c.hasYacc,
|
||||||
"OnlyCSrcs": !(hasAidl || hasLex || hasProto || hasRenderscript || hasSysprop || hasWinMsg || hasYacc),
|
"OnlyCSrcs": !(c.hasAidl || c.hasLex || c.hasProto || c.hasRenderscript || c.hasSysprop || c.hasWinMsg || c.hasYacc),
|
||||||
"OptimizeForSize": c.OptimizeForSize(),
|
"OptimizeForSize": c.OptimizeForSize(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2086,6 +2084,16 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|||||||
|
|
||||||
buildComplianceMetadataInfo(ctx, c, deps)
|
buildComplianceMetadataInfo(ctx, c, deps)
|
||||||
|
|
||||||
|
if b, ok := c.compiler.(*baseCompiler); ok {
|
||||||
|
c.hasAidl = b.hasSrcExt(ctx, ".aidl")
|
||||||
|
c.hasLex = b.hasSrcExt(ctx, ".l") || b.hasSrcExt(ctx, ".ll")
|
||||||
|
c.hasProto = b.hasSrcExt(ctx, ".proto")
|
||||||
|
c.hasRenderscript = b.hasSrcExt(ctx, ".rscript") || b.hasSrcExt(ctx, ".fs")
|
||||||
|
c.hasSysprop = b.hasSrcExt(ctx, ".sysprop")
|
||||||
|
c.hasWinMsg = b.hasSrcExt(ctx, ".mc")
|
||||||
|
c.hasYacc = b.hasSrcExt(ctx, ".y") || b.hasSrcExt(ctx, ".yy")
|
||||||
|
}
|
||||||
|
|
||||||
c.setOutputFiles(ctx)
|
c.setOutputFiles(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,7 +37,7 @@ type BaseCompilerProperties struct {
|
|||||||
// list of source files used to compile the C/C++ module. May be .c, .cpp, or .S files.
|
// list of source files used to compile the C/C++ module. May be .c, .cpp, or .S files.
|
||||||
// srcs may reference the outputs of other modules that produce source files like genrule
|
// srcs may reference the outputs of other modules that produce source files like genrule
|
||||||
// or filegroup using the syntax ":module".
|
// or filegroup using the syntax ":module".
|
||||||
Srcs []string `android:"path,arch_variant"`
|
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
|
||||||
|
|
||||||
// list of source files that should not be compiled with clang-tidy.
|
// list of source files that should not be compiled with clang-tidy.
|
||||||
Tidy_disabled_srcs []string `android:"path,arch_variant"`
|
Tidy_disabled_srcs []string `android:"path,arch_variant"`
|
||||||
@@ -47,7 +47,7 @@ type BaseCompilerProperties struct {
|
|||||||
|
|
||||||
// list of source files that should not be used to build the C/C++ module.
|
// list of source files that should not be used to build the C/C++ module.
|
||||||
// This is most useful in the arch/multilib variants to remove non-common files
|
// This is most useful in the arch/multilib variants to remove non-common files
|
||||||
Exclude_srcs []string `android:"path,arch_variant"`
|
Exclude_srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
|
||||||
|
|
||||||
// list of module-specific flags that will be used for C and C++ compiles.
|
// list of module-specific flags that will be used for C and C++ compiles.
|
||||||
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
|
Cflags proptools.Configurable[[]string] `android:"arch_variant"`
|
||||||
@@ -229,7 +229,7 @@ type BaseCompilerProperties struct {
|
|||||||
} `android:"arch_variant"`
|
} `android:"arch_variant"`
|
||||||
|
|
||||||
// Stores the original list of source files before being cleared by library reuse
|
// Stores the original list of source files before being cleared by library reuse
|
||||||
OriginalSrcs []string `blueprint:"mutated"`
|
OriginalSrcs proptools.Configurable[[]string] `blueprint:"mutated"`
|
||||||
|
|
||||||
// Build and link with OpenMP
|
// Build and link with OpenMP
|
||||||
Openmp *bool `android:"arch_variant"`
|
Openmp *bool `android:"arch_variant"`
|
||||||
@@ -300,7 +300,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||||||
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
|
deps.AidlLibs = append(deps.AidlLibs, compiler.Properties.Aidl.Libs...)
|
||||||
|
|
||||||
android.ProtoDeps(ctx, &compiler.Proto)
|
android.ProtoDeps(ctx, &compiler.Proto)
|
||||||
if compiler.hasSrcExt(".proto") {
|
if compiler.hasSrcExt(ctx, ".proto") {
|
||||||
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
|
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,7 +363,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
tc := ctx.toolchain()
|
tc := ctx.toolchain()
|
||||||
modulePath := ctx.ModuleDir()
|
modulePath := ctx.ModuleDir()
|
||||||
|
|
||||||
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
|
srcs := compiler.Properties.Srcs.GetOrDefault(ctx, nil)
|
||||||
|
exclude_srcs := compiler.Properties.Exclude_srcs.GetOrDefault(ctx, nil)
|
||||||
|
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, srcs, exclude_srcs)
|
||||||
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
|
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)
|
||||||
|
|
||||||
cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
|
cflags := compiler.Properties.Cflags.GetOrDefault(ctx, nil)
|
||||||
@@ -603,11 +605,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
flags.Global.CFlags = append(flags.Global.CFlags, "-DANDROID_STRICT")
|
flags.Global.CFlags = append(flags.Global.CFlags, "-DANDROID_STRICT")
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".proto") {
|
if compiler.hasSrcExt(ctx, ".proto") {
|
||||||
flags = protoFlags(ctx, flags, &compiler.Proto)
|
flags = protoFlags(ctx, flags, &compiler.Proto)
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".y") || compiler.hasSrcExt(".yy") {
|
if compiler.hasSrcExt(ctx, ".y") || compiler.hasSrcExt(ctx, ".yy") {
|
||||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
||||||
"-I"+android.PathForModuleGen(ctx, "yacc", ctx.ModuleDir()).String())
|
"-I"+android.PathForModuleGen(ctx, "yacc", ctx.ModuleDir()).String())
|
||||||
}
|
}
|
||||||
@@ -617,7 +619,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
ctx.ModuleErrorf("aidl.libs and (aidl.include_dirs or aidl.local_include_dirs) can't be set at the same time. For aidl headers, please only use aidl.libs prop")
|
ctx.ModuleErrorf("aidl.libs and (aidl.include_dirs or aidl.local_include_dirs) can't be set at the same time. For aidl headers, please only use aidl.libs prop")
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasAidl(deps) {
|
if compiler.hasAidl(ctx, deps) {
|
||||||
flags.aidlFlags = append(flags.aidlFlags, compiler.Properties.Aidl.Flags...)
|
flags.aidlFlags = append(flags.aidlFlags, compiler.Properties.Aidl.Flags...)
|
||||||
if len(compiler.Properties.Aidl.Local_include_dirs) > 0 {
|
if len(compiler.Properties.Aidl.Local_include_dirs) > 0 {
|
||||||
localAidlIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Aidl.Local_include_dirs)
|
localAidlIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Aidl.Local_include_dirs)
|
||||||
@@ -646,7 +648,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
}
|
}
|
||||||
flags.aidlFlags = append(flags.aidlFlags, "--min_sdk_version="+aidlMinSdkVersion)
|
flags.aidlFlags = append(flags.aidlFlags, "--min_sdk_version="+aidlMinSdkVersion)
|
||||||
|
|
||||||
if compiler.hasSrcExt(".aidl") {
|
if compiler.hasSrcExt(ctx, ".aidl") {
|
||||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
||||||
"-I"+android.PathForModuleGen(ctx, "aidl").String())
|
"-I"+android.PathForModuleGen(ctx, "aidl").String())
|
||||||
}
|
}
|
||||||
@@ -656,16 +658,16 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".rscript") || compiler.hasSrcExt(".fs") {
|
if compiler.hasSrcExt(ctx, ".rscript") || compiler.hasSrcExt(ctx, ".fs") {
|
||||||
flags = rsFlags(ctx, flags, &compiler.Properties)
|
flags = rsFlags(ctx, flags, &compiler.Properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".sysprop") {
|
if compiler.hasSrcExt(ctx, ".sysprop") {
|
||||||
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
flags.Local.CommonFlags = append(flags.Local.CommonFlags,
|
||||||
"-I"+android.PathForModuleGen(ctx, "sysprop", "include").String())
|
"-I"+android.PathForModuleGen(ctx, "sysprop", "include").String())
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(compiler.Properties.Srcs) > 0 {
|
if len(srcs) > 0 {
|
||||||
module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
|
module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName()
|
||||||
if inList("-Wno-error", flags.Local.CFlags) || inList("-Wno-error", flags.Local.CppFlags) {
|
if inList("-Wno-error", flags.Local.CFlags) || inList("-Wno-error", flags.Local.CppFlags) {
|
||||||
addToModuleList(ctx, modulesUsingWnoErrorKey, module)
|
addToModuleList(ctx, modulesUsingWnoErrorKey, module)
|
||||||
@@ -706,18 +708,18 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
return flags
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
func (compiler *baseCompiler) hasSrcExt(ext string) bool {
|
func (compiler *baseCompiler) hasSrcExt(ctx BaseModuleContext, ext string) bool {
|
||||||
for _, src := range compiler.srcsBeforeGen {
|
for _, src := range compiler.srcsBeforeGen {
|
||||||
if src.Ext() == ext {
|
if src.Ext() == ext {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, src := range compiler.Properties.Srcs {
|
for _, src := range compiler.Properties.Srcs.GetOrDefault(ctx, nil) {
|
||||||
if filepath.Ext(src) == ext {
|
if filepath.Ext(src) == ext {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, src := range compiler.Properties.OriginalSrcs {
|
for _, src := range compiler.Properties.OriginalSrcs.GetOrDefault(ctx, nil) {
|
||||||
if filepath.Ext(src) == ext {
|
if filepath.Ext(src) == ext {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -745,8 +747,8 @@ func ndkPathDeps(ctx ModuleContext) android.Paths {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (compiler *baseCompiler) hasAidl(deps PathDeps) bool {
|
func (compiler *baseCompiler) hasAidl(ctx BaseModuleContext, deps PathDeps) bool {
|
||||||
return len(deps.AidlLibraryInfos) > 0 || compiler.hasSrcExt(".aidl")
|
return len(deps.AidlLibraryInfos) > 0 || compiler.hasSrcExt(ctx, ".aidl")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
||||||
|
@@ -373,7 +373,7 @@ func NewFuzzer(hod android.HostOrDeviceSupported) *Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if targetFramework == fuzz.AFL {
|
if targetFramework == fuzz.AFL {
|
||||||
fuzzBin.baseCompiler.Properties.Srcs = append(fuzzBin.baseCompiler.Properties.Srcs, ":aflpp_driver", ":afl-compiler-rt")
|
fuzzBin.baseCompiler.Properties.Srcs.AppendSimpleValue([]string{":aflpp_driver", ":afl-compiler-rt"})
|
||||||
module.fuzzer.Properties.FuzzFramework = fuzz.AFL
|
module.fuzzer.Properties.FuzzFramework = fuzz.AFL
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
25
cc/image.go
25
cc/image.go
@@ -465,11 +465,8 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string {
|
|||||||
|
|
||||||
func squashVendorSrcs(m *Module) {
|
func squashVendorSrcs(m *Module) {
|
||||||
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
||||||
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
|
lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Vendor.Srcs)
|
||||||
lib.baseCompiler.Properties.Target.Vendor.Srcs...)
|
lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs)
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
|
|
||||||
lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...)
|
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
||||||
lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
|
lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...)
|
||||||
@@ -482,11 +479,8 @@ func squashVendorSrcs(m *Module) {
|
|||||||
|
|
||||||
func squashProductSrcs(m *Module) {
|
func squashProductSrcs(m *Module) {
|
||||||
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
||||||
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
|
lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Product.Srcs)
|
||||||
lib.baseCompiler.Properties.Target.Product.Srcs...)
|
lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Product.Exclude_srcs)
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
|
|
||||||
lib.baseCompiler.Properties.Target.Product.Exclude_srcs...)
|
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
||||||
lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
|
lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...)
|
||||||
@@ -499,11 +493,8 @@ func squashProductSrcs(m *Module) {
|
|||||||
|
|
||||||
func squashRecoverySrcs(m *Module) {
|
func squashRecoverySrcs(m *Module) {
|
||||||
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
||||||
lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
|
lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Recovery.Srcs)
|
||||||
lib.baseCompiler.Properties.Target.Recovery.Srcs...)
|
lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs)
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
|
|
||||||
lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...)
|
|
||||||
|
|
||||||
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
|
||||||
lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
|
lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...)
|
||||||
@@ -512,13 +503,13 @@ func squashRecoverySrcs(m *Module) {
|
|||||||
|
|
||||||
func squashVendorRamdiskSrcs(m *Module) {
|
func squashVendorRamdiskSrcs(m *Module) {
|
||||||
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
||||||
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
|
lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func squashRamdiskSrcs(m *Module) {
|
func squashRamdiskSrcs(m *Module) {
|
||||||
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
if lib, ok := m.compiler.(*libraryDecorator); ok {
|
||||||
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Ramdisk.Exclude_srcs...)
|
lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Ramdisk.Exclude_srcs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -142,7 +142,7 @@ type SharedProperties struct {
|
|||||||
// Use `StaticProperties` or `SharedProperties`, depending on which variant is needed.
|
// Use `StaticProperties` or `SharedProperties`, depending on which variant is needed.
|
||||||
// `StaticOrSharedProperties` exists only to avoid duplication.
|
// `StaticOrSharedProperties` exists only to avoid duplication.
|
||||||
type StaticOrSharedProperties struct {
|
type StaticOrSharedProperties struct {
|
||||||
Srcs []string `android:"path,arch_variant"`
|
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
|
||||||
|
|
||||||
Tidy_disabled_srcs []string `android:"path,arch_variant"`
|
Tidy_disabled_srcs []string `android:"path,arch_variant"`
|
||||||
|
|
||||||
@@ -633,14 +633,17 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
|||||||
return objs
|
return objs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srcs := library.baseCompiler.Properties.Srcs.GetOrDefault(ctx, nil)
|
||||||
|
staticSrcs := library.StaticProperties.Static.Srcs.GetOrDefault(ctx, nil)
|
||||||
|
sharedSrcs := library.SharedProperties.Shared.Srcs.GetOrDefault(ctx, nil)
|
||||||
if !library.buildShared() && !library.buildStatic() {
|
if !library.buildShared() && !library.buildStatic() {
|
||||||
if len(library.baseCompiler.Properties.Srcs) > 0 {
|
if len(srcs) > 0 {
|
||||||
ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
|
ctx.PropertyErrorf("srcs", "cc_library_headers must not have any srcs")
|
||||||
}
|
}
|
||||||
if len(library.StaticProperties.Static.Srcs) > 0 {
|
if len(staticSrcs) > 0 {
|
||||||
ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
|
ctx.PropertyErrorf("static.srcs", "cc_library_headers must not have any srcs")
|
||||||
}
|
}
|
||||||
if len(library.SharedProperties.Shared.Srcs) > 0 {
|
if len(sharedSrcs) > 0 {
|
||||||
ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
|
ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs")
|
||||||
}
|
}
|
||||||
return Objects{}
|
return Objects{}
|
||||||
@@ -651,8 +654,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
|||||||
for _, dir := range dirs {
|
for _, dir := range dirs {
|
||||||
flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir)
|
flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir)
|
||||||
}
|
}
|
||||||
totalLength := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) +
|
totalLength := len(srcs) + len(deps.GeneratedSources) +
|
||||||
len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs)
|
len(sharedSrcs) + len(staticSrcs)
|
||||||
if totalLength > 0 {
|
if totalLength > 0 {
|
||||||
flags.SAbiDump = true
|
flags.SAbiDump = true
|
||||||
}
|
}
|
||||||
@@ -662,13 +665,13 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
|||||||
buildFlags := flagsToBuilderFlags(flags)
|
buildFlags := flagsToBuilderFlags(flags)
|
||||||
|
|
||||||
if library.static() {
|
if library.static() {
|
||||||
srcs := android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Srcs)
|
srcs := android.PathsForModuleSrc(ctx, staticSrcs)
|
||||||
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, srcs,
|
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceStaticLibrary, srcs,
|
||||||
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_disabled_srcs),
|
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_disabled_srcs),
|
||||||
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_timeout_srcs),
|
android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_timeout_srcs),
|
||||||
library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
|
library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps))
|
||||||
} else if library.shared() {
|
} else if library.shared() {
|
||||||
srcs := android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Srcs)
|
srcs := android.PathsForModuleSrc(ctx, sharedSrcs)
|
||||||
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, srcs,
|
objs = objs.Append(compileObjs(ctx, buildFlags, android.DeviceSharedLibrary, srcs,
|
||||||
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_disabled_srcs),
|
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_disabled_srcs),
|
||||||
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_timeout_srcs),
|
android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_timeout_srcs),
|
||||||
@@ -1651,8 +1654,8 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||||||
|
|
||||||
// Optionally export aidl headers.
|
// Optionally export aidl headers.
|
||||||
if Bool(library.Properties.Aidl.Export_aidl_headers) {
|
if Bool(library.Properties.Aidl.Export_aidl_headers) {
|
||||||
if library.baseCompiler.hasAidl(deps) {
|
if library.baseCompiler.hasAidl(ctx, deps) {
|
||||||
if library.baseCompiler.hasSrcExt(".aidl") {
|
if library.baseCompiler.hasSrcExt(ctx, ".aidl") {
|
||||||
dir := android.PathForModuleGen(ctx, "aidl")
|
dir := android.PathForModuleGen(ctx, "aidl")
|
||||||
library.reexportDirs(dir)
|
library.reexportDirs(dir)
|
||||||
}
|
}
|
||||||
@@ -1668,7 +1671,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||||||
|
|
||||||
// Optionally export proto headers.
|
// Optionally export proto headers.
|
||||||
if Bool(library.Properties.Proto.Export_proto_headers) {
|
if Bool(library.Properties.Proto.Export_proto_headers) {
|
||||||
if library.baseCompiler.hasSrcExt(".proto") {
|
if library.baseCompiler.hasSrcExt(ctx, ".proto") {
|
||||||
var includes android.Paths
|
var includes android.Paths
|
||||||
if flags.proto.CanonicalPathFromRoot {
|
if flags.proto.CanonicalPathFromRoot {
|
||||||
includes = append(includes, flags.proto.SubDir)
|
includes = append(includes, flags.proto.SubDir)
|
||||||
@@ -1682,7 +1685,7 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the library is sysprop_library, expose either public or internal header selectively.
|
// If the library is sysprop_library, expose either public or internal header selectively.
|
||||||
if library.baseCompiler.hasSrcExt(".sysprop") {
|
if library.baseCompiler.hasSrcExt(ctx, ".sysprop") {
|
||||||
dir := android.PathForModuleGen(ctx, "sysprop", "include")
|
dir := android.PathForModuleGen(ctx, "sysprop", "include")
|
||||||
if library.Properties.Sysprop.Platform != nil {
|
if library.Properties.Sysprop.Platform != nil {
|
||||||
isOwnerPlatform := Bool(library.Properties.Sysprop.Platform)
|
isOwnerPlatform := Bool(library.Properties.Sysprop.Platform)
|
||||||
@@ -2091,7 +2094,7 @@ func reuseStaticLibrary(ctx android.BottomUpMutatorContext, shared *Module) {
|
|||||||
ctx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, reuseObjTag, ctx.ModuleName())
|
ctx.AddVariationDependencies([]blueprint.Variation{{"link", "static"}}, reuseObjTag, ctx.ModuleName())
|
||||||
sharedCompiler.baseCompiler.Properties.OriginalSrcs =
|
sharedCompiler.baseCompiler.Properties.OriginalSrcs =
|
||||||
sharedCompiler.baseCompiler.Properties.Srcs
|
sharedCompiler.baseCompiler.Properties.Srcs
|
||||||
sharedCompiler.baseCompiler.Properties.Srcs = nil
|
sharedCompiler.baseCompiler.Properties.Srcs = proptools.NewConfigurable[[]string](nil, nil)
|
||||||
sharedCompiler.baseCompiler.Properties.Generated_sources = nil
|
sharedCompiler.baseCompiler.Properties.Generated_sources = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ type prebuiltLinkerProperties struct {
|
|||||||
Source_module_name *string
|
Source_module_name *string
|
||||||
|
|
||||||
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
|
// a prebuilt library or binary. Can reference a genrule module that generates an executable file.
|
||||||
Srcs []string `android:"path,arch_variant"`
|
Srcs proptools.Configurable[[]string] `android:"path,arch_variant"`
|
||||||
|
|
||||||
Sanitized Sanitized `android:"arch_variant"`
|
Sanitized Sanitized `android:"arch_variant"`
|
||||||
|
|
||||||
@@ -75,10 +75,6 @@ func (p *prebuiltLinker) prebuilt() *android.Prebuilt {
|
|||||||
return &p.Prebuilt
|
return &p.Prebuilt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltLinker) PrebuiltSrcs() []string {
|
|
||||||
return p.properties.Srcs
|
|
||||||
}
|
|
||||||
|
|
||||||
type prebuiltLibraryInterface interface {
|
type prebuiltLibraryInterface interface {
|
||||||
libraryInterface
|
libraryInterface
|
||||||
prebuiltLinkerInterface
|
prebuiltLinkerInterface
|
||||||
@@ -226,14 +222,14 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
|
|||||||
|
|
||||||
func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string {
|
func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string {
|
||||||
sanitize := ctx.Module().(*Module).sanitize
|
sanitize := ctx.Module().(*Module).sanitize
|
||||||
srcs := p.properties.Srcs
|
srcs := p.properties.Srcs.GetOrDefault(ctx, nil)
|
||||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...)
|
srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...)
|
||||||
if p.static() {
|
if p.static() {
|
||||||
srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs...)
|
srcs = append(srcs, p.libraryDecorator.StaticProperties.Static.Srcs.GetOrDefault(ctx, nil)...)
|
||||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...)
|
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.StaticProperties.Static.Sanitized)...)
|
||||||
}
|
}
|
||||||
if p.shared() {
|
if p.shared() {
|
||||||
srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs...)
|
srcs = append(srcs, p.libraryDecorator.SharedProperties.Shared.Srcs.GetOrDefault(ctx, nil)...)
|
||||||
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...)
|
srcs = append(srcs, srcsForSanitizer(sanitize, p.libraryDecorator.SharedProperties.Shared.Sanitized)...)
|
||||||
}
|
}
|
||||||
return srcs
|
return srcs
|
||||||
@@ -248,7 +244,7 @@ func (p *prebuiltLibraryLinker) nativeCoverage() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *prebuiltLibraryLinker) disablePrebuilt() {
|
func (p *prebuiltLibraryLinker) disablePrebuilt() {
|
||||||
p.properties.Srcs = nil
|
p.properties.Srcs = proptools.NewConfigurable[[]string](nil, nil)
|
||||||
p.properties.Sanitized.None.Srcs = nil
|
p.properties.Sanitized.None.Srcs = nil
|
||||||
p.properties.Sanitized.Address.Srcs = nil
|
p.properties.Sanitized.Address.Srcs = nil
|
||||||
p.properties.Sanitized.Hwaddress.Srcs = nil
|
p.properties.Sanitized.Hwaddress.Srcs = nil
|
||||||
@@ -416,7 +412,7 @@ func (p *prebuiltBinaryLinker) hostToolPath() android.OptionalPath {
|
|||||||
func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
|
func (p *prebuiltBinaryLinker) link(ctx ModuleContext,
|
||||||
flags Flags, deps PathDeps, objs Objects) android.Path {
|
flags Flags, deps PathDeps, objs Objects) android.Path {
|
||||||
// TODO(ccross): verify shared library dependencies
|
// TODO(ccross): verify shared library dependencies
|
||||||
if len(p.properties.Srcs) > 0 {
|
if len(p.properties.Srcs.GetOrDefault(ctx, nil)) > 0 {
|
||||||
fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
|
fileName := p.getStem(ctx) + flags.Toolchain.ExecutableSuffix()
|
||||||
in := p.Prebuilt.SingleSourcePath(ctx)
|
in := p.Prebuilt.SingleSourcePath(ctx)
|
||||||
outputFile := android.PathForModuleOut(ctx, fileName)
|
outputFile := android.PathForModuleOut(ctx, fileName)
|
||||||
@@ -500,7 +496,7 @@ func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecor
|
|||||||
|
|
||||||
module.AddProperties(&prebuilt.properties)
|
module.AddProperties(&prebuilt.properties)
|
||||||
|
|
||||||
android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
|
android.InitConfigurablePrebuiltModule(module, &prebuilt.properties.Srcs)
|
||||||
return module, binary
|
return module, binary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user