From 96a692bfa93ef99304df9cb13d693af0a4a93904 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 8 Aug 2024 14:47:51 -0700 Subject: [PATCH] Make the srcs and exclude_srcs properties configurable Bug: 358377461 Bug: 342006386 Test: Presubmits Change-Id: I21c20254a3ad3e75dd401ab807eb57ddbbeac047 --- android/prebuilt.go | 16 ++++++++++++++++ cc/cc.go | 44 ++++++++++++++++++++++++++------------------ cc/compiler.go | 36 +++++++++++++++++++----------------- cc/fuzz.go | 2 +- cc/image.go | 25 ++++++++----------------- cc/library.go | 29 ++++++++++++++++------------- cc/prebuilt.go | 18 +++++++----------- 7 files changed, 93 insertions(+), 77 deletions(-) diff --git a/android/prebuilt.go b/android/prebuilt.go index 9c8c13093..fd5a6eaee 100644 --- a/android/prebuilt.go +++ b/android/prebuilt.go @@ -244,6 +244,8 @@ func InitPrebuiltModuleWithSrcSupplier(module PrebuiltInterface, srcsSupplier Pr 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) { if srcs == nil { panic(fmt.Errorf("srcs must not be nil")) @@ -256,6 +258,20 @@ func InitPrebuiltModule(module PrebuiltInterface, srcs *[]string) { 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) { srcPropsValue := reflect.ValueOf(srcProps).Elem() srcStructField, _ := srcPropsValue.Type().FieldByName(srcField) diff --git a/cc/cc.go b/cc/cc.go index 3c276d2c8..b3cac6256 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -906,19 +906,17 @@ type Module struct { logtagsPaths android.Paths WholeRustStaticlib bool + + hasAidl bool + hasLex bool + hasProto bool + hasRenderscript bool + hasSysprop bool + hasWinMsg bool + hasYacc bool } 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) (*d)["Cc"] = map[string]interface{}{ "SdkVersion": c.SdkVersion(), @@ -948,14 +946,14 @@ func (c *Module) AddJSONData(d *map[string]interface{}) { "IsVendorPublicLibrary": c.IsVendorPublicLibrary(), "ApexSdkVersion": c.apexSdkVersion, "TestFor": c.TestFor(), - "AidlSrcs": hasAidl, - "LexSrcs": hasLex, - "ProtoSrcs": hasProto, - "RenderscriptSrcs": hasRenderscript, - "SyspropSrcs": hasSysprop, - "WinMsgSrcs": hasWinMsg, - "YaccSrsc": hasYacc, - "OnlyCSrcs": !(hasAidl || hasLex || hasProto || hasRenderscript || hasSysprop || hasWinMsg || hasYacc), + "AidlSrcs": c.hasAidl, + "LexSrcs": c.hasLex, + "ProtoSrcs": c.hasProto, + "RenderscriptSrcs": c.hasRenderscript, + "SyspropSrcs": c.hasSysprop, + "WinMsgSrcs": c.hasWinMsg, + "YaccSrsc": c.hasYacc, + "OnlyCSrcs": !(c.hasAidl || c.hasLex || c.hasProto || c.hasRenderscript || c.hasSysprop || c.hasWinMsg || c.hasYacc), "OptimizeForSize": c.OptimizeForSize(), } } @@ -2086,6 +2084,16 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { 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) } diff --git a/cc/compiler.go b/cc/compiler.go index ed1053334..0e0b9a72d 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -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. // srcs may reference the outputs of other modules that produce source files like genrule // 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. 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. // 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. Cflags proptools.Configurable[[]string] `android:"arch_variant"` @@ -229,7 +229,7 @@ type BaseCompilerProperties struct { } `android:"arch_variant"` // 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 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...) 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)) } @@ -363,7 +363,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps tc := ctx.toolchain() 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...) 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") } - if compiler.hasSrcExt(".proto") { + if compiler.hasSrcExt(ctx, ".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, "-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") } - if compiler.hasAidl(deps) { + if compiler.hasAidl(ctx, deps) { flags.aidlFlags = append(flags.aidlFlags, compiler.Properties.Aidl.Flags...) if len(compiler.Properties.Aidl.Local_include_dirs) > 0 { 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) - if compiler.hasSrcExt(".aidl") { + if compiler.hasSrcExt(ctx, ".aidl") { flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-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) } - if compiler.hasSrcExt(".sysprop") { + if compiler.hasSrcExt(ctx, ".sysprop") { flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "sysprop", "include").String()) } - if len(compiler.Properties.Srcs) > 0 { + if len(srcs) > 0 { module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName() if inList("-Wno-error", flags.Local.CFlags) || inList("-Wno-error", flags.Local.CppFlags) { addToModuleList(ctx, modulesUsingWnoErrorKey, module) @@ -706,18 +708,18 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps return flags } -func (compiler *baseCompiler) hasSrcExt(ext string) bool { +func (compiler *baseCompiler) hasSrcExt(ctx BaseModuleContext, ext string) bool { for _, src := range compiler.srcsBeforeGen { if src.Ext() == ext { return true } } - for _, src := range compiler.Properties.Srcs { + for _, src := range compiler.Properties.Srcs.GetOrDefault(ctx, nil) { if filepath.Ext(src) == ext { return true } } - for _, src := range compiler.Properties.OriginalSrcs { + for _, src := range compiler.Properties.OriginalSrcs.GetOrDefault(ctx, nil) { if filepath.Ext(src) == ext { return true } @@ -745,8 +747,8 @@ func ndkPathDeps(ctx ModuleContext) android.Paths { return nil } -func (compiler *baseCompiler) hasAidl(deps PathDeps) bool { - return len(deps.AidlLibraryInfos) > 0 || compiler.hasSrcExt(".aidl") +func (compiler *baseCompiler) hasAidl(ctx BaseModuleContext, deps PathDeps) bool { + return len(deps.AidlLibraryInfos) > 0 || compiler.hasSrcExt(ctx, ".aidl") } func (compiler *baseCompiler) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { diff --git a/cc/fuzz.go b/cc/fuzz.go index 92f2c5e44..d9e221b16 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -373,7 +373,7 @@ func NewFuzzer(hod android.HostOrDeviceSupported) *Module { } 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 } }) diff --git a/cc/image.go b/cc/image.go index 2e52ccc63..7594a0854 100644 --- a/cc/image.go +++ b/cc/image.go @@ -465,11 +465,8 @@ func (c *Module) ExtraImageVariations(ctx android.BaseModuleContext) []string { func squashVendorSrcs(m *Module) { if lib, ok := m.compiler.(*libraryDecorator); ok { - lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, - lib.baseCompiler.Properties.Target.Vendor.Srcs...) - - lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, - lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs...) + lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Vendor.Srcs) + lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Vendor.Exclude_srcs) lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources, lib.baseCompiler.Properties.Target.Vendor.Exclude_generated_sources...) @@ -482,11 +479,8 @@ func squashVendorSrcs(m *Module) { func squashProductSrcs(m *Module) { if lib, ok := m.compiler.(*libraryDecorator); ok { - lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, - lib.baseCompiler.Properties.Target.Product.Srcs...) - - lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, - lib.baseCompiler.Properties.Target.Product.Exclude_srcs...) + lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Product.Srcs) + lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Product.Exclude_srcs) lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources, lib.baseCompiler.Properties.Target.Product.Exclude_generated_sources...) @@ -499,11 +493,8 @@ func squashProductSrcs(m *Module) { func squashRecoverySrcs(m *Module) { if lib, ok := m.compiler.(*libraryDecorator); ok { - lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs, - lib.baseCompiler.Properties.Target.Recovery.Srcs...) - - lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, - lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs...) + lib.baseCompiler.Properties.Srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Recovery.Srcs) + lib.baseCompiler.Properties.Exclude_srcs.AppendSimpleValue(lib.baseCompiler.Properties.Target.Recovery.Exclude_srcs) lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources, lib.baseCompiler.Properties.Target.Recovery.Exclude_generated_sources...) @@ -512,13 +503,13 @@ func squashRecoverySrcs(m *Module) { func squashVendorRamdiskSrcs(m *Module) { 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) { 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) } } diff --git a/cc/library.go b/cc/library.go index 092b17779..de0070a15 100644 --- a/cc/library.go +++ b/cc/library.go @@ -142,7 +142,7 @@ type SharedProperties struct { // Use `StaticProperties` or `SharedProperties`, depending on which variant is needed. // `StaticOrSharedProperties` exists only to avoid duplication. 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"` @@ -633,14 +633,17 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa 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 len(library.baseCompiler.Properties.Srcs) > 0 { + if len(srcs) > 0 { 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") } - if len(library.SharedProperties.Shared.Srcs) > 0 { + if len(sharedSrcs) > 0 { ctx.PropertyErrorf("shared.srcs", "cc_library_headers must not have any srcs") } return Objects{} @@ -651,8 +654,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa for _, dir := range dirs { flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir) } - totalLength := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + - len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs) + totalLength := len(srcs) + len(deps.GeneratedSources) + + len(sharedSrcs) + len(staticSrcs) if totalLength > 0 { flags.SAbiDump = true } @@ -662,13 +665,13 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa buildFlags := flagsToBuilderFlags(flags) 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, android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_disabled_srcs), android.PathsForModuleSrc(ctx, library.StaticProperties.Static.Tidy_timeout_srcs), library.baseCompiler.pathDeps, library.baseCompiler.cFlagsDeps)) } 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, android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_disabled_srcs), android.PathsForModuleSrc(ctx, library.SharedProperties.Shared.Tidy_timeout_srcs), @@ -1651,8 +1654,8 @@ func (library *libraryDecorator) link(ctx ModuleContext, // Optionally export aidl headers. if Bool(library.Properties.Aidl.Export_aidl_headers) { - if library.baseCompiler.hasAidl(deps) { - if library.baseCompiler.hasSrcExt(".aidl") { + if library.baseCompiler.hasAidl(ctx, deps) { + if library.baseCompiler.hasSrcExt(ctx, ".aidl") { dir := android.PathForModuleGen(ctx, "aidl") library.reexportDirs(dir) } @@ -1668,7 +1671,7 @@ func (library *libraryDecorator) link(ctx ModuleContext, // Optionally 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 if flags.proto.CanonicalPathFromRoot { 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 library.baseCompiler.hasSrcExt(".sysprop") { + if library.baseCompiler.hasSrcExt(ctx, ".sysprop") { dir := android.PathForModuleGen(ctx, "sysprop", "include") if library.Properties.Sysprop.Platform != nil { 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()) sharedCompiler.baseCompiler.Properties.OriginalSrcs = sharedCompiler.baseCompiler.Properties.Srcs - sharedCompiler.baseCompiler.Properties.Srcs = nil + sharedCompiler.baseCompiler.Properties.Srcs = proptools.NewConfigurable[[]string](nil, nil) sharedCompiler.baseCompiler.Properties.Generated_sources = nil } diff --git a/cc/prebuilt.go b/cc/prebuilt.go index e023a324c..fb151d8fd 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -48,7 +48,7 @@ type prebuiltLinkerProperties struct { Source_module_name *string // 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"` @@ -75,10 +75,6 @@ func (p *prebuiltLinker) prebuilt() *android.Prebuilt { return &p.Prebuilt } -func (p *prebuiltLinker) PrebuiltSrcs() []string { - return p.properties.Srcs -} - type prebuiltLibraryInterface interface { libraryInterface prebuiltLinkerInterface @@ -226,14 +222,14 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext, func (p *prebuiltLibraryLinker) prebuiltSrcs(ctx android.BaseModuleContext) []string { sanitize := ctx.Module().(*Module).sanitize - srcs := p.properties.Srcs + srcs := p.properties.Srcs.GetOrDefault(ctx, nil) srcs = append(srcs, srcsForSanitizer(sanitize, p.properties.Sanitized)...) 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)...) } 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)...) } return srcs @@ -248,7 +244,7 @@ func (p *prebuiltLibraryLinker) nativeCoverage() bool { } 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.Address.Srcs = nil p.properties.Sanitized.Hwaddress.Srcs = nil @@ -416,7 +412,7 @@ func (p *prebuiltBinaryLinker) hostToolPath() android.OptionalPath { func (p *prebuiltBinaryLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { // 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() in := p.Prebuilt.SingleSourcePath(ctx) outputFile := android.PathForModuleOut(ctx, fileName) @@ -500,7 +496,7 @@ func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecor module.AddProperties(&prebuilt.properties) - android.InitPrebuiltModule(module, &prebuilt.properties.Srcs) + android.InitConfigurablePrebuiltModule(module, &prebuilt.properties.Srcs) return module, binary }