Merge "Merge SingletonProviderContext with OtherModuleProviderContext" into main
diff --git a/android/container.go b/android/container.go
index c4fdd9c..05897dd 100644
--- a/android/container.go
+++ b/android/container.go
@@ -21,12 +21,22 @@
"github.com/google/blueprint"
)
+// ----------------------------------------------------------------------------
+// Start of the definitions of exception functions and the lookup table.
+//
+// Functions cannot be used as a value passed in providers, because functions are not
+// hashable. As a workaround, the [exceptionHandleFuncLabel] enum values are passed using providers,
+// and the corresponding functions are called from [exceptionHandleFunctionsTable] map.
+// ----------------------------------------------------------------------------
+
+type exceptionHandleFunc func(ModuleContext, Module, Module) bool
+
type StubsAvailableModule interface {
IsStubsModule() bool
}
// Returns true if the dependency module is a stubs module
-var depIsStubsModule = func(_ ModuleContext, _, dep Module) bool {
+var depIsStubsModule exceptionHandleFunc = func(_ ModuleContext, _, dep Module) bool {
if stubsModule, ok := dep.(StubsAvailableModule); ok {
return stubsModule.IsStubsModule()
}
@@ -41,13 +51,76 @@
checkStubs exceptionHandleFuncLabel = iota
)
-// Functions cannot be used as a value passed in providers, because functions are not
-// hashable. As a workaround, the exceptionHandleFunc enum values are passed using providers,
-// and the corresponding functions are called from this map.
-var exceptionHandleFunctionsTable = map[exceptionHandleFuncLabel]func(ModuleContext, Module, Module) bool{
+var exceptionHandleFunctionsTable = map[exceptionHandleFuncLabel]exceptionHandleFunc{
checkStubs: depIsStubsModule,
}
+// ----------------------------------------------------------------------------
+// Start of the definitions of container determination functions.
+//
+// Similar to the above section, below defines the functions used to determine
+// the container of each modules.
+// ----------------------------------------------------------------------------
+
+type containerBoundaryFunc func(mctx ModuleContext) bool
+
+var vendorContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool {
+ m, ok := mctx.Module().(ImageInterface)
+ return mctx.Module().InstallInVendor() || (ok && m.VendorVariantNeeded(mctx))
+}
+
+var systemContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool {
+ module := mctx.Module()
+
+ return !module.InstallInTestcases() &&
+ !module.InstallInData() &&
+ !module.InstallInRamdisk() &&
+ !module.InstallInVendorRamdisk() &&
+ !module.InstallInDebugRamdisk() &&
+ !module.InstallInRecovery() &&
+ !module.InstallInVendor() &&
+ !module.InstallInOdm() &&
+ !module.InstallInProduct() &&
+ determineModuleKind(module.base(), mctx.blueprintBaseModuleContext()) == platformModule
+}
+
+var productContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool {
+ m, ok := mctx.Module().(ImageInterface)
+ return mctx.Module().InstallInProduct() || (ok && m.ProductVariantNeeded(mctx))
+}
+
+var apexContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool {
+ _, ok := ModuleProvider(mctx, AllApexInfoProvider)
+ return ok
+}
+
+var ctsContainerBoundaryFunc containerBoundaryFunc = func(mctx ModuleContext) bool {
+ props := mctx.Module().GetProperties()
+ for _, prop := range props {
+ val := reflect.ValueOf(prop).Elem()
+ if val.Kind() == reflect.Struct {
+ testSuites := val.FieldByName("Test_suites")
+ if testSuites.IsValid() && testSuites.Kind() == reflect.Slice && slices.Contains(testSuites.Interface().([]string), "cts") {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+// Map of [*container] to the [containerBoundaryFunc]
+var containerBoundaryFunctionsTable = map[*container]containerBoundaryFunc{
+ VendorContainer: vendorContainerBoundaryFunc,
+ SystemContainer: systemContainerBoundaryFunc,
+ ProductContainer: productContainerBoundaryFunc,
+ ApexContainer: apexContainerBoundaryFunc,
+ CtsContainer: ctsContainerBoundaryFunc,
+}
+
+// ----------------------------------------------------------------------------
+// End of the definitions of container determination functions.
+// ----------------------------------------------------------------------------
+
type InstallableModule interface {
EnforceApiContainerChecks() bool
}
@@ -77,6 +150,7 @@
name: VendorVariation,
restricted: nil,
}
+
SystemContainer = &container{
name: "system",
restricted: []restriction{
@@ -90,6 +164,7 @@
},
},
}
+
ProductContainer = &container{
name: ProductVariation,
restricted: []restriction{
@@ -102,8 +177,10 @@
},
},
}
+
ApexContainer = initializeApexContainer()
- CtsContainer = &container{
+
+ CtsContainer = &container{
name: "cts",
restricted: []restriction{
{
@@ -116,6 +193,14 @@
},
},
}
+
+ allContainers = []*container{
+ VendorContainer,
+ SystemContainer,
+ ProductContainer,
+ ApexContainer,
+ CtsContainer,
+ }
)
func initializeApexContainer() *container {
@@ -155,68 +240,38 @@
return c.belongingContainers
}
-var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]()
-
-// Determines if the module can be installed in the system partition or not.
-// Logic is identical to that of modulePartition(...) defined in paths.go
-func installInSystemPartition(ctx ModuleContext) bool {
- module := ctx.Module()
- return !module.InstallInTestcases() &&
- !module.InstallInData() &&
- !module.InstallInRamdisk() &&
- !module.InstallInVendorRamdisk() &&
- !module.InstallInDebugRamdisk() &&
- !module.InstallInRecovery() &&
- !module.InstallInVendor() &&
- !module.InstallInOdm() &&
- !module.InstallInProduct() &&
- determineModuleKind(module.base(), ctx.blueprintBaseModuleContext()) == platformModule
+func (c *ContainersInfo) ApexNames() (ret []string) {
+ for _, apex := range c.belongingApexes {
+ ret = append(ret, apex.InApexModules...)
+ }
+ slices.Sort(ret)
+ return ret
}
-func generateContainerInfo(ctx ModuleContext) ContainersInfo {
- inSystem := installInSystemPartition(ctx)
- inProduct := ctx.Module().InstallInProduct()
- inVendor := ctx.Module().InstallInVendor()
- inCts := false
- inApex := false
-
- if m, ok := ctx.Module().(ImageInterface); ok {
- inProduct = inProduct || m.ProductVariantNeeded(ctx)
- inVendor = inVendor || m.VendorVariantNeeded(ctx)
+// Returns true if any of the apex the module belongs to is updatable.
+func (c *ContainersInfo) UpdatableApex() bool {
+ for _, apex := range c.belongingApexes {
+ if apex.Updatable {
+ return true
+ }
}
+ return false
+}
- props := ctx.Module().GetProperties()
- for _, prop := range props {
- val := reflect.ValueOf(prop).Elem()
- if val.Kind() == reflect.Struct {
- testSuites := val.FieldByName("Test_suites")
- if testSuites.IsValid() && testSuites.Kind() == reflect.Slice && slices.Contains(testSuites.Interface().([]string), "cts") {
- inCts = true
- }
+var ContainersInfoProvider = blueprint.NewProvider[ContainersInfo]()
+
+func generateContainerInfo(ctx ModuleContext) ContainersInfo {
+ var containers []*container
+
+ for _, cnt := range allContainers {
+ if containerBoundaryFunctionsTable[cnt](ctx) {
+ containers = append(containers, cnt)
}
}
var belongingApexes []ApexInfo
if apexInfo, ok := ModuleProvider(ctx, AllApexInfoProvider); ok {
belongingApexes = apexInfo.ApexInfos
- inApex = true
- }
-
- containers := []*container{}
- if inSystem {
- containers = append(containers, SystemContainer)
- }
- if inProduct {
- containers = append(containers, ProductContainer)
- }
- if inVendor {
- containers = append(containers, VendorContainer)
- }
- if inCts {
- containers = append(containers, CtsContainer)
- }
- if inApex {
- containers = append(containers, ApexContainer)
}
return ContainersInfo{
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 9c8c130..fd5a6ea 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -244,6 +244,8 @@
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 @@
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/bin/dirmods b/bin/dirmods
index a6d4de3..c8976d5 100755
--- a/bin/dirmods
+++ b/bin/dirmods
@@ -32,7 +32,10 @@
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('path')
+ parser.add_argument('--no-recurse', '-n', action='store_true',
+ help='Do not include modules defined in subdirs of path')
args = parser.parse_args()
+ should_recurse = not args.no_recurse
d = os.path.normpath(args.path)
# Fix absolute path to be relative to build top
@@ -43,15 +46,15 @@
if d.startswith(base):
d = d[len(base):]
- prefix = d + '/'
+ prefix = d + os.path.sep
module_info = modinfo.ReadModuleInfo()
results = set()
for m in module_info.values():
- for path in m.get(u'path', []):
- if path == d or path.startswith(prefix):
- name = m.get(u'module_name')
+ for path in m.get('path', []):
+ if path == d or (should_recurse and path.startswith(prefix)):
+ name = m.get('module_name')
if name:
results.add(name)
diff --git a/cc/cc.go b/cc/cc.go
index 3c276d2..b3cac62 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -906,19 +906,17 @@
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 @@
"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 @@
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 ed10533..0e0b9a7 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -37,7 +37,7 @@
// 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 @@
// 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 @@
} `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 @@
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 @@
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 @@
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 @@
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 @@
}
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 @@
}
}
- 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 @@
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 @@
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/config/global.go b/cc/config/global.go
index 7950713..0e8fff6 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -293,13 +293,6 @@
"-Wno-error=invalid-offsetof",
"-Wno-error=thread-safety-reference-return",
- // Irrelevant on Android because _we_ don't use exceptions, but causes
- // lots of build noise because libcxx/libcxxabi do. This can probably
- // go away when we're on a new enough libc++, but has to be global
- // until then because it causes warnings in the _callers_, not the
- // project itself.
- "-Wno-deprecated-dynamic-exception-spec",
-
// Allow using VLA CXX extension.
"-Wno-vla-cxx-extension",
}
diff --git a/cc/fuzz.go b/cc/fuzz.go
index 92f2c5e..d9e221b 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -373,7 +373,7 @@
}
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 2e52ccc..7594a08 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -465,11 +465,8 @@
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 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 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 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 092b177..de0070a 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -142,7 +142,7 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
}
// 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 @@
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 e023a32..fb151d8 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -48,7 +48,7 @@
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 @@
return &p.Prebuilt
}
-func (p *prebuiltLinker) PrebuiltSrcs() []string {
- return p.properties.Srcs
-}
-
type prebuiltLibraryInterface interface {
libraryInterface
prebuiltLinkerInterface
@@ -226,14 +222,14 @@
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) 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) 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 @@
module.AddProperties(&prebuilt.properties)
- android.InitPrebuiltModule(module, &prebuilt.properties.Srcs)
+ android.InitConfigurablePrebuiltModule(module, &prebuilt.properties.Srcs)
return module, binary
}
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index c38174c..d9ca854 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -51,7 +51,6 @@
const (
nsjailPath = "prebuilts/build-tools/linux-x86/bin/nsjail"
abfsSrcDir = "/src"
- abfsOutDir = "/src/out"
)
var sandboxConfig struct {
@@ -162,13 +161,37 @@
return sandboxConfig.outDir
}
- return sandboxConfig.outDir + ":" + abfsOutDir
+ return sandboxConfig.outDir + ":" + filepath.Join(abfsSrcDir, sandboxConfig.outDir)
+}
+
+// When configured to use ABFS, we need to allow the creation of the /src
+// directory. Therefore, we cannot mount the root "/" directory as read-only.
+// Instead, we individually mount the children of "/" as RO.
+func (c *Cmd) readMountArgs() []string {
+ if !c.config.UseABFS() {
+ // For now, just map everything. Make most things readonly.
+ return []string{"-R", "/"}
+ }
+
+ entries, err := os.ReadDir("/")
+ if err != nil {
+ // If we can't read "/", just use the default non-ABFS behavior.
+ return []string{"-R", "/"}
+ }
+
+ args := make([]string, 0, 2*len(entries))
+ for _, ent := range entries {
+ args = append(args, "-R", "/"+ent.Name())
+ }
+
+ return args
}
func (c *Cmd) wrapSandbox() {
wd, _ := os.Getwd()
- sandboxArgs := []string{
+ var sandboxArgs []string
+ sandboxArgs = append(sandboxArgs,
// The executable to run
"-x", c.Path,
@@ -200,10 +223,13 @@
"--rlimit_cpu", "soft",
"--rlimit_fsize", "soft",
"--rlimit_nofile", "soft",
+ )
- // For now, just map everything. Make most things readonly.
- "-R", "/",
+ sandboxArgs = append(sandboxArgs,
+ c.readMountArgs()...
+ )
+ sandboxArgs = append(sandboxArgs,
// Mount a writable tmp dir
"-B", "/tmp",
@@ -219,7 +245,7 @@
// Only log important warnings / errors
"-q",
- }
+ )
if c.config.UseABFS() {
sandboxArgs = append(sandboxArgs, "-B", "{ABFS_DIR}")
}