Merge "Remove workaround for old libc++" into main
diff --git a/android/config_test.go b/android/config_test.go
index ca7c7f8..7732168 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -150,12 +150,7 @@
for _, tc := range testCases {
fixture := GroupFixturePreparers(
- FixtureModifyProductVariables(func(vars FixtureProductVariables) {
- if vars.BuildFlags == nil {
- vars.BuildFlags = make(map[string]string)
- }
- vars.BuildFlags["RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS"] = tc.flag
- }),
+ PrepareForTestWithBuildFlag("RELEASE_ACONFIG_EXTRA_RELEASE_CONFIGS", tc.flag),
)
actual := fixture.RunTest(t).Config.ReleaseAconfigExtraReleaseConfigs()
AssertArrayString(t, tc.name, tc.expected, actual)
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/android/prebuilt_test.go b/android/prebuilt_test.go
index 6e4fc0c..5e4af0b 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -574,11 +574,7 @@
func TestPrebuiltErrorCannotListBothSourceAndPrebuiltInContributions(t *testing.T) {
selectMainlineModuleContritbutions := GroupFixturePreparers(
- FixtureModifyProductVariables(func(variables FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_apex_contributions",
- }
- }),
+ PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_apex_contributions"),
)
testPrebuiltErrorWithFixture(t, `Found duplicate variations of the same module in apex_contributions: foo and prebuilt_foo. Please remove one of these`, `
source {
diff --git a/android/testing.go b/android/testing.go
index dae787b..e3853b8 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -174,6 +174,16 @@
config.TestAllowNonExistentPaths = false
})
+// PrepareForTestWithBuildFlag returns a FixturePreparer that sets the given flag to the given value.
+func PrepareForTestWithBuildFlag(flag, value string) FixturePreparer {
+ return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
+ if variables.BuildFlags == nil {
+ variables.BuildFlags = make(map[string]string)
+ }
+ variables.BuildFlags[flag] = value
+ })
+}
+
func NewTestArchContext(config Config) *TestContext {
ctx := NewTestContext(config)
ctx.preDeps = append(ctx.preDeps, registerArchMutator)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 852f5fb..d6c8a8a 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11299,11 +11299,7 @@
fs["platform/Test.java"] = nil
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions),
)
ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment)
checkBootDexJarPath(t, ctx, "framework-foo", tc.expectedBootJar)
@@ -11442,11 +11438,7 @@
android.FixtureMergeMockFs(map[string][]byte{
"system/sepolicy/apex/com.android.foo-file_contexts": nil,
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions),
)
if tc.expectedError != "" {
preparer = preparer.ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern(tc.expectedError))
@@ -11562,11 +11554,7 @@
android.FixtureMergeMockFs(map[string][]byte{
"system/sepolicy/apex/com.android.adservices-file_contexts": nil,
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", tc.selectedApexContributions),
)
ctx := testApex(t, bp, preparer)
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 533f937..f8c823e 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -53,11 +53,7 @@
java.FixtureConfigureBootJars("com.android.art:baz", "com.android.art:quuz"),
java.FixtureConfigureApexBootJars("someapex:foo", "someapex:bar"),
prepareForTestWithArtApex,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "baz"),
).RunTestWithBp(t, `
@@ -731,11 +727,7 @@
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("foo", "quuz"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
apex {
name: "com.android.art",
diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go
index 7a17f50..95db37d 100644
--- a/apex/dexpreopt_bootjars_test.go
+++ b/apex/dexpreopt_bootjars_test.go
@@ -399,11 +399,7 @@
java.FixtureConfigureBootJars("com.android.art:core-oj"),
PrepareForTestWithApexBuildComponents,
prepareForTestWithArtApex,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ART": tc.selectedArtApexContributions,
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", tc.selectedArtApexContributions),
).RunTestWithBp(t, bp)
dexBootJars := result.ModuleForTests("dex_bootjars", "android_common")
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index 4a20cf0..645eebb 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -254,11 +254,7 @@
java.FixtureWithLastReleaseApis("foo"),
java.PrepareForTestWithDexpreopt,
dexpreopt.FixtureDisableDexpreoptBootImages(false),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
apex {
name: "com.android.art",
@@ -429,10 +425,9 @@
java.PrepareForTestWithJavaSdkLibraryFiles,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
}),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
+
java.FixtureWithPrebuiltApis(map[string][]string{
"current": {},
"30": {"foo"},
@@ -935,11 +930,7 @@
PrepareForTestWithApexBuildComponents,
prepareForTestWithMyapex,
java.FixtureConfigureApexBootJars(tc.configuredBootJars...),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ART": "my_apex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ART", "my_apex_contributions"),
)
if tc.errorExpected {
fixture = fixture.ExtendWithErrorHandler(
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/cc_test.go b/cc/cc_test.go
index b1c0945..7372fff 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -3194,12 +3194,7 @@
ctx = android.GroupFixturePreparers(
prepareForCcTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- if variables.BuildFlags == nil {
- variables.BuildFlags = make(map[string]string)
- }
- variables.BuildFlags["RELEASE_BOARD_API_LEVEL_FROZEN"] = "true"
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_BOARD_API_LEVEL_FROZEN", "true"),
).RunTestWithBp(t, bp)
testSdkVersionFlag("libfoo", "30")
testSdkVersionFlag("libbar", "29")
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 c533b6a..0e8fff6 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -275,7 +275,7 @@
"-Wno-zero-as-null-pointer-constant", // http://b/68236239
"-Wno-deprecated-anon-enum-enum-conversion", // http://b/153746485
"-Wno-deprecated-enum-enum-conversion",
- "-Wno-pessimizing-move", // http://b/154270751
+ "-Wno-error=pessimizing-move", // http://b/154270751
// New warnings to be fixed after clang-r399163
"-Wno-non-c-typedef-for-linkage", // http://b/161304145
// New warnings to be fixed after clang-r428724
@@ -361,6 +361,7 @@
"-Wno-unqualified-std-cast-call",
"-Wno-array-parameter",
"-Wno-gnu-offsetof-extensions",
+ "-Wno-pessimizing-move",
// TODO: Enable this warning http://b/315245071
"-Wno-fortify-source",
}
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/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 86e6af9..acbbabc 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -476,11 +476,7 @@
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
android.RegisterApexContributionsBuildComponents(ctx)
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
)
ctx := testPrebuilt(t, fmt.Sprintf(bp, tc.selectedDependencyName), map[string][]byte{
"libbar.so": nil,
@@ -574,11 +570,7 @@
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
android.RegisterApexContributionsBuildComponents(ctx)
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
)
if tc.expectedErr != "" {
preparer = preparer.ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(tc.expectedErr))
@@ -638,11 +630,7 @@
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
android.RegisterApexContributionsBuildComponents(ctx)
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
)
ctx := testPrebuilt(t, bp, map[string][]byte{
"libbar.so": nil,
diff --git a/java/base.go b/java/base.go
index f820629..8a4c64d 100644
--- a/java/base.go
+++ b/java/base.go
@@ -2027,16 +2027,20 @@
// Collect information for opening IDE project files in java/jdeps.go.
func (j *Module) IDEInfo(dpInfo *android.IdeInfo) {
- dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
- dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...)
- dpInfo.SrcJars = append(dpInfo.SrcJars, j.compiledSrcJars.Strings()...)
- dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
+ // jarjar rules will repackage the sources. To prevent misleading results, IdeInfo should contain the
+ // repackaged jar instead of the input sources.
if j.expandJarjarRules != nil {
dpInfo.Jarjar_rules = append(dpInfo.Jarjar_rules, j.expandJarjarRules.String())
+ dpInfo.Jars = append(dpInfo.Jars, j.headerJarFile.String())
+ } else {
+ dpInfo.Srcs = append(dpInfo.Srcs, j.expandIDEInfoCompiledSrcs...)
+ dpInfo.SrcJars = append(dpInfo.SrcJars, j.compiledSrcJars.Strings()...)
+ dpInfo.SrcJars = append(dpInfo.SrcJars, j.annoSrcJars.Strings()...)
}
+ dpInfo.Deps = append(dpInfo.Deps, j.CompilerDeps()...)
+ dpInfo.Aidl_include_dirs = append(dpInfo.Aidl_include_dirs, j.deviceProperties.Aidl.Include_dirs...)
dpInfo.Static_libs = append(dpInfo.Static_libs, j.properties.Static_libs...)
dpInfo.Libs = append(dpInfo.Libs, j.properties.Libs...)
- dpInfo.SrcJars = append(dpInfo.SrcJars, j.annoSrcJars.Strings()...)
}
func (j *Module) CompilerDeps() []string {
@@ -2374,16 +2378,24 @@
case bootClasspathTag:
// If a system modules dependency has been added to the bootclasspath
// then add its libs to the bootclasspath.
- sm := module.(SystemModulesProvider)
- deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars()...)
+ if sm, ok := android.OtherModuleProvider(ctx, module, SystemModulesProvider); ok {
+ depHeaderJars := sm.HeaderJars
+ deps.bootClasspath = append(deps.bootClasspath, depHeaderJars...)
+ } else {
+ ctx.PropertyErrorf("boot classpath dependency %q does not provide SystemModulesProvider",
+ ctx.OtherModuleName(module))
+ }
case systemModulesTag:
if deps.systemModules != nil {
panic("Found two system module dependencies")
}
- sm := module.(SystemModulesProvider)
- outputDir, outputDeps := sm.OutputDirAndDeps()
- deps.systemModules = &systemModules{outputDir, outputDeps}
+ if sm, ok := android.OtherModuleProvider(ctx, module, SystemModulesProvider); ok {
+ deps.systemModules = &systemModules{sm.OutputDir, sm.OutputDirDeps}
+ } else {
+ ctx.PropertyErrorf("system modules dependency %q does not provide SystemModulesProvider",
+ ctx.OtherModuleName(module))
+ }
case instrumentationForTag:
ctx.PropertyErrorf("instrumentation_for", "dependency %q of type %q does not provide JavaInfo so is unsuitable for use with this property", ctx.OtherModuleName(module), ctx.OtherModuleType(module))
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 8bc0a7e..d72417a 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -222,11 +222,7 @@
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("mysdklibrary", "myothersdklibrary", "mycoreplatform"),
FixtureConfigureApexBootJars("someapex:mysdklibrary"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
bootclasspath_fragment {
name: "myfragment",
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 730f236..f81c5ba 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -365,10 +365,10 @@
case bootClasspathTag:
if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
deps.bootClasspath = append(deps.bootClasspath, dep.ImplementationJars...)
- } else if sm, ok := module.(SystemModulesProvider); ok {
+ } else if sm, ok := android.OtherModuleProvider(ctx, module, SystemModulesProvider); ok {
// A system modules dependency has been added to the bootclasspath
// so add its libs to the bootclasspath.
- deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars()...)
+ deps.bootClasspath = append(deps.bootClasspath, sm.HeaderJars...)
} else {
panic(fmt.Errorf("unknown dependency %q for %q", otherName, ctx.ModuleName()))
}
@@ -396,9 +396,12 @@
if deps.systemModules != nil {
panic("Found two system module dependencies")
}
- sm := module.(SystemModulesProvider)
- outputDir, outputDeps := sm.OutputDirAndDeps()
- deps.systemModules = &systemModules{outputDir, outputDeps}
+ if sm, ok := android.OtherModuleProvider(ctx, module, SystemModulesProvider); ok {
+ deps.systemModules = &systemModules{sm.OutputDir, sm.OutputDirDeps}
+ } else {
+ ctx.PropertyErrorf("boot classpath dependency %q does not provide SystemModulesProvider",
+ ctx.OtherModuleName(module))
+ }
case aconfigDeclarationTag:
if dep, ok := android.OtherModuleProvider(ctx, module, android.AconfigDeclarationsProviderKey); ok {
deps.aconfigProtoFiles = append(deps.aconfigProtoFiles, dep.IntermediateCacheOutputPath)
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 6a14f36..1e8362c 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -421,11 +421,9 @@
result := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
variables.ExportRuntimeApis = proptools.BoolPtr(true)
}),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
android.FixtureMergeMockFs(map[string][]byte{
"a/A.java": nil,
"a/current.txt": nil,
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go
index 6229797..afe8b4c 100644
--- a/java/hiddenapi_singleton_test.go
+++ b/java/hiddenapi_singleton_test.go
@@ -203,10 +203,8 @@
FixtureConfigureBootJars("platform:foo"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild)
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
}),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
java_library {
name: "foo",
diff --git a/java/java.go b/java/java.go
index be3f90b..126d8f3 100644
--- a/java/java.go
+++ b/java/java.go
@@ -2261,8 +2261,9 @@
staticLibs = append(staticLibs, provider.HeaderJars...)
}
case systemModulesTag:
- module := dep.(SystemModulesProvider)
- systemModulesPaths = append(systemModulesPaths, module.HeaderJars()...)
+ if sm, ok := android.OtherModuleProvider(ctx, dep, SystemModulesProvider); ok {
+ systemModulesPaths = append(systemModulesPaths, sm.HeaderJars...)
+ }
case metalavaCurrentApiTimestampTag:
if currentApiTimestampProvider, ok := dep.(currentApiTimestampProvider); ok {
al.validationPaths = append(al.validationPaths, currentApiTimestampProvider.CurrentApiTimestamp())
diff --git a/java/java_test.go b/java/java_test.go
index 2d4fca2..86bfe9f 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -2634,11 +2634,7 @@
for _, tc := range testCases {
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName))
// check that rdep gets the correct variation of dep
@@ -2708,11 +2704,7 @@
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithPlatformCompatConfig,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName))
mergedGlobalConfig := ctx.SingletonForTests("platform_compat_config_singleton").Output("compat_config/merged_compat_config.xml")
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index 47bfac1..ff54da9 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -91,16 +91,23 @@
}
}
-func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
- expected := "Jarjar_rules.txt"
- module := LibraryFactory().(*Library)
- module.expandJarjarRules = android.PathForTesting(expected)
+func TestCollectJavaLibraryWithJarJarRules(t *testing.T) {
+ ctx, _ := testJava(t,
+ `
+ java_library {
+ name: "javalib",
+ srcs: ["foo.java"],
+ jarjar_rules: "jarjar_rules.txt",
+ }
+ `)
+ module := ctx.ModuleForTests("javalib", "android_common").Module().(*Library)
dpInfo := &android.IdeInfo{}
module.IDEInfo(dpInfo)
-
- if dpInfo.Jarjar_rules[0] != expected {
- t.Errorf("Library.IDEInfo() Jarjar_rules = %v, want %v", dpInfo.Jarjar_rules[0], expected)
+ android.AssertBoolEquals(t, "IdeInfo.Srcs of repackaged library should be empty", true, len(dpInfo.Srcs) == 0)
+ android.AssertStringEquals(t, "IdeInfo.Jar_rules of repackaged library should not be empty", "jarjar_rules.txt", dpInfo.Jarjar_rules[0])
+ if !android.SubstringInList(dpInfo.Jars, "soong/.intermediates/javalib/android_common/jarjar/turbine/javalib.jar") {
+ t.Errorf("IdeInfo.Jars of repackaged library should contain the output of jarjar-ing. All outputs: %v\n", dpInfo.Jars)
}
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index a8cc1b8..4f95a99 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -3602,3 +3602,19 @@
propertySet.AddProperty("doctag_files", dests)
}
}
+
+// TODO(b/358613520): This can be removed when modules are no longer allowed to depend on the top-level library.
+func (s *SdkLibrary) IDEInfo(dpInfo *android.IdeInfo) {
+ s.Library.IDEInfo(dpInfo)
+ if s.implLibraryModule != nil {
+ dpInfo.Deps = append(dpInfo.Deps, s.implLibraryModule.Name())
+ } else {
+ // This java_sdk_library does not have an implementation (it sets `api_only` to true).
+ // Examples of this are `art.module.intra.core.api` (IntraCore api surface).
+ // Return the "public" stubs for these.
+ stubPaths := s.findClosestScopePath(apiScopePublic)
+ if len(stubPaths.stubsHeaderPath) > 0 {
+ dpInfo.Jars = append(dpInfo.Jars, stubPaths.stubsHeaderPath[0].String())
+ }
+ }
+}
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 911e8b1..368eca7 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -35,11 +35,7 @@
"29": {"foo"},
"30": {"bar", "barney", "baz", "betty", "foo", "fred", "quuz", "wilma"},
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -537,11 +533,7 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
java_sdk_library {
name: "sdklib",
@@ -934,11 +926,7 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
java_sdk_library {
name: "sdklib",
@@ -987,11 +975,7 @@
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
preparer,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
java_sdk_library {
name: "sdklib",
@@ -1183,11 +1167,7 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib.source_preferred_using_legacy_flags", "sdklib.prebuilt_preferred_using_legacy_flags"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"),
).RunTestWithBp(t, bp)
// Make sure that rdeps get the correct source vs prebuilt based on mainline_module_contributions
@@ -1369,11 +1349,7 @@
"sdklib_group_foo",
"sdklib_owner_foo",
"foo"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
java_sdk_library {
name: "sdklib_no_group",
@@ -1785,12 +1761,8 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- // We can use any of the apex contribution build flags from build/soong/android/config.go#mainlineApexContributionBuildFlags here
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions",
- }
- }),
+ // We can use any of the apex contribution build flags from build/soong/android/config.go#mainlineApexContributionBuildFlags here
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"),
)
result := fixture.RunTestWithBp(t, bp)
@@ -1873,11 +1845,7 @@
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
FixtureWithLastReleaseApis("sdklib", "sdklib.v1", "sdklib.v2"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "my_mainline_module_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "my_mainline_module_contributions"),
)
for _, tc := range testCases {
diff --git a/java/system_modules.go b/java/system_modules.go
index 48b33ba..5b00079 100644
--- a/java/system_modules.go
+++ b/java/system_modules.go
@@ -120,14 +120,16 @@
return module
}
-type SystemModulesProvider interface {
- HeaderJars() android.Paths
- OutputDirAndDeps() (android.Path, android.Paths)
+type SystemModulesProviderInfo struct {
+ // The aggregated header jars from all jars specified in the libs property.
+ // Used when system module is added as a dependency to bootclasspath.
+ HeaderJars android.Paths
+
+ OutputDir android.Path
+ OutputDirDeps android.Paths
}
-var _ SystemModulesProvider = (*SystemModules)(nil)
-
-var _ SystemModulesProvider = (*systemModulesImport)(nil)
+var SystemModulesProvider = blueprint.NewProvider[*SystemModulesProviderInfo]()
type SystemModules struct {
android.ModuleBase
@@ -135,9 +137,6 @@
properties SystemModulesProperties
- // The aggregated header jars from all jars specified in the libs property.
- // Used when system module is added as a dependency to bootclasspath.
- headerJars android.Paths
outputDir android.Path
outputDeps android.Paths
}
@@ -147,17 +146,6 @@
Libs []string
}
-func (system *SystemModules) HeaderJars() android.Paths {
- return system.headerJars
-}
-
-func (system *SystemModules) OutputDirAndDeps() (android.Path, android.Paths) {
- if system.outputDir == nil || len(system.outputDeps) == 0 {
- panic("Missing directory for system module dependency")
- }
- return system.outputDir, system.outputDeps
-}
-
func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleContext) {
var jars android.Paths
@@ -167,9 +155,13 @@
}
})
- system.headerJars = jars
-
system.outputDir, system.outputDeps = TransformJarsToSystemModules(ctx, jars)
+
+ android.SetProvider(ctx, SystemModulesProvider, &SystemModulesProviderInfo{
+ HeaderJars: jars,
+ OutputDir: system.outputDir,
+ OutputDirDeps: system.outputDeps,
+ })
}
// ComponentDepsMutator is called before prebuilt modules without a corresponding source module are
diff --git a/java/system_modules_test.go b/java/system_modules_test.go
index 336dd21..1a8d0b5 100644
--- a/java/system_modules_test.go
+++ b/java/system_modules_test.go
@@ -182,11 +182,7 @@
for _, tc := range testCases {
res := android.GroupFixturePreparers(
prepareForJavaTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "myapex_contributions",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_APEX_CONTRIBUTIONS_ADSERVICES", "myapex_contributions"),
).RunTestWithBp(t, fmt.Sprintf(bp, tc.selectedDependencyName))
// check that rdep gets the correct variation of system_modules
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 7048a15..7ee548f 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -276,11 +276,7 @@
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
// file creation.
java.FixtureConfigureBootJars("platform:foo"),
@@ -799,11 +795,7 @@
// Add a platform_bootclasspath that depends on the fragment.
fixtureAddPlatformBootclasspathForBootclasspathFragment("myapex", "mybootclasspathfragment"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
android.MockFS{
"my-blocked.txt": nil,
@@ -1053,11 +1045,7 @@
variables.Platform_version_active_codenames = []string{"VanillaIceCream"}
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
android.FixtureWithRootAndroidBp(`
sdk {
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 0a5483b..0fb5c70 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -45,11 +45,7 @@
java.PrepareForTestWithJavaDefaultModules,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.FixtureWithLastReleaseApis("myjavalib"),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
)
// Contains tests for SDK members provided by the java package.
@@ -666,11 +662,7 @@
"1": {"myjavalib"},
"2": {"myjavalib"},
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1313,11 +1305,7 @@
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTestWithBp(t, `
sdk {
name: "mysdk",
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 4894210..057b370 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -457,11 +457,7 @@
android.FixtureMergeEnv(map[string]string{
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
}),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
- }),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
@@ -573,11 +569,9 @@
"SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE": "S",
}),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildFlags = map[string]string{
- "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
- }
variables.Platform_version_active_codenames = []string{"UpsideDownCake", "Tiramisu", "S-V2"}
}),
+ android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
).RunTest(t)
CheckSnapshot(t, result, "mysdk", "",
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}")
}