Merge "rust: Rename flag providers for clarity" into main
diff --git a/aconfig/codegen/cc_aconfig_library.go b/aconfig/codegen/cc_aconfig_library.go
index f9c7b8c..ce37456 100644
--- a/aconfig/codegen/cc_aconfig_library.go
+++ b/aconfig/codegen/cc_aconfig_library.go
@@ -22,7 +22,6 @@
"github.com/google/blueprint/proptools"
"fmt"
- "strconv"
"strings"
)
@@ -32,8 +31,6 @@
var ccDeclarationsTag = ccDeclarationsTagType{}
-const baseLibDep = "server_configurable_flags"
-
const libBaseDep = "libbase"
const libLogDep = "liblog"
const libAconfigStorageReadApiCcDep = "libaconfig_storage_read_api_cc"
@@ -86,15 +83,11 @@
// Add a dependency for the aconfig flags base library if it is not forced read only
if mode != "force-read-only" {
- deps.SharedLibs = append(deps.SharedLibs, baseLibDep)
-
+ deps.SharedLibs = append(deps.SharedLibs, libAconfigStorageReadApiCcDep)
+ deps.SharedLibs = append(deps.SharedLibs, libBaseDep)
+ deps.SharedLibs = append(deps.SharedLibs, libLogDep)
}
- // TODO: after storage migration is over, don't add these in force-read-only-mode.
- deps.SharedLibs = append(deps.SharedLibs, libAconfigStorageReadApiCcDep)
- deps.SharedLibs = append(deps.SharedLibs, libBaseDep)
- deps.SharedLibs = append(deps.SharedLibs, libLogDep)
-
// TODO: It'd be really nice if we could reexport this library and not make everyone do it.
return deps
@@ -156,7 +149,6 @@
Args: map[string]string{
"gendir": this.generatedDir.String(),
"mode": mode,
- "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorage()),
},
})
diff --git a/aconfig/codegen/cc_aconfig_library_test.go b/aconfig/codegen/cc_aconfig_library_test.go
index c308ed4..7c7037a 100644
--- a/aconfig/codegen/cc_aconfig_library_test.go
+++ b/aconfig/codegen/cc_aconfig_library_test.go
@@ -255,12 +255,12 @@
`))
module := result.ModuleForTests("my_cc_aconfig_library", "android_arm64_armv8-a_shared").Module()
- dependOnBaseLib := false
+ dependOnReadLib := false
result.VisitDirectDeps(module, func(dep blueprint.Module) {
- if dep.Name() == baseLibDep {
- dependOnBaseLib = true
+ if dep.Name() == libAconfigStorageReadApiCcDep {
+ dependOnReadLib = true
}
})
- android.AssertBoolEquals(t, "should not have dependency on server_configuriable_flags",
- dependOnBaseLib, false)
+ android.AssertBoolEquals(t, "should not have dependency on libaconfig_storage_read_api_cc",
+ dependOnReadLib, false)
}
diff --git a/aconfig/codegen/init.go b/aconfig/codegen/init.go
index 385fa49..325e367 100644
--- a/aconfig/codegen/init.go
+++ b/aconfig/codegen/init.go
@@ -54,12 +54,11 @@
` && ${aconfig} create-cpp-lib` +
` --mode ${mode}` +
` --cache ${in}` +
- ` --out ${gendir}` +
- ` --allow-instrumentation ${debug}`,
+ ` --out ${gendir}`,
CommandDeps: []string{
"$aconfig",
},
- }, "gendir", "mode", "debug")
+ }, "gendir", "mode")
// For rust_aconfig_library: Generate Rust library
rustRule = pctx.AndroidStaticRule("rust_aconfig_library",
@@ -69,12 +68,11 @@
` && ${aconfig} create-rust-lib` +
` --mode ${mode}` +
` --cache ${in}` +
- ` --allow-instrumentation ${debug}` +
` --out ${gendir}`,
CommandDeps: []string{
"$aconfig",
},
- }, "gendir", "mode", "debug")
+ }, "gendir", "mode")
)
func init() {
diff --git a/aconfig/codegen/rust_aconfig_library.go b/aconfig/codegen/rust_aconfig_library.go
index 4b896c3..53818c2 100644
--- a/aconfig/codegen/rust_aconfig_library.go
+++ b/aconfig/codegen/rust_aconfig_library.go
@@ -2,7 +2,6 @@
import (
"fmt"
- "strconv"
"android/soong/android"
"android/soong/rust"
@@ -83,7 +82,6 @@
Args: map[string]string{
"gendir": generatedDir.String(),
"mode": mode,
- "debug": strconv.FormatBool(ctx.Config().ReleaseReadFromNewStorage()),
},
})
a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}
@@ -102,7 +100,6 @@
func (a *aconfigDecorator) SourceProviderDeps(ctx rust.DepsContext, deps rust.Deps) rust.Deps {
deps = a.BaseSourceProvider.SourceProviderDeps(ctx, deps)
deps.Rustlibs = append(deps.Rustlibs, "libaconfig_storage_read_api")
- deps.Rustlibs = append(deps.Rustlibs, "libflags_rust")
deps.Rustlibs = append(deps.Rustlibs, "liblazy_static")
deps.Rustlibs = append(deps.Rustlibs, "liblogger")
deps.Rustlibs = append(deps.Rustlibs, "liblog_rust")
diff --git a/android/Android.bp b/android/Android.bp
index d27a8fa..75027b1 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -141,6 +141,7 @@
"license_kind_test.go",
"license_test.go",
"licenses_test.go",
+ "makevars_test.go",
"module_test.go",
"mutator_test.go",
"namespace_test.go",
diff --git a/android/androidmk.go b/android/androidmk.go
index f862a96..9c72606 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -333,6 +333,25 @@
dest string
}
+func (d *distCopy) String() string {
+ if len(d.dest) == 0 {
+ return d.from.String()
+ }
+ return fmt.Sprintf("%s:%s", d.from.String(), d.dest)
+}
+
+type distCopies []distCopy
+
+func (d *distCopies) Strings() (ret []string) {
+ if d == nil {
+ return
+ }
+ for _, dist := range *d {
+ ret = append(ret, dist.String())
+ }
+ return
+}
+
// Compute the contributions that the module makes to the dist.
func (a *AndroidMkEntries) getDistContributions(mod blueprint.Module) *distContributions {
amod := mod.(Module).base()
@@ -700,22 +719,26 @@
type androidMkSingleton struct{}
-func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
- var androidMkModulesList []blueprint.Module
+func allModulesSorted(ctx SingletonContext) []blueprint.Module {
+ var allModules []blueprint.Module
ctx.VisitAllModulesBlueprint(func(module blueprint.Module) {
- androidMkModulesList = append(androidMkModulesList, module)
+ allModules = append(allModules, module)
})
// Sort the module list by the module names to eliminate random churns, which may erroneously
// invoke additional build processes.
- sort.SliceStable(androidMkModulesList, func(i, j int) bool {
- return ctx.ModuleName(androidMkModulesList[i]) < ctx.ModuleName(androidMkModulesList[j])
+ sort.SliceStable(allModules, func(i, j int) bool {
+ return ctx.ModuleName(allModules[i]) < ctx.ModuleName(allModules[j])
})
- // If running in soong-only mode, do a different, more limited version of this singleton
+ return allModules
+}
+
+func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
+ // If running in soong-only mode, more limited version of this singleton is run as
+ // soong only androidmk singleton
if !ctx.Config().KatiEnabled() {
- c.soongOnlyBuildActions(ctx, androidMkModulesList)
return
}
@@ -726,7 +749,7 @@
moduleInfoJSON := PathForOutput(ctx, "module-info"+String(ctx.Config().productVariables.Make_suffix)+".json")
- err := translateAndroidMk(ctx, absolutePath(transMk.String()), moduleInfoJSON, androidMkModulesList)
+ err := translateAndroidMk(ctx, absolutePath(transMk.String()), moduleInfoJSON, allModulesSorted(ctx))
if err != nil {
ctx.Errorf(err.Error())
}
@@ -737,12 +760,37 @@
})
}
+type soongOnlyAndroidMkSingleton struct {
+ Singleton
+}
+
+func soongOnlyAndroidMkSingletonFactory() Singleton {
+ return &soongOnlyAndroidMkSingleton{}
+}
+
+func (so *soongOnlyAndroidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
+ if !ctx.Config().KatiEnabled() {
+ so.soongOnlyBuildActions(ctx, allModulesSorted(ctx))
+ }
+}
+
// In soong-only mode, we don't do most of the androidmk stuff. But disted files are still largely
// defined through the androidmk mechanisms, so this function is an alternate implementation of
// the androidmk singleton that just focuses on getting the dist contributions
-func (c *androidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []blueprint.Module) {
+func (so *soongOnlyAndroidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []blueprint.Module) {
allDistContributions, moduleInfoJSONs := getSoongOnlyDataFromMods(ctx, mods)
+ for _, provider := range makeVarsInitProviders {
+ mctx := &makeVarsContext{
+ SingletonContext: ctx,
+ pctx: provider.pctx,
+ }
+ provider.call(mctx)
+ if contribution := distsToDistContributions(mctx.dists); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ }
+
// Build module-info.json. Only in builds with HasDeviceProduct(), as we need a named
// device to have a TARGET_OUT folder.
if ctx.Config().HasDeviceProduct() {
@@ -821,12 +869,38 @@
}
}
+func distsToDistContributions(dists []dist) *distContributions {
+ if len(dists) == 0 {
+ return nil
+ }
+
+ copyGoals := []*copiesForGoals{}
+ for _, dist := range dists {
+ for _, goal := range dist.goals {
+ copyGoals = append(copyGoals, &copiesForGoals{
+ goals: goal,
+ copies: dist.paths,
+ })
+ }
+ }
+
+ return &distContributions{
+ copiesForGoals: copyGoals,
+ }
+}
+
// getSoongOnlyDataFromMods gathers data from the given modules needed in soong-only builds.
// Currently, this is the dist contributions, and the module-info.json contents.
func getSoongOnlyDataFromMods(ctx fillInEntriesContext, mods []blueprint.Module) ([]distContributions, []*ModuleInfoJSON) {
var allDistContributions []distContributions
var moduleInfoJSONs []*ModuleInfoJSON
for _, mod := range mods {
+ if distInfo, ok := OtherModuleProvider(ctx, mod, DistProvider); ok {
+ if contribution := distsToDistContributions(distInfo.Dists); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ }
+
if amod, ok := mod.(Module); ok && shouldSkipAndroidMkProcessing(ctx, amod.base()) {
continue
}
@@ -853,8 +927,7 @@
}
}
} else {
- switch x := mod.(type) {
- case AndroidMkDataProvider:
+ if x, ok := mod.(AndroidMkDataProvider); ok {
data := x.AndroidMk()
if data.Include == "" {
@@ -871,7 +944,8 @@
if contribution := data.Entries.getDistContributions(mod); contribution != nil {
allDistContributions = append(allDistContributions, *contribution)
}
- case AndroidMkEntriesProvider:
+ }
+ if x, ok := mod.(AndroidMkEntriesProvider); ok {
entriesList := x.AndroidMkEntries()
for _, entries := range entriesList {
entries.fillInEntries(ctx, mod)
@@ -885,8 +959,31 @@
allDistContributions = append(allDistContributions, *contribution)
}
}
- default:
- // Not exported to make so no make variables to set.
+ }
+ if x, ok := mod.(ModuleMakeVarsProvider); ok {
+ mctx := &makeVarsContext{
+ SingletonContext: ctx.(SingletonContext),
+ config: ctx.Config(),
+ pctx: pctx,
+ }
+ if !x.Enabled(ctx) {
+ continue
+ }
+ x.MakeVars(mctx)
+ if contribution := distsToDistContributions(mctx.dists); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ }
+ if x, ok := mod.(SingletonMakeVarsProvider); ok {
+ mctx := &makeVarsContext{
+ SingletonContext: ctx.(SingletonContext),
+ config: ctx.Config(),
+ pctx: pctx,
+ }
+ x.MakeVars(mctx)
+ if contribution := distsToDistContributions(mctx.dists); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
}
}
}
diff --git a/android/apex.go b/android/apex.go
index 08c82eb..a5ccd52 100644
--- a/android/apex.go
+++ b/android/apex.go
@@ -105,6 +105,9 @@
// thus wouldn't be merged.
func (i ApexInfo) mergedName() string {
name := "apex" + strconv.Itoa(i.MinSdkVersion.FinalOrFutureInt())
+ if i.UsePlatformApis {
+ name += "_p"
+ }
return name
}
@@ -613,25 +616,26 @@
apexInfos = allApexInfos.ApexInfos
}
- // Shortcut
- if len(apexInfos) == 0 {
- return
- }
-
- // Do some validity checks.
- // TODO(jiyong): is this the right place?
- base.checkApexAvailableProperty(ctx)
-
- if !module.UniqueApexVariations() && !base.ApexProperties.UniqueApexVariationsForDeps {
- apexInfos, _ = mergeApexVariations(apexInfos)
- }
-
if platformVariation && !ctx.Host() && !module.AvailableFor(AvailableToPlatform) && module.NotAvailableForPlatform() {
// Do not install the module for platform, but still allow it to output
// uninstallable AndroidMk entries in certain cases when they have side
// effects. TODO(jiyong): move this routine to somewhere else
module.MakeUninstallable()
}
+
+ // Do some validity checks.
+ // TODO(jiyong): is this the right place?
+ base.checkApexAvailableProperty(ctx)
+
+ // Shortcut
+ if len(apexInfos) == 0 {
+ return
+ }
+
+ if !module.UniqueApexVariations() && !base.ApexProperties.UniqueApexVariationsForDeps {
+ apexInfos, _ = mergeApexVariations(apexInfos)
+ }
+
if !platformVariation {
var thisApexInfo ApexInfo
diff --git a/android/apex_test.go b/android/apex_test.go
index 78597b2..acc195d 100644
--- a/android/apex_test.go
+++ b/android/apex_test.go
@@ -193,7 +193,7 @@
},
},
{
- name: "merge different UsePlatformApis but don't allow using platform api",
+ name: "don't merge different UsePlatformApis",
in: []ApexInfo{
{
ApexVariationName: "foo",
@@ -213,13 +213,20 @@
{
ApexVariationName: "apex10000",
MinSdkVersion: FutureApiLevel,
- InApexVariants: []string{"foo", "bar"},
+ InApexVariants: []string{"foo"},
+ ForPrebuiltApex: NotForPrebuiltApex,
+ },
+ {
+ ApexVariationName: "apex10000_p",
+ MinSdkVersion: FutureApiLevel,
+ UsePlatformApis: true,
+ InApexVariants: []string{"bar"},
ForPrebuiltApex: NotForPrebuiltApex,
},
},
wantAliases: [][2]string{
{"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"bar", "apex10000_p"},
},
},
{
@@ -242,7 +249,7 @@
},
wantMerged: []ApexInfo{
{
- ApexVariationName: "apex10000",
+ ApexVariationName: "apex10000_p",
MinSdkVersion: FutureApiLevel,
UsePlatformApis: true,
InApexVariants: []string{"foo", "bar"},
@@ -250,8 +257,8 @@
},
},
wantAliases: [][2]string{
- {"foo", "apex10000"},
- {"bar", "apex10000"},
+ {"foo", "apex10000_p"},
+ {"bar", "apex10000_p"},
},
},
}
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index dcf393d..35805a2 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -240,8 +240,8 @@
blueprint.RuleParams{
Command: `rm -rf $out && ` +
`${sqlite3} $out ".import --csv $in modules" && ` +
- `([ -z "${make_metadata}" ] || ${sqlite3} $out ".import --csv ${make_metadata} make_metadata") && ` +
- `([ -z "${make_modules}" ] || ${sqlite3} $out ".import --csv ${make_modules} make_modules")`,
+ `${sqlite3} $out ".import --csv ${make_metadata} make_metadata" && ` +
+ `${sqlite3} $out ".import --csv ${make_modules} make_modules"`,
CommandDeps: []string{"${sqlite3}"},
}, "make_metadata", "make_modules")
)
@@ -311,29 +311,29 @@
modulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "soong-modules.csv")
WriteFileRuleVerbatim(ctx, modulesCsv, buffer.String())
- var implicits []Path
- args := make(map[string]string)
+ // Metadata generated in Make
+ makeMetadataCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-metadata.csv")
+ makeModulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-modules.csv")
- if ctx.Config().KatiEnabled() {
- // Metadata generated in Make
- makeMetadataCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-metadata.csv")
- makeModulesCsv := PathForOutput(ctx, "compliance-metadata", deviceProduct, "make-modules.csv")
- implicits = append(implicits, makeMetadataCsv, makeModulesCsv)
- args["make_metadata"] = makeMetadataCsv.String()
- args["make_modules"] = makeModulesCsv.String()
- } else {
- args["make_metadata"] = ""
- args["make_modules"] = ""
+ if !ctx.Config().KatiEnabled() {
+ WriteFileRule(ctx, makeMetadataCsv, "installed_file,module_path,is_soong_module,is_prebuilt_make_module,product_copy_files,kernel_module_copy_files,is_platform_generated,static_libs,whole_static_libs,license_text")
+ WriteFileRule(ctx, makeModulesCsv, "name,module_path,module_class,module_type,static_libs,whole_static_libs,built_files,installed_files")
}
// Import metadata from Make and Soong to sqlite3 database
complianceMetadataDb := PathForOutput(ctx, "compliance-metadata", deviceProduct, "compliance-metadata.db")
ctx.Build(pctx, BuildParams{
- Rule: importCsv,
- Input: modulesCsv,
- Implicits: implicits,
- Output: complianceMetadataDb,
- Args: args,
+ Rule: importCsv,
+ Input: modulesCsv,
+ Implicits: []Path{
+ makeMetadataCsv,
+ makeModulesCsv,
+ },
+ Output: complianceMetadataDb,
+ Args: map[string]string{
+ "make_metadata": makeMetadataCsv.String(),
+ "make_modules": makeModulesCsv.String(),
+ },
})
// Phony rule "compliance-metadata.db". "m compliance-metadata.db" to create the compliance metadata database.
diff --git a/android/container_violations.go b/android/container_violations.go
index e1583c5..4c6386d 100644
--- a/android/container_violations.go
+++ b/android/container_violations.go
@@ -997,7 +997,7 @@
"android.nfc.flags-aconfig-java", // apex [com.android.nfcservices] -> system
"android.permission.flags-aconfig-java", // apex [com.android.nfcservices] -> apex [com.android.permission, test_com.android.permission]
// TODO(b/383782511): Remove the violations once the infra is fixed.
- "framework-nfc.impl", // apex [com.android.nfcservices] -> system
+ "framework-nfc.impl", // apex [com.android.nfcservices] -> system
},
"okhttp-norepackage": {
diff --git a/android/defs.go b/android/defs.go
index 4dd267a..57fcc9b 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -143,3 +143,13 @@
return ctx.Config().RBEWrapper()
})
}
+
+// CopyFileRule creates a ninja rule to copy path to outPath.
+func CopyFileRule(ctx ModuleContext, path Path, outPath OutputPath) {
+ ctx.Build(pctx, BuildParams{
+ Rule: Cp,
+ Input: path,
+ Output: outPath,
+ Description: "copy " + outPath.Base(),
+ })
+}
diff --git a/android/filegroup.go b/android/filegroup.go
index 4daff8f..47102b9 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -41,11 +41,11 @@
Exclude_srcs proptools.Configurable[[]string] `android:"path"`
- // Sources the will be included in the filegroup, but any module dependencies will be added
+ // Sources that will be included in the filegroup, but any module dependencies will be added
// using the device os and the device's first architecture's variant.
Device_first_srcs proptools.Configurable[[]string] `android:"path_device_first"`
- // Sources the will be included in the filegroup, but any module dependencies will be added
+ // Sources that will be included in the filegroup, but any module dependencies will be added
// using the device os and the common architecture's variant.
Device_common_srcs proptools.Configurable[[]string] `android:"path_device_common"`
diff --git a/android/hooks.go b/android/hooks.go
index f8022d0..5d509a4 100644
--- a/android/hooks.go
+++ b/android/hooks.go
@@ -100,12 +100,12 @@
l.appendPrependHelper(props, proptools.PrependMatchingProperties)
}
-func (l *loadHookContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module {
- return l.bp.CreateModule(factory, name, props...)
+func (l *loadHookContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) Module {
+ return bpModuleToModule(l.bp.CreateModule(factory, name, props...))
}
-func (l *loadHookContext) createModuleInDirectory(factory blueprint.ModuleFactory, name, moduleDir string, props ...interface{}) blueprint.Module {
- return l.bp.CreateModuleInDirectory(factory, name, moduleDir, props...)
+func (l *loadHookContext) createModuleInDirectory(factory blueprint.ModuleFactory, name, moduleDir string, props ...interface{}) Module {
+ return bpModuleToModule(l.bp.CreateModuleInDirectory(factory, name, moduleDir, props...))
}
type specifyDirectory struct {
@@ -130,8 +130,8 @@
type createModuleContext interface {
Module() Module
HasMutatorFinished(mutatorName string) bool
- createModule(blueprint.ModuleFactory, string, ...interface{}) blueprint.Module
- createModuleInDirectory(blueprint.ModuleFactory, string, string, ...interface{}) blueprint.Module
+ createModule(blueprint.ModuleFactory, string, ...interface{}) Module
+ createModuleInDirectory(blueprint.ModuleFactory, string, string, ...interface{}) Module
}
func createModule(ctx createModuleContext, factory ModuleFactory, ext string, specifyDirectory specifyDirectory, props ...interface{}) Module {
diff --git a/android/makevars.go b/android/makevars.go
index 8305d8e..3a60bbb 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -185,6 +185,7 @@
type makeVarsSingleton struct {
varsForTesting []makeVarsVariable
installsForTesting []byte
+ lateForTesting []byte
}
type makeVarsProvider struct {
@@ -220,7 +221,7 @@
type dist struct {
goals []string
- paths []string
+ paths distCopies
}
func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
@@ -285,6 +286,10 @@
katiVintfManifestInstalls = append(katiVintfManifestInstalls, info.KatiVintfInstalls...)
katiSymlinks = append(katiSymlinks, info.KatiSymlinks...)
}
+
+ if distInfo, ok := OtherModuleProvider(ctx, m, DistProvider); ok {
+ dists = append(dists, distInfo.Dists...)
+ }
})
compareKatiInstalls := func(a, b katiInstall) int {
@@ -330,7 +335,7 @@
return len(a) < len(b)
}
sort.Slice(dists, func(i, j int) bool {
- return lessArr(dists[i].goals, dists[j].goals) || lessArr(dists[i].paths, dists[j].paths)
+ return lessArr(dists[i].goals, dists[j].goals) || lessArr(dists[i].paths.Strings(), dists[j].paths.Strings())
})
outBytes := s.writeVars(vars)
@@ -354,6 +359,7 @@
if ctx.Config().RunningInsideUnitTest() {
s.varsForTesting = vars
s.installsForTesting = installsBytes
+ s.lateForTesting = lateOutBytes
}
}
@@ -458,7 +464,7 @@
for _, dist := range dists {
fmt.Fprintf(buf, ".PHONY: %s\n", strings.Join(dist.goals, " "))
fmt.Fprintf(buf, "$(call dist-for-goals,%s,%s)\n",
- strings.Join(dist.goals, " "), strings.Join(dist.paths, " "))
+ strings.Join(dist.goals, " "), strings.Join(dist.paths.Strings(), " "))
}
return buf.Bytes()
@@ -607,7 +613,7 @@
c.phonies = append(c.phonies, phony{name, deps})
}
-func (c *makeVarsContext) addDist(goals []string, paths []string) {
+func (c *makeVarsContext) addDist(goals []string, paths []distCopy) {
c.dists = append(c.dists, dist{
goals: goals,
paths: paths,
@@ -647,9 +653,16 @@
}
func (c *makeVarsContext) DistForGoals(goals []string, paths ...Path) {
- c.addDist(goals, Paths(paths).Strings())
+ var copies distCopies
+ for _, path := range paths {
+ copies = append(copies, distCopy{
+ from: path,
+ dest: path.Base(),
+ })
+ }
+ c.addDist(goals, copies)
}
func (c *makeVarsContext) DistForGoalsWithFilename(goals []string, path Path, filename string) {
- c.addDist(goals, []string{path.String() + ":" + filename})
+ c.addDist(goals, distCopies{{from: path, dest: filename}})
}
diff --git a/android/makevars_test.go b/android/makevars_test.go
new file mode 100644
index 0000000..5e4499f
--- /dev/null
+++ b/android/makevars_test.go
@@ -0,0 +1,42 @@
+package android
+
+import (
+ "regexp"
+ "testing"
+)
+
+func TestDistFilesInGenerateAndroidBuildActions(t *testing.T) {
+ result := GroupFixturePreparers(
+ FixtureRegisterWithContext(func(ctx RegistrationContext) {
+ ctx.RegisterModuleType("my_module_type", newDistFileModule)
+ }),
+ FixtureModifyConfig(SetKatiEnabledForTests),
+ PrepareForTestWithMakevars,
+ ).RunTestWithBp(t, `
+ my_module_type {
+ name: "foo",
+ }
+ `)
+
+ lateContents := string(result.SingletonForTests("makevars").Singleton().(*makeVarsSingleton).lateForTesting)
+ matched, err := regexp.MatchString(`call dist-for-goals,my_goal,.*/my_file.txt:my_file.txt\)`, lateContents)
+ if err != nil || !matched {
+ t.Fatalf("Expected a dist, but got: %s", lateContents)
+ }
+}
+
+type distFileModule struct {
+ ModuleBase
+}
+
+func newDistFileModule() Module {
+ m := &distFileModule{}
+ InitAndroidModule(m)
+ return m
+}
+
+func (m *distFileModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ out := PathForModuleOut(ctx, "my_file.txt")
+ WriteFileRule(ctx, out, "Hello, world!")
+ ctx.DistForGoal("my_goal", out)
+}
diff --git a/android/module.go b/android/module.go
index 39a1654..80275a3 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1925,6 +1925,12 @@
var HostToolProviderInfoProvider = blueprint.NewProvider[HostToolProviderInfo]()
+type DistInfo struct {
+ Dists []dist
+}
+
+var DistProvider = blueprint.NewProvider[DistInfo]()
+
type SourceFileGenerator interface {
GeneratedSourceFiles() Paths
GeneratedHeaderDirs() Paths
@@ -2222,6 +2228,13 @@
Phonies: ctx.phonies,
})
}
+
+ if len(ctx.dists) > 0 {
+ SetProvider(ctx, DistProvider, DistInfo{
+ Dists: ctx.dists,
+ })
+ }
+
buildComplianceMetadataProvider(ctx, m)
commonData := CommonModuleInfo{
diff --git a/android/module_context.go b/android/module_context.go
index 1f4758c..1851e7c 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -255,6 +255,24 @@
setContainersInfo(info ContainersInfo)
setAconfigPaths(paths Paths)
+
+ // DistForGoals creates a rule to copy one or more Paths to the artifacts
+ // directory on the build server when any of the specified goals are built.
+ DistForGoal(goal string, paths ...Path)
+
+ // DistForGoalWithFilename creates a rule to copy a Path to the artifacts
+ // directory on the build server with the given filename when the specified
+ // goal is built.
+ DistForGoalWithFilename(goal string, path Path, filename string)
+
+ // DistForGoals creates a rule to copy one or more Paths to the artifacts
+ // directory on the build server when any of the specified goals are built.
+ DistForGoals(goals []string, paths ...Path)
+
+ // DistForGoalsWithFilename creates a rule to copy a Path to the artifacts
+ // directory on the build server with the given filename when any of the
+ // specified goals are built.
+ DistForGoalsWithFilename(goals []string, path Path, filename string)
}
type moduleContext struct {
@@ -312,6 +330,8 @@
// complianceMetadataInfo is for different module types to dump metadata.
// See android.ModuleContext interface.
complianceMetadataInfo *ComplianceMetadataInfo
+
+ dists []dist
}
var _ ModuleContext = &moduleContext{}
@@ -591,7 +611,7 @@
func (m *moduleContext) PackageFile(installPath InstallPath, name string, srcPath Path) PackagingSpec {
fullInstallPath := installPath.Join(m, name)
- return m.packageFile(fullInstallPath, srcPath, false)
+ return m.packageFile(fullInstallPath, srcPath, false, false)
}
func (m *moduleContext) getAconfigPaths() Paths {
@@ -615,7 +635,7 @@
return owner, overrides
}
-func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool) PackagingSpec {
+func (m *moduleContext) packageFile(fullInstallPath InstallPath, srcPath Path, executable bool, requiresFullInstall bool) PackagingSpec {
licenseFiles := m.Module().EffectiveLicenseFiles()
owner, overrides := m.getOwnerAndOverrides()
spec := PackagingSpec{
@@ -630,6 +650,8 @@
archType: m.target.Arch.ArchType,
overrides: uniquelist.Make(overrides),
owner: owner,
+ requiresFullInstall: requiresFullInstall,
+ fullInstallPath: fullInstallPath,
}
m.packagingSpecs = append(m.packagingSpecs, spec)
return spec
@@ -637,6 +659,9 @@
func (m *moduleContext) installFile(installPath InstallPath, name string, srcPath Path, deps []InstallPath,
executable bool, hooks bool, checkbuild bool, extraZip *extraFilesZip) InstallPath {
+ if _, ok := srcPath.(InstallPath); ok {
+ m.ModuleErrorf("Src path cannot be another installed file. Please use a path from source or intermediates instead.")
+ }
fullInstallPath := installPath.Join(m, name)
if hooks {
@@ -705,7 +730,7 @@
m.installFiles = append(m.installFiles, fullInstallPath)
}
- m.packageFile(fullInstallPath, srcPath, executable)
+ m.packageFile(fullInstallPath, srcPath, executable, m.requiresFullInstall())
if checkbuild {
m.checkbuildFiles = append(m.checkbuildFiles, srcPath)
@@ -755,16 +780,18 @@
owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
- relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
- srcPath: nil,
- symlinkTarget: relPath,
- executable: false,
- partition: fullInstallPath.partition,
- skipInstall: m.skipInstall(),
- aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
- archType: m.target.Arch.ArchType,
- overrides: uniquelist.Make(overrides),
- owner: owner,
+ relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
+ srcPath: nil,
+ symlinkTarget: relPath,
+ executable: false,
+ partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
+ archType: m.target.Arch.ArchType,
+ overrides: uniquelist.Make(overrides),
+ owner: owner,
+ requiresFullInstall: m.requiresFullInstall(),
+ fullInstallPath: fullInstallPath,
})
return fullInstallPath
@@ -803,16 +830,18 @@
owner, overrides := m.getOwnerAndOverrides()
m.packagingSpecs = append(m.packagingSpecs, PackagingSpec{
- relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
- srcPath: nil,
- symlinkTarget: absPath,
- executable: false,
- partition: fullInstallPath.partition,
- skipInstall: m.skipInstall(),
- aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
- archType: m.target.Arch.ArchType,
- overrides: uniquelist.Make(overrides),
- owner: owner,
+ relPathInPackage: Rel(m, fullInstallPath.PartitionDir(), fullInstallPath.String()),
+ srcPath: nil,
+ symlinkTarget: absPath,
+ executable: false,
+ partition: fullInstallPath.partition,
+ skipInstall: m.skipInstall(),
+ aconfigPaths: uniquelist.Make(m.getAconfigPaths()),
+ archType: m.target.Arch.ArchType,
+ overrides: uniquelist.Make(overrides),
+ owner: owner,
+ requiresFullInstall: m.requiresFullInstall(),
+ fullInstallPath: fullInstallPath,
})
return fullInstallPath
@@ -950,3 +979,32 @@
func (m *moduleContext) setContainersInfo(info ContainersInfo) {
m.containersInfo = info
}
+
+func (c *moduleContext) DistForGoal(goal string, paths ...Path) {
+ c.DistForGoals([]string{goal}, paths...)
+}
+
+func (c *moduleContext) DistForGoalWithFilename(goal string, path Path, filename string) {
+ c.DistForGoalsWithFilename([]string{goal}, path, filename)
+}
+
+func (c *moduleContext) DistForGoals(goals []string, paths ...Path) {
+ var copies distCopies
+ for _, path := range paths {
+ copies = append(copies, distCopy{
+ from: path,
+ dest: path.Base(),
+ })
+ }
+ c.dists = append(c.dists, dist{
+ goals: slices.Clone(goals),
+ paths: copies,
+ })
+}
+
+func (c *moduleContext) DistForGoalsWithFilename(goals []string, path Path, filename string) {
+ c.dists = append(c.dists, dist{
+ goals: slices.Clone(goals),
+ paths: distCopies{{from: path, dest: filename}},
+ })
+}
diff --git a/android/module_info_json.go b/android/module_info_json.go
index f7bffdb..bb309ff 100644
--- a/android/module_info_json.go
+++ b/android/module_info_json.go
@@ -133,4 +133,12 @@
return gobtools.CustomGobDecode[combinedModuleInfoJSON](data, m)
}
+func (m *ModuleInfoJSON) GetInstalled() []string {
+ return m.core.Installed
+}
+
+func (m *ModuleInfoJSON) GetClass() []string {
+ return m.Class
+}
+
var ModuleInfoJSONProvider = blueprint.NewProvider[[]*ModuleInfoJSON]()
diff --git a/android/module_test.go b/android/module_test.go
index 6e6d449..3b81ded 100644
--- a/android/module_test.go
+++ b/android/module_test.go
@@ -1110,3 +1110,14 @@
"Module .+ and Vintf_fragment .+ are installed to different partitions.")).
RunTestWithBp(t, bp)
}
+
+func TestInvalidModuleName(t *testing.T) {
+ bp := `
+ deps {
+ name: "fo o",
+ }
+ `
+ prepareForModuleTests.
+ ExtendWithErrorHandler(FixtureExpectsOneErrorPattern(`should use a valid name`)).
+ RunTestWithBp(t, bp)
+}
diff --git a/android/mutator.go b/android/mutator.go
index 1523794..1b0700a 100644
--- a/android/mutator.go
+++ b/android/mutator.go
@@ -70,7 +70,8 @@
TopDown(name string, m TopDownMutator) MutatorHandle
BottomUp(name string, m BottomUpMutator) MutatorHandle
BottomUpBlueprint(name string, m blueprint.BottomUpMutator) MutatorHandle
- Transition(name string, m TransitionMutator) TransitionMutatorHandle
+ Transition(name string, m VariationTransitionMutator) TransitionMutatorHandle
+ InfoBasedTransition(name string, m androidTransitionMutator) TransitionMutatorHandle
}
type RegisterMutatorFunc func(RegisterMutatorsContext)
@@ -213,7 +214,7 @@
// dependency (some entries may be nil).
//
// This method will pause until the new dependencies have had the current mutator called on them.
- AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module
+ AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []Module
// AddReverseDependency adds a dependency from the destination to the given module.
// Does not affect the ordering of the current mutator pass, but will be ordered
@@ -229,7 +230,7 @@
// all the non-local variations of the current module, plus the variations argument.
//
// This method will pause until the new dependencies have had the current mutator called on them.
- AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []blueprint.Module
+ AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag, names ...string) []Module
// AddReverseVariationDependency adds a dependency from the named module to the current
// module. The given variations will be added to the current module's varations, and then the
@@ -252,7 +253,7 @@
// dependency only needs to match the supplied variations.
//
// This method will pause until the new dependencies have had the current mutator called on them.
- AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []blueprint.Module
+ AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string) []Module
// ReplaceDependencies finds all the variants of the module with the specified name, then
// replaces all dependencies onto those variants with the current variant of this module.
@@ -337,8 +338,22 @@
return mutator
}
-func (x *registerMutatorsContext) Transition(name string, m TransitionMutator) TransitionMutatorHandle {
- atm := &androidTransitionMutator{
+func (x *registerMutatorsContext) Transition(name string, m VariationTransitionMutator) TransitionMutatorHandle {
+ atm := &androidTransitionMutatorAdapter{
+ finalPhase: x.finalPhase,
+ mutator: variationTransitionMutatorAdapter{m},
+ name: name,
+ }
+ mutator := &mutator{
+ name: name,
+ transitionMutator: atm,
+ }
+ x.mutators = append(x.mutators, mutator)
+ return mutator
+}
+
+func (x *registerMutatorsContext) InfoBasedTransition(name string, m androidTransitionMutator) TransitionMutatorHandle {
+ atm := &androidTransitionMutatorAdapter{
finalPhase: x.finalPhase,
mutator: m,
name: name,
@@ -524,11 +539,11 @@
b.Module().base().commonProperties.DebugName = name
}
-func (b *bottomUpMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) blueprint.Module {
- return b.bp.CreateModule(factory, name, props...)
+func (b *bottomUpMutatorContext) createModule(factory blueprint.ModuleFactory, name string, props ...interface{}) Module {
+ return bpModuleToModule(b.bp.CreateModule(factory, name, props...))
}
-func (b *bottomUpMutatorContext) createModuleInDirectory(factory blueprint.ModuleFactory, name string, _ string, props ...interface{}) blueprint.Module {
+func (b *bottomUpMutatorContext) createModuleInDirectory(factory blueprint.ModuleFactory, name string, _ string, props ...interface{}) Module {
panic("createModuleInDirectory is not implemented for bottomUpMutatorContext")
}
@@ -536,11 +551,11 @@
return createModule(b, factory, "_bottomUpMutatorModule", doesNotSpecifyDirectory(), props...)
}
-func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []blueprint.Module {
+func (b *bottomUpMutatorContext) AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string) []Module {
if b.baseModuleContext.checkedMissingDeps() {
panic("Adding deps not allowed after checking for missing deps")
}
- return b.bp.AddDependency(module, tag, name...)
+ return bpModulesToModules(b.bp.AddDependency(module, tag, name...))
}
func (b *bottomUpMutatorContext) AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string) {
@@ -558,20 +573,20 @@
}
func (b *bottomUpMutatorContext) AddVariationDependencies(variations []blueprint.Variation, tag blueprint.DependencyTag,
- names ...string) []blueprint.Module {
+ names ...string) []Module {
if b.baseModuleContext.checkedMissingDeps() {
panic("Adding deps not allowed after checking for missing deps")
}
- return b.bp.AddVariationDependencies(variations, tag, names...)
+ return bpModulesToModules(b.bp.AddVariationDependencies(variations, tag, names...))
}
func (b *bottomUpMutatorContext) AddFarVariationDependencies(variations []blueprint.Variation,
- tag blueprint.DependencyTag, names ...string) []blueprint.Module {
+ tag blueprint.DependencyTag, names ...string) []Module {
if b.baseModuleContext.checkedMissingDeps() {
panic("Adding deps not allowed after checking for missing deps")
}
- return b.bp.AddFarVariationDependencies(variations, tag, names...)
+ return bpModulesToModules(b.bp.AddFarVariationDependencies(variations, tag, names...))
}
func (b *bottomUpMutatorContext) ReplaceDependencies(name string) {
@@ -587,3 +602,18 @@
}
b.bp.ReplaceDependenciesIf(name, predicate)
}
+
+func bpModulesToModules(bpModules []blueprint.Module) []Module {
+ modules := make([]Module, len(bpModules))
+ for i, bpModule := range bpModules {
+ modules[i] = bpModuleToModule(bpModule)
+ }
+ return modules
+}
+
+func bpModuleToModule(bpModule blueprint.Module) Module {
+ if bpModule != nil {
+ return bpModule.(Module)
+ }
+ return nil
+}
diff --git a/android/neverallow.go b/android/neverallow.go
index 7615ca8..70af2ac 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -65,6 +65,7 @@
AddNeverAllowRules(createKotlinPluginRule()...)
AddNeverAllowRules(createPrebuiltEtcBpDefineRule())
AddNeverAllowRules(createAutogenRroBpDefineRule())
+ AddNeverAllowRules(createNoSha1HashRule())
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -297,19 +298,31 @@
WithoutMatcher("visibility", InAllowedList([]string{"//trusty/vendor/google/aosp/scripts", "//trusty/vendor/google/proprietary/scripts"})).Because(reason),
NeverAllow().
ModuleType("genrule").
+ // TODO: remove the 4 below targets once new targets are submitted
Without("name", "trusty-arm64.lk.elf.gen").
Without("name", "trusty-arm64-virt-test-debug.lk.elf.gen").
Without("name", "trusty-x86_64.lk.elf.gen").
Without("name", "trusty-x86_64-test.lk.elf.gen").
+ // trusty vm target names moving forward
+ Without("name", "trusty-test_vm-arm64.elf.gen").
+ Without("name", "trusty-test_vm-x86.elf.gen").
+ Without("name", "trusty-security_vm-arm64.elf.gen").
+ Without("name", "trusty-security_vm-x86.elf.gen").
Without("name", "trusty-widevine_vm-arm64.elf.gen").
Without("name", "trusty-widevine_vm-x86.elf.gen").
WithMatcher("dir_srcs", isSetMatcherInstance).Because(reason),
NeverAllow().
ModuleType("genrule").
+ // TODO: remove the 4 below targets once new targets are submitted
Without("name", "trusty-arm64.lk.elf.gen").
Without("name", "trusty-arm64-virt-test-debug.lk.elf.gen").
Without("name", "trusty-x86_64.lk.elf.gen").
Without("name", "trusty-x86_64-test.lk.elf.gen").
+ // trusty vm target names moving forward
+ Without("name", "trusty-test_vm-arm64.elf.gen").
+ Without("name", "trusty-test_vm-x86.elf.gen").
+ Without("name", "trusty-security_vm-arm64.elf.gen").
+ Without("name", "trusty-security_vm-x86.elf.gen").
Without("name", "trusty-widevine_vm-arm64.elf.gen").
Without("name", "trusty-widevine_vm-x86.elf.gen").
With("keep_gendir", "true").Because(reason),
@@ -324,6 +337,14 @@
Because("is_auto_generated property is only allowed for filesystem modules in build/soong/fsgen directory")
}
+func createNoSha1HashRule() Rule {
+ return NeverAllow().
+ ModuleType("filesystem", "android_filesystem").
+ ModuleType("filesystem", "android_system_image").
+ With("avb_hash_algorithm", "sha1").
+ Because("sha1 is discouraged")
+}
+
func createKotlinPluginRule() []Rule {
kotlinPluginProjectsAllowedList := []string{
"external/kotlinc",
diff --git a/android/packaging.go b/android/packaging.go
index 738f215..d216c0c 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -63,6 +63,15 @@
// Name of the module where this packaging spec is output of
owner string
+
+ // If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use,
+ // for the soong-only migration.
+ requiresFullInstall bool
+
+ // The path to the installed file in out/target/product. This is for legacy purposes, with
+ // tools that want to interact with these files outside of the build. You should not use it
+ // inside of the build. Will be nil if this module doesn't require a "full install".
+ fullInstallPath InstallPath
}
type packagingSpecGob struct {
@@ -175,6 +184,24 @@
return p.aconfigPaths.ToSlice()
}
+// The path to the installed file in out/target/product. This is for legacy purposes, with
+// tools that want to interact with these files outside of the build. You should not use it
+// inside of the build. Will be nil if this module doesn't require a "full install".
+func (p *PackagingSpec) FullInstallPath() InstallPath {
+ return p.fullInstallPath
+}
+
+// If the ninja rule creating the FullInstallPath has already been emitted or not. Do not use,
+// for the soong-only migration.
+func (p *PackagingSpec) RequiresFullInstall() bool {
+ return p.requiresFullInstall
+}
+
+// The source file to be copied to the FullInstallPath. Do not use, for the soong-only migration.
+func (p *PackagingSpec) SrcPath() Path {
+ return p.srcPath
+}
+
type PackageModule interface {
Module
packagingBase() *PackagingBase
diff --git a/android/register.go b/android/register.go
index 8d2f19e..332ec27 100644
--- a/android/register.go
+++ b/android/register.go
@@ -192,6 +192,11 @@
func collateGloballyRegisteredSingletons() sortableComponents {
allSingletons := append(sortableComponents(nil), singletons...)
allSingletons = append(allSingletons,
+ // Soong only androidmk is registered later than other singletons in order to collect
+ // dist contributions from other singletons. This singleton is registered just before
+ // phony so that its phony rules can be collected by the phony singleton.
+ singleton{parallel: false, name: "soongonlyandroidmk", factory: soongOnlyAndroidMkSingletonFactory},
+
// Register phony just before makevars so it can write out its phony rules as Make rules
singleton{parallel: false, name: "phony", factory: phonySingletonFactory},
diff --git a/android/sdk_version.go b/android/sdk_version.go
index a9b88fb..fa3abaa 100644
--- a/android/sdk_version.go
+++ b/android/sdk_version.go
@@ -123,6 +123,31 @@
}
}
+func JavaLibraryNameToSdkKind(name string) (SdkKind, bool) {
+ if name == SdkPublic.DefaultJavaLibraryName() {
+ return SdkPublic, true
+ }
+ if name == SdkSystem.DefaultJavaLibraryName() {
+ return SdkSystem, true
+ }
+ if name == SdkTest.DefaultJavaLibraryName() {
+ return SdkTest, true
+ }
+ if name == SdkTestFrameworksCore.DefaultJavaLibraryName() {
+ return SdkTestFrameworksCore, true
+ }
+ if name == SdkCore.DefaultJavaLibraryName() {
+ return SdkCore, true
+ }
+ if name == SdkModule.DefaultJavaLibraryName() {
+ return SdkModule, true
+ }
+ if name == SdkSystemServer.DefaultJavaLibraryName() {
+ return SdkSystemServer, true
+ }
+ return SdkInvalid, false
+}
+
func (k SdkKind) DefaultExportableJavaLibraryName() string {
switch k {
case SdkPublic, SdkSystem, SdkTest, SdkModule, SdkSystemServer:
diff --git a/android/team_proto/OWNERS b/android/team_proto/OWNERS
index 2beb4f4..1eb820b 100644
--- a/android/team_proto/OWNERS
+++ b/android/team_proto/OWNERS
@@ -1,5 +1,4 @@
dariofreni@google.com
joeo@google.com
ronish@google.com
-caditya@google.com
rbraunstein@google.com
diff --git a/android/transition.go b/android/transition.go
index 7c04eff..e1aa891 100644
--- a/android/transition.go
+++ b/android/transition.go
@@ -73,29 +73,56 @@
// two systems: when creating new variations, Soong clones the old module and
// thus some way is needed to change it state whereas Bazel creates each
// configuration of a given configured target anew.
-type TransitionMutator interface {
+type TransitionMutator[T blueprint.TransitionInfo] interface {
// Split returns the set of variations that should be created for a module no
// matter who depends on it. Used when Make depends on a particular variation
// or when the module knows its variations just based on information given to
// it in the Blueprint file. This method should not mutate the module it is
// called on.
- Split(ctx BaseModuleContext) []string
+ Split(ctx BaseModuleContext) []T
// OutgoingTransition is called on a module to determine which variation it wants
// from its direct dependencies. The dependency itself can override this decision.
// This method should not mutate the module itself.
- OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
+ OutgoingTransition(ctx OutgoingTransitionContext, sourceTransitionInfo T) T
// IncomingTransition is called on a module to determine which variation it should
// be in based on the variation modules that depend on it want. This gives the module
// a final say about its own variations. This method should not mutate the module
// itself.
- IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string
+ IncomingTransition(ctx IncomingTransitionContext, incomingTransitionInfo T) T
// Mutate is called after a module was split into multiple variations on each variation.
// It should not split the module any further but adding new dependencies is
// fine. Unlike all the other methods on TransitionMutator, this method is
// allowed to mutate the module.
+ Mutate(ctx BottomUpMutatorContext, transitionInfo T)
+
+ // TransitionInfoFromVariation is called when adding dependencies with an explicit variation after the
+ // TransitionMutator has already run. It takes a variation name and returns a TransitionInfo for that
+ // variation. It may not be possible for some TransitionMutators to generate an appropriate TransitionInfo
+ // if the variation does not contain all the information from the TransitionInfo, in which case the
+ // TransitionMutator can panic in TransitionInfoFromVariation, and adding dependencies with explicit variations
+ // for this TransitionMutator is not supported.
+ TransitionInfoFromVariation(variation string) T
+}
+
+// androidTransitionMutator is a copy of blueprint.TransitionMutator with the context argument types changed
+// from blueprint.BaseModuleContext to BaseModuleContext, etc.
+type androidTransitionMutator interface {
+ Split(ctx BaseModuleContext) []blueprint.TransitionInfo
+ OutgoingTransition(ctx OutgoingTransitionContext, sourceTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo
+ IncomingTransition(ctx IncomingTransitionContext, incomingTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo
+ Mutate(ctx BottomUpMutatorContext, transitionInfo blueprint.TransitionInfo)
+ TransitionInfoFromVariation(variation string) blueprint.TransitionInfo
+}
+
+// VariationTransitionMutator is a simpler version of androidTransitionMutator that passes variation strings instead
+// of a blueprint.TransitionInfo object.
+type VariationTransitionMutator interface {
+ Split(ctx BaseModuleContext) []string
+ OutgoingTransition(ctx OutgoingTransitionContext, sourceVariation string) string
+ IncomingTransition(ctx IncomingTransitionContext, incomingVariation string) string
Mutate(ctx BottomUpMutatorContext, variation string)
}
@@ -108,6 +135,14 @@
// is being computed
Module() Module
+ // ModuleName returns the name of the module. This is generally the value that was returned by Module.Name() when
+ // the module was created, but may have been modified by calls to BottomUpMutatorContext.Rename.
+ ModuleName() string
+
+ // DepTag() Returns the dependency tag through which this dependency is
+ // reached
+ DepTag() blueprint.DependencyTag
+
// Config returns the configuration for the build.
Config() Config
@@ -128,6 +163,10 @@
// is being computed
Module() Module
+ // ModuleName returns the name of the module. This is generally the value that was returned by Module.Name() when
+ // the module was created, but may have been modified by calls to BottomUpMutatorContext.Rename.
+ ModuleName() string
+
// DepTag() Returns the dependency tag through which this dependency is
// reached
DepTag() blueprint.DependencyTag
@@ -138,68 +177,166 @@
DeviceConfig() DeviceConfig
}
-type androidTransitionMutator struct {
+// androidTransitionMutatorAdapter wraps an androidTransitionMutator to convert it to a blueprint.TransitionInfo
+// by converting the blueprint.*Context objects into android.*Context objects.
+type androidTransitionMutatorAdapter struct {
finalPhase bool
- mutator TransitionMutator
+ mutator androidTransitionMutator
name string
}
-func (a *androidTransitionMutator) Split(ctx blueprint.BaseModuleContext) []string {
+func (a *androidTransitionMutatorAdapter) Split(ctx blueprint.BaseModuleContext) []blueprint.TransitionInfo {
if a.finalPhase {
panic("TransitionMutator not allowed in FinalDepsMutators")
}
- if m, ok := ctx.Module().(Module); ok {
- moduleContext := m.base().baseModuleContextFactory(ctx)
- return a.mutator.Split(&moduleContext)
- } else {
- return []string{""}
- }
+ m := ctx.Module().(Module)
+ moduleContext := m.base().baseModuleContextFactory(ctx)
+ return a.mutator.Split(&moduleContext)
}
-func (a *androidTransitionMutator) OutgoingTransition(bpctx blueprint.OutgoingTransitionContext, sourceVariation string) string {
- if m, ok := bpctx.Module().(Module); ok {
- ctx := outgoingTransitionContextPool.Get().(*outgoingTransitionContextImpl)
- defer outgoingTransitionContextPool.Put(ctx)
- *ctx = outgoingTransitionContextImpl{
- archModuleContext: m.base().archModuleContextFactory(bpctx),
- bp: bpctx,
- }
- return a.mutator.OutgoingTransition(ctx, sourceVariation)
- } else {
- return ""
+func (a *androidTransitionMutatorAdapter) OutgoingTransition(bpctx blueprint.OutgoingTransitionContext,
+ sourceTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+ m := bpctx.Module().(Module)
+ ctx := outgoingTransitionContextPool.Get().(*outgoingTransitionContextImpl)
+ defer outgoingTransitionContextPool.Put(ctx)
+ *ctx = outgoingTransitionContextImpl{
+ archModuleContext: m.base().archModuleContextFactory(bpctx),
+ bp: bpctx,
}
+ return a.mutator.OutgoingTransition(ctx, sourceTransitionInfo)
}
-func (a *androidTransitionMutator) IncomingTransition(bpctx blueprint.IncomingTransitionContext, incomingVariation string) string {
- if m, ok := bpctx.Module().(Module); ok {
- ctx := incomingTransitionContextPool.Get().(*incomingTransitionContextImpl)
- defer incomingTransitionContextPool.Put(ctx)
- *ctx = incomingTransitionContextImpl{
- archModuleContext: m.base().archModuleContextFactory(bpctx),
- bp: bpctx,
- }
- return a.mutator.IncomingTransition(ctx, incomingVariation)
- } else {
- return ""
+func (a *androidTransitionMutatorAdapter) IncomingTransition(bpctx blueprint.IncomingTransitionContext,
+ incomingTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+ m := bpctx.Module().(Module)
+ ctx := incomingTransitionContextPool.Get().(*incomingTransitionContextImpl)
+ defer incomingTransitionContextPool.Put(ctx)
+ *ctx = incomingTransitionContextImpl{
+ archModuleContext: m.base().archModuleContextFactory(bpctx),
+ bp: bpctx,
}
+ return a.mutator.IncomingTransition(ctx, incomingTransitionInfo)
}
-func (a *androidTransitionMutator) Mutate(ctx blueprint.BottomUpMutatorContext, variation string) {
- if am, ok := ctx.Module().(Module); ok {
- if variation != "" {
- // TODO: this should really be checking whether the TransitionMutator affected this module, not
- // the empty variant, but TransitionMutator has no concept of skipping a module.
- base := am.base()
- base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, a.name)
- base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variation)
- }
-
- mctx := bottomUpMutatorContextFactory(ctx, am, a.finalPhase)
- defer bottomUpMutatorContextPool.Put(mctx)
- a.mutator.Mutate(mctx, variation)
+func (a *androidTransitionMutatorAdapter) Mutate(ctx blueprint.BottomUpMutatorContext, transitionInfo blueprint.TransitionInfo) {
+ am := ctx.Module().(Module)
+ variation := transitionInfo.Variation()
+ if variation != "" {
+ // TODO: this should really be checking whether the TransitionMutator affected this module, not
+ // the empty variant, but TransitionMutator has no concept of skipping a module.
+ base := am.base()
+ base.commonProperties.DebugMutators = append(base.commonProperties.DebugMutators, a.name)
+ base.commonProperties.DebugVariations = append(base.commonProperties.DebugVariations, variation)
}
+
+ mctx := bottomUpMutatorContextFactory(ctx, am, a.finalPhase)
+ defer bottomUpMutatorContextPool.Put(mctx)
+ a.mutator.Mutate(mctx, transitionInfo)
}
+func (a *androidTransitionMutatorAdapter) TransitionInfoFromVariation(variation string) blueprint.TransitionInfo {
+ return a.mutator.TransitionInfoFromVariation(variation)
+}
+
+// variationTransitionMutatorAdapter wraps a VariationTransitionMutator to convert it to an androidTransitionMutator
+// by wrapping the string info object used by VariationTransitionMutator with variationTransitionInfo to convert it into
+// blueprint.TransitionInfo.
+type variationTransitionMutatorAdapter struct {
+ m VariationTransitionMutator
+}
+
+func (v variationTransitionMutatorAdapter) Split(ctx BaseModuleContext) []blueprint.TransitionInfo {
+ variations := v.m.Split(ctx)
+ transitionInfos := make([]blueprint.TransitionInfo, 0, len(variations))
+ for _, variation := range variations {
+ transitionInfos = append(transitionInfos, variationTransitionInfo{variation})
+ }
+ return transitionInfos
+}
+
+func (v variationTransitionMutatorAdapter) OutgoingTransition(ctx OutgoingTransitionContext,
+ sourceTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+
+ sourceVariationTransitionInfo, _ := sourceTransitionInfo.(variationTransitionInfo)
+ outgoingVariation := v.m.OutgoingTransition(ctx, sourceVariationTransitionInfo.variation)
+ return variationTransitionInfo{outgoingVariation}
+}
+
+func (v variationTransitionMutatorAdapter) IncomingTransition(ctx IncomingTransitionContext,
+ incomingTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+
+ incomingVariationTransitionInfo, _ := incomingTransitionInfo.(variationTransitionInfo)
+ variation := v.m.IncomingTransition(ctx, incomingVariationTransitionInfo.variation)
+ return variationTransitionInfo{variation}
+}
+
+func (v variationTransitionMutatorAdapter) Mutate(ctx BottomUpMutatorContext, transitionInfo blueprint.TransitionInfo) {
+ variationTransitionInfo, _ := transitionInfo.(variationTransitionInfo)
+ v.m.Mutate(ctx, variationTransitionInfo.variation)
+}
+
+func (v variationTransitionMutatorAdapter) TransitionInfoFromVariation(variation string) blueprint.TransitionInfo {
+ return variationTransitionInfo{variation}
+}
+
+// variationTransitionInfo is a blueprint.TransitionInfo that contains a single variation string.
+type variationTransitionInfo struct {
+ variation string
+}
+
+func (v variationTransitionInfo) Variation() string {
+ return v.variation
+}
+
+// genericTransitionMutatorAdapter wraps a TransitionMutator to convert it to an androidTransitionMutator
+type genericTransitionMutatorAdapter[T blueprint.TransitionInfo] struct {
+ m TransitionMutator[T]
+}
+
+// NewGenericTransitionMutatorAdapter is used to convert a generic TransitionMutator[T] into an androidTransitionMutator
+// that can be passed to RegisterMutatorsContext.InfoBasedTransition.
+func NewGenericTransitionMutatorAdapter[T blueprint.TransitionInfo](m TransitionMutator[T]) androidTransitionMutator {
+ return &genericTransitionMutatorAdapter[T]{m}
+}
+
+func (g *genericTransitionMutatorAdapter[T]) convertTransitionInfoToT(transitionInfo blueprint.TransitionInfo) T {
+ if transitionInfo == nil {
+ var zero T
+ return zero
+ }
+ return transitionInfo.(T)
+}
+
+func (g *genericTransitionMutatorAdapter[T]) Split(ctx BaseModuleContext) []blueprint.TransitionInfo {
+ transitionInfos := g.m.Split(ctx)
+ bpTransitionInfos := make([]blueprint.TransitionInfo, 0, len(transitionInfos))
+ for _, transitionInfo := range transitionInfos {
+ bpTransitionInfos = append(bpTransitionInfos, transitionInfo)
+ }
+ return bpTransitionInfos
+}
+
+func (g *genericTransitionMutatorAdapter[T]) OutgoingTransition(ctx OutgoingTransitionContext, sourceTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+ sourceTransitionInfoT := g.convertTransitionInfoToT(sourceTransitionInfo)
+ return g.m.OutgoingTransition(ctx, sourceTransitionInfoT)
+}
+
+func (g *genericTransitionMutatorAdapter[T]) IncomingTransition(ctx IncomingTransitionContext, incomingTransitionInfo blueprint.TransitionInfo) blueprint.TransitionInfo {
+ incomingTransitionInfoT := g.convertTransitionInfoToT(incomingTransitionInfo)
+ return g.m.IncomingTransition(ctx, incomingTransitionInfoT)
+}
+
+func (g *genericTransitionMutatorAdapter[T]) Mutate(ctx BottomUpMutatorContext, transitionInfo blueprint.TransitionInfo) {
+ transitionInfoT := g.convertTransitionInfoToT(transitionInfo)
+ g.m.Mutate(ctx, transitionInfoT)
+}
+
+func (g *genericTransitionMutatorAdapter[T]) TransitionInfoFromVariation(variation string) blueprint.TransitionInfo {
+ return g.m.TransitionInfoFromVariation(variation)
+}
+
+// incomingTransitionContextImpl wraps a blueprint.IncomingTransitionContext to convert it to an
+// IncomingTransitionContext.
type incomingTransitionContextImpl struct {
archModuleContext
bp blueprint.IncomingTransitionContext
@@ -209,6 +346,14 @@
return c.bp.Module().(Module)
}
+func (c *incomingTransitionContextImpl) ModuleName() string {
+ return c.bp.ModuleName()
+}
+
+func (c *incomingTransitionContextImpl) DepTag() blueprint.DependencyTag {
+ return c.bp.DepTag()
+}
+
func (c *incomingTransitionContextImpl) Config() Config {
return c.bp.Config().(Config)
}
@@ -233,6 +378,8 @@
c.bp.PropertyErrorf(property, fmt, args)
}
+// outgoingTransitionContextImpl wraps a blueprint.OutgoingTransitionContext to convert it to an
+// OutgoingTransitionContext.
type outgoingTransitionContextImpl struct {
archModuleContext
bp blueprint.OutgoingTransitionContext
@@ -242,6 +389,10 @@
return c.bp.Module().(Module)
}
+func (c *outgoingTransitionContextImpl) ModuleName() string {
+ return c.bp.ModuleName()
+}
+
func (c *outgoingTransitionContextImpl) DepTag() blueprint.DependencyTag {
return c.bp.DepTag()
}
diff --git a/android/variable.go b/android/variable.go
index 3e637fe..4867067 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -551,6 +551,8 @@
SystemExtManifestFiles []string `json:",omitempty"`
DeviceManifestFiles []string `json:",omitempty"`
OdmManifestFiles []string `json:",omitempty"`
+
+ UseSoongNoticeXML *bool `json:",omitempty"`
}
type PartitionQualifiedVariablesType struct {
diff --git a/apex/androidmk.go b/apex/androidmk.go
index ec5ca15..3a81ee4 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -226,11 +226,6 @@
required = append(required, a.required...)
targetRequired = append(targetRequired, a.TargetRequiredModuleNames()...)
hostRequired = append(hostRequired, a.HostRequiredModuleNames()...)
- for _, fi := range a.filesInfo {
- required = append(required, fi.requiredModuleNames...)
- targetRequired = append(targetRequired, fi.targetRequiredModuleNames...)
- hostRequired = append(hostRequired, fi.hostRequiredModuleNames...)
- }
android.AndroidMkEmitAssignList(w, "LOCAL_REQUIRED_MODULES", moduleNames, a.makeModulesToInstall, required)
android.AndroidMkEmitAssignList(w, "LOCAL_TARGET_REQUIRED_MODULES", targetRequired)
android.AndroidMkEmitAssignList(w, "LOCAL_HOST_REQUIRED_MODULES", hostRequired)
@@ -261,6 +256,7 @@
fmt.Fprintln(w, "LOCAL_SOONG_INSTALLED_MODULE :=", a.installedFile.String())
fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_PAIRS :=", a.outputFile.String()+":"+a.installedFile.String())
fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_SYMLINKS := ", strings.Join(a.compatSymlinks.Strings(), " "))
+ fmt.Fprintln(w, "LOCAL_SOONG_INSTALL_PAIRS +=", a.extraInstalledPairs.String())
}
fmt.Fprintln(w, "LOCAL_APEX_KEY_PATH := ", a.apexKeysPath.String())
diff --git a/apex/apex.go b/apex/apex.go
index d98cfae..fa796e5 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -415,6 +415,30 @@
Min_sdk_version *string
}
+// installPair stores a path to a built object and its install location. It is used for holding
+// the installation location of the dexpreopt artifacts for system server jars in apexes that need
+// to be installed when the apex is installed.
+type installPair struct {
+ from android.Path
+ to android.InstallPath
+}
+
+type installPairs []installPair
+
+// String converts a list of installPair structs to the form accepted by LOCAL_SOONG_INSTALL_PAIRS.
+func (p installPairs) String() string {
+ sb := &strings.Builder{}
+ for i, pair := range p {
+ if i != 0 {
+ sb.WriteByte(' ')
+ }
+ sb.WriteString(pair.from.String())
+ sb.WriteByte(':')
+ sb.WriteString(pair.to.String())
+ }
+ return sb.String()
+}
+
type apexBundle struct {
// Inherited structs
android.ModuleBase
@@ -496,6 +520,12 @@
// Path where this APEX was installed.
installedFile android.InstallPath
+ // Extra files that are installed alongside this APEX.
+ extraInstalledFiles android.InstallPaths
+
+ // The source and install locations for extraInstalledFiles for use in LOCAL_SOONG_INSTALL_PAIRS.
+ extraInstalledPairs installPairs
+
// fragment for this apex for apexkeys.txt
apexKeysPath android.WritablePath
@@ -570,13 +600,15 @@
// Info for Android.mk Module name of `module` in AndroidMk. Note the generated AndroidMk
// module for apexFile is named something like <AndroidMk module name>.<apex name>[<apex
// suffix>]
- androidMkModuleName string // becomes LOCAL_MODULE
- class apexFileClass // becomes LOCAL_MODULE_CLASS
- moduleDir string // becomes LOCAL_PATH
- requiredModuleNames []string // becomes LOCAL_REQUIRED_MODULES
- targetRequiredModuleNames []string // becomes LOCAL_TARGET_REQUIRED_MODULES
- hostRequiredModuleNames []string // becomes LOCAL_HOST_REQUIRED_MODULES
- dataPaths []android.DataPath // becomes LOCAL_TEST_DATA
+ androidMkModuleName string // becomes LOCAL_MODULE
+ class apexFileClass // becomes LOCAL_MODULE_CLASS
+ moduleDir string // becomes LOCAL_PATH
+ dataPaths []android.DataPath // becomes LOCAL_TEST_DATA
+
+ // systemServerDexpreoptInstalls stores the list of dexpreopt artifacts for a system server jar.
+ systemServerDexpreoptInstalls []java.DexpreopterInstall
+ // systemServerDexJars stores the list of dexjars for a system server jar.
+ systemServerDexJars android.Paths
jacocoReportClassesFile android.Path // only for javalibs and apps
lintInfo *java.LintInfo // only for javalibs and apps
@@ -892,6 +924,12 @@
// Add a reverse dependency to all_apex_certs singleton module.
// all_apex_certs will use this dependency to collect the certificate of this apex.
ctx.AddReverseDependency(ctx.Module(), allApexCertsDepTag, "all_apex_certs")
+
+ // TODO: When all branches contain this singleton module, make this strict
+ // TODO: Add this dependency only for mainline prebuilts and not every prebuilt module
+ if ctx.OtherModuleExists("all_apex_contributions") {
+ ctx.AddDependency(ctx.Module(), android.AcDepTag, "all_apex_contributions")
+ }
}
type allApexCertsDependencyTag struct {
@@ -994,9 +1032,9 @@
// be built for this apexBundle.
apexVariationName := mctx.ModuleName() // could be com.android.foo
- if overridable, ok := mctx.Module().(android.OverridableModule); ok && overridable.GetOverriddenBy() != "" {
+ if a.GetOverriddenBy() != "" {
// use the overridden name com.mycompany.android.foo
- apexVariationName = overridable.GetOverriddenBy()
+ apexVariationName = a.GetOverriddenBy()
}
a.properties.ApexVariationName = apexVariationName
@@ -1164,8 +1202,6 @@
return []string{overridable.GetOverriddenBy()}
}
return []string{ai.ApexVariationName()}
- } else if _, ok := ctx.Module().(*OverrideApex); ok {
- return []string{ctx.ModuleName()}
}
return []string{""}
}
@@ -1182,8 +1218,6 @@
return overridable.GetOverriddenBy()
}
return ai.ApexVariationName()
- } else if _, ok := ctx.Module().(*OverrideApex); ok {
- return ctx.Module().Name()
}
return ""
@@ -1501,16 +1535,15 @@
af.lintInfo = lintInfo
}
af.customStem = module.Stem() + ".jar"
+ // Collect any system server dex jars and dexpreopt artifacts for installation alongside the apex.
// TODO: b/338641779 - Remove special casing of sdkLibrary once bcpf and sscpf depends
// on the implementation library
if sdkLib, ok := module.(*java.SdkLibrary); ok {
- for _, install := range sdkLib.BuiltInstalledForApex() {
- af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
- }
+ af.systemServerDexpreoptInstalls = append(af.systemServerDexpreoptInstalls, sdkLib.ApexSystemServerDexpreoptInstalls()...)
+ af.systemServerDexJars = append(af.systemServerDexJars, sdkLib.ApexSystemServerDexJars()...)
} else if dexpreopter, ok := module.(java.DexpreopterInterface); ok {
- for _, install := range dexpreopter.DexpreoptBuiltInstalledForApex() {
- af.requiredModuleNames = append(af.requiredModuleNames, install.FullModuleName())
- }
+ af.systemServerDexpreoptInstalls = append(af.systemServerDexpreoptInstalls, dexpreopter.ApexSystemServerDexpreoptInstalls()...)
+ af.systemServerDexJars = append(af.systemServerDexJars, dexpreopter.ApexSystemServerDexJars()...)
}
return af
}
@@ -1626,6 +1659,10 @@
// to the child modules. Returning false makes the visit to continue in the sibling or the parent
// modules. This is used in check* functions below.
func (a *apexBundle) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) {
+ apexVariationName := ctx.ModuleName()
+ if overrideName := a.GetOverriddenBy(); overrideName != "" {
+ apexVariationName = overrideName
+ }
ctx.WalkDeps(func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
@@ -1645,7 +1682,7 @@
}
ai, _ := android.OtherModuleProvider(ctx, child, android.ApexInfoProvider)
- externalDep := !android.InList(ctx.ModuleName(), ai.InApexVariants)
+ externalDep := !android.InList(apexVariationName, ai.InApexVariants)
// Visit actually
return do(ctx, parent, am, externalDep)
@@ -2258,6 +2295,7 @@
////////////////////////////////////////////////////////////////////////////////////////////
// 4) generate the build rules to create the APEX. This is done in builder.go.
a.buildManifest(ctx, vctx.provideNativeLibs, vctx.requireNativeLibs)
+ a.installApexSystemServerFiles(ctx)
a.buildApex(ctx)
a.buildApexDependencyInfo(ctx)
a.buildLintReports(ctx)
diff --git a/apex/apex_test.go b/apex/apex_test.go
index a5b66c1..987cb69 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -20,7 +20,6 @@
"path/filepath"
"reflect"
"regexp"
- "slices"
"sort"
"strconv"
"strings"
@@ -29,7 +28,6 @@
"android/soong/aconfig/codegen"
"github.com/google/blueprint"
- "github.com/google/blueprint/bpmodify"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -1249,12 +1247,12 @@
// Ensure that we are using non-stub variants of mylib2 and libfoo.shared_from_rust (because
// of the platform_apis: true)
- mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000").Rule("ld").Args["libFlags"]
+ mylibLdFlags := ctx.ModuleForTests("mylib", "android_arm64_armv8-a_shared_apex10000_p").Rule("ld").Args["libFlags"]
ensureNotContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared_current/mylib2.so")
ensureContains(t, mylibLdFlags, "mylib2/android_arm64_armv8-a_shared/mylib2.so")
ensureNotContains(t, mylibLdFlags, "libmylib2_rust/android_arm64_armv8-a_shared_current/unstripped/libmylib2_rust.so")
ensureContains(t, mylibLdFlags, "libmylib2_rust/android_arm64_armv8-a_shared/unstripped/libmylib2_rust.so")
- rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000").Rule("rustc").Args["linkFlags"]
+ rustDeps := ctx.ModuleForTests("foo.rust", "android_arm64_armv8-a_apex10000_p").Rule("rustc").Args["linkFlags"]
ensureNotContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared_current/libfoo.shared_from_rust.so")
ensureContains(t, rustDeps, "libfoo.shared_from_rust/android_arm64_armv8-a_shared/libfoo.shared_from_rust.so")
ensureNotContains(t, rustDeps, "libmylib_rust.shared_from_rust/android_arm64_armv8-a_shared_current/unstripped/libmylib_rust.shared_from_rust.so")
@@ -5475,7 +5473,7 @@
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
- out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
+ out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_com.android.art/modular-hiddenapi/index.csv
`)
})
@@ -5548,7 +5546,7 @@
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
- out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
+ out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_com.android.art/modular-hiddenapi/index.csv
`)
myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module()
@@ -5743,7 +5741,7 @@
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
- out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
+ out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_com.android.art/modular-hiddenapi/index.csv
`)
})
@@ -5842,7 +5840,7 @@
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/modular-hiddenapi/index.csv
- out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
+ out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_com.android.art/modular-hiddenapi/index.csv
`)
})
@@ -5954,7 +5952,7 @@
checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
- out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_apex10000/modular-hiddenapi/index.csv
+ out/soong/.intermediates/packages/modules/com.android.art/art-bootclasspath-fragment/android_common_com.android.art/modular-hiddenapi/index.csv
`)
})
@@ -9803,7 +9801,16 @@
var builder strings.Builder
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES := foo.myapex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex\n")
+ out := ctx.Config().OutDir()
+ ensureContains(t, androidMk, "LOCAL_SOONG_INSTALL_PAIRS += "+
+ filepath.Join(out, "soong/.intermediates/foo/android_common_apex10000/dexpreopt/foo/oat/arm64/javalib.odex")+
+ ":"+
+ filepath.Join(out, "target/product/test_device/system/framework/oat/arm64/apex@myapex@javalib@foo.jar@classes.odex")+
+ " "+
+ filepath.Join(out, "soong/.intermediates/foo/android_common_apex10000/dexpreopt/foo/oat/arm64/javalib.vdex")+
+ ":"+
+ filepath.Join(out, "target/product/test_device/system/framework/oat/arm64/apex@myapex@javalib@foo.jar@classes.vdex")+
+ "\n")
}
func TestAndroidMk_RequiredModules(t *testing.T) {
@@ -10823,15 +10830,6 @@
}
rust_library {
- name: "libflags_rust", // test mock
- crate_name: "flags_rust",
- srcs: ["lib.rs"],
- apex_available: [
- "myapex",
- ],
- }
-
- rust_library {
name: "liblazy_static", // test mock
crate_name: "lazy_static",
srcs: ["src/lib.rs"],
@@ -10951,8 +10949,8 @@
mod := ctx.ModuleForTests("myapex", "android_common_myapex")
s := mod.Rule("apexRule").Args["copy_commands"]
copyCmds := regexp.MustCompile(" *&& *").Split(s, -1)
- if len(copyCmds) != 34 {
- t.Fatalf("Expected 34 commands, got %d in:\n%s", len(copyCmds), s)
+ if len(copyCmds) != 32 {
+ t.Fatalf("Expected 32 commands, got %d in:\n%s", len(copyCmds), s)
}
ensureListContainsMatch(t, copyCmds, "^cp -f .*/aconfig_flags.pb .*/image.apex/etc/aconfig_flags.pb")
@@ -11302,7 +11300,7 @@
{
desc: "Source apex com.android.foo is selected, bootjar should come from source java library",
selectedApexContributions: "foo.source.contributions",
- expectedBootJar: "out/soong/.intermediates/foo-bootclasspath-fragment/android_common_apex10000/hiddenapi-modular/encoded/framework-foo.jar",
+ expectedBootJar: "out/soong/.intermediates/foo-bootclasspath-fragment/android_common_com.android.foo/hiddenapi-modular/encoded/framework-foo.jar",
},
{
desc: "Prebuilt apex prebuilt_com.android.foo is selected, profile should come from .prof deapexed from the prebuilt",
@@ -11359,7 +11357,7 @@
variation := func(moduleName string) string {
ret := "android_common_com.android.foo"
if moduleName == "com.google.android.foo" {
- ret = "android_common_com.google.android.foo_com.google.android.foo"
+ ret = "android_common_com.google.android.foo"
}
return ret
}
@@ -11874,7 +11872,7 @@
}
`)
- java.CheckModuleHasDependency(t, res.TestContext, "myoverrideapex", "android_common_myoverrideapex_myoverrideapex", "foo")
+ java.CheckModuleHasDependency(t, res.TestContext, "myoverrideapex", "android_common_myoverrideapex", "foo")
}
func TestUpdatableApexMinSdkVersionCurrent(t *testing.T) {
@@ -12210,396 +12208,3 @@
fileList := android.ContentFromFileRuleForTests(t, result, partition.Output("fileList"))
android.AssertDeepEquals(t, "filesystem with apex", "apex/myapex.apex\n", fileList)
}
-
-func TestApexVerifyNativeImplementationLibs(t *testing.T) {
- t.Parallel()
-
- extractDepenencyPathFromErrors := func(errs []error) []string {
- i := slices.IndexFunc(errs, func(err error) bool {
- return strings.Contains(err.Error(), "dependency path:")
- })
- if i < 0 {
- return nil
- }
- var dependencyPath []string
- for _, err := range errs[i+1:] {
- s := err.Error()
- lastSpace := strings.LastIndexByte(s, ' ')
- if lastSpace >= 0 {
- dependencyPath = append(dependencyPath, s[lastSpace+1:])
- }
- }
- return dependencyPath
- }
-
- checkErrors := func(wantDependencyPath []string) func(t *testing.T, result *android.TestResult) {
- return func(t *testing.T, result *android.TestResult) {
- t.Helper()
- if len(result.Errs) == 0 {
- t.Fatalf("expected errors")
- }
- t.Log("found errors:")
- for _, err := range result.Errs {
- t.Log(err)
- }
- if g, w := result.Errs[0].Error(), "library in apex transitively linked against implementation library"; !strings.Contains(g, w) {
- t.Fatalf("expected error %q, got %q", w, g)
- }
- dependencyPath := extractDepenencyPathFromErrors(result.Errs)
- if g, w := dependencyPath, wantDependencyPath; !slices.Equal(g, w) {
- t.Errorf("expected dependency path %q, got %q", w, g)
- }
- }
- }
-
- addToSharedLibs := func(module, lib string) func(bp *bpmodify.Blueprint) {
- return func(bp *bpmodify.Blueprint) {
- m := bp.ModulesByName(module)
- props, err := m.GetOrCreateProperty(bpmodify.List, "shared_libs")
- if err != nil {
- panic(err)
- }
- props.AddStringToList(lib)
- }
- }
-
- bpTemplate := `
- apex {
- name: "myapex",
- key: "myapex.key",
- native_shared_libs: ["mylib"],
- rust_dyn_libs: ["libmyrust"],
- binaries: ["mybin", "myrustbin"],
- jni_libs: ["libjni"],
- apps: ["myapp"],
- updatable: false,
- }
-
- apex {
- name: "otherapex",
- key: "myapex.key",
- native_shared_libs: ["libotherapex"],
- updatable: false,
- }
-
- apex_key {
- name: "myapex.key",
- public_key: "testkey.avbpubkey",
- private_key: "testkey.pem",
- }
-
- cc_library {
- name: "mylib",
- srcs: ["foo.cpp"],
- apex_available: ["myapex"],
- }
-
- cc_binary {
- name: "mybin",
- srcs: ["foo.cpp"],
- apex_available: ["myapex"],
- }
-
- rust_library {
- name: "libmyrust",
- crate_name: "myrust",
- srcs: ["src/lib.rs"],
- rustlibs: ["libmyrust_transitive_dylib"],
- rlibs: ["libmyrust_transitive_rlib"],
- apex_available: ["myapex"],
- }
-
- rust_library{
- name: "libmyrust_transitive_dylib",
- crate_name: "myrust_transitive_dylib",
- srcs: ["src/lib.rs"],
- apex_available: ["myapex"],
- }
-
- rust_library {
- name: "libmyrust_transitive_rlib",
- crate_name: "myrust_transitive_rlib",
- srcs: ["src/lib.rs"],
- apex_available: ["myapex"],
- }
-
- rust_binary {
- name: "myrustbin",
- srcs: ["src/main.rs"],
- apex_available: ["myapex"],
- }
-
- cc_library {
- name: "libbar",
- sdk_version: "current",
- srcs: ["bar.cpp"],
- apex_available: ["myapex"],
- stl: "none",
- }
-
- android_app {
- name: "myapp",
- jni_libs: ["libembeddedjni"],
- use_embedded_native_libs: true,
- sdk_version: "current",
- apex_available: ["myapex"],
- }
-
- cc_library {
- name: "libembeddedjni",
- sdk_version: "current",
- srcs: ["bar.cpp"],
- apex_available: ["myapex"],
- stl: "none",
- }
-
- cc_library {
- name: "libjni",
- sdk_version: "current",
- srcs: ["bar.cpp"],
- apex_available: ["myapex"],
- stl: "none",
- }
-
- cc_library {
- name: "libotherapex",
- sdk_version: "current",
- srcs: ["otherapex.cpp"],
- apex_available: ["otherapex"],
- stubs: {
- symbol_file: "libotherapex.map.txt",
- versions: ["1", "2", "3"],
- },
- stl: "none",
- }
-
- cc_library {
- name: "libplatform",
- sdk_version: "current",
- srcs: ["libplatform.cpp"],
- stubs: {
- symbol_file: "libplatform.map.txt",
- versions: ["1", "2", "3"],
- },
- stl: "none",
- system_shared_libs: [],
- }
- `
-
- testCases := []struct {
- name string
- bpModifier func(bp *bpmodify.Blueprint)
- dependencyPath []string
- }{
- {
- name: "library dependency in other apex",
- bpModifier: addToSharedLibs("mylib", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "mylib", "libotherapex"},
- },
- {
- name: "transitive library dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("mylib", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "mylib", "libbar", "libotherapex"},
- },
- {
- name: "library dependency in platform",
- bpModifier: addToSharedLibs("mylib", "libplatform#impl"),
- dependencyPath: []string{"myapex", "mylib", "libplatform"},
- },
- {
- name: "jni library dependency in other apex",
- bpModifier: addToSharedLibs("libjni", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "libjni", "libotherapex"},
- },
- {
- name: "transitive jni library dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libjni", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libjni", "libbar", "libotherapex"},
- },
- {
- name: "jni library dependency in platform",
- bpModifier: addToSharedLibs("libjni", "libplatform#impl"),
- dependencyPath: []string{"myapex", "libjni", "libplatform"},
- },
- {
- name: "transitive jni library dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libjni", "libbar")(bp)
- addToSharedLibs("libbar", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libjni", "libbar", "libplatform"},
- },
- {
- name: "app jni library dependency in other apex",
- bpModifier: addToSharedLibs("libembeddedjni", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "myapp", "libembeddedjni", "libotherapex"},
- },
- {
- name: "transitive app jni library dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libembeddedjni", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "myapp", "libembeddedjni", "libbar", "libotherapex"},
- },
- {
- name: "app jni library dependency in platform",
- bpModifier: addToSharedLibs("libembeddedjni", "libplatform#impl"),
- dependencyPath: []string{"myapex", "myapp", "libembeddedjni", "libplatform"},
- },
- {
- name: "transitive app jni library dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libembeddedjni", "libbar")(bp)
- addToSharedLibs("libbar", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "myapp", "libembeddedjni", "libbar", "libplatform"},
- },
- {
- name: "binary dependency in other apex",
- bpModifier: addToSharedLibs("mybin", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "mybin", "libotherapex"},
- },
- {
- name: "transitive binary dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("mybin", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "mybin", "libbar", "libotherapex"},
- },
- {
- name: "binary dependency in platform",
- bpModifier: addToSharedLibs("mybin", "libplatform#impl"),
- dependencyPath: []string{"myapex", "mybin", "libplatform"},
- },
- {
- name: "transitive binary dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("mybin", "libbar")(bp)
- addToSharedLibs("libbar", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "mybin", "libbar", "libplatform"},
- },
-
- {
- name: "rust library dependency in other apex",
- bpModifier: addToSharedLibs("libmyrust", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "libmyrust", "libotherapex"},
- },
- {
- name: "transitive rust library dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libbar", "libotherapex"},
- },
- {
- name: "rust library dependency in platform",
- bpModifier: addToSharedLibs("libmyrust", "libplatform#impl"),
- dependencyPath: []string{"myapex", "libmyrust", "libplatform"},
- },
- {
- name: "transitive rust library dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust", "libbar")(bp)
- addToSharedLibs("libbar", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libbar", "libplatform"},
- },
- {
- name: "transitive rust library dylib dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust_transitive_dylib", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libmyrust_transitive_dylib", "libotherapex"},
- },
- {
- name: "transitive rust library dylib dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust_transitive_dylib", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libmyrust_transitive_dylib", "libplatform"},
- },
- {
- name: "transitive rust library rlib dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust_transitive_rlib", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libmyrust_transitive_rlib", "libotherapex"},
- },
- {
- name: "transitive rust library rlib dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("libmyrust_transitive_rlib", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "libmyrust", "libmyrust_transitive_rlib", "libplatform"},
- },
- {
- name: "rust binary dependency in other apex",
- bpModifier: addToSharedLibs("myrustbin", "libotherapex#impl"),
- dependencyPath: []string{"myapex", "myrustbin", "libotherapex"},
- },
- {
- name: "transitive rust binary dependency in other apex",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("myrustbin", "libbar")(bp)
- addToSharedLibs("libbar", "libotherapex#impl")(bp)
- },
- dependencyPath: []string{"myapex", "myrustbin", "libbar", "libotherapex"},
- },
- {
- name: "rust binary dependency in platform",
- bpModifier: addToSharedLibs("myrustbin", "libplatform#impl"),
- dependencyPath: []string{"myapex", "myrustbin", "libplatform"},
- },
- {
- name: "transitive rust binary dependency in platform",
- bpModifier: func(bp *bpmodify.Blueprint) {
- addToSharedLibs("myrustbin", "libbar")(bp)
- addToSharedLibs("libbar", "libplatform#impl")(bp)
- },
- dependencyPath: []string{"myapex", "myrustbin", "libbar", "libplatform"},
- },
- }
-
- for _, testCase := range testCases {
- t.Run(testCase.name, func(t *testing.T) {
- t.Parallel()
- bp, err := bpmodify.NewBlueprint("", []byte(bpTemplate))
- if err != nil {
- t.Fatal(err)
- }
- if testCase.bpModifier != nil {
- func() {
- defer func() {
- if r := recover(); r != nil {
- t.Fatalf("panic in bpModifier: %v", r)
- }
- }()
- testCase.bpModifier(bp)
- }()
- }
- android.GroupFixturePreparers(
- android.PrepareForTestWithAndroidBuildComponents,
- cc.PrepareForTestWithCcBuildComponents,
- java.PrepareForTestWithDexpreopt,
- rust.PrepareForTestWithRustDefaultModules,
- PrepareForTestWithApexBuildComponents,
- prepareForTestWithMyapex,
- prepareForTestWithOtherapex,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.BuildId = proptools.StringPtr("TEST.BUILD_ID")
- }),
- ).ExtendWithErrorHandler(android.FixtureCustomErrorHandler(checkErrors(testCase.dependencyPath))).
- RunTestWithBp(t, bp.String())
- })
- }
-}
diff --git a/apex/bootclasspath_fragment_test.go b/apex/bootclasspath_fragment_test.go
index 71a8246..c7674b5 100644
--- a/apex/bootclasspath_fragment_test.go
+++ b/apex/bootclasspath_fragment_test.go
@@ -242,6 +242,7 @@
apex_available: [
"com.android.art",
],
+ min_sdk_version: "33",
}
`, content)
}
@@ -320,6 +321,7 @@
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
+ `all_apex_contributions`,
`art-bootclasspath-fragment`,
`com.android.art.key`,
`dex2oatd`,
@@ -425,6 +427,7 @@
})
java.CheckModuleDependencies(t, result.TestContext, "com.android.art", "android_common_com.android.art", []string{
+ `all_apex_contributions`,
`art-bootclasspath-fragment`,
`com.android.art.key`,
`dex2oatd`,
@@ -698,6 +701,7 @@
})
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{
+ `all_apex_contributions`,
`dex2oatd`,
`myapex.key`,
`mybootclasspathfragment`,
@@ -708,7 +712,7 @@
copyCommands := apexRule.Args["copy_commands"]
// Make sure that the fragment provides the hidden API encoded dex jars to the APEX.
- fragment := result.Module("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.Module("mybootclasspathfragment", "android_common_myapex")
info, _ := android.OtherModuleProvider(result, fragment, java.BootclasspathFragmentApexContentInfoProvider)
@@ -724,8 +728,8 @@
android.AssertStringDoesContain(t, name+" apex copy command", copyCommands, expectedCopyCommand)
}
- checkFragmentExportedDexJar("foo", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/foo.jar")
- checkFragmentExportedDexJar("bar", "out/soong/.intermediates/mybootclasspathfragment/android_common_apex10000/hiddenapi-modular/encoded/bar.jar")
+ checkFragmentExportedDexJar("foo", "out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/hiddenapi-modular/encoded/foo.jar")
+ checkFragmentExportedDexJar("bar", "out/soong/.intermediates/mybootclasspathfragment/android_common_myapex/hiddenapi-modular/encoded/bar.jar")
}
func getDexJarPath(result *android.TestResult, name string) string {
@@ -856,7 +860,7 @@
}
`)
- java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{
"all_apex_contributions",
"art-bootclasspath-fragment",
"bar",
@@ -871,7 +875,7 @@
quuzModuleLibStubs := getDexJarPath(result, "quuz.stubs.exportable.module_lib")
// Make sure that the fragment uses the quuz stub dex jars when generating the hidden API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1029,7 +1033,7 @@
}
`)
- java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{
"all_apex_contributions",
"android-non-updatable.stubs",
"android-non-updatable.stubs.module_lib",
@@ -1048,7 +1052,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1203,7 +1207,7 @@
}
`)
- java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{
"all_apex_contributions",
"android-non-updatable.stubs",
"android-non-updatable.stubs.system",
@@ -1219,7 +1223,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1358,7 +1362,7 @@
}
`)
- java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_apex10000", []string{
+ java.CheckModuleDependencies(t, result.TestContext, "mybootclasspathfragment", "android_common_myapex", []string{
"all_apex_contributions",
"art-bootclasspath-fragment",
"bar",
@@ -1377,7 +1381,7 @@
// Make sure that the fragment uses the android-non-updatable modules when generating the hidden
// API flags.
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
rule := fragment.Rule("modularHiddenAPIStubFlagsFile")
command := rule.RuleParams.Command
@@ -1460,7 +1464,7 @@
}
`)
- fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
+ fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_myapex")
classPathProtoContent := android.ContentFromFileRuleForTests(t, result.TestContext, fragment.Output("bootclasspath.pb.textproto"))
// foo
ensureContains(t, classPathProtoContent, `jars {
diff --git a/apex/builder.go b/apex/builder.go
index b317472..b40fd09 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -20,12 +20,14 @@
"path"
"path/filepath"
"runtime"
+ "slices"
"sort"
"strconv"
"strings"
"android/soong/aconfig"
"android/soong/android"
+ "android/soong/dexpreopt"
"android/soong/java"
"github.com/google/blueprint"
@@ -542,6 +544,64 @@
return processed
}
+// installApexSystemServerFiles installs dexpreopt and dexjar files for system server classpath entries
+// provided by the apex. They are installed here instead of in library module because there may be multiple
+// variants of the library, generally one for the "main" apex and another with a different min_sdk_version
+// for the Android Go version of the apex. Both variants would attempt to install to the same locations,
+// and the library variants cannot determine which one should. The apex module is better equipped to determine
+// if it is "selected".
+// This assumes that the jars produced by different min_sdk_version values are identical, which is currently
+// true but may not be true if the min_sdk_version difference between the variants spans version that changed
+// the dex format.
+func (a *apexBundle) installApexSystemServerFiles(ctx android.ModuleContext) {
+ // If performInstalls is set this module is responsible for creating the install rules.
+ performInstalls := a.GetOverriddenBy() == "" && !a.testApex && a.installable()
+ // TODO(b/234351700): Remove once ART does not have separated debug APEX, or make the selection
+ // explicit in the ART Android.bp files.
+ if ctx.Config().UseDebugArt() {
+ if ctx.ModuleName() == "com.android.art" {
+ performInstalls = false
+ }
+ } else {
+ if ctx.ModuleName() == "com.android.art.debug" {
+ performInstalls = false
+ }
+ }
+
+ psi := android.PrebuiltSelectionInfoMap{}
+ ctx.VisitDirectDeps(func(am android.Module) {
+ if info, exists := android.OtherModuleProvider(ctx, am, android.PrebuiltSelectionInfoProvider); exists {
+ psi = info
+ }
+ })
+
+ if len(psi.GetSelectedModulesForApiDomain(ctx.ModuleName())) > 0 {
+ performInstalls = false
+ }
+
+ for _, fi := range a.filesInfo {
+ for _, install := range fi.systemServerDexpreoptInstalls {
+ var installedFile android.InstallPath
+ if performInstalls {
+ installedFile = ctx.InstallFile(install.InstallDirOnDevice, install.InstallFileOnDevice, install.OutputPathOnHost)
+ } else {
+ // Another module created the install rules, but this module should still depend on
+ // the installed locations.
+ installedFile = install.InstallDirOnDevice.Join(ctx, install.InstallFileOnDevice)
+ }
+ a.extraInstalledFiles = append(a.extraInstalledFiles, installedFile)
+ a.extraInstalledPairs = append(a.extraInstalledPairs, installPair{install.OutputPathOnHost, installedFile})
+ }
+ if performInstalls {
+ for _, dexJar := range fi.systemServerDexJars {
+ // Copy the system server dex jar to a predefined location where dex2oat will find it.
+ android.CopyFileRule(ctx, dexJar,
+ android.PathForOutput(ctx, dexpreopt.SystemServerDexjarsDir, dexJar.Base()))
+ }
+ }
+ }
+}
+
// buildApex creates build rules to build an APEX using apexer.
func (a *apexBundle) buildApex(ctx android.ModuleContext) {
suffix := imageApexSuffix
@@ -603,7 +663,7 @@
} else {
if installSymbolFiles {
// store installedPath. symlinks might be created if required.
- installedPath = apexDir.Join(ctx, fi.installDir, fi.stem())
+ installedPath = ctx.InstallFile(apexDir.Join(ctx, fi.installDir), fi.stem(), fi.builtFile)
}
}
@@ -985,9 +1045,9 @@
a.SkipInstall()
}
+ installDeps := slices.Concat(a.compatSymlinks, a.extraInstalledFiles)
// Install to $OUT/soong/{target,host}/.../apex.
- a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile,
- a.compatSymlinks...)
+ a.installedFile = ctx.InstallFile(a.installDir, a.Name()+installSuffix, a.outputFile, installDeps...)
// installed-files.txt is dist'ed
a.installedFilesFile = a.buildInstalledFilesFile(ctx, a.outputFile, imageDir)
diff --git a/apex/classpath_element_test.go b/apex/classpath_element_test.go
index f367174..55f1475 100644
--- a/apex/classpath_element_test.go
+++ b/apex/classpath_element_test.go
@@ -198,11 +198,11 @@
result := preparer.RunTest(t)
- artFragment := result.Module("art-bootclasspath-fragment", "android_common_apex10000")
+ artFragment := result.Module("art-bootclasspath-fragment", "android_common_com.android.art")
artBaz := result.Module("baz", "android_common_apex10000")
artQuuz := result.Module("quuz", "android_common_apex10000")
- myFragment := result.Module("mybootclasspath-fragment", "android_common_apex10000")
+ myFragment := result.Module("mybootclasspath-fragment", "android_common_myapex")
myBar := result.Module("bar", "android_common_apex10000")
other := result.Module("othersdklibrary", "android_common_apex10000")
diff --git a/apex/dexpreopt_bootjars_test.go b/apex/dexpreopt_bootjars_test.go
index b51bb36..6fa1fe2 100644
--- a/apex/dexpreopt_bootjars_test.go
+++ b/apex/dexpreopt_bootjars_test.go
@@ -176,7 +176,7 @@
"out/soong/dexpreopt_arm64/dex_bootjars_input/foo.jar",
"out/soong/dexpreopt_arm64/dex_bootjars_input/bar.jar",
"out/soong/dexpreopt_arm64/dex_bootjars_input/baz.jar",
- "out/soong/.intermediates/art-bootclasspath-fragment/android_common_apex10000/art-bootclasspath-fragment/boot.prof",
+ "out/soong/.intermediates/art-bootclasspath-fragment/android_common_com.android.art/art-bootclasspath-fragment/boot.prof",
"out/soong/.intermediates/default/java/dex_bootjars/android_common/boot/boot.prof",
"out/soong/dexpreopt/uffd_gc_flag.txt",
}
@@ -396,7 +396,7 @@
{
desc: "Source apex com.android.art is selected, profile should come from source java library",
selectedArtApexContributions: "art.source.contributions",
- expectedProfile: "out/soong/.intermediates/art-bootclasspath-fragment/android_common_apex10000/art-bootclasspath-fragment/boot.prof",
+ expectedProfile: "out/soong/.intermediates/art-bootclasspath-fragment/android_common_com.android.art/art-bootclasspath-fragment/boot.prof",
},
{
desc: "Prebuilt apex prebuilt_com.android.art is selected, profile should come from .prof deapexed from the prebuilt",
diff --git a/apex/platform_bootclasspath_test.go b/apex/platform_bootclasspath_test.go
index c13d599..8b5fce9 100644
--- a/apex/platform_bootclasspath_test.go
+++ b/apex/platform_bootclasspath_test.go
@@ -165,12 +165,12 @@
android.AssertPathsRelativeToTopEquals(t, message, expected, info.FlagsFilesByCategory[category])
}
- android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
- android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
- android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/index.csv"}, info.IndexPaths)
+ android.AssertPathsRelativeToTopEquals(t, "annotation flags", []string{"out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/annotation-flags.csv"}, info.AnnotationFlagsPaths)
+ android.AssertPathsRelativeToTopEquals(t, "metadata flags", []string{"out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/metadata.csv"}, info.MetadataPaths)
+ android.AssertPathsRelativeToTopEquals(t, "index flags", []string{"out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/index.csv"}, info.IndexPaths)
- android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
- android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_apex30/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "stub flags", []string{"out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/filtered-stub-flags.csv:out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.StubFlagSubsets.RelativeToTop())
+ android.AssertArrayString(t, "all flags", []string{"out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/filtered-flags.csv:out/soong/.intermediates/bar-fragment/android_common_myapex/modular-hiddenapi/signature-patterns.csv"}, info.FlagSubsets.RelativeToTop())
}
// TestPlatformBootclasspath_LegacyPrebuiltFragment verifies that the
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index aaf2cb7..4fa43ba 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -15,6 +15,7 @@
package apex
import (
+ "slices"
"strconv"
"strings"
@@ -59,10 +60,12 @@
// Properties common to both prebuilt_apex and apex_set.
prebuiltCommonProperties *PrebuiltCommonProperties
- installDir android.InstallPath
- installFilename string
- installedFile android.InstallPath
- outputApex android.WritablePath
+ installDir android.InstallPath
+ installFilename string
+ installedFile android.InstallPath
+ extraInstalledFiles android.InstallPaths
+ extraInstalledPairs installPairs
+ outputApex android.WritablePath
// fragment for this apex for apexkeys.txt
apexKeysPath android.WritablePath
@@ -70,8 +73,12 @@
// Installed locations of symlinks for backward compatibility.
compatSymlinks android.InstallPaths
- hostRequired []string
- requiredModuleNames []string
+ // systemServerDexpreoptInstalls stores the list of dexpreopt artifacts for a system server jar.
+ systemServerDexpreoptInstalls []java.DexpreopterInstall
+
+ // systemServerDexJars stores the list of dexjars for system server jars in the prebuilt for use when
+ // dexpreopting system server jars that are later in the system server classpath.
+ systemServerDexJars android.Paths
}
type sanitizedPrebuilt interface {
@@ -188,9 +195,8 @@
// initApexFilesForAndroidMk initializes the prebuiltCommon.requiredModuleNames field with the install only deps of the prebuilt apex
func (p *prebuiltCommon) initApexFilesForAndroidMk(ctx android.ModuleContext) {
// If this apex contains a system server jar, then the dexpreopt artifacts should be added as required
- for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
- p.requiredModuleNames = append(p.requiredModuleNames, install.FullModuleName())
- }
+ p.systemServerDexpreoptInstalls = append(p.systemServerDexpreoptInstalls, p.Dexpreopter.ApexSystemServerDexpreoptInstalls()...)
+ p.systemServerDexJars = append(p.systemServerDexJars, p.Dexpreopter.ApexSystemServerDexJars()...)
}
// If this prebuilt has system server jar, create the rules to dexpreopt it and install it alongside the prebuilt apex
@@ -218,38 +224,58 @@
}
}
-func (p *prebuiltCommon) addRequiredModules(entries *android.AndroidMkEntries) {
- entries.AddStrings("LOCAL_REQUIRED_MODULES", p.requiredModuleNames...)
+// installApexSystemServerFiles installs dexpreopt files for system server classpath entries
+// provided by the apex. They are installed here instead of in library module because there may be multiple
+// variants of the library, generally one for the "main" apex and another with a different min_sdk_version
+// for the Android Go version of the apex. Both variants would attempt to install to the same locations,
+// and the library variants cannot determine which one should. The apex module is better equipped to determine
+// if it is "selected".
+// This assumes that the jars produced by different min_sdk_version values are identical, which is currently
+// true but may not be true if the min_sdk_version difference between the variants spans version that changed
+// the dex format.
+func (p *prebuiltCommon) installApexSystemServerFiles(ctx android.ModuleContext) {
+ performInstalls := android.IsModulePreferred(ctx.Module())
+
+ for _, install := range p.systemServerDexpreoptInstalls {
+ var installedFile android.InstallPath
+ if performInstalls {
+ installedFile = ctx.InstallFile(install.InstallDirOnDevice, install.InstallFileOnDevice, install.OutputPathOnHost)
+ } else {
+ installedFile = install.InstallDirOnDevice.Join(ctx, install.InstallFileOnDevice)
+ }
+ p.extraInstalledFiles = append(p.extraInstalledFiles, installedFile)
+ p.extraInstalledPairs = append(p.extraInstalledPairs, installPair{install.OutputPathOnHost, installedFile})
+ }
+
+ for _, dexJar := range p.systemServerDexJars {
+ // Copy the system server dex jar to a predefined location where dex2oat will find it.
+ android.CopyFileRule(ctx, dexJar,
+ android.PathForOutput(ctx, dexpreopt.SystemServerDexjarsDir, dexJar.Base()))
+ }
}
func (p *prebuiltCommon) AndroidMkEntries() []android.AndroidMkEntries {
entriesList := []android.AndroidMkEntries{
{
- Class: "ETC",
- OutputFile: android.OptionalPathForPath(p.outputApex),
- Include: "$(BUILD_PREBUILT)",
- Host_required: p.hostRequired,
+ Class: "ETC",
+ OutputFile: android.OptionalPathForPath(p.outputApex),
+ Include: "$(BUILD_PREBUILT)",
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
entries.SetString("LOCAL_MODULE_PATH", p.installDir.String())
entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
entries.SetPath("LOCAL_SOONG_INSTALLED_MODULE", p.installedFile)
- entries.SetString("LOCAL_SOONG_INSTALL_PAIRS", p.outputApex.String()+":"+p.installedFile.String())
+ installPairs := append(installPairs{{p.outputApex, p.installedFile}}, p.extraInstalledPairs...)
+ entries.SetString("LOCAL_SOONG_INSTALL_PAIRS", installPairs.String())
entries.AddStrings("LOCAL_SOONG_INSTALL_SYMLINKS", p.compatSymlinks.Strings()...)
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.prebuiltCommonProperties.Overrides...)
entries.SetString("LOCAL_APEX_KEY_PATH", p.apexKeysPath.String())
- p.addRequiredModules(entries)
},
},
},
}
- // Add the dexpreopt artifacts to androidmk
- for _, install := range p.Dexpreopter.DexpreoptBuiltInstalledForApex() {
- entriesList = append(entriesList, install.ToMakeEntries())
- }
-
return entriesList
}
@@ -679,7 +705,9 @@
}
if p.installable() {
- p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, p.compatSymlinks...)
+ p.installApexSystemServerFiles(ctx)
+ installDeps := slices.Concat(p.compatSymlinks, p.extraInstalledFiles)
+ p.installedFile = ctx.InstallFile(p.installDir, p.installFilename, p.inputApex, installDeps...)
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
@@ -690,16 +718,6 @@
return p.provenanceMetaDataFile
}
-// prebuiltApexExtractorModule is a private module type that is only created by the prebuilt_apex
-// module. It extracts the correct apex to use and makes it available for use by apex_set.
-type prebuiltApexExtractorModule struct {
- android.ModuleBase
-
- properties ApexExtractorProperties
-
- extractedApex android.WritablePath
-}
-
// extract registers the build actions to extract an apex from .apks file
// returns the path of the extracted apex
func extract(ctx android.ModuleContext, apexSet android.Path, prerelease *bool) android.Path {
@@ -866,7 +884,8 @@
a.installDir = android.PathForModuleInstall(ctx, "apex")
if a.installable() {
- a.installedFile = ctx.InstallFile(a.installDir, a.installFilename, a.outputApex)
+ a.installApexSystemServerFiles(ctx)
+ a.installedFile = ctx.InstallFile(a.installDir, a.installFilename, a.outputApex, a.extraInstalledFiles...)
}
// in case that apex_set replaces source apex (using prefer: prop)
@@ -878,11 +897,3 @@
ctx.SetOutputFiles(android.Paths{a.outputApex}, "")
}
-
-type systemExtContext struct {
- android.ModuleContext
-}
-
-func (*systemExtContext) SystemExtSpecific() bool {
- return true
-}
diff --git a/apex/systemserver_classpath_fragment_test.go b/apex/systemserver_classpath_fragment_test.go
index 7dbac5f..c643a8c 100644
--- a/apex/systemserver_classpath_fragment_test.go
+++ b/apex/systemserver_classpath_fragment_test.go
@@ -108,6 +108,7 @@
})
java.CheckModuleDependencies(t, ctx, "myapex", "android_common_myapex", []string{
+ `all_apex_contributions`,
`dex2oatd`,
`myapex.key`,
`mysystemserverclasspathfragment`,
@@ -166,6 +167,7 @@
})
java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex", []string{
+ `all_apex_contributions`,
`dex2oatd`,
`myapex.key`,
`mysystemserverclasspathfragment`,
diff --git a/bin/soongdbg b/bin/soongdbg
index 0807291..dad5137 100755
--- a/bin/soongdbg
+++ b/bin/soongdbg
@@ -450,13 +450,17 @@
def main():
+ global SOONG_DEBUG_DATA_FILENAME
parser = argparse.ArgumentParser()
+ parser.add_argument("-f", "--debug-file", nargs=1, help="location of the debug info file",
+ default=[SOONG_DEBUG_DATA_FILENAME])
subparsers = parser.add_subparsers(required=True, dest="command")
for name in sorted(COMMANDS.keys()):
command = COMMANDS[name]
subparser = subparsers.add_parser(name, help=command.help)
command.args(subparser)
args = parser.parse_args()
+ SOONG_DEBUG_DATA_FILENAME = args.debug_file[0]
COMMANDS[args.command].run(args)
sys.exit(0)
diff --git a/cc/builder.go b/cc/builder.go
index c94a674..16f006d 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -974,13 +974,18 @@
func transformDumpToLinkedDump(ctx android.ModuleContext, sAbiDumps android.Paths, soFile android.Path,
baseName string, exportedIncludeDirs []string, symbolFile android.OptionalPath,
excludedSymbolVersions, excludedSymbolTags, includedSymbolTags []string,
- api string) android.Path {
+ api string, commonGlobalIncludes bool) android.Path {
outputFile := android.PathForModuleOut(ctx, baseName+".lsdump")
implicits := android.Paths{soFile}
symbolFilterStr := "-so " + soFile.String()
exportedHeaderFlags := android.JoinWithPrefix(exportedIncludeDirs, "-I")
+ // If this library does not export any include directory, do not append the flags
+ // so that the ABI tool dumps everything without filtering by the include directories.
+ if commonGlobalIncludes && len(exportedIncludeDirs) > 0 {
+ exportedHeaderFlags += " ${config.CommonGlobalIncludes}"
+ }
if symbolFile.Valid() {
implicits = append(implicits, symbolFile.Path())
diff --git a/cc/cc.go b/cc/cc.go
index 0279928..dd557b5 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -66,19 +66,19 @@
type CompilerInfo struct {
Srcs android.Paths
// list of module-specific flags that will be used for C and C++ compiles.
- Cflags proptools.Configurable[[]string]
+ Cflags []string
AidlInterfaceInfo AidlInterfaceInfo
LibraryDecoratorInfo *LibraryDecoratorInfo
}
type LinkerInfo struct {
- WholeStaticLibs proptools.Configurable[[]string]
+ WholeStaticLibs []string
// list of modules that should be statically linked into this module.
- StaticLibs proptools.Configurable[[]string]
+ StaticLibs []string
// list of modules that should be dynamically linked into this module.
- SharedLibs proptools.Configurable[[]string]
+ SharedLibs []string
// list of modules that should only provide headers for this module.
- HeaderLibs proptools.Configurable[[]string]
+ HeaderLibs []string
ImplementationModuleName *string
BinaryDecoratorInfo *BinaryDecoratorInfo
@@ -91,7 +91,7 @@
type BinaryDecoratorInfo struct{}
type LibraryDecoratorInfo struct {
- ExportIncludeDirs proptools.Configurable[[]string]
+ ExportIncludeDirs []string
InjectBsslHash bool
}
@@ -839,6 +839,7 @@
reexportFlags bool
explicitlyVersioned bool
+ explicitlyImpl bool
dataLib bool
ndk bool
@@ -934,6 +935,11 @@
llndkHeaderLibTag = dependencyTag{name: "llndk_header_lib"}
)
+func IsExplicitImplSharedDepTag(depTag blueprint.DependencyTag) bool {
+ ccLibDepTag, ok := depTag.(libraryDependencyTag)
+ return ok && ccLibDepTag.shared() && ccLibDepTag.explicitlyImpl
+}
+
func IsSharedDepTag(depTag blueprint.DependencyTag) bool {
ccLibDepTag, ok := depTag.(libraryDependencyTag)
return ok && ccLibDepTag.shared()
@@ -2289,9 +2295,10 @@
HasLlndkStubs: c.HasLlndkStubs(),
}
if c.compiler != nil {
+ cflags := c.compiler.baseCompilerProps().Cflags
ccInfo.CompilerInfo = &CompilerInfo{
Srcs: c.compiler.(CompiledInterface).Srcs(),
- Cflags: c.compiler.baseCompilerProps().Cflags,
+ Cflags: cflags.GetOrDefault(ctx, nil),
AidlInterfaceInfo: AidlInterfaceInfo{
Sources: c.compiler.baseCompilerProps().AidlInterface.Sources,
AidlRoot: c.compiler.baseCompilerProps().AidlInterface.AidlRoot,
@@ -2302,16 +2309,17 @@
switch decorator := c.compiler.(type) {
case *libraryDecorator:
ccInfo.CompilerInfo.LibraryDecoratorInfo = &LibraryDecoratorInfo{
- ExportIncludeDirs: decorator.flagExporter.Properties.Export_include_dirs,
+ ExportIncludeDirs: decorator.flagExporter.Properties.Export_include_dirs.GetOrDefault(ctx, nil),
}
}
}
if c.linker != nil {
+ baseLinkerProps := c.linker.baseLinkerProps()
ccInfo.LinkerInfo = &LinkerInfo{
- WholeStaticLibs: c.linker.baseLinkerProps().Whole_static_libs,
- StaticLibs: c.linker.baseLinkerProps().Static_libs,
- SharedLibs: c.linker.baseLinkerProps().Shared_libs,
- HeaderLibs: c.linker.baseLinkerProps().Header_libs,
+ WholeStaticLibs: baseLinkerProps.Whole_static_libs.GetOrDefault(ctx, nil),
+ StaticLibs: baseLinkerProps.Static_libs.GetOrDefault(ctx, nil),
+ SharedLibs: baseLinkerProps.Shared_libs.GetOrDefault(ctx, nil),
+ HeaderLibs: baseLinkerProps.Header_libs.GetOrDefault(ctx, nil),
}
switch decorator := c.linker.(type) {
case *binaryDecorator:
@@ -2699,6 +2707,9 @@
variations = append(variations, blueprint.Variation{Mutator: "version", Variation: version})
if tag, ok := depTag.(libraryDependencyTag); ok {
tag.explicitlyVersioned = true
+ if version == "" {
+ tag.explicitlyImpl = true
+ }
// depTag is an interface that contains a concrete non-pointer struct. That makes the local
// tag variable a copy of the contents of depTag, and updating it doesn't change depTag. Reassign
// the modified copy to depTag.
@@ -4074,7 +4085,7 @@
func (c *Module) IncomingDepIsInSameApex(depTag blueprint.DependencyTag) bool {
if c.HasStubsVariants() {
- if IsSharedDepTag(depTag) {
+ if IsSharedDepTag(depTag) && !IsExplicitImplSharedDepTag(depTag) {
// dynamic dep to a stubs lib crosses APEX boundary
return false
}
diff --git a/cc/cmake_snapshot.go b/cc/cmake_snapshot.go
index 71fbcce..3f6a01d 100644
--- a/cc/cmake_snapshot.go
+++ b/cc/cmake_snapshot.go
@@ -204,24 +204,19 @@
return info.CompilerInfo.AidlInterfaceInfo
},
"getCflagsProperty": func(ctx android.ModuleContext, info *CcInfo) []string {
- prop := info.CompilerInfo.Cflags
- return prop.GetOrDefault(ctx, nil)
+ return info.CompilerInfo.Cflags
},
"getWholeStaticLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string {
- prop := info.LinkerInfo.WholeStaticLibs
- return prop.GetOrDefault(ctx, nil)
+ return info.LinkerInfo.WholeStaticLibs
},
"getStaticLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string {
- prop := info.LinkerInfo.StaticLibs
- return prop.GetOrDefault(ctx, nil)
+ return info.LinkerInfo.StaticLibs
},
"getSharedLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string {
- prop := info.LinkerInfo.SharedLibs
- return prop.GetOrDefault(ctx, nil)
+ return info.LinkerInfo.SharedLibs
},
"getHeaderLibsProperty": func(ctx android.ModuleContext, info *CcInfo) []string {
- prop := info.LinkerInfo.HeaderLibs
- return prop.GetOrDefault(ctx, nil)
+ return info.LinkerInfo.HeaderLibs
},
"getExtraLibs": getExtraLibs,
"getIncludeDirs": getIncludeDirs,
@@ -552,7 +547,7 @@
func getIncludeDirs(ctx android.ModuleContext, m android.ModuleProxy, info *CcInfo) []string {
moduleDir := ctx.OtherModuleDir(m) + string(filepath.Separator)
if info.CompilerInfo.LibraryDecoratorInfo != nil {
- return sliceWithPrefix(moduleDir, info.CompilerInfo.LibraryDecoratorInfo.ExportIncludeDirs.GetOrDefault(ctx, nil))
+ return sliceWithPrefix(moduleDir, info.CompilerInfo.LibraryDecoratorInfo.ExportIncludeDirs)
}
return nil
}
diff --git a/cc/compiler.go b/cc/compiler.go
index 3730bbe..949603e 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -324,6 +324,10 @@
getNamedMapForConfig(ctx.Config(), key).Store(module, true)
}
+func requiresGlobalIncludes(ctx ModuleContext) bool {
+ return !(ctx.useSdk() || ctx.InVendorOrProduct()) || ctx.Host()
+}
+
func useGnuExtensions(gnuExtensions *bool) bool {
return proptools.BoolDefault(gnuExtensions, true)
}
@@ -452,7 +456,7 @@
flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+modulePath)
}
- if !(ctx.useSdk() || ctx.InVendorOrProduct()) || ctx.Host() {
+ if requiresGlobalIncludes(ctx) {
flags.SystemIncludeFlags = append(flags.SystemIncludeFlags,
"${config.CommonGlobalIncludes}",
tc.IncludeFlags())
diff --git a/cc/config/global.go b/cc/config/global.go
index 4407967..7bea124 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -382,8 +382,8 @@
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
- ClangDefaultVersion = "clang-r536225"
- ClangDefaultShortVersion = "19"
+ ClangDefaultVersion = "clang-r547379"
+ ClangDefaultShortVersion = "20"
// Directories with warnings from Android.bp files.
WarningAllowedProjects = []string{
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 287967c..c070050 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -41,7 +41,6 @@
}
linuxMuslCflags = []string{
- "-D_LIBCPP_HAS_MUSL_LIBC",
"-DANDROID_HOST_MUSL",
"-nostdlibinc",
"--sysroot /dev/null",
diff --git a/cc/coverage.go b/cc/coverage.go
index c8ff82b..757641c 100644
--- a/cc/coverage.go
+++ b/cc/coverage.go
@@ -273,8 +273,6 @@
type coverageTransitionMutator struct{}
-var _ android.TransitionMutator = (*coverageTransitionMutator)(nil)
-
func (c coverageTransitionMutator) Split(ctx android.BaseModuleContext) []string {
if c, ok := ctx.Module().(*Module); ok && c.coverage != nil {
if c.coverage.Properties.NeedCoverageVariant {
diff --git a/cc/installer.go b/cc/installer.go
index 30f9612..d7d8c6d 100644
--- a/cc/installer.go
+++ b/cc/installer.go
@@ -107,6 +107,10 @@
installer.installDeps = append(installer.installDeps, installedData...)
}
+func (installer *baseInstaller) installStandaloneTestDep(ctx ModuleContext, standaloneTestDep android.PackagingSpec) {
+ installer.installTestData(ctx, []android.DataPath{{SrcPath: standaloneTestDep.ToGob().SrcPath, RelativeInstallPath: "standalone-libs"}})
+}
+
func (installer *baseInstaller) everInstallable() bool {
// Most cc modules are installable.
return true
diff --git a/cc/library.go b/cc/library.go
index 950ea91..789190c 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -630,10 +630,17 @@
}
if library.sabi.shouldCreateSourceAbiDump() {
dirs := library.exportedIncludeDirsForAbiCheck(ctx)
- flags.SAbiFlags = make([]string, 0, len(dirs))
+ flags.SAbiFlags = make([]string, 0, len(dirs)+1)
for _, dir := range dirs {
flags.SAbiFlags = append(flags.SAbiFlags, "-I"+dir)
}
+ // If this library does not export any include directory, do not append the flags
+ // so that the ABI tool dumps everything without filtering by the include directories.
+ // requiresGlobalIncludes returns whether this library can include CommonGlobalIncludes.
+ // If the library cannot include them, it cannot export them.
+ if len(dirs) > 0 && requiresGlobalIncludes(ctx) {
+ flags.SAbiFlags = append(flags.SAbiFlags, "${config.CommonGlobalIncludes}")
+ }
totalLength := len(srcs) + len(deps.GeneratedSources) +
len(sharedSrcs) + len(staticSrcs)
if totalLength > 0 {
@@ -1362,13 +1369,15 @@
deps PathDeps, sAbiDumpFiles android.Paths, soFile android.Path, libFileName string,
excludeSymbolVersions, excludeSymbolTags []string,
sdkVersionForVendorApiLevel string) android.Path {
+ // Though LLNDK is implemented in system, the callers in vendor cannot include CommonGlobalIncludes,
+ // so commonGlobalIncludes is false.
return transformDumpToLinkedDump(ctx,
sAbiDumpFiles, soFile, libFileName+".llndk",
library.llndkIncludeDirsForAbiCheck(ctx, deps),
android.OptionalPathForModuleSrc(ctx, library.Properties.Llndk.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"llndk"}, sdkVersionForVendorApiLevel)
+ []string{"llndk"}, sdkVersionForVendorApiLevel, false /* commonGlobalIncludes */)
}
func (library *libraryDecorator) linkApexSAbiDumpFiles(ctx ModuleContext,
@@ -1381,7 +1390,7 @@
android.OptionalPathForModuleSrc(ctx, library.Properties.Stubs.Symbol_file),
append([]string{"*_PLATFORM", "*_PRIVATE"}, excludeSymbolVersions...),
append([]string{"platform-only"}, excludeSymbolTags...),
- []string{"apex", "systemapi"}, sdkVersion)
+ []string{"apex", "systemapi"}, sdkVersion, requiresGlobalIncludes(ctx))
}
func getRefAbiDumpFile(ctx android.ModuleInstallPathContext,
@@ -1524,7 +1533,7 @@
android.OptionalPathForModuleSrc(ctx, library.symbolFileForAbiCheck(ctx)),
headerAbiChecker.Exclude_symbol_versions,
headerAbiChecker.Exclude_symbol_tags,
- []string{} /* includeSymbolTags */, currSdkVersion)
+ []string{} /* includeSymbolTags */, currSdkVersion, requiresGlobalIncludes(ctx))
var llndkDump, apexVariantDump android.Path
tags := classifySourceAbiDump(ctx.Module().(*Module))
diff --git a/cc/makevars.go b/cc/makevars.go
index ca97b76..c945102 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -175,16 +175,18 @@
sort.Strings(ndkKnownLibs)
ctx.Strict("NDK_KNOWN_LIBS", strings.Join(ndkKnownLibs, " "))
- hostTargets := ctx.Config().Targets[ctx.Config().BuildOS]
- makeVarsToolchain(ctx, "", hostTargets[0])
- if len(hostTargets) > 1 {
- makeVarsToolchain(ctx, "2ND_", hostTargets[1])
+ if hostTargets := ctx.Config().Targets[ctx.Config().BuildOS]; len(hostTargets) > 0 {
+ makeVarsToolchain(ctx, "", hostTargets[0])
+ if len(hostTargets) > 1 {
+ makeVarsToolchain(ctx, "2ND_", hostTargets[1])
+ }
}
- deviceTargets := ctx.Config().Targets[android.Android]
- makeVarsToolchain(ctx, "", deviceTargets[0])
- if len(deviceTargets) > 1 {
- makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
+ if deviceTargets := ctx.Config().Targets[android.Android]; len(deviceTargets) > 0 {
+ makeVarsToolchain(ctx, "", deviceTargets[0])
+ if len(deviceTargets) > 1 {
+ makeVarsToolchain(ctx, "2ND_", deviceTargets[1])
+ }
}
}
diff --git a/cc/strip.go b/cc/strip.go
index 36c0c48..a950df8 100644
--- a/cc/strip.go
+++ b/cc/strip.go
@@ -23,10 +23,8 @@
// StripProperties defines the type of stripping applied to the module.
type StripProperties struct {
Strip struct {
- // none forces all stripping to be disabled.
- // Device modules default to stripping enabled leaving mini debuginfo.
- // Host modules default to stripping disabled, but can be enabled by setting any other
- // strip boolean property.
+ // Device and host modules default to stripping enabled leaving mini debuginfo.
+ // This can be disabled by setting none to true.
None *bool `android:"arch_variant"`
// all forces stripping everything, including the mini debug info.
diff --git a/cc/test.go b/cc/test.go
index dad4afa..9f86c7a 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -18,6 +18,7 @@
"path/filepath"
"strconv"
+ "github.com/google/blueprint/depset"
"github.com/google/blueprint/proptools"
"android/soong/android"
@@ -128,6 +129,13 @@
// Install the test into a folder named for the module in all test suites.
Per_testcase_directory *bool
+
+ // Install the test's dependencies into a folder named standalone-libs relative to the
+ // test's installation path. ld-library-path will be set to this path in the test's
+ // auto-generated config. This way the dependencies can be used by the test without having
+ // to manually install them to the device. See more details in
+ // go/standalone-native-device-tests.
+ Standalone_test *bool
}
func init() {
@@ -380,6 +388,7 @@
TestInstallBase: testInstallBase,
DeviceTemplate: "${NativeTestConfigTemplate}",
HostTemplate: "${NativeHostTestConfigTemplate}",
+ StandaloneTest: test.Properties.Standalone_test,
})
test.extraTestConfigs = android.PathsForModuleSrc(ctx, test.Properties.Test_options.Extra_test_configs)
@@ -421,6 +430,21 @@
test.binaryDecorator.baseInstaller.installTestData(ctx, test.data)
test.binaryDecorator.baseInstaller.install(ctx, file)
+ if Bool(test.Properties.Standalone_test) {
+ packagingSpecsBuilder := depset.NewBuilder[android.PackagingSpec](depset.TOPOLOGICAL)
+
+ ctx.VisitDirectDeps(func(dep android.Module) {
+ deps := android.OtherModuleProviderOrDefault(ctx, dep, android.InstallFilesProvider)
+ packagingSpecsBuilder.Transitive(deps.TransitivePackagingSpecs)
+ })
+
+ for _, standaloneTestDep := range packagingSpecsBuilder.Build().ToList() {
+ if standaloneTestDep.ToGob().SrcPath == nil {
+ continue
+ }
+ test.binaryDecorator.baseInstaller.installStandaloneTestDep(ctx, standaloneTestDep)
+ }
+ }
}
func getTestInstallBase(useVendor bool) string {
diff --git a/cc/testing.go b/cc/testing.go
index 14a6b7a..c9d362d 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -193,7 +193,7 @@
},
apex_available: [
"//apex_available:platform",
- "myapex"
+ "//apex_available:anyapex",
],
llndk: {
symbol_file: "libm.map.txt",
@@ -253,7 +253,7 @@
},
apex_available: [
"//apex_available:platform",
- "myapex"
+ "//apex_available:anyapex",
],
llndk: {
symbol_file: "libdl.map.txt",
diff --git a/compliance/Android.bp b/compliance/Android.bp
index a1f2015..25f6f86 100644
--- a/compliance/Android.bp
+++ b/compliance/Android.bp
@@ -37,3 +37,38 @@
"//visibility:any_system_partition",
],
}
+
+notice_xml {
+ name: "notice_xml_system_ext",
+ partition_name: "system_ext",
+}
+
+notice_xml {
+ name: "notice_xml_system_dlkm",
+ partition_name: "system_dlkm",
+}
+
+notice_xml {
+ name: "notice_xml_product",
+ partition_name: "product",
+}
+
+notice_xml {
+ name: "notice_xml_odm",
+ partition_name: "odm",
+}
+
+notice_xml {
+ name: "notice_xml_odm_dlkm",
+ partition_name: "odm_dlkm",
+}
+
+notice_xml {
+ name: "notice_xml_vendor",
+ partition_name: "vendor",
+}
+
+notice_xml {
+ name: "notice_xml_vendor_dlkm",
+ partition_name: "vendor_dlkm",
+}
diff --git a/compliance/notice.go b/compliance/notice.go
index edd1b34..c5b0fbe 100644
--- a/compliance/notice.go
+++ b/compliance/notice.go
@@ -71,12 +71,17 @@
}
func (nx *NoticeXmlModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ prodVars := ctx.Config().ProductVariables()
+ buildFingerprintFile := android.PathForArbitraryOutput(ctx, "target", "product", android.String(prodVars.DeviceName), "build_fingerprint.txt")
+ implicits := []android.Path{buildFingerprintFile}
+
output := android.PathForModuleOut(ctx, "NOTICE.xml.gz")
metadataDb := android.PathForOutput(ctx, "compliance-metadata", ctx.Config().DeviceProduct(), "compliance-metadata.db")
ctx.Build(pctx, android.BuildParams{
- Rule: genNoticeXmlRule,
- Input: metadataDb,
- Output: output,
+ Rule: genNoticeXmlRule,
+ Input: metadataDb,
+ Implicits: implicits,
+ Output: output,
Args: map[string]string{
"productOut": filepath.Join(ctx.Config().OutDir(), "target", "product", ctx.Config().DeviceName()),
"soongOut": ctx.Config().SoongOutDir(),
@@ -86,8 +91,10 @@
nx.outputFile = output.OutputPath
- installPath := android.PathForModuleInPartitionInstall(ctx, nx.props.Partition_name, "etc")
- ctx.PackageFile(installPath, "NOTICE.xml.gz", nx.outputFile)
+ if android.Bool(ctx.Config().ProductVariables().UseSoongNoticeXML) {
+ installPath := android.PathForModuleInPartitionInstall(ctx, nx.props.Partition_name, "etc")
+ ctx.InstallFile(installPath, "NOTICE.xml.gz", nx.outputFile)
+ }
}
func (nx *NoticeXmlModule) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go
index 7a39fa1..e882470 100644
--- a/dexpreopt/dexpreopt.go
+++ b/dexpreopt/dexpreopt.go
@@ -46,13 +46,14 @@
const SystemPartition = "/system/"
const SystemOtherPartition = "/system_other/"
+const SystemServerDexjarsDir = "system_server_dexjars"
var DexpreoptRunningInSoong = false
// GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a
// ModuleConfig. The produced files and their install locations will be available through rule.Installs().
func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongConfig,
- global *GlobalConfig, module *ModuleConfig, productPackages android.Path, copyApexSystemServerJarDex bool) (
+ global *GlobalConfig, module *ModuleConfig, productPackages android.Path) (
rule *android.RuleBuilder, err error) {
defer func() {
@@ -83,7 +84,7 @@
if !dexpreoptDisabled(ctx, global, module) {
if valid, err := validateClassLoaderContext(module.ClassLoaderContexts); err != nil {
- android.ReportPathErrorf(ctx, err.Error())
+ android.ReportPathErrorf(ctx, "%s", err.Error())
} else if valid {
fixClassLoaderContext(module.ClassLoaderContexts)
@@ -94,7 +95,7 @@
for archIdx, _ := range module.Archs {
dexpreoptCommand(ctx, globalSoong, global, module, rule, archIdx, profile, appImage,
- generateDM, productPackages, copyApexSystemServerJarDex)
+ generateDM, productPackages)
}
}
}
@@ -231,7 +232,7 @@
func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig,
global *GlobalConfig, module *ModuleConfig, rule *android.RuleBuilder, archIdx int,
- profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path, copyApexSystemServerJarDex bool) {
+ profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path) {
arch := module.Archs[archIdx]
@@ -279,19 +280,6 @@
clcTarget = append(clcTarget, GetSystemServerDexLocation(ctx, global, lib))
}
- if DexpreoptRunningInSoong && copyApexSystemServerJarDex {
- // Copy the system server jar to a predefined location where dex2oat will find it.
- dexPathHost := SystemServerDexJarHostPath(ctx, module.Name)
- rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String()))
- rule.Command().Text("cp -f").Input(module.DexPath).Output(dexPathHost)
- } else {
- // For Make modules the copy rule is generated in the makefiles, not in dexpreopt.sh.
- // This is necessary to expose the rule to Ninja, otherwise it has rules that depend on
- // the jar (namely, dexpreopt commands for all subsequent system server jars that have
- // this one in their class loader context), but no rule that creates it (because Ninja
- // cannot see the rule in the generated dexpreopt.sh script).
- }
-
clcHostString := "PCL[" + strings.Join(clcHost.Strings(), ":") + "]"
clcTargetString := "PCL[" + strings.Join(clcTarget, ":") + "]"
@@ -581,11 +569,11 @@
func SystemServerDexJarHostPath(ctx android.PathContext, jar string) android.OutputPath {
if DexpreoptRunningInSoong {
// Soong module, just use the default output directory $OUT/soong.
- return android.PathForOutput(ctx, "system_server_dexjars", jar+".jar")
+ return android.PathForOutput(ctx, SystemServerDexjarsDir, jar+".jar")
} else {
// Make module, default output directory is $OUT (passed via the "null config" created
// by dexpreopt_gen). Append Soong subdirectory to match Soong module paths.
- return android.PathForOutput(ctx, "soong", "system_server_dexjars", jar+".jar")
+ return android.PathForOutput(ctx, "soong", SystemServerDexjarsDir, jar+".jar")
}
}
diff --git a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
index 7512005..8033b48 100644
--- a/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
+++ b/dexpreopt/dexpreopt_gen/dexpreopt_gen.go
@@ -205,9 +205,8 @@
panic(err)
}
}
- cpApexSscpServerJar := false // dexpreopt_gen operates on make modules, and since sscp libraries are in soong, this should be a noop
dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(
- ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath), cpApexSscpServerJar)
+ ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath))
if err != nil {
panic(err)
}
diff --git a/dexpreopt/dexpreopt_test.go b/dexpreopt/dexpreopt_test.go
index 1f188d5..f9b8880 100644
--- a/dexpreopt/dexpreopt_test.go
+++ b/dexpreopt/dexpreopt_test.go
@@ -104,7 +104,7 @@
module := testSystemModuleConfig(ctx, "test")
productPackages := android.PathForTesting("product_packages.txt")
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -164,7 +164,7 @@
for _, test := range tests {
global.PatternsOnSystemOther = test.patterns
for _, mt := range test.moduleTests {
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -199,7 +199,7 @@
global.ApexSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"com.android.apex1:service-A"})
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -211,15 +211,6 @@
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
- android.AssertStringListContains(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar")
-
- // rule with apex sscp cp as false
- rule, err = GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, false)
- if err != nil {
- t.Fatal(err)
- }
- android.AssertStringListDoesNotContain(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar")
-
// cleanup the global variable for test
DexpreoptRunningInSoong = oldDexpreoptRunningInSoong
}
@@ -242,7 +233,7 @@
global.ApexSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"com.android.apex1:service-A"})
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -254,15 +245,6 @@
android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String())
- android.AssertStringListContains(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar")
-
- // rule with apex sscp cp as false
- rule, err = GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, false)
- if err != nil {
- t.Fatal(err)
- }
- android.AssertStringListDoesNotContain(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar")
-
// cleanup the global variable for test
DexpreoptRunningInSoong = oldDexpreoptRunningInSoong
}
@@ -278,7 +260,7 @@
global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"platform:service-A"})
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -302,7 +284,7 @@
global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"system_ext:service-A"})
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -326,7 +308,7 @@
global.ApexStandaloneSystemServerJars = android.CreateTestConfiguredJarList(
[]string{"com.android.apex1:service-A"})
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
@@ -349,7 +331,7 @@
module.ProfileClassListing = android.OptionalPathForPath(android.PathForTesting("profile"))
- rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true)
+ rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages)
if err != nil {
t.Fatal(err)
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 2bcbde1..bf54c09 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -499,9 +499,21 @@
ip.addInstallRules(ctx)
}
+ p.updateModuleInfoJSON(ctx)
+
ctx.SetOutputFiles(p.outputFilePaths.Paths(), "")
}
+func (p *PrebuiltEtc) updateModuleInfoJSON(ctx android.ModuleContext) {
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ moduleInfoJSON.Class = []string{"ETC"}
+ if p.makeClass != "" {
+ moduleInfoJSON.Class = []string{p.makeClass}
+ }
+ moduleInfoJSON.SystemSharedLibs = []string{"none"}
+ moduleInfoJSON.Tags = []string{"optional"}
+}
+
type installProperties struct {
filename string
sourceFilePath android.Path
diff --git a/filesystem/aconfig_files.go b/filesystem/aconfig_files.go
index 9a3ca54..6d03402 100644
--- a/filesystem/aconfig_files.go
+++ b/filesystem/aconfig_files.go
@@ -34,7 +34,13 @@
var importAconfigDependencyTag = interPartitionDepTag{}
-func (f *filesystem) buildAconfigFlagsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, dir android.OutputPath) {
+func (f *filesystem) buildAconfigFlagsFiles(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ specs map[string]android.PackagingSpec,
+ dir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
var caches []android.Path
for _, ps := range specs {
caches = append(caches, ps.GetAconfigPaths()...)
@@ -70,6 +76,10 @@
for _, cache := range caches {
cmd.FlagWithInput("--cache ", cache)
}
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig_flags.pb"),
+ SourcePath: installAconfigFlagsPath,
+ })
f.appendToEntry(ctx, installAconfigFlagsPath)
installAconfigStorageDir := dir.Join(ctx, "etc", "aconfig")
@@ -90,6 +100,10 @@
FlagWithOutput("--out ", outputPath).
FlagWithArg("--cache ", installAconfigFlagsPath.String()).
FlagWithArg("--version ", strconv.Itoa(storageFilesVersion))
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc/aconfig", fileName),
+ SourcePath: outputPath,
+ })
f.appendToEntry(ctx, outputPath)
}
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 3e2f61f..6c04828 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -210,7 +210,7 @@
// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/main.mk;l=1396;drc=6595459cdd8164a6008335f6372c9f97b9094060
ctx.Phony("droidcore-unbundled", allImagesStamp)
- validations = append(validations, a.copyFilesToProductOutForSoongOnly(ctx))
+ deps = append(deps, a.copyFilesToProductOutForSoongOnly(ctx))
}
ctx.Build(pctx, android.BuildParams{
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index a6177e3..6ac89ad 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -16,7 +16,6 @@
import (
"android/soong/android"
- "fmt"
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -36,19 +35,8 @@
func (a *androidDevice) copyFilesToProductOutForSoongOnly(ctx android.ModuleContext) android.Path {
filesystemInfos := a.getFsInfos(ctx)
- // The current logic to copy the staging directories to PRODUCT_OUT isn't very sound.
- // We only track dependencies on the image file, so if the image file wasn't changed, the
- // staging directory won't be re-copied. If you do an installclean, it would remove the copied
- // staging directories but not affect the intermediates path image file, so the next build
- // wouldn't re-copy them. As a hack, create a presence detector that would be deleted on
- // an installclean to use as a dep for the staging dir copies.
- productOutPresenceDetector := android.PathForModuleInPartitionInstall(ctx, "", "product_out_presence_detector.txt")
- ctx.Build(pctx, android.BuildParams{
- Rule: android.Touch,
- Output: productOutPresenceDetector,
- })
-
var deps android.Paths
+ var depsNoImg android.Paths // subset of deps without any img files. used for sbom creation.
for _, partition := range android.SortedKeys(filesystemInfos) {
info := filesystemInfos[partition]
@@ -58,32 +46,58 @@
Input: info.Output,
Output: imgInstallPath,
})
- dirStamp := android.PathForModuleOut(ctx, partition+"_staging_dir_copy_stamp.txt")
- dirInstallPath := android.PathForModuleInPartitionInstall(ctx, "", partition)
- ctx.Build(pctx, android.BuildParams{
- Rule: copyStagingDirRule,
- Output: dirStamp,
- Implicits: []android.Path{
- info.Output,
- productOutPresenceDetector,
- },
- Args: map[string]string{
- "dir": info.RebasedDir.String(),
- "dest": dirInstallPath.String(),
- },
- })
// Make it so doing `m <moduleName>` or `m <partitionType>image` will copy the files to
// PRODUCT_OUT
- ctx.Phony(info.ModuleName, dirStamp, imgInstallPath)
if partition == "system_ext" {
partition = "systemext"
}
- ctx.Phony(fmt.Sprintf("%simage", partition), dirStamp, imgInstallPath)
+ partition = partition + "image"
+ ctx.Phony(info.ModuleName, imgInstallPath)
+ ctx.Phony(partition, imgInstallPath)
+ for _, fip := range info.FullInstallPaths {
+ // TODO: Directories. But maybe they're not necessary? Adevice doesn't care
+ // about empty directories, still need to check if adb sync does.
+ if !fip.IsDir {
+ if !fip.RequiresFullInstall {
+ // Some modules set requires_full_install: false, which causes their staging
+ // directory file to not be installed. This is usually because the file appears
+ // in both PRODUCT_COPY_FILES and a soong module for the handwritten soong system
+ // image. In this case, that module's installed files would conflict with the
+ // PRODUCT_COPY_FILES. However, in soong-only builds, we don't automatically
+ // create rules for PRODUCT_COPY_FILES unless they're needed in the partition.
+ // So in that case, nothing is creating the installed path. Create them now
+ // if that's the case.
+ if fip.SymlinkTarget == "" {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cp,
+ Input: fip.SourcePath,
+ Output: fip.FullInstallPath,
+ })
+ } else {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.SymlinkWithBash,
+ Output: fip.FullInstallPath,
+ Args: map[string]string{
+ "fromPath": fip.SymlinkTarget,
+ },
+ })
+ }
+ }
+ ctx.Phony(info.ModuleName, fip.FullInstallPath)
+ ctx.Phony(partition, fip.FullInstallPath)
+ deps = append(deps, fip.FullInstallPath)
+ depsNoImg = append(depsNoImg, fip.FullInstallPath)
+ ctx.Phony("sync_"+partition, fip.FullInstallPath)
+ ctx.Phony("sync", fip.FullInstallPath)
+ }
+ }
- deps = append(deps, imgInstallPath, dirStamp)
+ deps = append(deps, imgInstallPath)
}
+ a.createComplianceMetadataTimestamp(ctx, depsNoImg)
+
// List all individual files to be copied to PRODUCT_OUT here
if a.deviceProps.Bootloader != nil {
bootloaderInstallPath := android.PathForModuleInPartitionInstall(ctx, "", "bootloader")
@@ -163,9 +177,31 @@
Implicits: deps,
})
+ emptyFile := android.PathForModuleOut(ctx, "empty_file")
+ android.WriteFileRule(ctx, emptyFile, "")
+
+ // TODO: We don't have these tests building in soong yet. Add phonies for them so that CI builds
+ // that try to build them don't error out.
+ ctx.Phony("continuous_instrumentation_tests", emptyFile)
+ ctx.Phony("continuous_native_tests", emptyFile)
+ ctx.Phony("device-tests", emptyFile)
+ ctx.Phony("device-platinum-tests", emptyFile)
+ ctx.Phony("platform_tests", emptyFile)
+
return copyToProductOutTimestamp
}
+// createComplianceMetadataTimestampForSoongOnly creates a timestamp file in m --soong-only
+// this timestamp file depends on installed files of the main `android_device`.
+// Any changes to installed files of the main `android_device` will retrigger SBOM generation
+func (a *androidDevice) createComplianceMetadataTimestamp(ctx android.ModuleContext, installedFiles android.Paths) {
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Touch,
+ Implicits: installedFiles,
+ Output: android.PathForOutput(ctx, "compliance-metadata", ctx.Config().DeviceProduct(), "installed_files.stamp"),
+ })
+}
+
// Returns a mapping from partition type -> FilesystemInfo. This includes filesystems that are
// nested inside of other partitions, such as the partitions inside super.img, or ramdisk inside
// of boot.
diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go
index 9d4ba3e..f32993c 100644
--- a/filesystem/avb_add_hash_footer.go
+++ b/filesystem/avb_add_hash_footer.go
@@ -46,7 +46,7 @@
type avbAddHashFooterProperties struct {
// Source file of this image. Can reference a genrule type module with the ":module" syntax.
- Src *string `android:"path,arch_variant"`
+ Src proptools.Configurable[string] `android:"path,arch_variant,replace_instead_of_append"`
// Set the name of the output. Defaults to <module_name>.img.
Filename *string
@@ -91,12 +91,13 @@
func (a *avbAddHashFooter) GenerateAndroidBuildActions(ctx android.ModuleContext) {
builder := android.NewRuleBuilder(pctx, ctx)
+ src := a.properties.Src.GetOrDefault(ctx, "")
- if a.properties.Src == nil {
+ if src == "" {
ctx.PropertyErrorf("src", "missing source file")
return
}
- input := android.PathForModuleSrc(ctx, proptools.String(a.properties.Src))
+ input := android.PathForModuleSrc(ctx, src)
output := android.PathForModuleOut(ctx, a.installFileName())
builder.Command().Text("cp").Input(input).Output(output)
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 815113e..0ce31b2 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -79,7 +79,7 @@
}
type filesystemBuilder interface {
- BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath)
+ BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath, fullInstallPaths *[]FullInstallPathInfo)
// Function that filters PackagingSpec in PackagingBase.GatherPackagingSpecs()
FilterPackagingSpec(spec android.PackagingSpec) bool
// Function that modifies PackagingSpec in PackagingBase.GatherPackagingSpecs() to customize.
@@ -119,7 +119,7 @@
Avb_algorithm *string
// Hash algorithm used for avbtool (for descriptors). This is passed as hash_algorithm to
- // avbtool. Default used by avbtool is sha1.
+ // avbtool. Default is sha256.
Avb_hash_algorithm *string
// The security patch passed to as the com.android.build.<type>.security_patch avb property.
@@ -389,6 +389,34 @@
BuildImagePropFileDeps android.Paths
// Packaging specs to be installed on the system_other image, for the initial boot's dexpreopt.
SpecsForSystemOther map[string]android.PackagingSpec
+
+ FullInstallPaths []FullInstallPathInfo
+}
+
+// FullInstallPathInfo contains information about the "full install" paths of all the files
+// inside this partition. The full install paths are the files installed in
+// out/target/product/<device>/<partition>. This is essentially legacy behavior, maintained for
+// tools like adb sync and adevice, but we should update them to query the build system for the
+// installed files no matter where they are.
+type FullInstallPathInfo struct {
+ // RequiresFullInstall tells us if the origional module did the install to FullInstallPath
+ // already. If it's false, the android_device module needs to emit the install rule.
+ RequiresFullInstall bool
+ // The "full install" paths for the files in this filesystem. This is the paths in the
+ // out/target/product/<device>/<partition> folder. They're not used by this filesystem,
+ // but can be depended on by the top-level android_device module to cause the staging
+ // directories to be built.
+ FullInstallPath android.InstallPath
+
+ // The file that's copied to FullInstallPath. May be nil if SymlinkTarget is set or IsDir is
+ // true.
+ SourcePath android.Path
+
+ // The target of the symlink, if this file is a symlink.
+ SymlinkTarget string
+
+ // If this file is a directory. Only used for empty directories, which are mostly mount points.
+ IsDir bool
}
var FilesystemProvider = blueprint.NewProvider[FilesystemInfo]()
@@ -441,6 +469,13 @@
if ps.SkipInstall() {
return false
}
+ // "apex" is a fake partition used to install files in out/target/product/<device>/apex/.
+ // Don't include these files in the partition. We should also look into removing the following
+ // TODO to check the PackagingSpec's partition against this filesystem's partition for all
+ // modules, not just autogenerated ones, which will fix this as well.
+ if ps.Partition() == "apex" {
+ return false
+ }
if proptools.Bool(f.properties.Is_auto_generated) { // TODO (spandandas): Remove this.
pt := f.PartitionType()
return ps.Partition() == pt || strings.HasPrefix(ps.Partition(), pt+"/")
@@ -485,13 +520,23 @@
// Wipe the root dir to get rid of leftover files from prior builds
builder.Command().Textf("rm -rf %s && mkdir -p %s", rootDir, rootDir)
specs := f.gatherFilteredPackagingSpecs(ctx)
- f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
- f.buildNonDepsFiles(ctx, builder, rootDir)
- f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir)
- f.buildEventLogtagsFile(ctx, builder, rebasedDir)
- f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir)
- f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir)
+ var fullInstallPaths []FullInstallPathInfo
+ for _, spec := range specs {
+ fullInstallPaths = append(fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: spec.FullInstallPath(),
+ RequiresFullInstall: spec.RequiresFullInstall(),
+ SourcePath: spec.SrcPath(),
+ SymlinkTarget: spec.ToGob().SymlinkTarget,
+ })
+ }
+
+ f.entries = f.copyPackagingSpecs(ctx, builder, specs, rootDir, rebasedDir)
+ f.buildNonDepsFiles(ctx, builder, rootDir, rebasedDir, &fullInstallPaths)
+ f.buildFsverityMetadataFiles(ctx, builder, specs, rootDir, rebasedDir, &fullInstallPaths)
+ f.buildEventLogtagsFile(ctx, builder, rebasedDir, &fullInstallPaths)
+ f.buildAconfigFlagsFiles(ctx, builder, specs, rebasedDir, &fullInstallPaths)
+ f.filesystemBuilder.BuildLinkerConfigFile(ctx, builder, rebasedDir, &fullInstallPaths)
var mapFile android.Path
var outputHermetic android.Path
@@ -531,6 +576,7 @@
BuildImagePropFile: buildImagePropFile,
BuildImagePropFileDeps: buildImagePropFileDeps,
SpecsForSystemOther: f.systemOtherFiles(ctx),
+ FullInstallPaths: fullInstallPaths,
}
android.SetProvider(ctx, FilesystemProvider, fsInfo)
@@ -645,11 +691,36 @@
// Copy extra files/dirs that are not from the `deps` property to `rootDir`, checking for conflicts with files
// already in `rootDir`.
-func (f *filesystem) buildNonDepsFiles(ctx android.ModuleContext, builder *android.RuleBuilder, rootDir android.OutputPath) {
+func (f *filesystem) buildNonDepsFiles(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rootDir android.OutputPath,
+ rebasedDir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
+ rebasedPrefix, err := filepath.Rel(rootDir.String(), rebasedDir.String())
+ if err != nil || strings.HasPrefix(rebasedPrefix, "../") {
+ panic("rebasedDir could not be made relative to rootDir")
+ }
+ if !strings.HasSuffix(rebasedPrefix, "/") {
+ rebasedPrefix += "/"
+ }
+ if rebasedPrefix == "./" {
+ rebasedPrefix = ""
+ }
+
// create dirs and symlinks
for _, dir := range f.properties.Dirs.GetOrDefault(ctx, nil) {
// OutputPath.Join verifies dir
builder.Command().Text("mkdir -p").Text(rootDir.Join(ctx, dir).String())
+ // Only add the fullInstallPath logic for files in the rebased dir. The root dir
+ // is harder to install to.
+ if strings.HasPrefix(dir, rebasedPrefix) {
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), strings.TrimPrefix(dir, rebasedPrefix)),
+ IsDir: true,
+ })
+ }
}
for _, symlink := range f.properties.Symlinks {
@@ -672,6 +743,14 @@
builder.Command().Text("mkdir -p").Text(filepath.Dir(dst.String()))
builder.Command().Text("ln -sf").Text(proptools.ShellEscape(target)).Text(dst.String())
f.appendToEntry(ctx, dst)
+ // Only add the fullInstallPath logic for files in the rebased dir. The root dir
+ // is harder to install to.
+ if strings.HasPrefix(name, rebasedPrefix) {
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), strings.TrimPrefix(name, rebasedPrefix)),
+ SymlinkTarget: target,
+ })
+ }
}
// https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=2835;drc=b186569ef00ff2f2a1fab28aedc75ebc32bcd67b
@@ -824,9 +903,8 @@
if !proptools.BoolDefault(f.properties.Use_fec, true) {
avb_add_hashtree_footer_args += " --do_not_generate_fec"
}
- if hashAlgorithm := proptools.String(f.properties.Avb_hash_algorithm); hashAlgorithm != "" {
- avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
- }
+ hashAlgorithm := proptools.StringDefault(f.properties.Avb_hash_algorithm, "sha256")
+ avb_add_hashtree_footer_args += " --hash_algorithm " + hashAlgorithm
if f.properties.Rollback_index != nil {
rollbackIndex := proptools.Int(f.properties.Rollback_index)
if rollbackIndex < 0 {
@@ -1019,7 +1097,12 @@
"recovery",
}
-func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
+func (f *filesystem) buildEventLogtagsFile(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rebasedDir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
if !proptools.Bool(f.properties.Build_logtags) {
return
}
@@ -1029,10 +1112,20 @@
builder.Command().Text("mkdir").Flag("-p").Text(etcPath.String())
builder.Command().Text("cp").Input(android.MergedLogtagsPath(ctx)).Text(eventLogtagsPath.String())
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc", "event-log-tags"),
+ SourcePath: android.MergedLogtagsPath(ctx),
+ })
+
f.appendToEntry(ctx, eventLogtagsPath)
}
-func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
+func (f *filesystem) BuildLinkerConfigFile(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rebasedDir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
if !proptools.Bool(f.properties.Linker_config.Gen_linker_config) {
return
}
@@ -1043,6 +1136,11 @@
output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
builder.Command().Text("cp").Input(intermediateOutput).Output(output)
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), "etc", "linker.config.pb"),
+ SourcePath: intermediateOutput,
+ })
+
f.appendToEntry(ctx, output)
}
diff --git a/filesystem/fsverity_metadata.go b/filesystem/fsverity_metadata.go
index c3f1936..a3a2086 100644
--- a/filesystem/fsverity_metadata.go
+++ b/filesystem/fsverity_metadata.go
@@ -44,7 +44,14 @@
android.WriteFileRuleVerbatim(ctx, outputPath, buf.String())
}
-func (f *filesystem) buildFsverityMetadataFiles(ctx android.ModuleContext, builder *android.RuleBuilder, specs map[string]android.PackagingSpec, rootDir android.OutputPath, rebasedDir android.OutputPath) {
+func (f *filesystem) buildFsverityMetadataFiles(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ specs map[string]android.PackagingSpec,
+ rootDir android.OutputPath,
+ rebasedDir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
match := func(path string) bool {
for _, pattern := range f.properties.Fsverity.Inputs.GetOrDefault(ctx, nil) {
if matched, err := filepath.Match(pattern, path); matched {
@@ -82,9 +89,13 @@
FlagWithInput("--fsverity-path ", fsverityPath).
FlagWithArg("--signature ", "none").
FlagWithArg("--hash-alg ", "sha256").
- FlagWithArg("--output ", destPath.String()).
+ FlagWithOutput("--output ", destPath).
Text(srcPath.String())
f.appendToEntry(ctx, destPath)
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ SourcePath: destPath,
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), spec.RelPathInPackage()+".fsv_meta"),
+ })
}
fsVerityBaseDir := rootDir.String()
@@ -148,6 +159,10 @@
FlagWithArg("--version-name ", ctx.Config().AppsDefaultVersionName()).
FlagWithInput("--manifest ", manifestTemplatePath).
Text(" --rename-manifest-package com.android.security.fsverity_metadata." + f.partitionName())
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ SourcePath: apkPath,
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), fmt.Sprintf("etc/security/fsverity/BuildManifest%s.apk", apkNameSuffix)),
+ })
f.appendToEntry(ctx, apkPath)
@@ -160,6 +175,10 @@
FlagWithInput("--cert ", pemPath).
FlagWithInput("--key ", keyPath).
ImplicitOutput(idsigPath)
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ SourcePath: idsigPath,
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, f.PartitionType(), fmt.Sprintf("etc/security/fsverity/BuildManifest%s.apk.idsig", apkNameSuffix)),
+ })
f.appendToEntry(ctx, idsigPath)
}
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 874d20d..cc9093f 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -44,7 +44,12 @@
return s.filesystem.properties
}
-func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
+func (s *systemImage) BuildLinkerConfigFile(
+ ctx android.ModuleContext,
+ builder *android.RuleBuilder,
+ rebasedDir android.OutputPath,
+ fullInstallPaths *[]FullInstallPathInfo,
+) {
if !proptools.Bool(s.filesystem.properties.Linker_config.Gen_linker_config) {
return
}
@@ -55,6 +60,11 @@
intermediateOutput := android.PathForModuleOut(ctx, "linker.config.pb")
linkerconfig.BuildLinkerConfig(ctx, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, intermediateOutput)
builder.Command().Text("cp").Input(intermediateOutput).Output(output)
+
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, s.PartitionType(), "etc", "linker.config.pb"),
+ SourcePath: intermediateOutput,
+ })
} else {
// TODO: This branch is the logic that make uses for the linker config file, which is
// different than linkerconfig.BuildLinkerConfig used above. Keeping both branches for now
@@ -87,6 +97,11 @@
Implicit(llndkMovedToApexLibraries)
// TODO: Make also supports adding an extra append command with PRODUCT_EXTRA_STUB_LIBRARIES,
// but that variable appears to have no usages.
+
+ *fullInstallPaths = append(*fullInstallPaths, FullInstallPathInfo{
+ FullInstallPath: android.PathForModuleInPartitionInstall(ctx, s.PartitionType(), "etc", "linker.config.pb"),
+ SourcePath: output,
+ })
}
s.appendToEntry(ctx, output)
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 9dcbec1..63d0791 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -1163,6 +1163,10 @@
ctx.Phony("product_config_to_bp", generatedBp)
+ if !ctx.Config().KatiEnabled() {
+ // Cannot diff since the kati packaging rules will not be created.
+ return
+ }
var diffTestFiles []android.Path
for _, partitionType := range partitions.types() {
diffTestFile := f.createFileListDiffTest(ctx, partitionType, partitions.nameForType(partitionType))
diff --git a/fsgen/vbmeta_partitions.go b/fsgen/vbmeta_partitions.go
index 93425ae..11f4bd0 100644
--- a/fsgen/vbmeta_partitions.go
+++ b/fsgen/vbmeta_partitions.go
@@ -234,10 +234,14 @@
// Skip if the partition is not auto generated
continue
}
+ name := partitions.nameForType(partitionType)
+ if name == "" {
+ name = generatedModuleNameForPartition(ctx.Config(), partitionType)
+ }
if includeAsChainedPartitionInVbmeta(partitionType) {
- chainedPartitionModules = append(chainedPartitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
+ chainedPartitionModules = append(chainedPartitionModules, name)
} else if includeAsIncludedPartitionInVbmeta(partitionType) {
- includePartitionModules = append(includePartitionModules, generatedModuleNameForPartition(ctx.Config(), partitionType))
+ includePartitionModules = append(includePartitionModules, name)
}
}
diff --git a/golang/golang.go b/golang/golang.go
index d33f5e0..9e0744a 100644
--- a/golang/golang.go
+++ b/golang/golang.go
@@ -97,17 +97,16 @@
outputFile := android.PathForArbitraryOutput(ctx, android.Rel(ctx, ctx.Config().OutDir(), g.IntermediateFile())).WithoutRel()
g.outputFile = outputFile
- // Don't create install rules for modules used by bootstrap, the install command line will differ from
- // what was used during bootstrap, which will cause ninja to rebuild the module on the next run,
- // triggering reanalysis.
- if !usedByBootstrap(ctx.ModuleName()) {
- installPath := ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), ctx.ModuleName(), outputFile)
+ installPath := ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), ctx.ModuleName(), outputFile)
- // Modules in an unexported namespace have no install rule, only add modules in the exported namespaces
- // to the blueprint_tools phony rules.
- if !ctx.Config().KatiEnabled() || g.ExportedToMake() {
- ctx.Phony("blueprint_tools", installPath)
- }
+ // Modules in an unexported namespace have no install rule, only add modules in the exported namespaces
+ // to the blueprint_tools phony rules.
+ if g.ExportedToMake() && !usedByBootstrap(ctx.ModuleName()) {
+ // Don't add the installed file of bootstrap tools to the deps of `blueprint_tools`.
+ // The install command line will differ from what was used during bootstrap,
+ // which will cause ninja to rebuild the module on the next run,
+ // triggering reanalysis.
+ ctx.Phony("blueprint_tools", installPath)
}
ctx.SetOutputFiles(android.Paths{outputFile}, "")
diff --git a/java/Android.bp b/java/Android.bp
index 885e682..911af83 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -51,6 +51,7 @@
"gen.go",
"generated_java_library.go",
"genrule.go",
+ "genrule_combiner.go",
"hiddenapi.go",
"hiddenapi_modular.go",
"hiddenapi_monolithic.go",
@@ -95,6 +96,7 @@
"droiddoc_test.go",
"droidstubs_test.go",
"fuzz_test.go",
+ "genrule_combiner_test.go",
"genrule_test.go",
"generated_java_library_test.go",
"hiddenapi_singleton_test.go",
diff --git a/java/aar.go b/java/aar.go
index 3479f93..0a5a4c4 100644
--- a/java/aar.go
+++ b/java/aar.go
@@ -1063,6 +1063,8 @@
}
a.setOutputFiles(ctx)
+
+ buildComplianceMetadata(ctx)
}
func (a *AndroidLibrary) setOutputFiles(ctx android.ModuleContext) {
@@ -1594,6 +1596,8 @@
ctx.SetOutputFiles([]android.Path{a.implementationAndResourcesJarFile}, "")
ctx.SetOutputFiles([]android.Path{a.aarPath}, ".aar")
+
+ buildComplianceMetadata(ctx)
}
func (a *AARImport) HeaderJars() android.Paths {
diff --git a/java/aar_test.go b/java/aar_test.go
index aa4f0af..3ac228d 100644
--- a/java/aar_test.go
+++ b/java/aar_test.go
@@ -21,6 +21,7 @@
)
func TestAarImportProducesJniPackages(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -50,6 +51,7 @@
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
appMod := ctx.Module(tc.name, "android_common")
appTestMod := ctx.ModuleForTests(tc.name, "android_common")
@@ -84,6 +86,7 @@
}
func TestLibraryFlagsPackages(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
).RunTestWithBp(t, `
@@ -133,6 +136,7 @@
}
func TestAndroidLibraryOutputFilesRel(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
diff --git a/java/android_manifest_test.go b/java/android_manifest_test.go
index 7c91884..edb22fc 100644
--- a/java/android_manifest_test.go
+++ b/java/android_manifest_test.go
@@ -21,6 +21,7 @@
)
func TestManifestMerger(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "app",
@@ -100,6 +101,7 @@
}
func TestManifestValuesApplicationIdSetsPackageName(t *testing.T) {
+ t.Parallel()
bp := `
android_test {
name: "test",
diff --git a/java/androidmk.go b/java/androidmk.go
index fe3c7a2..c9de7e6 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -70,11 +70,7 @@
if library.hideApexVariantFromMake {
// For a java library built for an APEX, we don't need a Make module for itself. Otherwise, it
// will conflict with the platform variant because they have the same module name in the
- // makefile. However, we need to add its dexpreopt outputs as sub-modules, if it is preopted.
- dexpreoptEntries := library.dexpreopter.AndroidMkEntriesForApex()
- if len(dexpreoptEntries) > 0 {
- entriesList = append(entriesList, dexpreoptEntries...)
- }
+ // makefile.
entriesList = append(entriesList, android.AndroidMkEntries{Disabled: true})
} else if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) {
// Platform variant. If not available for the platform, we don't need Make module.
@@ -124,6 +120,14 @@
}
},
},
+ ExtraFooters: []android.AndroidMkExtraFootersFunc{
+ func(w io.Writer, name, prefix, moduleDir string) {
+ if library.apiXmlFile != nil {
+ fmt.Fprintf(w, "$(call declare-1p-target,%s,)\n", library.apiXmlFile.String())
+ fmt.Fprintf(w, "$(eval $(call copy-one-file,%s,$(TARGET_OUT_COMMON_INTERMEDIATES)/%s))\n", library.apiXmlFile.String(), library.apiXmlFile.Base())
+ }
+ },
+ },
})
}
@@ -556,8 +560,6 @@
func(w io.Writer, name, prefix, moduleDir string) {
if dstubs.apiLintTimestamp != nil {
if dstubs.apiLintReport != nil {
- fmt.Fprintf(w, "$(call dist-for-goals,%s,%s:%s)\n", dstubs.Name()+"-api-lint",
- dstubs.apiLintReport.String(), "apilint/"+dstubs.Name()+"-lint-report.txt")
fmt.Fprintf(w, "$(call declare-0p-target,%s)\n", dstubs.apiLintReport.String())
}
}
diff --git a/java/androidmk_test.go b/java/androidmk_test.go
index 1d98b18..9306e72 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -23,6 +23,7 @@
)
func TestRequired(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -42,6 +43,7 @@
}
func TestHostdex(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -72,6 +74,7 @@
}
func TestHostdexRequired(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -103,6 +106,7 @@
}
func TestHostdexSpecificRequired(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -136,6 +140,7 @@
}
func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -173,6 +178,7 @@
}
func TestImportSoongDexJar(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
java_import {
name: "my-java-import",
@@ -191,6 +197,7 @@
}
func TestAndroidTestHelperApp_LocalDisableTestConfig(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_test_helper_app {
name: "foo",
@@ -209,6 +216,7 @@
}
func TestGetOverriddenPackages(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(
t, `
android_app {
@@ -255,6 +263,7 @@
}
func TestJniAsRequiredDeps(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
cc.PrepareForTestWithCcDefaultModules,
diff --git a/java/app.go b/java/app.go
index da7eb02..abbf034 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1103,6 +1103,8 @@
}
a.setOutputFiles(ctx)
+
+ buildComplianceMetadata(ctx)
}
func (a *AndroidApp) setOutputFiles(ctx android.ModuleContext) {
diff --git a/java/app_import.go b/java/app_import.go
index a997e35..dc1aa74 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -531,6 +531,8 @@
ctx.SetOutputFiles([]android.Path{a.outputFile}, "")
+ buildComplianceMetadata(ctx)
+
// TODO: androidmk converter jni libs
}
@@ -770,9 +772,27 @@
func (a *AndroidTestImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.generateAndroidBuildActions(ctx)
+ a.updateModuleInfoJSON(ctx)
+
a.data = android.PathsForModuleSrc(ctx, a.testProperties.Data)
}
+func (a *AndroidTestImport) updateModuleInfoJSON(ctx android.ModuleContext) {
+ moduleInfoJSON := ctx.ModuleInfoJSON()
+ moduleInfoJSON.Class = []string{"APPS"}
+ moduleInfoJSON.CompatibilitySuites = []string{"null-suite"}
+ if len(a.testProperties.Test_suites) > 0 {
+ moduleInfoJSON.CompatibilitySuites = a.testProperties.Test_suites
+ }
+ moduleInfoJSON.SystemSharedLibs = []string{"none"}
+ moduleInfoJSON.Tags = []string{"tests"}
+ moduleInfoJSON.RegisterNameOverride = a.BaseModuleName()
+ testConfig := android.ExistentPathForSource(ctx, ctx.ModuleDir(), "AndroidTest.xml")
+ if testConfig.Valid() {
+ moduleInfoJSON.TestConfig = []string{testConfig.String()}
+ }
+}
+
func (a *AndroidTestImport) InstallInTestcases() bool {
return true
}
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 2ec7ed4..52ae719 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -26,6 +26,7 @@
)
func TestAndroidAppImport(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -60,6 +61,7 @@
}
func TestAndroidAppImportWithDefaults(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -99,6 +101,7 @@
}
func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -126,6 +129,7 @@
}
func TestAndroidAppImport_Presigned(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -160,6 +164,7 @@
}
func TestAndroidAppImport_SigningLineage(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -203,6 +208,7 @@
}
func TestAndroidAppImport_SigningLineageFilegroup(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -235,6 +241,7 @@
}
func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -270,6 +277,7 @@
}
func TestAndroidAppImport_DpiVariants(t *testing.T) {
+ t.Parallel()
bp := `
android_app_import {
name: "foo",
@@ -356,6 +364,7 @@
}
func TestAndroidAppImport_Filename(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -448,6 +457,7 @@
}
func TestAndroidAppImport_ArchVariants(t *testing.T) {
+ t.Parallel()
// The test config's target arch is ARM64.
testCases := []struct {
name string
@@ -573,6 +583,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, test.bp)
variant := ctx.ModuleForTests("foo", "android_common")
@@ -598,6 +609,7 @@
}
func TestAndroidAppImport_SoongConfigVariables(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -640,6 +652,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
android.PrepareForTestWithSoongConfigModuleBuildComponents,
@@ -675,6 +688,7 @@
}
func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app {
name: "foo",
@@ -703,6 +717,7 @@
}
func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
+ t.Parallel()
bp := `
android_app_import {
name: "no_relative_install_path",
@@ -747,13 +762,17 @@
},
}
for _, testCase := range testCases {
- ctx, _ := testJava(t, bp)
- mod := ctx.ModuleForTests(testCase.name, "android_common").Module().(*AndroidAppImport)
- android.AssertPathRelativeToTopEquals(t, testCase.errorMessage, testCase.expectedInstallPath, mod.installPath)
+ t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
+ ctx, _ := testJava(t, bp)
+ mod := ctx.ModuleForTests(testCase.name, "android_common").Module().(*AndroidAppImport)
+ android.AssertPathRelativeToTopEquals(t, testCase.errorMessage, testCase.expectedInstallPath, mod.installPath)
+ })
}
}
func TestAndroidAppImport_ExtractApk(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app_import {
name: "foo",
@@ -770,6 +789,7 @@
}
}
func TestAndroidTestImport(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_test_import {
name: "foo",
@@ -798,6 +818,7 @@
}
func TestAndroidTestImport_NoJinUncompressForPresigned(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_test_import {
name: "foo",
@@ -835,6 +856,7 @@
}
func TestAndroidTestImport_Preprocessed(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_test_import {
name: "foo",
@@ -861,9 +883,11 @@
}
func TestAndroidAppImport_Preprocessed(t *testing.T) {
+ t.Parallel()
for _, dontUncompressPrivAppDexs := range []bool{false, true} {
name := fmt.Sprintf("dontUncompressPrivAppDexs:%t", dontUncompressPrivAppDexs)
t.Run(name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -938,6 +962,7 @@
}
func TestAndroidTestImport_UncompressDex(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -1001,6 +1026,7 @@
name := fmt.Sprintf("%s,unbundled:%t,dontUncompressPrivAppDexs:%t",
tt.name, unbundled, dontUncompressPrivAppDexs)
t.Run(name, func(t *testing.T) {
+ t.Parallel()
test(t, tt.bp, unbundled, dontUncompressPrivAppDexs)
})
}
@@ -1009,6 +1035,7 @@
}
func TestAppImportMissingCertificateAllowMissingDependencies(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestWithAllowMissingDependencies,
diff --git a/java/app_set_test.go b/java/app_set_test.go
index c02b359..cc7af04 100644
--- a/java/app_set_test.go
+++ b/java/app_set_test.go
@@ -24,6 +24,7 @@
)
func TestAndroidAppSet(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app_set {
name: "foo",
@@ -65,6 +66,7 @@
}
func TestAndroidAppSet_Variants(t *testing.T) {
+ t.Parallel()
bp := `
android_app_set {
name: "foo",
@@ -113,24 +115,24 @@
}
for _, test := range testCases {
- ctx := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
- variables.Platform_sdk_version = &test.sdkVersion
- }),
- android.FixtureModifyConfig(func(config android.Config) {
- config.Targets[android.Android] = test.targets
- }),
- ).RunTestWithBp(t, bp)
+ t.Run(test.name, func(t *testing.T) {
+ ctx := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.AAPTPrebuiltDPI = test.aaptPrebuiltDPI
+ variables.Platform_sdk_version = &test.sdkVersion
+ }),
+ android.FixtureModifyConfig(func(config android.Config) {
+ config.Targets[android.Android] = test.targets
+ }),
+ ).RunTestWithBp(t, bp)
- module := ctx.ModuleForTests("foo", "android_common")
- const packedSplitApks = "foo.zip"
- params := module.Output(packedSplitApks)
- for k, v := range test.expected {
- t.Run(test.name, func(t *testing.T) {
+ module := ctx.ModuleForTests("foo", "android_common")
+ const packedSplitApks = "foo.zip"
+ params := module.Output(packedSplitApks)
+ for k, v := range test.expected {
android.AssertStringEquals(t, fmt.Sprintf("arg value for `%s`", k), v, params.Args[k])
- })
- }
+ }
+ })
}
}
diff --git a/java/app_test.go b/java/app_test.go
index bde801b..701fc35 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -42,6 +42,7 @@
}
func TestApp(t *testing.T) {
+ t.Parallel()
resourceFiles := []string{
"res/layout/layout.xml",
"res/values/strings.xml",
@@ -56,6 +57,7 @@
for _, moduleType := range []string{"android_app", "android_library"} {
t.Run(moduleType, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureModifyMockFS(func(fs android.MockFS) {
@@ -101,6 +103,7 @@
}
func TestAppSplits(t *testing.T) {
+ t.Parallel()
ctx := testApp(t, `
android_app {
name: "foo",
@@ -125,6 +128,7 @@
}
func TestPlatformAPIs(t *testing.T) {
+ t.Parallel()
testJava(t, `
android_app {
name: "foo",
@@ -159,6 +163,7 @@
}
func TestAndroidAppLinkType(t *testing.T) {
+ t.Parallel()
testJava(t, `
android_app {
name: "foo",
@@ -248,6 +253,7 @@
}
func TestUpdatableApps(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -359,6 +365,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
errorHandler := android.FixtureExpectsNoErrors
if test.expectedError != "" {
errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError)
@@ -373,6 +380,7 @@
}
func TestUpdatableApps_TransitiveDepsShouldSetMinSdkVersion(t *testing.T) {
+ t.Parallel()
testJavaError(t, `module "bar".*: should support min_sdk_version\(29\)`, cc.GatherRequiredDepsForTest(android.Android)+`
android_app {
name: "foo",
@@ -391,6 +399,7 @@
}
func TestUpdatableApps_JniLibsShouldShouldSupportMinSdkVersion(t *testing.T) {
+ t.Parallel()
testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
android_app {
name: "foo",
@@ -411,6 +420,7 @@
}
func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) {
+ t.Parallel()
bp := cc.GatherRequiredDepsForTest(android.Android) + `
android_app {
name: "foo",
@@ -466,6 +476,7 @@
}
func TestUpdatableApps_ErrorIfJniLibDoesntSupportMinSdkVersion(t *testing.T) {
+ t.Parallel()
bp := cc.GatherRequiredDepsForTest(android.Android) + `
android_app {
name: "foo",
@@ -487,6 +498,7 @@
}
func TestUpdatableApps_ErrorIfDepMinSdkVersionIsHigher(t *testing.T) {
+ t.Parallel()
bp := cc.GatherRequiredDepsForTest(android.Android) + `
android_app {
name: "foo",
@@ -518,6 +530,7 @@
}
func TestUpdatableApps_ApplyDefaultUpdatableModuleVersion(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -538,6 +551,7 @@
}
func TestUpdatableApps_ApplyOverrideApexManifestDefaultVersion(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeEnv(map[string]string{
@@ -561,6 +575,7 @@
}
func TestResourceDirs(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
prop string
@@ -597,6 +612,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
fs.AddToFixture(),
@@ -618,6 +634,7 @@
}
func TestLibraryAssets(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "foo",
@@ -712,6 +729,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
m := ctx.ModuleForTests(test.name, "android_common")
// Check asset flag in aapt2 link flags
@@ -747,6 +765,7 @@
}
func TestAppJavaResources(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "foo",
@@ -792,6 +811,7 @@
}
func TestAndroidResourceProcessor(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
appUsesRP bool
@@ -1224,6 +1244,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
bp := fmt.Sprintf(`
android_app {
name: "app",
@@ -1420,6 +1441,7 @@
}
func TestAndroidResourceOverlays(t *testing.T) {
+ t.Parallel()
type moduleAndVariant struct {
module string
variant string
@@ -1616,6 +1638,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
fs.AddToFixture(),
@@ -1725,6 +1748,7 @@
}
func TestAppSdkVersion(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
sdkVersion string
@@ -1792,6 +1816,7 @@
for _, moduleType := range []string{"android_app", "android_library"} {
for _, test := range testCases {
t.Run(moduleType+" "+test.name, func(t *testing.T) {
+ t.Parallel()
platformApiProp := ""
if test.platformApis {
platformApiProp = "platform_apis: true,"
@@ -1828,6 +1853,7 @@
}
func TestVendorAppSdkVersion(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
sdkVersion string
@@ -1870,6 +1896,7 @@
for _, sdkKind := range []string{"", "system_"} {
for _, test := range testCases {
t.Run(moduleType+" "+test.name, func(t *testing.T) {
+ t.Parallel()
bp := fmt.Sprintf(`%s {
name: "foo",
srcs: ["a.java"],
@@ -1901,6 +1928,7 @@
}
func TestJNIABI(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
@@ -1957,6 +1985,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.Output("jnilibs.zip")
var abis []string
@@ -1975,6 +2004,7 @@
}
func TestAppSdkVersionByPartition(t *testing.T) {
+ t.Parallel()
testJavaError(t, "sdk_version must have a value when the module is located at vendor or product", `
android_app {
name: "foo",
@@ -2019,6 +2049,7 @@
}
func TestJNIPackaging(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
@@ -2090,6 +2121,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput("jnilibs.zip")
if g, w := (jniLibZip.Rule != nil), test.packaged; g != w {
@@ -2110,6 +2142,7 @@
}
func TestJNISDK(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
@@ -2180,6 +2213,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.MaybeOutput("jnilibs.zip")
@@ -2205,6 +2239,7 @@
}
t.Run("jni_uses_platform_apis_error", func(t *testing.T) {
+ t.Parallel()
testJavaError(t, `jni_uses_platform_apis: can only be set for modules that set sdk_version`, `
android_test {
name: "app_platform",
@@ -2215,6 +2250,7 @@
})
t.Run("jni_uses_sdk_apis_error", func(t *testing.T) {
+ t.Parallel()
testJavaError(t, `jni_uses_sdk_apis: can only be set for modules that do not set sdk_version`, `
android_test {
name: "app_sdk",
@@ -2227,6 +2263,7 @@
}
func TestCertificates(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -2364,6 +2401,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -2401,6 +2439,7 @@
}
func TestRequestV4SigningFlag(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -2445,6 +2484,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, test.bp)
@@ -2459,6 +2499,7 @@
}
func TestPackageNameOverride(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -2516,6 +2557,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -2544,6 +2586,7 @@
}
func TestInstrumentationTargetOverridden(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "foo",
@@ -2575,6 +2618,7 @@
}
func TestOverrideAndroidApp(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(
t, `
android_app {
@@ -2757,6 +2801,7 @@
}
func TestOverrideAndroidAppOverrides(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(
t, `
android_app {
@@ -2815,6 +2860,7 @@
}
func TestOverrideAndroidAppWithPrebuilt(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(
t, `
android_app {
@@ -2850,6 +2896,7 @@
}
func TestOverrideAndroidAppStem(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app {
name: "foo",
@@ -2924,6 +2971,7 @@
}
func TestOverrideAndroidAppDependency(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app {
name: "foo",
@@ -3159,6 +3207,7 @@
}
func TestStl(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
cc_library {
name: "libjni",
@@ -3201,6 +3250,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
app := ctx.ModuleForTests(test.name, "android_common")
jniLibZip := app.Output("jnilibs.zip")
var jnis []string
@@ -3431,6 +3481,7 @@
}
func TestDexpreoptBcp(t *testing.T) {
+ t.Parallel()
bp := `
java_sdk_library {
name: "foo",
@@ -3473,6 +3524,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -3491,6 +3543,7 @@
}
func TestCodelessApp(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -3555,6 +3608,7 @@
for _, test := range testCases {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
ctx := testApp(t, test.bp)
foo := ctx.ModuleForTests("foo", "android_common")
@@ -3567,6 +3621,7 @@
}
func TestUncompressDex(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -3666,10 +3721,13 @@
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
t.Run("platform", func(t *testing.T) {
+ t.Parallel()
test(t, tt.bp, tt.uncompressedPlatform, false)
})
t.Run("unbundled", func(t *testing.T) {
+ t.Parallel()
test(t, tt.bp, tt.uncompressedUnbundled, true)
})
})
@@ -3691,6 +3749,7 @@
}
func TestExportedProguardFlagFiles(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
android_app {
name: "foo",
@@ -3752,6 +3811,7 @@
}
func TestTargetSdkVersionManifestFixer(t *testing.T) {
+ t.Parallel()
platform_sdk_codename := "Tiramisu"
platform_sdk_version := 33
testCases := []struct {
@@ -3804,43 +3864,47 @@
},
}
for _, testCase := range testCases {
- targetSdkVersionTemplate := ""
- if testCase.targetSdkVersionInBp != "" {
- targetSdkVersionTemplate = fmt.Sprintf(`target_sdk_version: "%s",`, testCase.targetSdkVersionInBp)
- }
- bp := fmt.Sprintf(`
+ t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
+ targetSdkVersionTemplate := ""
+ if testCase.targetSdkVersionInBp != "" {
+ targetSdkVersionTemplate = fmt.Sprintf(`target_sdk_version: "%s",`, testCase.targetSdkVersionInBp)
+ }
+ bp := fmt.Sprintf(`
android_app {
name: "foo",
sdk_version: "current",
%s
}
`, targetSdkVersionTemplate)
- fixture := android.GroupFixturePreparers(
- prepareForJavaTest,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- if testCase.platformSdkFinal {
- variables.Platform_sdk_final = proptools.BoolPtr(true)
- }
- // explicitly set platform_sdk_codename to make the test deterministic
- variables.Platform_sdk_codename = &platform_sdk_codename
- variables.Platform_sdk_version = &platform_sdk_version
- variables.Platform_version_active_codenames = []string{platform_sdk_codename}
- // create a non-empty list if unbundledBuild==true
- if testCase.unbundledBuild {
- variables.Unbundled_build_apps = []string{"apex_a", "apex_b"}
- }
- }),
- )
+ fixture := android.GroupFixturePreparers(
+ prepareForJavaTest,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ if testCase.platformSdkFinal {
+ variables.Platform_sdk_final = proptools.BoolPtr(true)
+ }
+ // explicitly set platform_sdk_codename to make the test deterministic
+ variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Platform_sdk_version = &platform_sdk_version
+ variables.Platform_version_active_codenames = []string{platform_sdk_codename}
+ // create a non-empty list if unbundledBuild==true
+ if testCase.unbundledBuild {
+ variables.Unbundled_build_apps = []string{"apex_a", "apex_b"}
+ }
+ }),
+ )
- result := fixture.RunTestWithBp(t, bp)
- foo := result.ModuleForTests("foo", "android_common")
+ result := fixture.RunTestWithBp(t, bp)
+ foo := result.ModuleForTests("foo", "android_common")
- manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
- android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
+ android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ })
}
}
func TestDefaultAppTargetSdkVersionForUpdatableModules(t *testing.T) {
+ t.Parallel()
platform_sdk_codename := "Tiramisu"
platform_sdk_version := 33
testCases := []struct {
@@ -3896,11 +3960,13 @@
},
}
for _, testCase := range testCases {
- targetSdkVersionTemplate := ""
- if testCase.targetSdkVersionInBp != nil {
- targetSdkVersionTemplate = fmt.Sprintf(`target_sdk_version: "%s",`, *testCase.targetSdkVersionInBp)
- }
- bp := fmt.Sprintf(`
+ t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
+ targetSdkVersionTemplate := ""
+ if testCase.targetSdkVersionInBp != nil {
+ targetSdkVersionTemplate = fmt.Sprintf(`target_sdk_version: "%s",`, *testCase.targetSdkVersionInBp)
+ }
+ bp := fmt.Sprintf(`
android_app {
name: "foo",
sdk_version: "current",
@@ -3911,30 +3977,32 @@
}
`, targetSdkVersionTemplate, testCase.updatable, testCase.updatable) // enforce default target sdk version if app is updatable
- fixture := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.PrepareForTestWithAllowMissingDependencies,
- android.PrepareForTestWithAndroidMk,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- // explicitly set following platform variables to make the test deterministic
- variables.Platform_sdk_final = &testCase.platform_sdk_final
- variables.Platform_sdk_version = &platform_sdk_version
- variables.Platform_sdk_codename = &platform_sdk_codename
- variables.Platform_version_active_codenames = []string{platform_sdk_codename}
- variables.Unbundled_build = proptools.BoolPtr(true)
- variables.Unbundled_build_apps = []string{"sampleModule"}
- }),
- )
+ fixture := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestWithAllowMissingDependencies,
+ android.PrepareForTestWithAndroidMk,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ // explicitly set following platform variables to make the test deterministic
+ variables.Platform_sdk_final = &testCase.platform_sdk_final
+ variables.Platform_sdk_version = &platform_sdk_version
+ variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Platform_version_active_codenames = []string{platform_sdk_codename}
+ variables.Unbundled_build = proptools.BoolPtr(true)
+ variables.Unbundled_build_apps = []string{"sampleModule"}
+ }),
+ )
- result := fixture.RunTestWithBp(t, bp)
- foo := result.ModuleForTests("foo", "android_common")
+ result := fixture.RunTestWithBp(t, bp)
+ foo := result.ModuleForTests("foo", "android_common")
- manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
- android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+*testCase.targetSdkVersionExpected)
+ manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
+ android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+*testCase.targetSdkVersionExpected)
+ })
}
}
func TestEnforceDefaultAppTargetSdkVersionFlag(t *testing.T) {
+ t.Parallel()
platform_sdk_codename := "Tiramisu"
platform_sdk_version := 33
testCases := []struct {
@@ -3979,8 +4047,10 @@
},
}
for _, testCase := range testCases {
- errExpected := testCase.expectedError != ""
- bp := fmt.Sprintf(`
+ t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
+ errExpected := testCase.expectedError != ""
+ bp := fmt.Sprintf(`
android_app {
name: "foo",
enforce_default_target_sdk_version: %t,
@@ -3991,35 +4061,37 @@
}
`, testCase.enforceDefaultTargetSdkVersion, testCase.targetSdkVersionInBp, testCase.updatable)
- fixture := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.PrepareForTestWithAllowMissingDependencies,
- android.PrepareForTestWithAndroidMk,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- // explicitly set following platform variables to make the test deterministic
- variables.Platform_sdk_final = &testCase.platform_sdk_final
- variables.Platform_sdk_version = &platform_sdk_version
- variables.Platform_sdk_codename = &platform_sdk_codename
- variables.Unbundled_build = proptools.BoolPtr(true)
- variables.Unbundled_build_apps = []string{"sampleModule"}
- }),
- )
+ fixture := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestWithAllowMissingDependencies,
+ android.PrepareForTestWithAndroidMk,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ // explicitly set following platform variables to make the test deterministic
+ variables.Platform_sdk_final = &testCase.platform_sdk_final
+ variables.Platform_sdk_version = &platform_sdk_version
+ variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Unbundled_build = proptools.BoolPtr(true)
+ variables.Unbundled_build_apps = []string{"sampleModule"}
+ }),
+ )
- errorHandler := android.FixtureExpectsNoErrors
- if errExpected {
- errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.expectedError)
- }
- result := fixture.ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, bp)
+ errorHandler := android.FixtureExpectsNoErrors
+ if errExpected {
+ errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.expectedError)
+ }
+ result := fixture.ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, bp)
- if !errExpected {
- foo := result.ModuleForTests("foo", "android_common")
- manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
- android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
- }
+ if !errExpected {
+ foo := result.ModuleForTests("foo", "android_common")
+ manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
+ android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ }
+ })
}
}
func TestEnforceDefaultAppTargetSdkVersionFlagForTests(t *testing.T) {
+ t.Parallel()
platform_sdk_codename := "Tiramisu"
platform_sdk_version := 33
testCases := []struct {
@@ -4052,8 +4124,10 @@
},
}
for _, testCase := range testCases {
- errExpected := testCase.expectedError != ""
- bp := fmt.Sprintf(`
+ t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
+ errExpected := testCase.expectedError != ""
+ bp := fmt.Sprintf(`
android_test {
name: "foo",
enforce_default_target_sdk_version: %t,
@@ -4062,35 +4136,37 @@
}
`, testCase.enforceDefaultTargetSdkVersion, testCase.targetSdkVersionInBp)
- fixture := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.PrepareForTestWithAllowMissingDependencies,
- android.PrepareForTestWithAndroidMk,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- // explicitly set following platform variables to make the test deterministic
- variables.Platform_sdk_final = &testCase.platform_sdk_final
- variables.Platform_sdk_version = &platform_sdk_version
- variables.Platform_sdk_codename = &platform_sdk_codename
- variables.Unbundled_build = proptools.BoolPtr(true)
- variables.Unbundled_build_apps = []string{"sampleModule"}
- }),
- )
+ fixture := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestWithAllowMissingDependencies,
+ android.PrepareForTestWithAndroidMk,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ // explicitly set following platform variables to make the test deterministic
+ variables.Platform_sdk_final = &testCase.platform_sdk_final
+ variables.Platform_sdk_version = &platform_sdk_version
+ variables.Platform_sdk_codename = &platform_sdk_codename
+ variables.Unbundled_build = proptools.BoolPtr(true)
+ variables.Unbundled_build_apps = []string{"sampleModule"}
+ }),
+ )
- errorHandler := android.FixtureExpectsNoErrors
- if errExpected {
- errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.expectedError)
- }
- result := fixture.ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, bp)
+ errorHandler := android.FixtureExpectsNoErrors
+ if errExpected {
+ errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.expectedError)
+ }
+ result := fixture.ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, bp)
- if !errExpected {
- foo := result.ModuleForTests("foo", "android_common")
- manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
- android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
- }
+ if !errExpected {
+ foo := result.ModuleForTests("foo", "android_common")
+ manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
+ android.AssertStringDoesContain(t, testCase.name, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ }
+ })
}
}
func TestAppMissingCertificateAllowMissingDependencies(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestWithAllowMissingDependencies,
@@ -4120,6 +4196,7 @@
}
func TestAppIncludesJniPackages(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -4182,6 +4259,7 @@
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
app := ctx.ModuleForTests(tc.name, "android_common")
outputFile := "jnilibs.zip"
@@ -4206,6 +4284,7 @@
}
func TestTargetSdkVersionMtsTests(t *testing.T) {
+ t.Parallel()
platformSdkCodename := "Tiramisu"
android_test := "android_test"
android_test_helper_app := "android_test_helper_app"
@@ -4261,14 +4340,18 @@
}),
)
for _, testCase := range testCases {
- result := fixture.RunTestWithBp(t, fmt.Sprintf(bpTemplate, testCase.moduleType, testCase.targetSdkVersionInBp, testCase.testSuites))
- mytest := result.ModuleForTests("mytest", "android_common")
- manifestFixerArgs := mytest.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
- android.AssertStringDoesContain(t, testCase.desc, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ t.Run(testCase.desc, func(t *testing.T) {
+ t.Parallel()
+ result := fixture.RunTestWithBp(t, fmt.Sprintf(bpTemplate, testCase.moduleType, testCase.targetSdkVersionInBp, testCase.testSuites))
+ mytest := result.ModuleForTests("mytest", "android_common")
+ manifestFixerArgs := mytest.Output("manifest_fixer/AndroidManifest.xml").Args["args"]
+ android.AssertStringDoesContain(t, testCase.desc, manifestFixerArgs, "--targetSdkVersion "+testCase.targetSdkVersionExpected)
+ })
}
}
func TestPrivappAllowlist(t *testing.T) {
+ t.Parallel()
testJavaError(t, "privileged must be set in order to use privapp_allowlist", `
android_app {
name: "foo",
@@ -4311,6 +4394,7 @@
}
func TestPrivappAllowlistAndroidMk(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestWithAndroidMk,
@@ -4390,6 +4474,7 @@
}
func TestAppFlagsPackages(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureMergeMockFs(
@@ -4454,6 +4539,7 @@
}
func TestAppFlagsPackagesPropagation(t *testing.T) {
+ t.Parallel()
ctx := testApp(t, `
aconfig_declarations {
name: "foo",
@@ -4531,6 +4617,7 @@
// Test that dexpreopt is disabled if an optional_uses_libs exists, but does not provide an implementation.
func TestNoDexpreoptOptionalUsesLibDoesNotHaveImpl(t *testing.T) {
+ t.Parallel()
bp := `
java_sdk_library_import {
name: "sdklib_noimpl",
@@ -4660,6 +4747,7 @@
}
func TestAppStem(t *testing.T) {
+ t.Parallel()
ctx := testApp(t, `
android_app {
name: "foo",
@@ -4677,6 +4765,7 @@
}
func TestAppMinSdkVersionOverride(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -4710,6 +4799,7 @@
}
func TestNotApplyDefaultUpdatableModuleVersion(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -4729,6 +4819,7 @@
}
func TestNotApplyOverrideApexManifestDefaultVersion(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeEnv(map[string]string{
@@ -4751,6 +4842,7 @@
}
func TestResourcesWithFlagDirectories(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeMockFs(android.MockFS{
@@ -4855,17 +4947,20 @@
},
}
for _, tc := range testCases {
- result := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.EnforceRROTargets = []string{"*"}
- }),
- android.OptionalFixturePreparer(tc.preparer),
- ).RunTestWithBp(t, bp)
- vendorOverlayApk := result.ModuleForTests("foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").MaybeOutput("foo__test_product__auto_generated_rro_vendor.apk")
- android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, vendorOverlayApk.Rule != nil)
- overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").MaybeOutput("override_foo__test_product__auto_generated_rro_vendor.apk")
- android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.Rule != nil)
+ t.Run(tc.desc, func(t *testing.T) {
+ t.Parallel()
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.EnforceRROTargets = []string{"*"}
+ }),
+ android.OptionalFixturePreparer(tc.preparer),
+ ).RunTestWithBp(t, bp)
+ vendorOverlayApk := result.ModuleForTests("foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").MaybeOutput("foo__test_product__auto_generated_rro_vendor.apk")
+ android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, vendorOverlayApk.Rule != nil)
+ overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").MaybeOutput("override_foo__test_product__auto_generated_rro_vendor.apk")
+ android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.Rule != nil)
+ })
}
}
@@ -4922,22 +5017,25 @@
},
}
for _, tc := range testCases {
- result := android.GroupFixturePreparers(
- PrepareForTestWithJavaDefaultModules,
- android.PrepareForTestWithSoongConfigModuleBuildComponents,
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.EnforceRROTargets = []string{"*"}
- }),
- android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
- variables.DeviceResourceOverlays = []string{"device/company/test_product"}
- }),
- android.MockFS{
- "res/foo.xml": nil,
- "device/company/test_product/res/foo.xml": nil,
- }.AddToFixture(),
- android.OptionalFixturePreparer(tc.preparer),
- ).RunTestWithBp(t, bp)
- overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").Module().(*AutogenRuntimeResourceOverlay)
- android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.exportPackage != nil)
+ t.Run(tc.desc, func(t *testing.T) {
+ t.Parallel()
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ android.PrepareForTestWithSoongConfigModuleBuildComponents,
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.EnforceRROTargets = []string{"*"}
+ }),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.DeviceResourceOverlays = []string{"device/company/test_product"}
+ }),
+ android.MockFS{
+ "res/foo.xml": nil,
+ "device/company/test_product/res/foo.xml": nil,
+ }.AddToFixture(),
+ android.OptionalFixturePreparer(tc.preparer),
+ ).RunTestWithBp(t, bp)
+ overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").Module().(*AutogenRuntimeResourceOverlay)
+ android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.exportPackage != nil)
+ })
}
}
diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go
index d6777e5..f6d6cad 100644
--- a/java/bootclasspath_fragment.go
+++ b/java/bootclasspath_fragment.go
@@ -290,6 +290,10 @@
return m
}
+func (m *BootclasspathFragmentModule) UniqueApexVariations() bool {
+ return true
+}
+
func (m *BootclasspathFragmentModule) bootclasspathFragmentPropertyCheck(ctx android.ModuleContext) {
contents := m.properties.Contents.GetOrDefault(ctx, nil)
if len(contents) == 0 {
@@ -527,19 +531,18 @@
}
// Bootclasspath fragment modules that are for the platform do not produce boot related files.
- apexInfos, _ := android.ModuleProvider(ctx, android.AllApexInfoProvider)
- if apexInfos == nil {
+ apexInfo, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
+ if apexInfo.IsForPlatform() {
return ""
}
- for _, apexInfo := range apexInfos.ApexInfos {
- for _, apex := range apexInfo.InApexVariants {
- if isProfileProviderApex(ctx, apex) {
- return apex
+ for _, config := range genBootImageConfigs(ctx) {
+ if config.profileProviderModule == b.BaseModuleName() {
+ if len(config.profileImports) > 0 {
+ return config.profileImports[0]
}
}
}
-
return ""
}
diff --git a/java/bootclasspath_fragment_test.go b/java/bootclasspath_fragment_test.go
index 3aa1258..d181ce0 100644
--- a/java/bootclasspath_fragment_test.go
+++ b/java/bootclasspath_fragment_test.go
@@ -31,6 +31,7 @@
)
func TestBootclasspathFragment_UnknownImageName(t *testing.T) {
+ t.Parallel()
prepareForTestWithBootclasspathFragment.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
`\Qimage_name: unknown image name "unknown", expected "art"\E`)).
@@ -50,6 +51,7 @@
}
func TestPrebuiltBootclasspathFragment_UnknownImageName(t *testing.T) {
+ t.Parallel()
prepareForTestWithBootclasspathFragment.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
`\Qimage_name: unknown image name "unknown", expected "art"\E`)).
@@ -68,6 +70,7 @@
}
func TestBootclasspathFragmentInconsistentArtConfiguration_Platform(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
dexpreopt.FixtureSetArtBootJars("platform:foo", "apex:bar"),
@@ -99,6 +102,7 @@
}
func TestBootclasspathFragmentInconsistentArtConfiguration_ApexMixture(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForTestWithBootclasspathFragment,
dexpreopt.FixtureSetArtBootJars("apex1:foo", "apex2:bar"),
@@ -131,6 +135,7 @@
}
func TestBootclasspathFragment_Coverage(t *testing.T) {
+ t.Parallel()
prepareWithBp := android.FixtureWithRootAndroidBp(`
bootclasspath_fragment {
name: "myfragment",
@@ -204,11 +209,13 @@
)
t.Run("without coverage", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
checkContents(t, result, "mybootlib")
})
t.Run("with coverage", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithFrameworkJacocoInstrumentation,
preparer,
diff --git a/java/builder.go b/java/builder.go
index 22dad10..ade9784 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -323,6 +323,13 @@
Command: `${keep-flagged-apis} ${in} > ${out}`,
CommandDeps: []string{"${keep-flagged-apis}"},
})
+
+ generateApiXMLRule = pctx.AndroidStaticRule("generateApiXMLRule",
+ blueprint.RuleParams{
+ Command: `${config.JavaCmd} ${config.JavaVmFlags} -Xmx4g -jar ${config.MetalavaJar} jar-to-jdiff ${in} ${out}`,
+ CommandDeps: []string{"${config.JavaCmd}", "${config.MetalavaJar}"},
+ Description: "Converting API file to XML",
+ })
)
func init() {
diff --git a/java/container_test.go b/java/container_test.go
index 25cfa4c..515236d 100644
--- a/java/container_test.go
+++ b/java/container_test.go
@@ -26,6 +26,7 @@
}
func TestJavaContainersModuleProperties(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
).RunTestWithBp(t, `
diff --git a/java/device_host_converter_test.go b/java/device_host_converter_test.go
index 6ccc5c1..45369e2 100644
--- a/java/device_host_converter_test.go
+++ b/java/device_host_converter_test.go
@@ -22,6 +22,7 @@
)
func TestDeviceForHost(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "device_module",
@@ -102,6 +103,7 @@
}
func TestHostForDevice(t *testing.T) {
+ t.Parallel()
bp := `
java_library_host {
name: "host_module",
diff --git a/java/dex.go b/java/dex.go
index 00a0537..64465a2 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -234,21 +234,29 @@
deps = append(deps, f)
}
- var requestReleaseMode bool
+ var requestReleaseMode, requestDebugMode bool
requestReleaseMode, flags = android.RemoveFromList("--release", flags)
+ requestDebugMode, flags = android.RemoveFromList("--debug", flags)
if ctx.Config().Getenv("NO_OPTIMIZE_DX") != "" || ctx.Config().Getenv("GENERATE_DEX_DEBUG") != "" {
- flags = append(flags, "--debug")
+ requestDebugMode = true
requestReleaseMode = false
}
// Don't strip out debug information for eng builds, unless the target
// explicitly provided the `--release` build flag. This allows certain
// test targets to remain optimized as part of eng test_suites builds.
- if requestReleaseMode {
+ if requestDebugMode {
+ flags = append(flags, "--debug")
+ } else if requestReleaseMode {
flags = append(flags, "--release")
} else if ctx.Config().Eng() {
flags = append(flags, "--debug")
+ } else if !d.effectiveOptimizeEnabled() && d.dexProperties.Optimize.EnabledByDefault {
+ // D8 uses --debug by default, whereas R8 uses --release by default.
+ // For targets that default to R8 usage (e.g., apps), but override this default, we still
+ // want D8 to run in release mode, preserving semantics as much as possible between the two.
+ flags = append(flags, "--release")
}
// Supplying the platform build flag disables various features like API modeling and desugaring.
diff --git a/java/dex_test.go b/java/dex_test.go
index 8bc28e6..4e515b4 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -16,6 +16,7 @@
import (
"fmt"
+ "strconv"
"testing"
"android/soong/android"
@@ -24,6 +25,7 @@
)
func TestR8(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app {
name: "app",
@@ -91,6 +93,7 @@
}
func TestR8TransitiveDeps(t *testing.T) {
+ t.Parallel()
bp := `
override_android_app {
name: "override_app",
@@ -192,6 +195,7 @@
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
fixturePreparer := PrepareForTestWithJavaDefaultModules
if tc.unbundled {
fixturePreparer = android.GroupFixturePreparers(
@@ -259,6 +263,7 @@
}
func TestR8Flags(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app {
name: "app",
@@ -288,6 +293,7 @@
}
func TestD8(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
java_library {
name: "foo",
@@ -306,14 +312,25 @@
name: "static_lib",
srcs: ["foo.java"],
}
+
+ android_app {
+ name: "app",
+ srcs: ["foo.java"],
+ platform_apis: true,
+ optimize: {
+ enabled: false,
+ },
+ }
`)
foo := result.ModuleForTests("foo", "android_common")
lib := result.ModuleForTests("lib", "android_common")
+ app := result.ModuleForTests("app", "android_common")
staticLib := result.ModuleForTests("static_lib", "android_common")
fooJavac := foo.Rule("javac")
fooD8 := foo.Rule("d8")
+ appD8 := app.Rule("d8")
libHeader := lib.Output("turbine-combined/lib.jar").Output
staticLibHeader := staticLib.Output("turbine-combined/static_lib.jar").Output
@@ -326,9 +343,20 @@
fooD8.Args["d8Flags"], libHeader.String())
android.AssertStringDoesNotContain(t, "expected no static_lib header jar in foo javac classpath",
fooD8.Args["d8Flags"], staticLibHeader.String())
+
+ // A --release flag is added only for targets that opt out of default R8 behavior (e.g., apps).
+ // For library targets that don't use R8 by default, no --debug or --release flag should be
+ // added, instead relying on default D8 behavior (--debug).
+ android.AssertStringDoesContain(t, "expected --release in app d8 flags",
+ appD8.Args["d8Flags"], "--release")
+ android.AssertStringDoesNotContain(t, "expected no --release flag in lib d8 flags",
+ fooD8.Args["d8Flags"], "--release")
+ android.AssertStringDoesNotContain(t, "expected no --debug flag in lib d8 flags",
+ fooD8.Args["d8Flags"], "--debug")
}
func TestProguardFlagsInheritanceStatic(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app {
name: "app",
@@ -383,6 +411,7 @@
}
func TestProguardFlagsInheritance(t *testing.T) {
+ t.Parallel()
directDepFlagsFileName := "direct_dep.flags"
transitiveDepFlagsFileName := "transitive_dep.flags"
@@ -601,6 +630,7 @@
for _, topLevelModuleDef := range topLevelModules {
for _, tc := range testcases {
t.Run(topLevelModuleDef.name+"-"+tc.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureMergeMockFs(android.MockFS{
@@ -642,6 +672,7 @@
}
func TestProguardFlagsInheritanceAppImport(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "app",
@@ -664,6 +695,7 @@
}
func TestR8FlagsArtProfile(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, `
android_app {
name: "app",
@@ -696,6 +728,7 @@
//
// The rewritten profile should be used since the dex signatures in the checked-in profile will not match the optimized binary.
func TestEnableProfileRewritingIsRequiredForOptimizedApps(t *testing.T) {
+ t.Parallel()
testJavaError(t,
"Enable_profile_rewriting must be true when profile_guided dexpreopt and R8 optimization/obfuscation is turned on",
`
@@ -715,11 +748,15 @@
}
func TestDebugReleaseFlags(t *testing.T) {
+ t.Parallel()
bp := `
android_app {
name: "app",
srcs: ["foo.java"],
platform_apis: true,
+ optimize: {
+ enabled: %s,
+ },
dxflags: ["%s"]
}
`
@@ -728,6 +765,7 @@
name string
envVar string
isEng bool
+ useD8 bool
dxFlags string
expectedFlags string
}{
@@ -767,10 +805,24 @@
// Eng mode does *not* override explicit dxflags.
expectedFlags: "--release",
},
+ {
+ name: "app_d8",
+ useD8: true,
+ // D8 usage w/ apps should explicitly enable --release mode.
+ expectedFlags: "--release",
+ },
+ {
+ name: "app_d8_debug",
+ useD8: true,
+ dxFlags: "--debug",
+ // D8 usage w/ apps respects overriding dxFlags.
+ expectedFlags: "--debug",
+ },
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
fixturePreparer := PrepareForTestWithJavaDefaultModules
fixturePreparer = android.GroupFixturePreparers(
fixturePreparer,
@@ -788,11 +840,16 @@
}),
)
}
- result := fixturePreparer.RunTestWithBp(t, fmt.Sprintf(bp, tc.dxFlags))
+ result := fixturePreparer.RunTestWithBp(t, fmt.Sprintf(bp, strconv.FormatBool(!tc.useD8), tc.dxFlags))
- appR8 := result.ModuleForTests("app", "android_common").Rule("r8")
- android.AssertStringDoesContain(t, "expected flag in R8 flags",
- appR8.Args["r8Flags"], tc.expectedFlags)
+ dexRuleKey := "r8"
+ if tc.useD8 {
+ dexRuleKey = "d8"
+ }
+ dexFlagsKey := dexRuleKey + "Flags"
+ appDex := result.ModuleForTests("app", "android_common").Rule(dexRuleKey)
+ android.AssertStringDoesContain(t, "expected flag in dex flags",
+ appDex.Args[dexFlagsKey], tc.expectedFlags)
var unexpectedFlags string
if tc.expectedFlags == "--debug" {
@@ -801,8 +858,8 @@
unexpectedFlags = "--debug"
}
if unexpectedFlags != "" {
- android.AssertStringDoesNotContain(t, "unexpected flag in R8 flags",
- appR8.Args["r8Flags"], unexpectedFlags)
+ android.AssertStringDoesNotContain(t, "unexpected flag in dex flags",
+ appDex.Args[dexFlagsKey], unexpectedFlags)
}
})
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index f52ce5d..15e40ba 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -36,69 +36,24 @@
// If the java module is to be installed into an APEX, this list contains information about the
// dexpreopt outputs to be installed on devices. Note that these dexpreopt outputs are installed
// outside of the APEX.
- DexpreoptBuiltInstalledForApex() []dexpreopterInstall
+ ApexSystemServerDexpreoptInstalls() []DexpreopterInstall
- // The Make entries to install the dexpreopt outputs. Derived from
- // `DexpreoptBuiltInstalledForApex`.
- AndroidMkEntriesForApex() []android.AndroidMkEntries
+ // ApexSystemServerDexJars returns the list of dex jars if this is an apex system server jar.
+ ApexSystemServerDexJars() android.Paths
// See `dexpreopter.outputProfilePathOnHost`.
OutputProfilePathOnHost() android.Path
}
-type dexpreopterInstall struct {
- // A unique name to distinguish an output from others for the same java library module. Usually in
- // the form of `<arch>-<encoded-path>.odex/vdex/art`.
- name string
-
- // The name of the input java module.
- moduleName string
-
+type DexpreopterInstall struct {
// The path to the dexpreopt output on host.
- outputPathOnHost android.Path
+ OutputPathOnHost android.Path
// The directory on the device for the output to install to.
- installDirOnDevice android.InstallPath
+ InstallDirOnDevice android.InstallPath
// The basename (the last segment of the path) for the output to install as.
- installFileOnDevice string
-}
-
-// The full module name of the output in the makefile.
-func (install *dexpreopterInstall) FullModuleName() string {
- return install.moduleName + install.SubModuleName()
-}
-
-// The sub-module name of the output in the makefile (the name excluding the java module name).
-func (install *dexpreopterInstall) SubModuleName() string {
- return "-dexpreopt-" + install.name
-}
-
-// Returns Make entries for installing the file.
-//
-// This function uses a value receiver rather than a pointer receiver to ensure that the object is
-// safe to use in `android.AndroidMkExtraEntriesFunc`.
-func (install dexpreopterInstall) ToMakeEntries() android.AndroidMkEntries {
- return android.AndroidMkEntries{
- OverrideName: install.FullModuleName(),
- Class: "ETC",
- OutputFile: android.OptionalPathForPath(install.outputPathOnHost),
- ExtraEntries: []android.AndroidMkExtraEntriesFunc{
- func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
- entries.SetString("LOCAL_MODULE_PATH", install.installDirOnDevice.String())
- entries.SetString("LOCAL_INSTALLED_MODULE_STEM", install.installFileOnDevice)
- entries.SetString("LOCAL_NOT_AVAILABLE_FOR_PLATFORM", "false")
- },
- },
- }
-}
-
-func (install dexpreopterInstall) AddModuleInfoJSONForApex(ctx android.ModuleContext) {
- moduleInfoJSON := ctx.ExtraModuleInfoJSON()
- moduleInfoJSON.RegisterNameOverride = install.FullModuleName()
- moduleInfoJSON.ModuleNameOverride = install.FullModuleName()
- moduleInfoJSON.Class = []string{"ETC"}
- moduleInfoJSON.SystemSharedLibs = []string{"none"}
+ InstallFileOnDevice string
}
type Dexpreopter struct {
@@ -128,8 +83,9 @@
classLoaderContexts dexpreopt.ClassLoaderContextMap
// See the `dexpreopt` function for details.
- builtInstalled string
- builtInstalledForApex []dexpreopterInstall
+ builtInstalled string
+ apexSystemServerDexpreoptInstalls []DexpreopterInstall
+ apexSystemServerDexJars android.Paths
// The config is used for two purposes:
// - Passing dexpreopt information about libraries from Soong to Make. This is needed when
@@ -286,20 +242,6 @@
if !isApexSystemServerJar {
return true
}
- ai, _ := android.ModuleProvider(ctx, android.ApexInfoProvider)
- allApexInfos := []android.ApexInfo{}
- if allApexInfosProvider, ok := android.ModuleProvider(ctx, android.AllApexInfoProvider); ok {
- allApexInfos = allApexInfosProvider.ApexInfos
- }
- if len(allApexInfos) > 0 && !ai.MinSdkVersion.EqualTo(allApexInfos[0].MinSdkVersion) {
- // Apex system server jars are dexpreopted and installed on to the system image.
- // Since we can have BigAndroid and Go variants of system server jar providing apexes,
- // and these two variants can have different min_sdk_versions, hide one of the apex variants
- // from make to prevent collisions.
- //
- // Unlike cc, min_sdk_version does not have an effect on the build actions of java libraries.
- ctx.Module().MakeUninstallable()
- }
} else {
// Don't preopt the platform variant of an APEX system server jar to avoid conflicts.
if isApexSystemServerJar {
@@ -550,12 +492,8 @@
Output(appProductPackages)
productPackagesRule.Restat().Build("product_packages."+dexJarStem, "dexpreopt product_packages")
- // Prebuilts are active, do not copy the dexpreopt'd source javalib to out/soong/system_server_dexjars
- // The javalib from the deapexed prebuilt will be copied to this location.
- // TODO (b/331665856): Implement a principled solution for this.
- copyApexSystemServerJarDex := !disableSourceApexVariant(ctx) && !ctx.Module().IsHideFromMake()
dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(
- ctx, globalSoong, global, dexpreoptConfig, appProductPackages, copyApexSystemServerJarDex)
+ ctx, globalSoong, global, dexpreoptConfig, appProductPackages)
if err != nil {
ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error())
return
@@ -588,7 +526,6 @@
partition = ""
}
installBase := filepath.Base(install.To)
- arch := filepath.Base(installDir)
installPath := android.PathForModuleInPartitionInstall(ctx, partition, installDir)
isProfile := strings.HasSuffix(installBase, ".prof")
@@ -604,16 +541,13 @@
// libraries, only those in the system server classpath are handled here.
// Preopting of boot classpath jars in the ART APEX are handled in
// java/dexpreopt_bootjars.go, and other APEX jars are not preopted.
- // The installs will be handled by Make as sub-modules of the java library.
- di := dexpreopterInstall{
- name: arch + "-" + installBase,
- moduleName: libName,
- outputPathOnHost: install.From,
- installDirOnDevice: installPath,
- installFileOnDevice: installBase,
+ // The installs will be handled the apex module that includes this library.
+ di := DexpreopterInstall{
+ OutputPathOnHost: install.From,
+ InstallDirOnDevice: installPath,
+ InstallFileOnDevice: installBase,
}
- ctx.InstallFile(di.installDirOnDevice, di.installFileOnDevice, di.outputPathOnHost)
- d.builtInstalledForApex = append(d.builtInstalledForApex, di)
+ d.apexSystemServerDexpreoptInstalls = append(d.apexSystemServerDexpreoptInstalls, di)
}
} else if !d.preventInstall {
@@ -622,6 +556,15 @@
}
}
+ if isApexSystemServerJar {
+ // Store the dex jar location for system server jars in apexes, the apex will copy the file into
+ // a known location for dex2oat.
+ d.apexSystemServerDexJars = append(d.apexSystemServerDexJars, dexJarFile)
+ } else if isSystemServerJar && !d.preventInstall {
+ // Copy the dex jar into a known location for dex2oat for non-apex system server jars.
+ android.CopyFileRule(ctx, dexJarFile, android.PathForOutput(ctx, dexpreopt.SystemServerDexjarsDir, dexJarFile.Base()))
+ }
+
if !isApexSystemServerJar {
d.builtInstalled = dexpreoptRule.Installs().String()
}
@@ -656,22 +599,12 @@
}
}
-func (d *dexpreopter) DexpreoptBuiltInstalledForApex() []dexpreopterInstall {
- return d.builtInstalledForApex
+func (d *dexpreopter) ApexSystemServerDexpreoptInstalls() []DexpreopterInstall {
+ return d.apexSystemServerDexpreoptInstalls
}
-func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries {
- var entries []android.AndroidMkEntries
- for _, install := range d.builtInstalledForApex {
- entries = append(entries, install.ToMakeEntries())
- }
- return entries
-}
-
-func (d *dexpreopter) ModuleInfoJSONForApex(ctx android.ModuleContext) {
- for _, install := range d.builtInstalledForApex {
- install.AddModuleInfoJSONForApex(ctx)
- }
+func (d *dexpreopter) ApexSystemServerDexJars() android.Paths {
+ return d.apexSystemServerDexJars
}
func (d *dexpreopter) OutputProfilePathOnHost() android.Path {
diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go
index 8c60d23..093cc87 100644
--- a/java/dexpreopt_bootjars.go
+++ b/java/dexpreopt_bootjars.go
@@ -293,6 +293,9 @@
// Profiles imported from APEXes, in addition to the profile at the default path. Each entry must
// be the name of an APEX module.
profileImports []string
+
+ // The name of the module that provides boot image profiles, if any.
+ profileProviderModule string
}
// Target-dependent description of a boot image.
@@ -563,6 +566,9 @@
// The prebuilt might have been renamed by prebuilt_rename mutator if the source module does not exist.
// Remove the prebuilt_ prefix.
ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, android.RemoveOptionalPrebuiltPrefix(selected))
+ } else {
+ // Couldn't find a dependency, do it again to report an error.
+ ctx.AddFarVariationDependencies(apexVariationOfSelected, dexpreoptBootJarDepTag, selected)
}
}
}
diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go
index dc0973c..fb5c325 100644
--- a/java/dexpreopt_config.go
+++ b/java/dexpreopt_config.go
@@ -67,15 +67,16 @@
// ART boot image for testing only. Do not rely on it to make any build-time decision.
artCfg := bootImageConfig{
- name: artBootImageName,
- enabledIfExists: "art-bootclasspath-fragment",
- stem: bootImageStem,
- installDir: "apex/art_boot_images/javalib",
- modules: global.TestOnlyArtBootImageJars,
- preloadedClassesFile: "art/build/boot/preloaded-classes",
- compilerFilter: "speed-profile",
- singleImage: false,
- profileImports: profileImports,
+ name: artBootImageName,
+ enabledIfExists: "art-bootclasspath-fragment",
+ stem: bootImageStem,
+ installDir: "apex/art_boot_images/javalib",
+ modules: global.TestOnlyArtBootImageJars,
+ preloadedClassesFile: "art/build/boot/preloaded-classes",
+ compilerFilter: "speed-profile",
+ singleImage: false,
+ profileImports: profileImports,
+ profileProviderModule: "art-bootclasspath-fragment",
}
// Framework config for the boot image extension.
diff --git a/java/dexpreopt_config_test.go b/java/dexpreopt_config_test.go
index 44d2127..99b1f23 100644
--- a/java/dexpreopt_config_test.go
+++ b/java/dexpreopt_config_test.go
@@ -23,6 +23,7 @@
)
func TestBootImageConfig(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" {
t.Skipf("Skipping as boot image config test is only supported on linux not %s", runtime.GOOS)
}
diff --git a/java/dexpreopt_config_testing.go b/java/dexpreopt_config_testing.go
index 33c682b..fbdb7b0 100644
--- a/java/dexpreopt_config_testing.go
+++ b/java/dexpreopt_config_testing.go
@@ -1217,6 +1217,7 @@
}
t.Run(imageConfig.name, func(t *testing.T) {
+ t.Parallel()
nestedCheckBootImageConfig(t, result, imageConfig, mutated, expected)
})
}
@@ -1246,6 +1247,7 @@
for i, variant := range imageConfig.variants {
expectedVariant := expected.variants[i]
t.Run(variant.target.Arch.ArchType.String(), func(t *testing.T) {
+ t.Parallel()
android.AssertDeepEquals(t, "archType", expectedVariant.archType, variant.target.Arch.ArchType)
android.AssertDeepEquals(t, "dexLocations", expectedVariant.dexLocations, variant.dexLocations)
android.AssertDeepEquals(t, "dexLocationsDeps", expectedVariant.dexLocationsDeps, variant.dexLocationsDeps)
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go
index 207ff65..bf66047 100644
--- a/java/dexpreopt_test.go
+++ b/java/dexpreopt_test.go
@@ -17,7 +17,6 @@
import (
"fmt"
"runtime"
- "strings"
"testing"
"android/soong/android"
@@ -30,6 +29,7 @@
}
func TestDexpreoptEnabled(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
bp string
@@ -219,6 +219,7 @@
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
preparers := android.GroupFixturePreparers(
PrepareForTestWithDexpreopt,
PrepareForTestWithFakeApexMutator,
@@ -258,6 +259,7 @@
}
func TestDex2oatToolDeps(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" {
// The host binary paths checked below are build OS dependent.
t.Skipf("Unsupported build OS %s", runtime.GOOS)
@@ -273,6 +275,7 @@
name := fmt.Sprintf("sourceEnabled:%t,prebuiltEnabled:%t,prebuiltPreferred:%t",
sourceEnabled, prebuiltEnabled, prebuiltPreferred)
t.Run(name, func(t *testing.T) {
+ t.Parallel()
result := preparers.RunTestWithBp(t, fmt.Sprintf(`
cc_binary {
name: "dex2oatd",
@@ -305,7 +308,7 @@
testDex2oatToolDep(false, true, false, prebuiltDex2oatPath)
}
-func TestDexpreoptBuiltInstalledForApex(t *testing.T) {
+func TestApexSystemServerDexpreoptInstalls(t *testing.T) {
preparers := android.GroupFixturePreparers(
PrepareForTestWithDexpreopt,
PrepareForTestWithFakeApexMutator,
@@ -325,25 +328,35 @@
module := ctx.ModuleForTests("service-foo", "android_common_apex1000")
library := module.Module().(*Library)
- installs := library.dexpreopter.DexpreoptBuiltInstalledForApex()
+ installs := library.dexpreopter.ApexSystemServerDexpreoptInstalls()
+ dexJars := library.dexpreopter.ApexSystemServerDexJars()
android.AssertIntEquals(t, "install count", 2, len(installs))
+ android.AssertIntEquals(t, "dexjar count", 1, len(dexJars))
- android.AssertStringEquals(t, "installs[0] FullModuleName",
- "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex",
- installs[0].FullModuleName())
+ android.AssertPathRelativeToTopEquals(t, "installs[0] OutputPathOnHost",
+ "out/soong/.intermediates/service-foo/android_common_apex1000/dexpreopt/service-foo/oat/arm64/javalib.odex",
+ installs[0].OutputPathOnHost)
- android.AssertStringEquals(t, "installs[0] SubModuleName",
- "-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex",
- installs[0].SubModuleName())
+ android.AssertPathRelativeToTopEquals(t, "installs[0] InstallDirOnDevice",
+ "out/target/product/test_device/system/framework/oat/arm64",
+ installs[0].InstallDirOnDevice)
- android.AssertStringEquals(t, "installs[1] FullModuleName",
- "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex",
- installs[1].FullModuleName())
+ android.AssertStringEquals(t, "installs[0] InstallFileOnDevice",
+ "apex@com.android.apex1@javalib@service-foo.jar@classes.odex",
+ installs[0].InstallFileOnDevice)
- android.AssertStringEquals(t, "installs[1] SubModuleName",
- "-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex",
- installs[1].SubModuleName())
+ android.AssertPathRelativeToTopEquals(t, "installs[1] OutputPathOnHost",
+ "out/soong/.intermediates/service-foo/android_common_apex1000/dexpreopt/service-foo/oat/arm64/javalib.vdex",
+ installs[1].OutputPathOnHost)
+
+ android.AssertPathRelativeToTopEquals(t, "installs[1] InstallDirOnDevice",
+ "out/target/product/test_device/system/framework/oat/arm64",
+ installs[1].InstallDirOnDevice)
+
+ android.AssertStringEquals(t, "installs[1] InstallFileOnDevice",
+ "apex@com.android.apex1@javalib@service-foo.jar@classes.vdex",
+ installs[1].InstallFileOnDevice)
// Not an APEX system server jar.
result = preparers.RunTestWithBp(t, `
@@ -357,98 +370,11 @@
module = ctx.ModuleForTests("foo", "android_common")
library = module.Module().(*Library)
- installs = library.dexpreopter.DexpreoptBuiltInstalledForApex()
+ installs = library.dexpreopter.ApexSystemServerDexpreoptInstalls()
+ dexJars = library.dexpreopter.ApexSystemServerDexJars()
android.AssertIntEquals(t, "install count", 0, len(installs))
-}
-
-func filterDexpreoptEntriesList(entriesList []android.AndroidMkEntries) []android.AndroidMkEntries {
- var results []android.AndroidMkEntries
- for _, entries := range entriesList {
- if strings.Contains(entries.EntryMap["LOCAL_MODULE"][0], "-dexpreopt-") {
- results = append(results, entries)
- }
- }
- return results
-}
-
-func verifyEntries(t *testing.T, message string, expectedModule string,
- expectedPrebuiltModuleFile string, expectedModulePath string, expectedInstalledModuleStem string,
- entries android.AndroidMkEntries) {
- android.AssertStringEquals(t, message+" LOCAL_MODULE", expectedModule,
- entries.EntryMap["LOCAL_MODULE"][0])
-
- android.AssertStringEquals(t, message+" LOCAL_MODULE_CLASS", "ETC",
- entries.EntryMap["LOCAL_MODULE_CLASS"][0])
-
- android.AssertStringDoesContain(t, message+" LOCAL_PREBUILT_MODULE_FILE",
- entries.EntryMap["LOCAL_PREBUILT_MODULE_FILE"][0], expectedPrebuiltModuleFile)
-
- android.AssertStringDoesContain(t, message+" LOCAL_MODULE_PATH",
- entries.EntryMap["LOCAL_MODULE_PATH"][0], expectedModulePath)
-
- android.AssertStringEquals(t, message+" LOCAL_INSTALLED_MODULE_STEM",
- expectedInstalledModuleStem, entries.EntryMap["LOCAL_INSTALLED_MODULE_STEM"][0])
-
- android.AssertStringEquals(t, message+" LOCAL_NOT_AVAILABLE_FOR_PLATFORM",
- "false", entries.EntryMap["LOCAL_NOT_AVAILABLE_FOR_PLATFORM"][0])
-}
-
-func TestAndroidMkEntriesForApex(t *testing.T) {
- preparers := android.GroupFixturePreparers(
- PrepareForTestWithDexpreopt,
- PrepareForTestWithFakeApexMutator,
- dexpreopt.FixtureSetApexSystemServerJars("com.android.apex1:service-foo"),
- )
-
- // An APEX system server jar.
- result := preparers.RunTestWithBp(t, `
- java_library {
- name: "service-foo",
- installable: true,
- srcs: ["a.java"],
- apex_available: ["com.android.apex1"],
- sdk_version: "current",
- }`)
- ctx := result.TestContext
- module := ctx.ModuleForTests("service-foo", "android_common_apex1000")
-
- entriesList := android.AndroidMkEntriesForTest(t, ctx, module.Module())
- entriesList = filterDexpreoptEntriesList(entriesList)
-
- android.AssertIntEquals(t, "entries count", 2, len(entriesList))
-
- verifyEntries(t,
- "entriesList[0]",
- "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.odex",
- "/dexpreopt/service-foo/oat/arm64/javalib.odex",
- "/system/framework/oat/arm64",
- "apex@com.android.apex1@javalib@service-foo.jar@classes.odex",
- entriesList[0])
-
- verifyEntries(t,
- "entriesList[1]",
- "service-foo-dexpreopt-arm64-apex@com.android.apex1@javalib@service-foo.jar@classes.vdex",
- "/dexpreopt/service-foo/oat/arm64/javalib.vdex",
- "/system/framework/oat/arm64",
- "apex@com.android.apex1@javalib@service-foo.jar@classes.vdex",
- entriesList[1])
-
- // Not an APEX system server jar.
- result = preparers.RunTestWithBp(t, `
- java_library {
- name: "foo",
- installable: true,
- srcs: ["a.java"],
- sdk_version: "current",
- }`)
- ctx = result.TestContext
- module = ctx.ModuleForTests("foo", "android_common")
-
- entriesList = android.AndroidMkEntriesForTest(t, ctx, module.Module())
- entriesList = filterDexpreoptEntriesList(entriesList)
-
- android.AssertIntEquals(t, "entries count", 0, len(entriesList))
+ android.AssertIntEquals(t, "dexjar count", 0, len(dexJars))
}
func TestGenerateProfileEvenIfDexpreoptIsDisabled(t *testing.T) {
diff --git a/java/droiddoc_test.go b/java/droiddoc_test.go
index 9e1ebbe..2256f1e 100644
--- a/java/droiddoc_test.go
+++ b/java/droiddoc_test.go
@@ -23,6 +23,7 @@
)
func TestDroiddoc(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -97,6 +98,7 @@
}
func TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
+ t.Parallel()
testJavaError(t, "flags is set. Cannot set args", `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 22f4d98..c8f798a 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -1524,6 +1524,18 @@
}
)
+func (d *Droidstubs) MakeVars(ctx android.MakeVarsModuleContext) {
+ if d.apiLintTimestamp != nil {
+ if d.apiLintReport != nil {
+ ctx.DistForGoalsWithFilename(
+ []string{fmt.Sprintf("%s-api-lint", d.Name()), "droidcore"},
+ d.apiLintReport,
+ fmt.Sprintf("apilint/%s-lint-report.txt", d.Name()),
+ )
+ }
+ }
+}
+
func StubsDefaultsFactory() android.Module {
module := &DocDefaults{}
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 75a0a31..faa9a15 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -27,6 +27,7 @@
)
func TestDroidstubs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -139,6 +140,7 @@
}
func TestPublicDroidstubs(t *testing.T) {
+ t.Parallel()
patterns := getAndroidJarPatternsForDroidstubs(t, "public")
android.AssertArrayString(t, "order of patterns", []string{
@@ -148,6 +150,7 @@
}
func TestSystemDroidstubs(t *testing.T) {
+ t.Parallel()
patterns := getAndroidJarPatternsForDroidstubs(t, "system")
android.AssertArrayString(t, "order of patterns", []string{
@@ -159,6 +162,7 @@
}
func TestModuleLibDroidstubs(t *testing.T) {
+ t.Parallel()
patterns := getAndroidJarPatternsForDroidstubs(t, "module-lib")
android.AssertArrayString(t, "order of patterns", []string{
diff --git a/java/fuzz_test.go b/java/fuzz_test.go
index f29c913..40adae0 100644
--- a/java/fuzz_test.go
+++ b/java/fuzz_test.go
@@ -30,6 +30,7 @@
)
func TestJavaFuzz(t *testing.T) {
+ t.Parallel()
result := prepForJavaFuzzTest.RunTestWithBp(t, `
java_fuzz {
name: "foo",
diff --git a/java/generated_java_library_test.go b/java/generated_java_library_test.go
index a5c4be1..7efd54b 100644
--- a/java/generated_java_library_test.go
+++ b/java/generated_java_library_test.go
@@ -52,6 +52,7 @@
}
func TestGenLib(t *testing.T) {
+ t.Parallel()
bp := `
test_java_gen_lib {
name: "javagenlibtest",
diff --git a/java/genrule_combiner.go b/java/genrule_combiner.go
new file mode 100644
index 0000000..357dc2c
--- /dev/null
+++ b/java/genrule_combiner.go
@@ -0,0 +1,252 @@
+// Copyright 2019 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "fmt"
+ "io"
+
+ "android/soong/android"
+ "android/soong/dexpreopt"
+
+ "github.com/google/blueprint/depset"
+ "github.com/google/blueprint/proptools"
+)
+
+type GenruleCombiner struct {
+ android.ModuleBase
+ android.DefaultableModuleBase
+
+ genruleCombinerProperties GenruleCombinerProperties
+
+ headerJars android.Paths
+ implementationJars android.Paths
+ implementationAndResourceJars android.Paths
+ resourceJars android.Paths
+ aconfigProtoFiles android.Paths
+
+ srcJarArgs []string
+ srcJarDeps android.Paths
+
+ headerDirs android.Paths
+
+ combinedHeaderJar android.Path
+ combinedImplementationJar android.Path
+}
+
+type GenruleCombinerProperties struct {
+ // List of modules whose implementation (and resources) jars will be visible to modules
+ // that depend on this module.
+ Static_libs proptools.Configurable[[]string] `android:"arch_variant"`
+
+ // List of modules whose header jars will be visible to modules that depend on this module.
+ Headers proptools.Configurable[[]string] `android:"arch_variant"`
+}
+
+// java_genrule_combiner provides the implementation and resource jars from `static_libs`, with
+// the header jars from `headers`.
+//
+// This is useful when a java_genrule is used to change the implementation of a java library
+// without requiring a change in the header jars.
+func GenruleCombinerFactory() android.Module {
+ module := &GenruleCombiner{}
+
+ module.AddProperties(&module.genruleCombinerProperties)
+ InitJavaModule(module, android.HostAndDeviceSupported)
+ return module
+}
+
+var genruleCombinerHeaderDepTag = dependencyTag{name: "genrule_combiner_header"}
+
+func (j *GenruleCombiner) DepsMutator(ctx android.BottomUpMutatorContext) {
+ ctx.AddVariationDependencies(nil, staticLibTag,
+ j.genruleCombinerProperties.Static_libs.GetOrDefault(ctx, nil)...)
+ ctx.AddVariationDependencies(nil, genruleCombinerHeaderDepTag,
+ j.genruleCombinerProperties.Headers.GetOrDefault(ctx, nil)...)
+}
+
+func (j *GenruleCombiner) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if len(j.genruleCombinerProperties.Static_libs.GetOrDefault(ctx, nil)) < 1 {
+ ctx.PropertyErrorf("static_libs", "at least one dependency is required")
+ }
+
+ if len(j.genruleCombinerProperties.Headers.GetOrDefault(ctx, nil)) < 1 {
+ ctx.PropertyErrorf("headers", "at least one dependency is required")
+ }
+
+ var transitiveHeaderJars []depset.DepSet[android.Path]
+ var transitiveImplementationJars []depset.DepSet[android.Path]
+ var transitiveResourceJars []depset.DepSet[android.Path]
+ var sdkVersion android.SdkSpec
+ var stubsLinkType StubsLinkType
+ moduleWithSdkDepInfo := &ModuleWithSdkDepInfo{}
+
+ // Collect the headers first, so that aconfig flag values for the libraries will override
+ // values from the headers (if they are different).
+ ctx.VisitDirectDepsWithTag(genruleCombinerHeaderDepTag, func(m android.Module) {
+ if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
+ j.headerJars = append(j.headerJars, dep.HeaderJars...)
+
+ j.srcJarArgs = append(j.srcJarArgs, dep.SrcJarArgs...)
+ j.srcJarDeps = append(j.srcJarDeps, dep.SrcJarDeps...)
+ j.aconfigProtoFiles = append(j.aconfigProtoFiles, dep.AconfigIntermediateCacheOutputPaths...)
+ sdkVersion = dep.SdkVersion
+ stubsLinkType = dep.StubsLinkType
+ *moduleWithSdkDepInfo = *dep.ModuleWithSdkDepInfo
+
+ transitiveHeaderJars = append(transitiveHeaderJars, dep.TransitiveStaticLibsHeaderJars)
+ } else if dep, ok := android.OtherModuleProvider(ctx, m, android.CodegenInfoProvider); ok {
+ j.aconfigProtoFiles = append(j.aconfigProtoFiles, dep.IntermediateCacheOutputPaths...)
+ } else {
+ ctx.PropertyErrorf("headers", "module %q cannot be used as a dependency", ctx.OtherModuleName(m))
+ }
+ })
+ ctx.VisitDirectDepsWithTag(staticLibTag, func(m android.Module) {
+ if dep, ok := android.OtherModuleProvider(ctx, m, JavaInfoProvider); ok {
+ j.implementationJars = append(j.implementationJars, dep.ImplementationJars...)
+ j.implementationAndResourceJars = append(j.implementationAndResourceJars, dep.ImplementationAndResourcesJars...)
+ j.resourceJars = append(j.resourceJars, dep.ResourceJars...)
+
+ transitiveImplementationJars = append(transitiveImplementationJars, dep.TransitiveStaticLibsImplementationJars)
+ transitiveResourceJars = append(transitiveResourceJars, dep.TransitiveStaticLibsResourceJars)
+ j.aconfigProtoFiles = append(j.aconfigProtoFiles, dep.AconfigIntermediateCacheOutputPaths...)
+ } else if dep, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider); ok {
+ // This is provided by `java_genrule` modules.
+ j.implementationJars = append(j.implementationJars, dep.DefaultOutputFiles...)
+ j.implementationAndResourceJars = append(j.implementationAndResourceJars, dep.DefaultOutputFiles...)
+ stubsLinkType = Implementation
+ } else {
+ ctx.PropertyErrorf("static_libs", "module %q cannot be used as a dependency", ctx.OtherModuleName(m))
+ }
+ })
+
+ jarName := ctx.ModuleName() + ".jar"
+
+ if len(j.implementationAndResourceJars) > 1 {
+ outputFile := android.PathForModuleOut(ctx, "combined", jarName)
+ TransformJarsToJar(ctx, outputFile, "combine", j.implementationAndResourceJars,
+ android.OptionalPath{}, false, nil, nil)
+ j.combinedImplementationJar = outputFile
+ } else if len(j.implementationAndResourceJars) == 1 {
+ j.combinedImplementationJar = j.implementationAndResourceJars[0]
+ }
+
+ if len(j.headerJars) > 1 {
+ outputFile := android.PathForModuleOut(ctx, "turbine-combined", jarName)
+ TransformJarsToJar(ctx, outputFile, "turbine combine", j.headerJars,
+ android.OptionalPath{}, false, nil, []string{"META-INF/TRANSITIVE"})
+ j.combinedHeaderJar = outputFile
+ j.headerDirs = append(j.headerDirs, android.PathForModuleOut(ctx, "turbine-combined"))
+ } else if len(j.headerJars) == 1 {
+ j.combinedHeaderJar = j.headerJars[0]
+ }
+
+ javaInfo := &JavaInfo{
+ HeaderJars: android.Paths{j.combinedHeaderJar},
+ LocalHeaderJars: android.Paths{j.combinedHeaderJar},
+ TransitiveStaticLibsHeaderJars: depset.New(depset.PREORDER, android.Paths{j.combinedHeaderJar}, transitiveHeaderJars),
+ TransitiveStaticLibsImplementationJars: depset.New(depset.PREORDER, android.Paths{j.combinedImplementationJar}, transitiveImplementationJars),
+ TransitiveStaticLibsResourceJars: depset.New(depset.PREORDER, nil, transitiveResourceJars),
+ GeneratedSrcjars: android.Paths{j.combinedImplementationJar},
+ ImplementationAndResourcesJars: android.Paths{j.combinedImplementationJar},
+ ImplementationJars: android.Paths{j.combinedImplementationJar},
+ ModuleWithSdkDepInfo: moduleWithSdkDepInfo,
+ ResourceJars: j.resourceJars,
+ OutputFile: j.combinedImplementationJar,
+ SdkVersion: sdkVersion,
+ SrcJarArgs: j.srcJarArgs,
+ SrcJarDeps: j.srcJarDeps,
+ StubsLinkType: stubsLinkType,
+ AconfigIntermediateCacheOutputPaths: j.aconfigProtoFiles,
+ }
+ setExtraJavaInfo(ctx, j, javaInfo)
+ ctx.SetOutputFiles(android.Paths{javaInfo.OutputFile}, "")
+ ctx.SetOutputFiles(android.Paths{javaInfo.OutputFile}, android.DefaultDistTag)
+ ctx.SetOutputFiles(javaInfo.ImplementationAndResourcesJars, ".jar")
+ ctx.SetOutputFiles(javaInfo.HeaderJars, ".hjar")
+ android.SetProvider(ctx, JavaInfoProvider, javaInfo)
+
+}
+
+func (j *GenruleCombiner) GeneratedSourceFiles() android.Paths {
+ return append(android.Paths{}, j.combinedImplementationJar)
+}
+
+func (j *GenruleCombiner) GeneratedHeaderDirs() android.Paths {
+ return append(android.Paths{}, j.headerDirs...)
+}
+
+func (j *GenruleCombiner) GeneratedDeps() android.Paths {
+ return append(android.Paths{}, j.combinedImplementationJar)
+}
+
+func (j *GenruleCombiner) Srcs() android.Paths {
+ return append(android.Paths{}, j.implementationAndResourceJars...)
+}
+
+func (j *GenruleCombiner) HeaderJars() android.Paths {
+ return j.headerJars
+}
+
+func (j *GenruleCombiner) ImplementationAndResourcesJars() android.Paths {
+ return j.implementationAndResourceJars
+}
+
+func (j *GenruleCombiner) DexJarBuildPath(ctx android.ModuleErrorfContext) android.Path {
+ return nil
+}
+
+func (j *GenruleCombiner) DexJarInstallPath() android.Path {
+ return nil
+}
+
+func (j *GenruleCombiner) AidlIncludeDirs() android.Paths {
+ return nil
+}
+
+func (j *GenruleCombiner) ClassLoaderContexts() dexpreopt.ClassLoaderContextMap {
+ return nil
+}
+
+func (j *GenruleCombiner) JacocoReportClassesFile() android.Path {
+ return nil
+}
+
+func (j *GenruleCombiner) AndroidMk() android.AndroidMkData {
+ return android.AndroidMkData{
+ Class: "JAVA_LIBRARIES",
+ OutputFile: android.OptionalPathForPath(j.combinedImplementationJar),
+ // Make does not support Windows Java modules
+ Disabled: j.Os() == android.Windows,
+ Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
+ Extra: []android.AndroidMkExtraFunc{
+ func(w io.Writer, outputFile android.Path) {
+ fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
+ fmt.Fprintln(w, "LOCAL_SOONG_HEADER_JAR :=", j.combinedHeaderJar.String())
+ fmt.Fprintln(w, "LOCAL_SOONG_CLASSES_JAR :=", j.combinedImplementationJar.String())
+ },
+ },
+ }
+}
+
+// implement the following interface for IDE completion.
+var _ android.IDEInfo = (*GenruleCombiner)(nil)
+
+func (j *GenruleCombiner) IDEInfo(ctx android.BaseModuleContext, ideInfo *android.IdeInfo) {
+ ideInfo.Deps = append(ideInfo.Deps, j.genruleCombinerProperties.Static_libs.GetOrDefault(ctx, nil)...)
+ ideInfo.Libs = append(ideInfo.Libs, j.genruleCombinerProperties.Static_libs.GetOrDefault(ctx, nil)...)
+ ideInfo.Deps = append(ideInfo.Deps, j.genruleCombinerProperties.Headers.GetOrDefault(ctx, nil)...)
+ ideInfo.Libs = append(ideInfo.Libs, j.genruleCombinerProperties.Headers.GetOrDefault(ctx, nil)...)
+}
diff --git a/java/genrule_combiner_test.go b/java/genrule_combiner_test.go
new file mode 100644
index 0000000..a458952
--- /dev/null
+++ b/java/genrule_combiner_test.go
@@ -0,0 +1,237 @@
+// Copyright 2018 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package java
+
+import (
+ "reflect"
+ "testing"
+
+ "android/soong/android"
+)
+
+func TestJarGenruleCombinerSingle(t *testing.T) {
+ t.Parallel()
+ t.Helper()
+ ctx := prepareForJavaTest.RunTestWithBp(t, `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ }
+
+ java_genrule {
+ name: "gen",
+ tool_files: ["b.java"],
+ cmd: "$(location b.java) $(in) $(out)",
+ out: ["gen.jar"],
+ srcs: [":foo"],
+ }
+
+ java_genrule_combiner {
+ name: "jarcomb",
+ static_libs: ["gen"],
+ headers: ["foo"],
+ }
+
+ java_library {
+ name: "bar",
+ static_libs: ["jarcomb"],
+ srcs: ["c.java"],
+ }
+
+ java_library {
+ name: "baz",
+ libs: ["jarcomb"],
+ srcs: ["c.java"],
+ }
+ `).TestContext
+
+ fooMod := ctx.ModuleForTests("foo", "android_common")
+ fooCombined := fooMod.Output("turbine-combined/foo.jar")
+ fooOutputFiles, _ := android.OtherModuleProvider(ctx.OtherModuleProviderAdaptor(), fooMod.Module(), android.OutputFilesProvider)
+ fooHeaderJars := fooOutputFiles.TaggedOutputFiles[".hjar"]
+
+ genMod := ctx.ModuleForTests("gen", "android_common")
+ gen := genMod.Output("gen.jar")
+
+ jarcombMod := ctx.ModuleForTests("jarcomb", "android_common")
+ jarcombInfo, _ := android.OtherModuleProvider(ctx.OtherModuleProviderAdaptor(), jarcombMod.Module(), JavaInfoProvider)
+ jarcombOutputFiles, _ := android.OtherModuleProvider(ctx.OtherModuleProviderAdaptor(), jarcombMod.Module(), android.OutputFilesProvider)
+
+ // Confirm that jarcomb simply forwards the jarcomb implementation and the foo headers.
+ if len(jarcombOutputFiles.DefaultOutputFiles) != 1 ||
+ android.PathRelativeToTop(jarcombOutputFiles.DefaultOutputFiles[0]) != android.PathRelativeToTop(gen.Output) {
+ t.Errorf("jarcomb Implementation %v is not [%q]",
+ android.PathsRelativeToTop(jarcombOutputFiles.DefaultOutputFiles), android.PathRelativeToTop(gen.Output))
+ }
+ jarcombHeaderJars := jarcombOutputFiles.TaggedOutputFiles[".hjar"]
+ if !reflect.DeepEqual(jarcombHeaderJars, fooHeaderJars) {
+ t.Errorf("jarcomb Header jar %v is not %q",
+ jarcombHeaderJars, fooHeaderJars)
+ }
+
+ // Confirm that JavaInfoProvider agrees.
+ if len(jarcombInfo.ImplementationJars) != 1 ||
+ android.PathRelativeToTop(jarcombInfo.ImplementationJars[0]) != android.PathRelativeToTop(gen.Output) {
+ t.Errorf("jarcomb ImplementationJars %v is not [%q]",
+ android.PathsRelativeToTop(jarcombInfo.ImplementationJars), android.PathRelativeToTop(gen.Output))
+ }
+ if len(jarcombInfo.HeaderJars) != 1 ||
+ android.PathRelativeToTop(jarcombInfo.HeaderJars[0]) != android.PathRelativeToTop(fooCombined.Output) {
+ t.Errorf("jarcomb HeaderJars %v is not [%q]",
+ android.PathsRelativeToTop(jarcombInfo.HeaderJars), android.PathRelativeToTop(fooCombined.Output))
+ }
+
+ barMod := ctx.ModuleForTests("bar", "android_common")
+ bar := barMod.Output("javac/bar.jar")
+ barCombined := barMod.Output("combined/bar.jar")
+
+ // Confirm that bar uses the Implementation from gen and headerJars from foo.
+ if len(barCombined.Inputs) != 2 ||
+ barCombined.Inputs[0].String() != bar.Output.String() ||
+ barCombined.Inputs[1].String() != gen.Output.String() {
+ t.Errorf("bar combined jar inputs %v is not [%q, %q]",
+ barCombined.Inputs.Strings(), bar.Output.String(), gen.Output.String())
+ }
+
+ bazMod := ctx.ModuleForTests("baz", "android_common")
+ baz := bazMod.Output("javac/baz.jar")
+
+ string_in_list := func(s string, l []string) bool {
+ for _, v := range l {
+ if s == v {
+ return true
+ }
+ }
+ return false
+ }
+
+ // Confirm that baz uses the headerJars from foo.
+ bazImplicitsRel := android.PathsRelativeToTop(baz.Implicits)
+ for _, v := range android.PathsRelativeToTop(fooHeaderJars) {
+ if !string_in_list(v, bazImplicitsRel) {
+ t.Errorf("baz Implicits %v does not contain %q", bazImplicitsRel, v)
+ }
+ }
+}
+
+func TestJarGenruleCombinerMulti(t *testing.T) {
+ t.Parallel()
+ t.Helper()
+ ctx := prepareForJavaTest.RunTestWithBp(t, `
+ java_library {
+ name: "foo1",
+ srcs: ["foo1_a.java"],
+ }
+
+ java_library {
+ name: "foo2",
+ srcs: ["foo2_a.java"],
+ }
+
+ java_genrule {
+ name: "gen1",
+ tool_files: ["b.java"],
+ cmd: "$(location b.java) $(in) $(out)",
+ out: ["gen1.jar"],
+ srcs: [":foo1"],
+ }
+
+ java_genrule {
+ name: "gen2",
+ tool_files: ["b.java"],
+ cmd: "$(location b.java) $(in) $(out)",
+ out: ["gen2.jar"],
+ srcs: [":foo2"],
+ }
+
+ // Combine multiple java_genrule modules.
+ java_genrule_combiner {
+ name: "jarcomb",
+ static_libs: ["gen1", "gen2"],
+ headers: ["foo1", "foo2"],
+ }
+
+ java_library {
+ name: "bar",
+ static_libs: ["jarcomb"],
+ srcs: ["c.java"],
+ }
+
+ java_library {
+ name: "baz",
+ libs: ["jarcomb"],
+ srcs: ["c.java"],
+ }
+ `).TestContext
+
+ gen1Mod := ctx.ModuleForTests("gen1", "android_common")
+ gen1 := gen1Mod.Output("gen1.jar")
+ gen2Mod := ctx.ModuleForTests("gen2", "android_common")
+ gen2 := gen2Mod.Output("gen2.jar")
+
+ jarcombMod := ctx.ModuleForTests("jarcomb", "android_common")
+ jarcomb := jarcombMod.Output("combined/jarcomb.jar")
+ jarcombTurbine := jarcombMod.Output("turbine-combined/jarcomb.jar")
+ _ = jarcombTurbine
+ jarcombInfo, _ := android.OtherModuleProvider(ctx.OtherModuleProviderAdaptor(), jarcombMod.Module(), JavaInfoProvider)
+ _ = jarcombInfo
+ jarcombOutputFiles, _ := android.OtherModuleProvider(ctx.OtherModuleProviderAdaptor(), jarcombMod.Module(), android.OutputFilesProvider)
+ jarcombHeaderJars := jarcombOutputFiles.TaggedOutputFiles[".hjar"]
+
+ if len(jarcomb.Inputs) != 2 ||
+ jarcomb.Inputs[0].String() != gen1.Output.String() ||
+ jarcomb.Inputs[1].String() != gen2.Output.String() {
+ t.Errorf("jarcomb inputs %v are not [%q, %q]",
+ jarcomb.Inputs.Strings(), gen1.Output.String(), gen2.Output.String())
+ }
+
+ if len(jarcombHeaderJars) != 1 ||
+ android.PathRelativeToTop(jarcombHeaderJars[0]) != android.PathRelativeToTop(jarcombTurbine.Output) {
+ t.Errorf("jarcomb Header jars %v is not [%q]",
+ android.PathsRelativeToTop(jarcombHeaderJars), android.PathRelativeToTop(jarcombTurbine.Output))
+ }
+
+ barMod := ctx.ModuleForTests("bar", "android_common")
+ bar := barMod.Output("javac/bar.jar")
+ barCombined := barMod.Output("combined/bar.jar")
+
+ // Confirm that bar uses the Implementation and Headers from jarcomb.
+ if len(barCombined.Inputs) != 2 ||
+ barCombined.Inputs[0].String() != bar.Output.String() ||
+ barCombined.Inputs[1].String() != jarcomb.Output.String() {
+ t.Errorf("bar combined jar inputs %v is not [%q, %q]",
+ barCombined.Inputs.Strings(), bar.Output.String(), jarcomb.Output.String())
+ }
+
+ bazMod := ctx.ModuleForTests("baz", "android_common")
+ baz := bazMod.Output("javac/baz.jar")
+
+ string_in_list := func(s string, l []string) bool {
+ for _, v := range l {
+ if s == v {
+ return true
+ }
+ }
+ return false
+ }
+
+ // Confirm that baz uses the headerJars from foo.
+ bazImplicitsRel := android.PathsRelativeToTop(baz.Implicits)
+ for _, v := range android.PathsRelativeToTop(jarcombHeaderJars) {
+ if !string_in_list(v, bazImplicitsRel) {
+ t.Errorf("baz Implicits %v does not contain %q", bazImplicitsRel, v)
+ }
+ }
+}
diff --git a/java/genrule_test.go b/java/genrule_test.go
index 1c294b2..b4e9d21 100644
--- a/java/genrule_test.go
+++ b/java/genrule_test.go
@@ -31,6 +31,7 @@
}
func TestGenruleCmd(t *testing.T) {
+ t.Parallel()
fs := map[string][]byte{
"tool": nil,
"foo": nil,
@@ -64,6 +65,7 @@
}
func TestJarGenrules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go
index afe8b4c..c14fdb7 100644
--- a/java/hiddenapi_singleton_test.go
+++ b/java/hiddenapi_singleton_test.go
@@ -44,6 +44,7 @@
)
func TestHiddenAPISingleton(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
FixtureConfigureBootJars("platform:foo"),
@@ -63,6 +64,7 @@
}
func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T) {
+ t.Parallel()
expectedErrorMessage := "module prebuilt_foo{os:android,arch:common} does not provide a dex jar"
android.GroupFixturePreparers(
@@ -86,6 +88,7 @@
}
func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
FixtureConfigureBootJars("platform:foo"),
@@ -105,6 +108,7 @@
}
func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
FixtureConfigureBootJars("platform:foo"),
@@ -134,6 +138,7 @@
}
func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
FixtureConfigureBootJars("platform:foo"),
@@ -163,6 +168,7 @@
}
func TestHiddenAPISingletonSdks(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
unbundledBuild bool
@@ -246,6 +252,7 @@
}
func TestHiddenAPISingletonWithPrebuiltCsvFile(t *testing.T) {
+ t.Parallel()
// The idea behind this test is to ensure that when the build is
// confugured with a PrebuiltHiddenApiDir that the rules for the
@@ -289,6 +296,7 @@
}
func TestHiddenAPIEncoding_JavaSdkLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
@@ -324,10 +332,7 @@
android.AssertPathRelativeToTopEquals(t, "encode embedded java_library", encodedDexJar, exportedDexJar)
}
- // The java_library embedded with the java_sdk_library must be dex encoded.
- t.Run("foo", func(t *testing.T) {
- expectedUnencodedDexJar := "out/soong/.intermediates/foo.impl/android_common/aligned/foo.jar"
- expectedEncodedDexJar := "out/soong/.intermediates/foo.impl/android_common/hiddenapi/foo.jar"
- checkDexEncoded(t, "foo", expectedUnencodedDexJar, expectedEncodedDexJar)
- })
+ expectedUnencodedDexJar := "out/soong/.intermediates/foo.impl/android_common/aligned/foo.jar"
+ expectedEncodedDexJar := "out/soong/.intermediates/foo.impl/android_common/hiddenapi/foo.jar"
+ checkDexEncoded(t, "foo", expectedUnencodedDexJar, expectedEncodedDexJar)
}
diff --git a/java/jacoco_test.go b/java/jacoco_test.go
index 1882908..58a091e 100644
--- a/java/jacoco_test.go
+++ b/java/jacoco_test.go
@@ -17,6 +17,7 @@
import "testing"
func TestJacocoFilterToSpecs(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name, in, out string
}{
@@ -54,6 +55,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
got, err := jacocoFilterToSpec(testCase.in)
if err != nil {
t.Error(err)
@@ -66,6 +68,7 @@
}
func TestJacocoFiltersToZipCommand(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
includes, excludes []string
@@ -96,6 +99,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
got := jacocoFiltersToZipCommand(testCase.includes, testCase.excludes)
if got != testCase.out {
t.Errorf("expected %q got %q", testCase.out, got)
diff --git a/java/java.go b/java/java.go
index d9a6b35..c1ce880 100644
--- a/java/java.go
+++ b/java/java.go
@@ -64,6 +64,7 @@
ctx.RegisterModuleType("java_api_library", ApiLibraryFactory)
ctx.RegisterModuleType("java_api_contribution", ApiContributionFactory)
ctx.RegisterModuleType("java_api_contribution_import", ApiContributionImportFactory)
+ ctx.RegisterModuleType("java_genrule_combiner", GenruleCombinerFactory)
// This mutator registers dependencies on dex2oat for modules that should be
// dexpreopted. This is done late when the final variants have been
@@ -373,7 +374,7 @@
ProvidesUsesLibInfo *ProvidesUsesLibInfo
- ModuleWithUsesLibraryInfo *ModuleWithUsesLibraryInfo
+ MissingOptionalUsesLibs []string
ModuleWithSdkDepInfo *ModuleWithSdkDepInfo
@@ -402,7 +403,12 @@
BuiltInstalled string
- BuiltInstalledForApex []dexpreopterInstall
+ // ApexSystemServerDexpreoptInstalls stores the list of dexpreopt artifacts if this is a system server
+ // jar in an apex.
+ ApexSystemServerDexpreoptInstalls []DexpreopterInstall
+
+ // ApexSystemServerDexJars stores the list of dex jars if this is a system server jar in an apex.
+ ApexSystemServerDexJars android.Paths
// The config is used for two purposes:
// - Passing dexpreopt information about libraries from Soong to Make. This is needed when
@@ -590,7 +596,7 @@
)
func IsLibDepTag(depTag blueprint.DependencyTag) bool {
- return depTag == libTag || depTag == sdkLibTag
+ return depTag == libTag
}
func IsStaticLibDepTag(depTag blueprint.DependencyTag) bool {
@@ -823,6 +829,8 @@
combinedExportedProguardFlagsFile android.Path
InstallMixin func(ctx android.ModuleContext, installPath android.Path) (extraInstallDeps android.InstallPaths)
+
+ apiXmlFile android.WritablePath
}
var _ android.ApexModule = (*Library)(nil)
@@ -1129,7 +1137,8 @@
javaInfo.BootDexJarPath = j.bootDexJarPath
javaInfo.UncompressDexState = j.uncompressDexState
javaInfo.Active = j.active
- javaInfo.BuiltInstalledForApex = j.builtInstalledForApex
+ javaInfo.ApexSystemServerDexpreoptInstalls = j.apexSystemServerDexpreoptInstalls
+ javaInfo.ApexSystemServerDexJars = j.apexSystemServerDexJars
javaInfo.BuiltInstalled = j.builtInstalled
javaInfo.ConfigPath = j.configPath
javaInfo.OutputProfilePathOnHost = j.outputProfilePathOnHost
@@ -1147,6 +1156,10 @@
setOutputFiles(ctx, j.Module)
j.javaLibraryModuleInfoJSON(ctx)
+
+ buildComplianceMetadata(ctx)
+
+ j.createApiXmlFile(ctx)
}
func (j *Library) javaLibraryModuleInfoJSON(ctx android.ModuleContext) *android.ModuleInfoJSON {
@@ -1170,11 +1183,34 @@
if j.hideApexVariantFromMake {
moduleInfoJSON.Disabled = true
- j.dexpreopter.ModuleInfoJSONForApex(ctx)
}
return moduleInfoJSON
}
+func buildComplianceMetadata(ctx android.ModuleContext) {
+ // Dump metadata that can not be done in android/compliance-metadata.go
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ builtFiles := ctx.GetOutputFiles().DefaultOutputFiles.Strings()
+ for _, paths := range ctx.GetOutputFiles().TaggedOutputFiles {
+ builtFiles = append(builtFiles, paths.Strings()...)
+ }
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.BUILT_FILES, android.FirstUniqueStrings(builtFiles))
+
+ // Static deps
+ staticDepNames := make([]string, 0)
+ staticDepFiles := android.Paths{}
+ ctx.VisitDirectDepsWithTag(staticLibTag, func(module android.Module) {
+ if dep, ok := android.OtherModuleProvider(ctx, module, JavaInfoProvider); ok {
+ staticDepNames = append(staticDepNames, module.Name())
+ staticDepFiles = append(staticDepFiles, dep.ImplementationJars...)
+ staticDepFiles = append(staticDepFiles, dep.HeaderJars...)
+ staticDepFiles = append(staticDepFiles, dep.ResourceJars...)
+ }
+ })
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEPS, android.FirstUniqueStrings(staticDepNames))
+ complianceMetadataInfo.SetListValue(android.ComplianceMetadataProp.STATIC_DEP_FILES, android.FirstUniqueStrings(staticDepFiles.Strings()))
+}
+
func (j *Library) getJarInstallDir(ctx android.ModuleContext) android.InstallPath {
var installDir android.InstallPath
if ctx.InstallInTestcases() {
@@ -1228,6 +1264,35 @@
}
}
+var apiXMLGeneratingApiSurfaces = []android.SdkKind{
+ android.SdkPublic,
+ android.SdkSystem,
+ android.SdkModule,
+ android.SdkSystemServer,
+ android.SdkTest,
+}
+
+func (j *Library) createApiXmlFile(ctx android.ModuleContext) {
+ if kind, ok := android.JavaLibraryNameToSdkKind(ctx.ModuleName()); ok && android.InList(kind, apiXMLGeneratingApiSurfaces) {
+ scopePrefix := AllApiScopes.matchingScopeFromSdkKind(kind).apiFilePrefix
+ j.apiXmlFile = android.PathForModuleOut(ctx, fmt.Sprintf("%sapi.xml", scopePrefix))
+ ctx.Build(pctx, android.BuildParams{
+ Rule: generateApiXMLRule,
+ // LOCAL_SOONG_CLASSES_JAR
+ Input: j.implementationAndResourcesJar,
+ Output: j.apiXmlFile,
+ })
+ }
+}
+
+var _ android.ModuleMakeVarsProvider = (*Library)(nil)
+
+func (j *Library) MakeVars(ctx android.MakeVarsModuleContext) {
+ if j.apiXmlFile != nil {
+ ctx.DistForGoal("dist_files", j.apiXmlFile)
+ }
+}
+
const (
aidlIncludeDir = "aidl"
javaDir = "java"
@@ -1857,8 +1922,8 @@
dataPath := android.DataPath{SrcPath: data}
ctx.InstallTestData(pathInTestCases, []android.DataPath{dataPath})
}
- if j.installFile != nil {
- ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.installFile)
+ if j.outputFile != nil {
+ ctx.InstallFile(pathInTestCases, ctx.ModuleName()+".jar", j.outputFile)
}
}
}
@@ -3173,6 +3238,8 @@
ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, "")
ctx.SetOutputFiles(android.Paths{j.combinedImplementationFile}, ".jar")
+
+ buildComplianceMetadata(ctx)
}
func (j *Import) maybeInstall(ctx android.ModuleContext, jarName string, outputFile android.Path) {
@@ -3646,11 +3713,11 @@
usesLibrary *usesLibrary) {
dep, ok := android.OtherModuleProvider(ctx, depModule, JavaInfoProvider)
- if !ok || dep.ModuleWithUsesLibraryInfo == nil {
+ if !ok {
return
}
- for _, lib := range dep.ModuleWithUsesLibraryInfo.UsesLibrary.usesLibraryProperties.Missing_optional_uses_libs {
+ for _, lib := range dep.MissingOptionalUsesLibs {
if !android.InList(lib, usesLibrary.usesLibraryProperties.Missing_optional_uses_libs) {
usesLibrary.usesLibraryProperties.Missing_optional_uses_libs =
append(usesLibrary.usesLibraryProperties.Missing_optional_uses_libs, lib)
@@ -3738,9 +3805,7 @@
}
if mwul, ok := module.(ModuleWithUsesLibrary); ok {
- javaInfo.ModuleWithUsesLibraryInfo = &ModuleWithUsesLibraryInfo{
- UsesLibrary: mwul.UsesLibrary(),
- }
+ javaInfo.MissingOptionalUsesLibs = mwul.UsesLibrary().usesLibraryProperties.Missing_optional_uses_libs
}
if mwsd, ok := module.(moduleWithSdkDep); ok {
diff --git a/java/java_test.go b/java/java_test.go
index 53d2f5c..de58237 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -117,6 +117,7 @@
// Test that the PrepareForTestWithJavaDefaultModules provides all the files that it uses by
// running it in a fixture that requires all source files to exist.
func TestPrepareForTestWithJavaDefaultModules(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestDisallowNonExistentPaths,
@@ -124,6 +125,7 @@
}
func TestJavaLinkType(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_library {
name: "foo",
@@ -212,6 +214,7 @@
}
func TestSimple(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
@@ -341,6 +344,7 @@
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
tt.preparer,
@@ -378,6 +382,7 @@
}
func TestExportedPlugins(t *testing.T) {
+ t.Parallel()
type Result struct {
library string
processors string
@@ -456,6 +461,7 @@
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_plugin {
name: "plugin",
@@ -484,6 +490,7 @@
}
func TestSdkVersionByPartition(t *testing.T) {
+ t.Parallel()
testJavaError(t, "sdk_version must have a value when the module is located at vendor or product", `
java_library {
name: "foo",
@@ -525,6 +532,7 @@
}
func TestArchSpecific(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -544,6 +552,7 @@
}
func TestBinary(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library_host {
name: "foo",
@@ -586,6 +595,7 @@
}
func TestTest(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_test_host {
name: "foo",
@@ -618,6 +628,7 @@
}
func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "target_library",
@@ -665,6 +676,7 @@
var _ android.ModuleErrorfContext = (*moduleErrorfTestCtx)(nil)
func TestPrebuilts(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -765,6 +777,7 @@
}
func TestPrebuiltStubsSources(t *testing.T) {
+ t.Parallel()
test := func(t *testing.T, sourcesPath string, expectedInputs []string) {
ctx, _ := testJavaWithFS(t, fmt.Sprintf(`
prebuilt_stubs_sources {
@@ -782,10 +795,12 @@
}
t.Run("empty/missing directory", func(t *testing.T) {
+ t.Parallel()
test(t, "empty-directory", nil)
})
t.Run("non-empty set of sources", func(t *testing.T) {
+ t.Parallel()
test(t, "stubs/sources", []string{
"stubs/sources/pkg/A.java",
"stubs/sources/pkg/B.java",
@@ -794,6 +809,7 @@
}
func TestDefaults(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_defaults {
name: "defaults",
@@ -869,6 +885,7 @@
}
func TestResources(t *testing.T) {
+ t.Parallel()
var table = []struct {
name string
prop string
@@ -940,6 +957,7 @@
for _, test := range table {
t.Run(test.name, func(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -975,6 +993,7 @@
}
func TestIncludeSrcs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -1042,6 +1061,7 @@
}
func TestGeneratedSources(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -1078,6 +1098,7 @@
}
func TestTurbine(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest, FixtureWithPrebuiltApis(map[string][]string{"14": {"foo"}})).
RunTestWithBp(t, `
@@ -1119,6 +1140,7 @@
}
func TestSharding(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "bar",
@@ -1137,6 +1159,7 @@
}
func TestExcludeFileGroupInSrcs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1163,6 +1186,7 @@
}
func TestJavaLibraryOutputFiles(t *testing.T) {
+ t.Parallel()
testJavaWithFS(t, "", map[string][]byte{
"libcore/Android.bp": []byte(`
java_library {
@@ -1180,6 +1204,7 @@
}
func TestJavaImportOutputFiles(t *testing.T) {
+ t.Parallel()
testJavaWithFS(t, "", map[string][]byte{
"libcore/Android.bp": []byte(`
java_import {
@@ -1196,6 +1221,7 @@
}
func TestJavaImport(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "source_library",
@@ -1323,6 +1349,7 @@
}
func TestCompilerFlags(t *testing.T) {
+ t.Parallel()
for _, testCase := range compilerFlagsTestCases {
ctx := &mockContext{result: true}
CheckKotlincFlags(ctx, []string{testCase.in})
@@ -1353,7 +1380,9 @@
}
func TestPatchModule(t *testing.T) {
+ t.Parallel()
t.Run("Java language level 8", func(t *testing.T) {
+ t.Parallel()
// Test with legacy javac -source 1.8 -target 1.8
bp := `
java_library {
@@ -1386,6 +1415,7 @@
})
t.Run("Java language level 9", func(t *testing.T) {
+ t.Parallel()
// Test with default javac -source 9 -target 9
bp := `
java_library {
@@ -1426,6 +1456,7 @@
}
func TestJavaLibraryWithSystemModules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "lib-with-source-system-modules",
@@ -1482,6 +1513,7 @@
}
func TestAidlExportIncludeDirsFromImports(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1506,6 +1538,7 @@
}
func TestAidlFlagsArePassedToTheAidlCompiler(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1522,6 +1555,7 @@
}
func TestAidlFlagsWithMinSdkVersion(t *testing.T) {
+ t.Parallel()
fixture := android.GroupFixturePreparers(
prepareForJavaTest, FixtureWithPrebuiltApis(map[string][]string{"14": {"foo"}}))
@@ -1535,6 +1569,7 @@
{"system_current", `sdk_version: "system_current"`, "current"},
} {
t.Run(tc.name, func(t *testing.T) {
+ t.Parallel()
ctx := fixture.RunTestWithBp(t, `
java_library {
name: "foo",
@@ -1552,6 +1587,7 @@
}
func TestAidlFlagsMinSdkVersionDroidstubs(t *testing.T) {
+ t.Parallel()
bpTemplate := `
droidstubs {
name: "foo-stubs",
@@ -1585,6 +1621,7 @@
}
func TestAidlEnforcePermissions(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1601,6 +1638,7 @@
}
func TestAidlEnforcePermissionsException(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1621,6 +1659,7 @@
}
func TestDataNativeBinaries(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
android.PrepareForTestWithAllowMissingDependencies).RunTestWithBp(t, `
@@ -1646,6 +1685,7 @@
}
func TestDefaultInstallable(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_test_host {
name: "foo"
@@ -1659,6 +1699,7 @@
}
func TestErrorproneEnabled(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1687,6 +1728,7 @@
}
func TestErrorproneDisabled(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
@@ -1721,6 +1763,7 @@
}
func TestErrorproneEnabledOnlyByEnvironmentVariable(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
@@ -1751,6 +1794,7 @@
}
func TestDataDeviceBinsBuildsDeviceBinary(t *testing.T) {
+ t.Parallel()
testCases := []struct {
dataDeviceBinType string
depCompileMultilib string
@@ -1887,6 +1931,7 @@
testName := fmt.Sprintf(`data_device_bins_%s with compile_multilib:"%s"`, tc.dataDeviceBinType, tc.depCompileMultilib)
t.Run(testName, func(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(PrepareForIntegrationTestWithJava).
ExtendWithErrorHandler(errorHandler).
RunTestWithBp(t, bp)
@@ -1922,6 +1967,7 @@
}
func TestDeviceBinaryWrapperGeneration(t *testing.T) {
+ t.Parallel()
// Scenario 1: java_binary has main_class property in its bp
ctx, _ := testJava(t, `
java_binary {
@@ -1945,6 +1991,7 @@
}
func TestJavaApiContributionEmptyApiFile(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureMergeEnv(
@@ -1968,6 +2015,7 @@
}
func TestJavaApiLibraryAndProviderLink(t *testing.T) {
+ t.Parallel()
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2034,6 +2082,7 @@
}
func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
+ t.Parallel()
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2142,6 +2191,7 @@
}
func TestJavaApiLibraryJarGeneration(t *testing.T) {
+ t.Parallel()
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2208,6 +2258,7 @@
}
func TestJavaApiLibraryLibsLink(t *testing.T) {
+ t.Parallel()
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2296,6 +2347,7 @@
}
func TestJavaApiLibraryStaticLibsLink(t *testing.T) {
+ t.Parallel()
provider_bp_a := `
java_api_contribution {
name: "foo1",
@@ -2383,6 +2435,7 @@
}
func TestTransitiveSrcFiles(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "a",
@@ -2406,6 +2459,7 @@
}
func TestTradefedOptions(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
java_test_host {
name: "foo",
@@ -2430,6 +2484,7 @@
}
func TestTestRunnerOptions(t *testing.T) {
+ t.Parallel()
result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
java_test_host {
name: "foo",
@@ -2454,6 +2509,7 @@
}
func TestJavaLibraryWithResourcesStem(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -2473,6 +2529,7 @@
}
func TestHeadersOnly(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -2491,6 +2548,7 @@
}
func TestJavaApiContributionImport(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureMergeEnv(
@@ -2519,6 +2577,7 @@
}
func TestJavaApiLibraryApiFilesSorting(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_api_library {
name: "foo",
@@ -2547,6 +2606,7 @@
}
func TestSdkLibraryProvidesSystemModulesToApiLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -2576,6 +2636,7 @@
}
func TestApiLibraryDroidstubsDependency(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -2622,6 +2683,7 @@
}
func TestDisableFromTextStubForCoverageBuild(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -2651,6 +2713,7 @@
}
func TestMultiplePrebuilts(t *testing.T) {
+ t.Parallel()
bp := `
// an rdep
java_library {
@@ -2749,6 +2812,7 @@
}
func TestMultiplePlatformCompatConfigPrebuilts(t *testing.T) {
+ t.Parallel()
bp := `
// multiple variations of platform_compat_config
// source
@@ -2809,6 +2873,7 @@
}
func TestApiLibraryAconfigDeclarations(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
@@ -2919,6 +2984,7 @@
// Don't allow setting test-only on things that are always tests or never tests.
func TestInvalidTestOnlyTargets(t *testing.T) {
+ t.Parallel()
testCases := []string{
` java_test { name: "java-test", test_only: true, srcs: ["foo.java"], } `,
` java_test_host { name: "java-test-host", test_only: true, srcs: ["foo.java"], } `,
@@ -2954,6 +3020,7 @@
}
func TestJavaLibHostWithStem(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library_host {
name: "foo",
@@ -2972,6 +3039,7 @@
}
func TestJavaLibWithStem(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -2989,6 +3057,7 @@
}
func TestJavaLibraryOutputFilesRel(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -3034,6 +3103,7 @@
}
func TestCoverage(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
prepareForTestWithFrameworkJacocoInstrumentation,
@@ -3104,6 +3174,7 @@
// Test that a dependency edge is created to the matching variant of a native library listed in `jni_libs` of java_binary
func TestNativeRequiredDepOfJavaBinary(t *testing.T) {
+ t.Parallel()
findDepsOfModule := func(ctx *android.TestContext, module android.Module, depName string) []blueprint.Module {
var ret []blueprint.Module
ctx.VisitDirectDeps(module, func(dep blueprint.Module) {
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index 1435000..2cbf75b 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -22,6 +22,7 @@
)
func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t,
`
java_library {name: "Foo"}
@@ -42,6 +43,7 @@
}
func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t,
`
java_library {name: "Foo"}
@@ -62,6 +64,7 @@
}
func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t,
`
java_library {
@@ -79,6 +82,7 @@
}
func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t,
`
java_library {
@@ -98,6 +102,7 @@
}
func TestCollectJavaLibraryWithJarJarRules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t,
`
java_library {
@@ -117,6 +122,7 @@
}
func TestCollectJavaLibraryLinkingAgainstVersionedSdk(t *testing.T) {
+ t.Parallel()
ctx := android.GroupFixturePreparers(
prepareForJavaTest,
FixtureWithPrebuiltApis(map[string][]string{
diff --git a/java/kotlin_test.go b/java/kotlin_test.go
index ad8734d..3a20335 100644
--- a/java/kotlin_test.go
+++ b/java/kotlin_test.go
@@ -24,6 +24,7 @@
)
func TestKotlin(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
@@ -234,6 +235,7 @@
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
tt.preparer,
@@ -275,6 +277,7 @@
}
func TestKapt(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
@@ -303,6 +306,7 @@
}
`
t.Run("", func(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, bp)
buildOS := ctx.Config().BuildOS.String()
@@ -384,6 +388,7 @@
})
t.Run("errorprone", func(t *testing.T) {
+ t.Parallel()
env := map[string]string{
"RUN_ERROR_PRONE": "true",
}
@@ -434,6 +439,7 @@
}
func TestKaptEncodeFlags(t *testing.T) {
+ t.Parallel()
// Compares the kaptEncodeFlags against the results of the example implementation at
// https://kotlinlang.org/docs/reference/kapt.html#apjavac-options-encoding
tests := []struct {
@@ -484,6 +490,7 @@
for i, test := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
+ t.Parallel()
got := kaptEncodeFlags(test.in)
if got != test.out {
t.Errorf("\nwant %q\n got %q", test.out, got)
@@ -493,6 +500,7 @@
}
func TestKotlinCompose(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
@@ -544,6 +552,7 @@
}
func TestKotlinPlugin(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
).RunTestWithBp(t, `
diff --git a/java/lint_test.go b/java/lint_test.go
index 617dc54..f7d3229 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -22,6 +22,7 @@
)
func TestJavaLintDoesntUseBaselineImplicitly(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -46,6 +47,7 @@
}
func TestJavaLintRequiresCustomLintFileToExist(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.PrepareForTestDisallowNonExistentPaths,
@@ -65,6 +67,7 @@
}
func TestJavaLintUsesCorrectBpConfig(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -101,6 +104,7 @@
}
func TestJavaLintBypassUpdatableChecks(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
bp string
@@ -144,6 +148,7 @@
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
+ t.Parallel()
errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.error)
android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules).
ExtendWithErrorHandler(errorHandler).
@@ -153,6 +158,7 @@
}
func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "foo",
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index 152eb1e..86062d4 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -15,6 +15,8 @@
package java
import (
+ "github.com/google/blueprint"
+
"android/soong/android"
"android/soong/dexpreopt"
)
@@ -33,9 +35,18 @@
platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"}
platformBootclasspathBootJarDepTag = bootclasspathDependencyTag{name: "platform-boot-jar"}
platformBootclasspathApexBootJarDepTag = bootclasspathDependencyTag{name: "apex-boot-jar"}
- platformBootclasspathImplLibDepTag = dependencyTag{name: "impl-lib-tag"}
)
+type platformBootclasspathImplLibDepTagType struct {
+ blueprint.BaseDependencyTag
+}
+
+func (p platformBootclasspathImplLibDepTagType) ExcludeFromVisibilityEnforcement() {}
+
+var platformBootclasspathImplLibDepTag platformBootclasspathImplLibDepTagType
+
+var _ android.ExcludeFromVisibilityEnforcementTag = platformBootclasspathImplLibDepTag
+
type platformBootclasspathModule struct {
android.ModuleBase
ClasspathFragmentBase
diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go
index 1f691a0..db85579 100644
--- a/java/platform_bootclasspath_test.go
+++ b/java/platform_bootclasspath_test.go
@@ -27,6 +27,7 @@
)
func TestPlatformBootclasspath(t *testing.T) {
+ t.Parallel()
preparer := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
FixtureConfigureBootJars("platform:foo", "system_ext:bar"),
@@ -81,6 +82,7 @@
`)
t.Run("missing", func(t *testing.T) {
+ t.Parallel()
preparer.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`"platform-bootclasspath" depends on undefined module "foo"`)).
RunTest(t)
@@ -96,6 +98,7 @@
android.AssertArrayString(t, "srcjar inputs", expected, srcjar.Implicits.Strings())
}
t.Run("source", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
preparer,
addSourceBootclassPathModule,
@@ -112,6 +115,7 @@
})
t.Run("prebuilt", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
preparer,
addPrebuiltBootclassPathModule,
@@ -128,6 +132,7 @@
})
t.Run("source+prebuilt - source preferred", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
preparer,
addSourceBootclassPathModule,
@@ -145,6 +150,7 @@
})
t.Run("source+prebuilt - prebuilt preferred", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
preparer,
addSourceBootclassPathModule,
@@ -162,6 +168,7 @@
})
t.Run("dex import", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
preparer,
android.FixtureAddTextFile("deximport/Android.bp", `
@@ -184,6 +191,7 @@
}
func TestPlatformBootclasspathVariant(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
android.FixtureWithRootAndroidBp(`
@@ -198,6 +206,7 @@
}
func TestPlatformBootclasspath_ClasspathFragmentPaths(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
android.FixtureWithRootAndroidBp(`
@@ -213,6 +222,7 @@
}
func TestPlatformBootclasspathModule_AndroidMkEntries(t *testing.T) {
+ t.Parallel()
preparer := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
android.FixtureWithRootAndroidBp(`
@@ -223,6 +233,7 @@
)
t.Run("AndroidMkEntries", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule)
@@ -232,6 +243,7 @@
})
t.Run("hiddenapi-flags-entry", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
p := result.Module("platform-bootclasspath", "android_common").(*platformBootclasspathModule)
@@ -243,6 +255,7 @@
})
t.Run("classpath-fragment-entry", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
want := map[string][]string{
@@ -267,6 +280,7 @@
}
func TestPlatformBootclasspath_Dist(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
FixtureConfigureBootJars("platform:foo", "platform:bar"),
@@ -310,6 +324,7 @@
}
func TestPlatformBootclasspath_HiddenAPIMonolithicFiles(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
hiddenApiFixtureFactory,
PrepareForTestWithJavaSdkLibraryFiles,
diff --git a/java/platform_compat_config_test.go b/java/platform_compat_config_test.go
index f7529a7..72f81e0 100644
--- a/java/platform_compat_config_test.go
+++ b/java/platform_compat_config_test.go
@@ -21,6 +21,7 @@
)
func TestPlatformCompatConfig(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithPlatformCompatConfig,
android.FixtureWithRootAndroidBp(`
diff --git a/java/plugin_test.go b/java/plugin_test.go
index dc29b1c..95f4aca 100644
--- a/java/plugin_test.go
+++ b/java/plugin_test.go
@@ -19,6 +19,7 @@
)
func TestNoPlugin(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -43,6 +44,7 @@
}
func TestPlugin(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -82,6 +84,7 @@
}
func TestPluginGeneratesApi(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
diff --git a/java/prebuilt_apis_test.go b/java/prebuilt_apis_test.go
index b6fb2c6..c6a5913 100644
--- a/java/prebuilt_apis_test.go
+++ b/java/prebuilt_apis_test.go
@@ -29,6 +29,7 @@
}
func TestPrebuiltApis_SystemModulesCreation(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
FixtureWithPrebuiltApis(map[string][]string{
@@ -61,6 +62,7 @@
}
func TestPrebuiltApis_WithExtensions(t *testing.T) {
+ t.Parallel()
runTestWithBaseExtensionLevel := func(v int) (foo_input, bar_input, baz_input string) {
result := android.GroupFixturePreparers(
prepareForJavaTest,
@@ -101,6 +103,7 @@
}
func TestPrebuiltApis_WithIncrementalApi(t *testing.T) {
+ t.Parallel()
runTestWithIncrementalApi := func() (foo_input, bar_input, baz_input string) {
result := android.GroupFixturePreparers(
prepareForJavaTest,
diff --git a/java/proto_test.go b/java/proto_test.go
index d1cb714..5b184b6 100644
--- a/java/proto_test.go
+++ b/java/proto_test.go
@@ -28,6 +28,7 @@
`
func TestProtoStream(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "java-stream-protos",
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
index f7fe8e3..ac4f147 100644
--- a/java/ravenwood_test.go
+++ b/java/ravenwood_test.go
@@ -103,6 +103,7 @@
var installPathPrefix = "out/host/linux-x86/testcases"
func TestRavenwoodRuntime(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("requires linux")
}
@@ -133,6 +134,7 @@
}
func TestRavenwoodTest(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("requires linux")
}
diff --git a/java/robolectric.go b/java/robolectric.go
index ed3fc9a..43e17f9 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -144,20 +144,25 @@
r.forceOSType = ctx.Config().BuildOS
r.forceArchType = ctx.Config().BuildArch
- var options []tradefed.Option
- options = append(options, tradefed.Option{Name: "java-flags", Value: "-Drobolectric=true"})
+ var extraTestRunnerOptions []tradefed.Option
+ extraTestRunnerOptions = append(extraTestRunnerOptions, tradefed.Option{Name: "java-flags", Value: "-Drobolectric=true"})
if proptools.BoolDefault(r.robolectricProperties.Strict_mode, true) {
- options = append(options, tradefed.Option{Name: "java-flags", Value: "-Drobolectric.strict.mode=true"})
+ extraTestRunnerOptions = append(extraTestRunnerOptions, tradefed.Option{Name: "java-flags", Value: "-Drobolectric.strict.mode=true"})
}
+ var extraOptions []tradefed.Option
+ var javaHome = ctx.Config().Getenv("ANDROID_JAVA_HOME")
+ extraOptions = append(extraOptions, tradefed.Option{Name: "java-folder", Value: javaHome})
+
r.testConfig = tradefed.AutoGenTestConfig(ctx, tradefed.AutoGenTestConfigOptions{
- TestConfigProp: r.testProperties.Test_config,
- TestConfigTemplateProp: r.testProperties.Test_config_template,
- TestSuites: r.testProperties.Test_suites,
- TestRunnerOptions: options,
- AutoGenConfig: r.testProperties.Auto_gen_config,
- DeviceTemplate: "${RobolectricTestConfigTemplate}",
- HostTemplate: "${RobolectricTestConfigTemplate}",
+ TestConfigProp: r.testProperties.Test_config,
+ TestConfigTemplateProp: r.testProperties.Test_config_template,
+ TestSuites: r.testProperties.Test_suites,
+ OptionsForAutogenerated: extraOptions,
+ TestRunnerOptions: extraTestRunnerOptions,
+ AutoGenConfig: r.testProperties.Auto_gen_config,
+ DeviceTemplate: "${RobolectricTestConfigTemplate}",
+ HostTemplate: "${RobolectricTestConfigTemplate}",
})
r.data = android.PathsForModuleSrc(ctx, r.testProperties.Data)
r.data = append(r.data, android.PathsForModuleSrc(ctx, r.testProperties.Device_common_data)...)
diff --git a/java/robolectric_test.go b/java/robolectric_test.go
index 78326ab..ad0613e 100644
--- a/java/robolectric_test.go
+++ b/java/robolectric_test.go
@@ -71,6 +71,7 @@
)
func TestRobolectricJniTest(t *testing.T) {
+ t.Parallel()
if runtime.GOOS != "linux" {
t.Skip("requires linux")
}
diff --git a/java/rro.go b/java/rro.go
index 44d5564..d9f4ff7 100644
--- a/java/rro.go
+++ b/java/rro.go
@@ -206,6 +206,8 @@
android.SetProvider(ctx, FlagsPackagesProvider, FlagsPackages{
AconfigTextFiles: aconfigTextFilePaths,
})
+
+ buildComplianceMetadata(ctx)
}
func (r *RuntimeResourceOverlay) SdkVersion(ctx android.EarlyModuleContext) android.SdkSpec {
diff --git a/java/rro_test.go b/java/rro_test.go
index b946511..1978ad6 100644
--- a/java/rro_test.go
+++ b/java/rro_test.go
@@ -24,6 +24,7 @@
)
func TestRuntimeResourceOverlay(t *testing.T) {
+ t.Parallel()
fs := android.MockFS{
"baz/res/res/values/strings.xml": nil,
"bar/res/res/values/strings.xml": nil,
@@ -129,6 +130,7 @@
}
func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureModifyConfig(android.SetKatiEnabledForTests),
diff --git a/java/sdk.go b/java/sdk.go
index bb2aa8d..4960ab5 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -390,4 +390,8 @@
ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
ctx.Strict("API_FINGERPRINT", android.ApiFingerprintPath(ctx).String())
+
+ if ctx.Config().BuildOS == android.Linux {
+ ctx.DistForGoals([]string{"sdk", "droidcore"}, android.ApiFingerprintPath(ctx))
+ }
}
diff --git a/java/sdk_library.go b/java/sdk_library.go
index 05a5b49..b6bac2d 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -316,6 +316,15 @@
return name
}
+func (scopes apiScopes) matchingScopeFromSdkKind(kind android.SdkKind) *apiScope {
+ for _, scope := range scopes {
+ if scope.kind == kind {
+ return scope
+ }
+ }
+ return nil
+}
+
var (
scopeByName = make(map[string]*apiScope)
allScopeNames []string
@@ -1246,7 +1255,8 @@
commonToSdkLibraryAndImport
- builtInstalledForApex []dexpreopterInstall
+ apexSystemServerDexpreoptInstalls []DexpreopterInstall
+ apexSystemServerDexJars android.Paths
}
func (module *SdkLibrary) generateTestAndSystemScopesByDefault() bool {
@@ -1501,7 +1511,8 @@
module.dexJarFile = makeDexJarPathFromPath(module.implLibraryInfo.DexJarFile.Path())
module.headerJarFile = module.implLibraryInfo.HeaderJars[0]
module.implementationAndResourcesJar = module.implLibraryInfo.ImplementationAndResourcesJars[0]
- module.builtInstalledForApex = module.implLibraryInfo.BuiltInstalledForApex
+ module.apexSystemServerDexpreoptInstalls = module.implLibraryInfo.ApexSystemServerDexpreoptInstalls
+ module.apexSystemServerDexJars = module.implLibraryInfo.ApexSystemServerDexJars
module.dexpreopter.configPath = module.implLibraryInfo.ConfigPath
module.dexpreopter.outputProfilePathOnHost = module.implLibraryInfo.OutputProfilePathOnHost
@@ -1584,8 +1595,12 @@
ctx.SetOutputFiles(info.GeneratedSrcjars, ".generated_srcjars")
}
-func (module *SdkLibrary) BuiltInstalledForApex() []dexpreopterInstall {
- return module.builtInstalledForApex
+func (module *SdkLibrary) ApexSystemServerDexpreoptInstalls() []DexpreopterInstall {
+ return module.apexSystemServerDexpreoptInstalls
+}
+
+func (module *SdkLibrary) ApexSystemServerDexJars() android.Paths {
+ return module.apexSystemServerDexJars
}
func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go
index 6031d72..0aed4b8 100644
--- a/java/sdk_library_test.go
+++ b/java/sdk_library_test.go
@@ -25,6 +25,7 @@
)
func TestJavaSdkLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -187,6 +188,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -236,6 +238,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary_Validation_ValidVersion(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -263,6 +266,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary_Validation_AtLeastTAttributes(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -292,6 +296,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary_Validation_MinAndMaxDeviceSdk(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -319,6 +324,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary_Validation_MinAndMaxDeviceSdkAndModuleMinSdk(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -347,6 +353,7 @@
}
func TestJavaSdkLibrary_UpdatableLibrary_usesNewTag(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -370,6 +377,7 @@
}
func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -426,6 +434,7 @@
}
func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -455,6 +464,7 @@
}
func TestJavaSdkLibrary_AccessOutputFiles(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -478,6 +488,7 @@
}
func TestJavaSdkLibrary_AccessOutputFiles_NoAnnotations(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -503,6 +514,7 @@
}
func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -527,6 +539,7 @@
}
func TestJavaSdkLibrary_Deps(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -557,6 +570,7 @@
}
func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
+ t.Parallel()
prepareForJavaTest.RunTestWithBp(t, `
java_sdk_library_import {
name: "foo",
@@ -582,6 +596,7 @@
}
func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) {
+ t.Parallel()
bp := `
java_sdk_library_import {
name: "foo",
@@ -592,6 +607,7 @@
`
t.Run("stubs.source", func(t *testing.T) {
+ t.Parallel()
prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.stubs.source"`)).
RunTestWithBp(t, bp+`
@@ -607,6 +623,7 @@
})
t.Run("api.txt", func(t *testing.T) {
+ t.Parallel()
prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.api.txt"`)).
RunTestWithBp(t, bp+`
@@ -621,6 +638,7 @@
})
t.Run("removed-api.txt", func(t *testing.T) {
+ t.Parallel()
prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo" is not a SourceFileProducer or having valid output file for tag ".public.removed-api.txt"`)).
RunTestWithBp(t, bp+`
@@ -636,6 +654,7 @@
}
func TestJavaSdkLibrary_InvalidScopes(t *testing.T) {
+ t.Parallel()
prepareForJavaTest.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(`module "foo": enabled api scope "system" depends on disabled scope "public"`)).
RunTestWithBp(t, `
@@ -656,6 +675,7 @@
}
func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -674,6 +694,7 @@
}
func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -694,6 +715,7 @@
}
func TestJavaSdkLibrary_SystemServer(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -714,6 +736,7 @@
}
func TestJavaSdkLibrary_SystemServer_AccessToStubScopeLibs(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -788,6 +811,7 @@
}
func TestJavaSdkLibraryImport(t *testing.T) {
+ t.Parallel()
result := prepareForJavaTest.RunTestWithBp(t, `
java_library {
name: "foo",
@@ -844,6 +868,7 @@
}
func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -986,7 +1011,9 @@
}
func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
+ t.Parallel()
t.Run("prefer", func(t *testing.T) {
+ t.Parallel()
testJavaSdkLibraryImport_Preferred(t, "prefer: true,", android.NullFixturePreparer)
})
}
@@ -994,6 +1021,7 @@
// If a module is listed in `mainline_module_contributions, it should be used
// It will supersede any other source vs prebuilt selection mechanism like `prefer` attribute
func TestSdkLibraryImport_MetadataModuleSupersedesPreferred(t *testing.T) {
+ t.Parallel()
bp := `
apex_contributions {
name: "my_mainline_module_contributions",
@@ -1113,6 +1141,7 @@
}
func TestJavaSdkLibraryDist(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
PrepareForTestWithJavaBuildComponents,
PrepareForTestWithJavaDefaultModules,
@@ -1179,6 +1208,7 @@
for _, tt := range testCases {
t.Run(tt.module, func(t *testing.T) {
+ t.Parallel()
m := result.ModuleForTests(apiScopePublic.exportableStubsLibraryModuleName(tt.module), "android_common").Module().(*Library)
dists := m.Dists()
if len(dists) != 1 {
@@ -1195,6 +1225,7 @@
}
func TestSdkLibrary_CheckMinSdkVersion(t *testing.T) {
+ t.Parallel()
preparer := android.GroupFixturePreparers(
PrepareForTestWithJavaBuildComponents,
PrepareForTestWithJavaDefaultModules,
@@ -1279,6 +1310,7 @@
}
func TestJavaSdkLibrary_StubOnlyLibs_PassedToDroidstubs(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1306,6 +1338,7 @@
}
func TestJavaSdkLibrary_Scope_Libs_PassedToDroidstubs(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1333,6 +1366,7 @@
}
func TestJavaSdkLibrary_ApiLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1383,6 +1417,7 @@
}
func TestStaticDepStubLibrariesVisibility(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1412,6 +1447,7 @@
}
func TestSdkLibraryDependency(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1444,6 +1480,7 @@
}
func TestSdkLibraryExportableStubsLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1494,6 +1531,7 @@
// For java libraries depending on java_sdk_library(_import) via libs, assert that
// rdep gets stubs of source if source is listed in apex_contributions and prebuilt has prefer (legacy mechanism)
func TestStubResolutionOfJavaSdkLibraryInLibs(t *testing.T) {
+ t.Parallel()
bp := `
apex_contributions {
name: "my_mainline_module_contributions",
@@ -1547,6 +1585,7 @@
// test that rdep gets resolved to the correct version of a java_sdk_library (source or a specific prebuilt)
func TestMultipleSdkLibraryPrebuilts(t *testing.T) {
+ t.Parallel()
bp := `
apex_contributions {
name: "my_mainline_module_contributions",
@@ -1632,6 +1671,7 @@
}
func TestStubLinkType(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1668,6 +1708,7 @@
}
func TestSdkLibDirectDependency(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
@@ -1732,6 +1773,7 @@
}
func TestSdkLibDirectDependencyWithPrebuiltSdk(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForJavaTest,
PrepareForTestWithJavaSdkLibraryFiles,
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 9bfe6a2..e926307 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -53,6 +53,7 @@
}
func TestClasspath(t *testing.T) {
+ t.Parallel()
const frameworkAidl = "-I" + defaultJavaDir + "/framework/aidl"
var classpathTestcases = []classpathTestCase{
{
@@ -388,17 +389,18 @@
},
}
- t.Parallel()
t.Run("basic", func(t *testing.T) {
t.Parallel()
testClasspathTestCases(t, classpathTestcases, false, false)
})
t.Run("Always_use_prebuilt_sdks=true", func(t *testing.T) {
+ t.Parallel()
testClasspathTestCases(t, classpathTestcases, true, false)
})
t.Run("UseTransitiveJarsInClasspath", func(t *testing.T) {
+ t.Parallel()
testClasspathTestCases(t, classpathTestcases, false, true)
})
}
@@ -571,6 +573,7 @@
// Test with legacy javac -source 1.8 -target 1.8
t.Run("Java language level 8", func(t *testing.T) {
+ t.Parallel()
result := fixtureFactory.RunTestWithBp(t, bpJava8)
checkClasspath(t, result, true /* isJava8 */)
@@ -584,6 +587,7 @@
// Test with default javac -source 9 -target 9
t.Run("Java language level 9", func(t *testing.T) {
+ t.Parallel()
result := fixtureFactory.RunTestWithBp(t, bp)
checkClasspath(t, result, false /* isJava8 */)
@@ -602,6 +606,7 @@
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 8 -target 8
t.Run("REL + Java language level 8", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bpJava8)
@@ -610,6 +615,7 @@
// Test again with PLATFORM_VERSION_CODENAME=REL, javac -source 9 -target 9
t.Run("REL + Java language level 9", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
fixtureFactory, prepareWithPlatformVersionRel).RunTestWithBp(t, bp)
diff --git a/java/sdk_version_test.go b/java/sdk_version_test.go
index 88351d2..6f0370a 100644
--- a/java/sdk_version_test.go
+++ b/java/sdk_version_test.go
@@ -25,6 +25,7 @@
}
func TestSystemSdkFromVendor(t *testing.T) {
+ t.Parallel()
fixtures := android.GroupFixturePreparers(
PrepareForTestWithJavaDefaultModules,
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
diff --git a/java/system_modules_test.go b/java/system_modules_test.go
index b05b0e4..b7a99b5 100644
--- a/java/system_modules_test.go
+++ b/java/system_modules_test.go
@@ -51,6 +51,7 @@
`)
func TestJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForJavaTest, addSourceSystemModules).RunTest(t)
// check the existence of the source module
@@ -78,6 +79,7 @@
`)
func TestJavaSystemModulesImport(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForJavaTest, addPrebuiltSystemModules).RunTest(t)
// check the existence of the renamed prebuilt module
@@ -90,6 +92,7 @@
}
func TestJavaSystemModulesMixSourceAndPrebuilt(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForJavaTest,
addSourceSystemModules,
@@ -114,6 +117,7 @@
}
func TestMultipleSystemModulesPrebuilts(t *testing.T) {
+ t.Parallel()
bp := `
// an rdep
java_library {
diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go
index 3176ad9..f3074ed 100644
--- a/java/systemserver_classpath_fragment.go
+++ b/java/systemserver_classpath_fragment.go
@@ -58,6 +58,10 @@
return m
}
+func (m *platformSystemServerClasspathModule) UniqueApexVariations() bool {
+ return true
+}
+
func (p *platformSystemServerClasspathModule) AndroidMkEntries() (entries []android.AndroidMkEntries) {
return p.classpathFragmentBase().androidMkEntries()
}
@@ -115,6 +119,9 @@
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
return m
}
+func (m *SystemServerClasspathModule) UniqueApexVariations() bool {
+ return true
+}
func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if len(s.properties.Contents.GetOrDefault(ctx, nil)) == 0 && len(s.properties.Standalone_contents.GetOrDefault(ctx, nil)) == 0 {
diff --git a/java/systemserver_classpath_fragment_test.go b/java/systemserver_classpath_fragment_test.go
index 2a1728b..704f5a4 100644
--- a/java/systemserver_classpath_fragment_test.go
+++ b/java/systemserver_classpath_fragment_test.go
@@ -25,6 +25,7 @@
)
func TestPlatformSystemServerClasspathVariant(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -39,6 +40,7 @@
}
func TestPlatformSystemServerClasspath_ClasspathFragmentPaths(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -54,6 +56,7 @@
}
func TestPlatformSystemServerClasspathModule_AndroidMkEntries(t *testing.T) {
+ t.Parallel()
preparer := android.GroupFixturePreparers(
prepareForTestWithSystemServerClasspath,
android.FixtureWithRootAndroidBp(`
@@ -97,6 +100,7 @@
}
func TestSystemServerClasspathFragmentWithoutContents(t *testing.T) {
+ t.Parallel()
prepareForTestWithSystemServerClasspath.
ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(
`\QEither contents or standalone_contents needs to be non-empty\E`)).
diff --git a/python/binary.go b/python/binary.go
index a3acb34..4d6e118 100644
--- a/python/binary.go
+++ b/python/binary.go
@@ -23,6 +23,7 @@
"android/soong/android"
"android/soong/cc"
+
"github.com/google/blueprint"
)
@@ -143,8 +144,7 @@
}
srcsZips = append(srcsZips, depsSrcsZips...)
p.installSource = registerBuildActionForParFile(ctx, embeddedLauncher, launcherPath,
- p.getHostInterpreterName(ctx, p.properties.Actual_version),
- main, p.getStem(ctx), srcsZips)
+ "python3", main, p.getStem(ctx), srcsZips)
var sharedLibs []string
// if embedded launcher is enabled, we need to collect the shared library dependencies of the
@@ -205,23 +205,6 @@
return BoolDefault(b.binaryProperties.Autorun, true)
}
-// get host interpreter name.
-func (p *PythonBinaryModule) getHostInterpreterName(ctx android.ModuleContext,
- actualVersion string) string {
- var interp string
- switch actualVersion {
- case pyVersion2:
- interp = "python2.7"
- case pyVersion3:
- interp = "python3"
- default:
- panic(fmt.Errorf("unknown Python actualVersion: %q for module: %q.",
- actualVersion, ctx.ModuleName()))
- }
-
- return interp
-}
-
// find main program path within runfiles tree.
func (p *PythonBinaryModule) getPyMainFile(ctx android.ModuleContext,
srcsPathMappings []pathMapping) string {
diff --git a/python/defaults.go b/python/defaults.go
index 3dc5bc4..b5ee2bc 100644
--- a/python/defaults.go
+++ b/python/defaults.go
@@ -18,10 +18,6 @@
"android/soong/android"
)
-func init() {
- android.RegisterModuleType("python_defaults", DefaultsFactory)
-}
-
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
diff --git a/python/library.go b/python/library.go
index 7cdb80b..c197028 100644
--- a/python/library.go
+++ b/python/library.go
@@ -27,6 +27,7 @@
func registerPythonLibraryComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("python_library_host", PythonLibraryHostFactory)
ctx.RegisterModuleType("python_library", PythonLibraryFactory)
+ ctx.RegisterModuleType("python_defaults", DefaultsFactory)
}
func PythonLibraryHostFactory() android.Module {
diff --git a/python/python.go b/python/python.go
index 09af62e..f8f4165 100644
--- a/python/python.go
+++ b/python/python.go
@@ -23,6 +23,7 @@
"strings"
"android/soong/cc"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
@@ -39,19 +40,6 @@
var PythonLibraryInfoProvider = blueprint.NewProvider[PythonLibraryInfo]()
-func init() {
- registerPythonMutators(android.InitRegistrationContext)
-}
-
-func registerPythonMutators(ctx android.RegistrationContext) {
- ctx.PreDepsMutators(RegisterPythonPreDepsMutators)
-}
-
-// Exported to support other packages using Python modules in tests.
-func RegisterPythonPreDepsMutators(ctx android.RegisterMutatorsContext) {
- ctx.Transition("python_version", &versionSplitTransitionMutator{})
-}
-
// the version-specific properties that apply to python modules.
type VersionProperties struct {
// whether the module is required to be built with this version.
@@ -127,18 +115,14 @@
Py3 VersionProperties `android:"arch_variant"`
} `android:"arch_variant"`
- // the actual version each module uses after variations created.
- // this property name is hidden from users' perspectives, and soong will populate it during
- // runtime.
- Actual_version string `blueprint:"mutated"`
-
- // whether the module is required to be built with actual_version.
- // this is set by the python version mutator based on version-specific properties
+ // This enabled property is to accept the collapsed enabled property from the VersionProperties.
+ // It is unused now, as all builds should be python3.
Enabled *bool `blueprint:"mutated"`
- // whether the binary is required to be built with embedded launcher for this actual_version.
- // this is set by the python version mutator based on version-specific properties
- Embedded_launcher *bool `blueprint:"mutated"`
+ // whether the binary is required to be built with an embedded python interpreter, defaults to
+ // true. This allows taking the resulting binary outside of the build and running it on machines
+ // that don't have python installed or may have an older version of python.
+ Embedded_launcher *bool
}
// Used to store files of current module after expanding dependencies
@@ -252,8 +236,6 @@
pathComponentRegexp = regexp.MustCompile(`^[a-zA-Z_][a-zA-Z0-9_-]*$`)
pyExt = ".py"
protoExt = ".proto"
- pyVersion2 = "PY2"
- pyVersion3 = "PY3"
internalPath = "internal"
)
@@ -261,71 +243,6 @@
getBaseProperties() *BaseProperties
}
-type versionSplitTransitionMutator struct{}
-
-func (versionSplitTransitionMutator) Split(ctx android.BaseModuleContext) []string {
- if base, ok := ctx.Module().(basePropertiesProvider); ok {
- props := base.getBaseProperties()
- var variants []string
- // PY3 is first so that we alias the PY3 variant rather than PY2 if both
- // are available
- if proptools.BoolDefault(props.Version.Py3.Enabled, true) {
- variants = append(variants, pyVersion3)
- }
- if proptools.BoolDefault(props.Version.Py2.Enabled, false) {
- if ctx.ModuleName() != "py2-cmd" &&
- ctx.ModuleName() != "py2-stdlib" {
- ctx.PropertyErrorf("version.py2.enabled", "Python 2 is no longer supported, please convert to python 3.")
- }
- variants = append(variants, pyVersion2)
- }
- return variants
- }
- return []string{""}
-}
-
-func (versionSplitTransitionMutator) OutgoingTransition(ctx android.OutgoingTransitionContext, sourceVariation string) string {
- return ""
-}
-
-func (versionSplitTransitionMutator) IncomingTransition(ctx android.IncomingTransitionContext, incomingVariation string) string {
- if incomingVariation != "" {
- return incomingVariation
- }
- if base, ok := ctx.Module().(basePropertiesProvider); ok {
- props := base.getBaseProperties()
- if proptools.BoolDefault(props.Version.Py3.Enabled, true) {
- return pyVersion3
- } else {
- return pyVersion2
- }
- }
-
- return ""
-}
-
-func (versionSplitTransitionMutator) Mutate(ctx android.BottomUpMutatorContext, variation string) {
- if variation == "" {
- return
- }
- if base, ok := ctx.Module().(basePropertiesProvider); ok {
- props := base.getBaseProperties()
- props.Actual_version = variation
-
- var versionProps *VersionProperties
- if variation == pyVersion3 {
- versionProps = &props.Version.Py3
- } else if variation == pyVersion2 {
- versionProps = &props.Version.Py2
- }
-
- err := proptools.AppendMatchingProperties([]interface{}{props}, versionProps, nil)
- if err != nil {
- panic(err)
- }
- }
-}
-
func anyHasExt(paths []string, ext string) bool {
for _, p := range paths {
if filepath.Ext(p) == ext {
@@ -345,19 +262,26 @@
// - if required, specifies launcher and adds launcher dependencies,
// - applies python version mutations to Python dependencies
func (p *PythonLibraryModule) DepsMutator(ctx android.BottomUpMutatorContext) {
- android.ProtoDeps(ctx, &p.protoProperties)
+ // Flatten the version.py3 props down into the main property struct. Leftover from when
+ // there was both python2 and 3 in the build, and properties could be different between them.
+ if base, ok := ctx.Module().(basePropertiesProvider); ok {
+ props := base.getBaseProperties()
- versionVariation := []blueprint.Variation{
- {"python_version", p.properties.Actual_version},
+ err := proptools.AppendMatchingProperties([]interface{}{props}, &props.Version.Py3, nil)
+ if err != nil {
+ panic(err)
+ }
}
+ android.ProtoDeps(ctx, &p.protoProperties)
+
// If sources contain a proto file, add dependency on libprotobuf-python
if p.anySrcHasExt(ctx, protoExt) && p.Name() != "libprotobuf-python" {
- ctx.AddVariationDependencies(versionVariation, pythonLibTag, "libprotobuf-python")
+ ctx.AddDependency(ctx.Module(), pythonLibTag, "libprotobuf-python")
}
// Add python library dependencies for this python version variation
- ctx.AddVariationDependencies(versionVariation, pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
+ ctx.AddDependency(ctx.Module(), pythonLibTag, android.LastUniqueStrings(p.properties.Libs)...)
// Emulate the data property for java_data but with the arch variation overridden to "common"
// so that it can point to java modules.
@@ -394,55 +318,38 @@
launcherSharedLibDeps = append(launcherSharedLibDeps, "libc_musl")
}
- switch p.properties.Actual_version {
- case pyVersion2:
- stdLib = "py2-stdlib"
-
- launcherModule = "py2-launcher"
- if autorun {
- launcherModule = "py2-launcher-autorun"
- }
-
- launcherSharedLibDeps = append(launcherSharedLibDeps, "libc++")
- case pyVersion3:
- var prebuiltStdLib bool
- if targetForDeps.Os.Bionic() {
- prebuiltStdLib = false
- } else if ctx.Config().VendorConfig("cpython3").Bool("force_build_host") {
- prebuiltStdLib = false
- } else {
- prebuiltStdLib = true
- }
-
- if prebuiltStdLib {
- stdLib = "py3-stdlib-prebuilt"
- } else {
- stdLib = "py3-stdlib"
- }
-
- launcherModule = "py3-launcher"
- if autorun {
- launcherModule = "py3-launcher-autorun"
- }
- if ctx.Config().HostStaticBinaries() && targetForDeps.Os == android.LinuxMusl {
- launcherModule += "-static"
- }
- if ctx.Device() {
- launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
- }
- default:
- panic(fmt.Errorf("unknown Python Actual_version: %q for module: %q.",
- p.properties.Actual_version, ctx.ModuleName()))
+ var prebuiltStdLib bool
+ if targetForDeps.Os.Bionic() {
+ prebuiltStdLib = false
+ } else if ctx.Config().VendorConfig("cpython3").Bool("force_build_host") {
+ prebuiltStdLib = false
+ } else {
+ prebuiltStdLib = true
}
+
+ if prebuiltStdLib {
+ stdLib = "py3-stdlib-prebuilt"
+ } else {
+ stdLib = "py3-stdlib"
+ }
+
+ launcherModule = "py3-launcher"
+ if autorun {
+ launcherModule = "py3-launcher-autorun"
+ }
+ if ctx.Config().HostStaticBinaries() && targetForDeps.Os == android.LinuxMusl {
+ launcherModule += "-static"
+ }
+ if ctx.Device() {
+ launcherSharedLibDeps = append(launcherSharedLibDeps, "liblog")
+ }
+
targetVariations := targetForDeps.Variations()
if ctx.ModuleName() != stdLib {
- stdLibVariations := make([]blueprint.Variation, 0, len(targetVariations)+1)
- stdLibVariations = append(stdLibVariations, blueprint.Variation{Mutator: "python_version", Variation: p.properties.Actual_version})
- stdLibVariations = append(stdLibVariations, targetVariations...)
// Using AddFarVariationDependencies for all of these because they can be for a different
// platform, like if the python module itself was being compiled for device, we may want
// the python interpreter built for host so that we can precompile python sources.
- ctx.AddFarVariationDependencies(stdLibVariations, stdLibTag, stdLib)
+ ctx.AddFarVariationDependencies(targetVariations, stdLibTag, stdLib)
}
ctx.AddFarVariationDependencies(targetVariations, launcherTag, launcherModule)
ctx.AddFarVariationDependencies(targetVariations, launcherSharedLibTag, launcherSharedLibDeps...)
@@ -450,6 +357,9 @@
// GenerateAndroidBuildActions performs build actions common to all Python modules
func (p *PythonLibraryModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ if proptools.BoolDefault(p.properties.Version.Py2.Enabled, false) {
+ ctx.PropertyErrorf("version.py2.enabled", "Python 2 is no longer supported, please convert to python 3.")
+ }
expandedSrcs := android.PathsForModuleSrcExcludes(ctx, p.properties.Srcs, p.properties.Exclude_srcs)
// Keep before any early returns.
android.SetProvider(ctx, android.TestOnlyProviderKey, android.TestModuleInformation{
@@ -490,7 +400,8 @@
// generate the zipfile of all source and data files
p.srcsZip = p.createSrcsZip(ctx, pkgPath)
- p.precompiledSrcsZip = p.precompileSrcs(ctx)
+ // TODO(b/388344853): precompilation temporarily disabled for python3.13 upgrade
+ p.precompiledSrcsZip = p.srcsZip //p.precompileSrcs(ctx)
android.SetProvider(ctx, PythonLibraryInfoProvider, PythonLibraryInfo{
SrcsPathMappings: p.getSrcsPathMappings(),
diff --git a/python/python_test.go b/python/python_test.go
index 6a6bd1d..0e97626 100644
--- a/python/python_test.go
+++ b/python/python_test.go
@@ -36,10 +36,8 @@
}
var (
- buildNamePrefix = "soong_python_test"
- // We allow maching almost anything before the actual variant so that the os/arch variant
- // is matched.
- moduleVariantErrTemplate = `%s: module %q variant "[a-zA-Z0-9_]*%s": `
+ buildNamePrefix = "soong_python_test"
+ moduleVariantErrTemplate = `%s: module %q variant "[a-zA-Z0-9_]*": `
pkgPathErrTemplate = moduleVariantErrTemplate +
"pkg_path: %q must be a relative path contained in par file."
badIdentifierErrTemplate = moduleVariantErrTemplate +
@@ -48,9 +46,8 @@
"found two files to be placed at the same location within zip %q." +
" First file: in module %s at path %q." +
" Second file: in module %s at path %q."
- noSrcFileErr = moduleVariantErrTemplate + "doesn't have any source files!"
- badSrcFileExtErr = moduleVariantErrTemplate + "srcs: found non (.py|.proto) file: %q!"
- badDataFileExtErr = moduleVariantErrTemplate + "data: found (.py) file: %q!"
+ badSrcFileExtErr = moduleVariantErrTemplate + `srcs: found non \(.py\|.proto\) file: %q!`
+ badDataFileExtErr = moduleVariantErrTemplate + `data: found \(.py\) file: %q!`
bpFile = "Android.bp"
data = []struct {
@@ -61,20 +58,6 @@
expectedBinaries []pyModule
}{
{
- desc: "module without any src files",
- mockFiles: map[string][]byte{
- filepath.Join("dir", bpFile): []byte(
- `python_library_host {
- name: "lib1",
- }`,
- ),
- },
- errors: []string{
- fmt.Sprintf(noSrcFileErr,
- "dir/Android.bp:1:1", "lib1", "PY3"),
- },
- },
- {
desc: "module with bad src file ext",
mockFiles: map[string][]byte{
filepath.Join("dir", bpFile): []byte(
@@ -89,7 +72,7 @@
},
errors: []string{
fmt.Sprintf(badSrcFileExtErr,
- "dir/Android.bp:3:11", "lib1", "PY3", "dir/file1.exe"),
+ "dir/Android.bp:3:11", "lib1", "dir/file1.exe"),
},
},
{
@@ -111,7 +94,7 @@
},
errors: []string{
fmt.Sprintf(badDataFileExtErr,
- "dir/Android.bp:6:11", "lib1", "PY3", "dir/file2.py"),
+ "dir/Android.bp:6:11", "lib1", "dir/file2.py"),
},
},
{
@@ -146,9 +129,9 @@
},
errors: []string{
fmt.Sprintf(pkgPathErrTemplate,
- "dir/Android.bp:11:15", "lib2", "PY3", "a/c/../../../"),
+ "dir/Android.bp:11:15", "lib2", "a/c/../../../"),
fmt.Sprintf(pkgPathErrTemplate,
- "dir/Android.bp:19:15", "lib3", "PY3", "/a/c/../../"),
+ "dir/Android.bp:19:15", "lib3", "/a/c/../../"),
},
},
{
@@ -171,11 +154,11 @@
},
errors: []string{
fmt.Sprintf(badIdentifierErrTemplate, "dir/Android.bp:4:11",
- "lib1", "PY3", "a/b/c/-e/f/file1.py", "-e"),
+ "lib1", "a/b/c/-e/f/file1.py", "-e"),
fmt.Sprintf(badIdentifierErrTemplate, "dir/Android.bp:4:11",
- "lib1", "PY3", "a/b/c/.file1.py", ".file1"),
+ "lib1", "a/b/c/.file1.py", ".file1"),
fmt.Sprintf(badIdentifierErrTemplate, "dir/Android.bp:4:11",
- "lib1", "PY3", "a/b/c/123/file1.py", "123"),
+ "lib1", "a/b/c/123/file1.py", "123"),
},
},
{
@@ -219,115 +202,15 @@
},
errors: []string{
fmt.Sprintf(dupRunfileErrTemplate, "dir/Android.bp:20:6",
- "bin", "PY3", "a/b/c/file1.py", "bin", "dir/file1.py",
+ "bin", "a/b/c/file1.py", "bin", "dir/file1.py",
"lib1", "dir/c/file1.py"),
},
},
- {
- desc: "module for testing dependencies",
- mockFiles: map[string][]byte{
- filepath.Join("dir", bpFile): []byte(
- `python_defaults {
- name: "default_lib",
- srcs: [
- "default.py",
- ],
- version: {
- py2: {
- enabled: true,
- srcs: [
- "default_py2.py",
- ],
- },
- py3: {
- enabled: false,
- srcs: [
- "default_py3.py",
- ],
- },
- },
- }
-
- python_library_host {
- name: "lib5",
- pkg_path: "a/b/",
- srcs: [
- "file1.py",
- ],
- version: {
- py2: {
- enabled: true,
- },
- py3: {
- enabled: true,
- },
- },
- }
-
- python_library_host {
- name: "lib6",
- pkg_path: "c/d/",
- srcs: [
- "file2.py",
- ],
- libs: [
- "lib5",
- ],
- }
-
- python_binary_host {
- name: "bin",
- defaults: ["default_lib"],
- pkg_path: "e/",
- srcs: [
- "bin.py",
- ],
- libs: [
- "lib5",
- ],
- version: {
- py3: {
- enabled: true,
- srcs: [
- "file4.py",
- ],
- libs: [
- "lib6",
- ],
- },
- },
- }`,
- ),
- filepath.Join("dir", "default.py"): nil,
- filepath.Join("dir", "default_py2.py"): nil,
- filepath.Join("dir", "default_py3.py"): nil,
- filepath.Join("dir", "file1.py"): nil,
- filepath.Join("dir", "file2.py"): nil,
- filepath.Join("dir", "bin.py"): nil,
- filepath.Join("dir", "file4.py"): nil,
- },
- expectedBinaries: []pyModule{
- {
- name: "bin",
- actualVersion: "PY3",
- pyRunfiles: []string{
- "e/default.py",
- "e/bin.py",
- "e/default_py3.py",
- "e/file4.py",
- },
- srcsZip: "out/soong/.intermediates/dir/bin/PY3/bin.py.srcszip",
- },
- },
- },
}
)
func TestPythonModule(t *testing.T) {
for _, d := range data {
- if d.desc != "module with duplicate runfile path" {
- continue
- }
d.mockFiles[filepath.Join("common", bpFile)] = []byte(`
python_library {
name: "py3-stdlib",
@@ -416,10 +299,6 @@
for i, bp := range testCases {
ctx := android.GroupFixturePreparers(
PrepareForTestWithPythonBuildComponents,
- android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
-
- ctx.RegisterModuleType("python_defaults", DefaultsFactory)
- }),
android.PrepareForTestWithAllowMissingDependencies).
ExtendWithErrorHandler(android.FixtureIgnoreErrors).
RunTestWithBp(t, bp)
diff --git a/python/testing.go b/python/testing.go
index ce1a5ab..fe53ee5 100644
--- a/python/testing.go
+++ b/python/testing.go
@@ -20,5 +20,4 @@
android.FixtureRegisterWithContext(registerPythonBinaryComponents),
android.FixtureRegisterWithContext(registerPythonLibraryComponents),
android.FixtureRegisterWithContext(registerPythonTestComponents),
- android.FixtureRegisterWithContext(registerPythonMutators),
)
diff --git a/rust/bindgen.go b/rust/bindgen.go
index 8accd03..2f84168 100644
--- a/rust/bindgen.go
+++ b/rust/bindgen.go
@@ -398,7 +398,7 @@
//
// This is necessary to avoid a circular dependency between the source variant and the
// dependent cc module.
- deps.StaticLibs = append(deps.StaticLibs, String(b.Properties.Static_inline_library))
+ deps.WholeStaticLibs = append(deps.WholeStaticLibs, String(b.Properties.Static_inline_library))
}
deps.SharedLibs = append(deps.SharedLibs, b.ClangProperties.Shared_libs.GetOrDefault(ctx, nil)...)
diff --git a/rust/config/global.go b/rust/config/global.go
index 2623a5c..907316f 100644
--- a/rust/config/global.go
+++ b/rust/config/global.go
@@ -25,7 +25,7 @@
var (
pctx = android.NewPackageContext("android/soong/rust/config")
- RustDefaultVersion = "1.82.0"
+ RustDefaultVersion = "1.83.0"
RustDefaultBase = "prebuilts/rust/"
DefaultEdition = "2021"
Stdlibs = []string{
diff --git a/rust/coverage.go b/rust/coverage.go
index ae95e46..798b21d 100644
--- a/rust/coverage.go
+++ b/rust/coverage.go
@@ -16,12 +16,12 @@
import (
"android/soong/android"
+
"github.com/google/blueprint"
"android/soong/cc"
)
-var CovLibraryName = "libprofile-clang-extras"
var ProfilerBuiltins = "libprofiler_builtins.rust_sysroot"
// Add '%c' to default specifier after we resolve http://b/210012154
@@ -38,12 +38,20 @@
return []interface{}{&cov.Properties}
}
+func getClangProfileLibraryName(ctx ModuleContextIntf) string {
+ if ctx.RustModule().UseSdk() {
+ return "libprofile-clang-extras_ndk"
+ } else {
+ return "libprofile-clang-extras"
+ }
+}
+
func (cov *coverage) deps(ctx DepsContext, deps Deps) Deps {
if cov.Properties.NeedCoverageVariant {
if ctx.Device() {
ctx.AddVariationDependencies([]blueprint.Variation{
{Mutator: "link", Variation: "static"},
- }, cc.CoverageDepTag, CovLibraryName)
+ }, cc.CoverageDepTag, getClangProfileLibraryName(ctx))
}
// no_std modules are missing libprofiler_builtins which provides coverage, so we need to add it as a dependency.
@@ -66,7 +74,7 @@
flags.RustFlags = append(flags.RustFlags,
"-C instrument-coverage", "-g")
if ctx.Device() {
- m := ctx.GetDirectDepProxyWithTag(CovLibraryName, cc.CoverageDepTag)
+ m := ctx.GetDirectDepProxyWithTag(getClangProfileLibraryName(ctx), cc.CoverageDepTag)
coverage := android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider)
flags.LinkFlags = append(flags.LinkFlags,
profileInstrFlag, "-g", coverage.OutputFile.Path().String(), "-Wl,--wrap,open")
diff --git a/rust/library.go b/rust/library.go
index 769a682..14d908c 100644
--- a/rust/library.go
+++ b/rust/library.go
@@ -202,6 +202,9 @@
}
func (library *libraryDecorator) nativeCoverage() bool {
+ if library.BuildStubs() {
+ return false
+ }
return true
}
diff --git a/rust/rust.go b/rust/rust.go
index b1880cf..dfd39f7 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1199,10 +1199,11 @@
// Define the linker info if compiler != nil because Rust currently
// does compilation and linking in one step. If this changes in the future,
// move this as appropriate.
+ baseCompilerProps := mod.compiler.baseCompilerProps()
ccInfo.LinkerInfo = &cc.LinkerInfo{
- WholeStaticLibs: mod.compiler.baseCompilerProps().Whole_static_libs,
- StaticLibs: mod.compiler.baseCompilerProps().Static_libs,
- SharedLibs: mod.compiler.baseCompilerProps().Shared_libs,
+ WholeStaticLibs: baseCompilerProps.Whole_static_libs.GetOrDefault(ctx, nil),
+ StaticLibs: baseCompilerProps.Static_libs.GetOrDefault(ctx, nil),
+ SharedLibs: baseCompilerProps.Shared_libs.GetOrDefault(ctx, nil),
}
android.SetProvider(ctx, cc.CcInfoProvider, ccInfo)
@@ -2129,7 +2130,7 @@
}
if mod.HasStubsVariants() {
- if cc.IsSharedDepTag(depTag) {
+ if cc.IsSharedDepTag(depTag) && !cc.IsExplicitImplSharedDepTag(depTag) {
// dynamic dep to a stubs lib crosses APEX boundary
return false
}
diff --git a/scripts/gen_build_prop.py b/scripts/gen_build_prop.py
index 355f33d..74befd5 100644
--- a/scripts/gen_build_prop.py
+++ b/scripts/gen_build_prop.py
@@ -369,9 +369,6 @@
props = list(filter(lambda x: not x.startswith("ro.setupwizard.mode="), props))
props.append("ro.setupwizard.mode=OPTIONAL")
- if not config["SdkBuild"]:
- # To speedup startup of non-preopted builds, don't verify or compile the boot image.
- props.append("dalvik.vm.image-dex2oat-filter=extract")
# b/323566535
props.append("init.svc_debug.no_fatal.zygote=true")
diff --git a/sdk/bootclasspath_fragment_sdk_test.go b/sdk/bootclasspath_fragment_sdk_test.go
index 34e11f0..ad315bf 100644
--- a/sdk/bootclasspath_fragment_sdk_test.go
+++ b/sdk/bootclasspath_fragment_sdk_test.go
@@ -73,6 +73,7 @@
}
func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithDexpreopt,
@@ -514,7 +515,9 @@
}
func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
+ t.Parallel()
t.Run("added-directly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -566,6 +569,7 @@
.intermediates/mycoreplatform.stubs.source/android_common/exportable/mycoreplatform.stubs.source_removed.txt -> sdk_library/public/mycoreplatform-removed.txt
`
t.Run("added-via-apex", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -575,6 +579,7 @@
})
t.Run("added-directly-and-indirectly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithBootClasspathFragment_Contents(t, `
sdk {
name: "mysdk",
@@ -599,6 +604,7 @@
// TestSnapshotWithBootClasspathFragment_Fragments makes sure that the fragments property of a
// bootclasspath_fragment is correctly output to the sdk snapshot.
func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -734,6 +740,7 @@
// Test that bootclasspath_fragment works with sdk.
func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForSdkTestWithApex,
prepareForSdkTestWithJava,
@@ -752,6 +759,13 @@
bootclasspath_fragments: ["mybootclasspathfragment"],
}
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ bootclasspath_fragments: ["mybootclasspathfragment"],
+ }
+
bootclasspath_fragment {
name: "mybootclasspathfragment",
image_name: "art",
@@ -794,7 +808,7 @@
java_import {
name: "mybootlib",
visibility: ["//visibility:public"],
- apex_available: ["com.android.art"],
+ apex_available: ["myapex"],
jars: ["java/mybootlib.jar"],
}
`),
@@ -802,6 +816,7 @@
}
func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -1127,7 +1142,9 @@
}
func TestSnapshotWithBootClasspathFragment_MinSdkVersion(t *testing.T) {
+ t.Parallel()
t.Run("target S build", func(t *testing.T) {
+ t.Parallel()
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
@@ -1184,6 +1201,7 @@
})
t.Run("target-Tiramisu-build", func(t *testing.T) {
+ t.Parallel()
expectedSnapshot := `
// This is auto-generated. DO NOT EDIT.
@@ -1268,6 +1286,7 @@
}
func TestSnapshotWithEmptyBootClasspathFragment(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
diff --git a/sdk/bp_test.go b/sdk/bp_test.go
index c620ac2..d3eaafe 100644
--- a/sdk/bp_test.go
+++ b/sdk/bp_test.go
@@ -73,6 +73,7 @@
}
func TestAddPropertySimple(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
for name, val := range map[string]interface{}{
"x": "taxi",
@@ -91,14 +92,17 @@
}
func TestAddPropertySubset(t *testing.T) {
+ t.Parallel()
getFixtureMap := map[string]func() interface{}{
"property set": propertySetFixture,
"property struct": propertyStructFixture,
}
t.Run("add new subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
set.AddProperty("new", getFixture())
checkPropertySetFixture(t, set, true)
@@ -108,8 +112,10 @@
})
t.Run("merge existing subset", func(t *testing.T) {
+ t.Parallel()
for name, getFixture := range getFixtureMap {
t.Run(name, func(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("flag", false)
@@ -123,12 +129,14 @@
})
t.Run("add conflicting subset", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
android.AssertPanicMessageContains(t, "adding x again should panic", `Property "x" already exists in property set`,
func() { set.AddProperty("x", propertySetFixture()) })
})
t.Run("add non-pointer struct", func(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
str := propertyStructFixture().(*propertyStruct)
android.AssertPanicMessageContains(t, "adding a non-pointer struct should panic", "Value is a struct, not a pointer to one:",
@@ -137,6 +145,7 @@
}
func TestAddPropertySetNew(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -144,6 +153,7 @@
}
func TestAddPropertySetExisting(t *testing.T) {
+ t.Parallel()
set := propertySetFixture().(*bpPropertySet)
subset := set.AddPropertySet("sub")
subset.AddProperty("new", "d^^b")
@@ -176,6 +186,7 @@
}
func TestTransformRemoveProperty(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddProperty("fred", "12")
@@ -188,6 +199,7 @@
}
func TestTransformRemovePropertySet(t *testing.T) {
+ t.Parallel()
set := newPropertySet()
set.AddProperty("name", "name")
set.AddPropertySet("fred")
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go
index 25839b8..5bac67d 100644
--- a/sdk/cc_sdk_test.go
+++ b/sdk/cc_sdk_test.go
@@ -58,6 +58,7 @@
// Contains tests for SDK members provided by the cc package.
func TestSingleDeviceOsAssumption(t *testing.T) {
+ t.Parallel()
// Mock a module with DeviceSupported() == true.
s := &sdk{}
android.InitAndroidArchModule(s, android.DeviceSupported, android.MultilibCommon)
@@ -72,6 +73,7 @@
}
func TestSdkIsCompileMultilibBoth(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -102,6 +104,7 @@
}
func TestSdkCompileMultilibOverride(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -161,6 +164,7 @@
// Make sure the sdk can use host specific cc libraries static/shared and both.
func TestHostSdkWithCc(t *testing.T) {
+ t.Parallel()
testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -184,6 +188,7 @@
// Make sure the sdk can use cc libraries static/shared and both.
func TestSdkWithCc(t *testing.T) {
+ t.Parallel()
testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -214,6 +219,7 @@
}
func TestSnapshotWithObject(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -268,6 +274,7 @@
}
func TestSnapshotWithCcDuplicateHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -305,6 +312,7 @@
}
func TestSnapshotWithCcExportGeneratedHeaders(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -393,6 +401,7 @@
// handling is tested with the sanitize clauses (but note there's a lot of
// built-in logic in sanitize.go that can affect those flags).
func TestSnapshotWithCcSharedLibraryCommonProperties(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -475,6 +484,7 @@
}
func TestSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "mymodule_exports",
@@ -523,6 +533,7 @@
}
func TestMultipleHostOsTypesSnapshotWithCcBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -604,6 +615,7 @@
}
func TestSnapshotWithSingleHostOsType(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTest,
ccTestFs.AddToFixture(),
@@ -721,6 +733,7 @@
// Test that we support the necessary flags for the linker binary, which is
// special in several ways.
func TestSnapshotWithCcStaticNocrtBinary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "mymodule_exports",
@@ -785,19 +798,26 @@
}
func TestSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
native_shared_libs: ["mynativelib"],
}
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+
cc_library_shared {
name: "mynativelib",
srcs: [
"Test.cpp",
"aidl/foo/bar/Test.aidl",
],
- apex_available: ["apex1", "apex2"],
+ apex_available: ["myapex"],
export_include_dirs: ["myinclude"],
aidl: {
export_aidl_headers: true,
@@ -807,6 +827,18 @@
`)
CheckSnapshot(t, result, "mysdk", "",
+ snapshotTestPreparer(checkSnapshotWithoutSource,
+ android.FixtureMergeMockFs(android.MockFS{
+ "myapex/Android.bp": []byte(`
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+ `),
+ "myapex/apex_manifest.json": nil,
+ }),
+ ),
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
@@ -819,10 +851,7 @@
name: "mynativelib",
prefer: false,
visibility: ["//visibility:public"],
- apex_available: [
- "apex1",
- "apex2",
- ],
+ apex_available: ["myapex"],
stl: "none",
compile_multilib: "both",
export_include_dirs: ["include/myinclude"],
@@ -856,6 +885,7 @@
}
func TestSnapshotWithCcSharedLibrarySharedLibs(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1005,6 +1035,7 @@
}
func TestHostSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1085,6 +1116,7 @@
}
func TestMultipleHostOsTypesSnapshotWithCcSharedLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1168,6 +1200,7 @@
}
func TestSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1232,6 +1265,7 @@
}
func TestHostSnapshotWithCcStaticLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1307,6 +1341,7 @@
}
func TestSnapshotWithCcLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1376,6 +1411,7 @@
}
func TestSnapshotSameLibraryWithNativeLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1477,6 +1513,7 @@
}
func TestSnapshotSameLibraryWithAndroidNativeLibsAndHostNativeSharedLib(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
host_supported: true,
@@ -1578,6 +1615,7 @@
}
func TestSnapshotSameLibraryWithNativeStaticLibsAndNativeSharedLib(t *testing.T) {
+ t.Parallel()
testSdkError(t, "Incompatible member types", `
module_exports {
host_supported: true,
@@ -1609,6 +1647,7 @@
}
func TestHostSnapshotWithMultiLib64(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
module_exports {
name: "myexports",
@@ -1682,6 +1721,7 @@
}
func TestSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1721,6 +1761,7 @@
}
func TestSnapshotWithCcHeadersLibraryAndNativeBridgeSupport(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
@@ -1778,6 +1819,7 @@
// module that has different output files for a native bridge target requests the native bridge
// variants are copied into the sdk snapshot that it reports an error.
func TestSnapshotWithCcHeadersLibrary_DetectsNativeBridgeSpecificProperties(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
PrepareForTestWithSdkBuildComponents,
@@ -1814,6 +1856,7 @@
}
func TestSnapshotWithCcHeadersLibraryAndImageVariants(t *testing.T) {
+ t.Parallel()
testImageVariant := func(t *testing.T, property, trait string) {
result := android.GroupFixturePreparers(
cc.PrepareForTestWithCcDefaultModules,
@@ -1877,6 +1920,7 @@
}
func TestHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -1933,6 +1977,7 @@
}
func TestDeviceAndHostSnapshotWithCcHeadersLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2002,6 +2047,7 @@
}
func TestSystemSharedLibPropagation(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2162,6 +2208,7 @@
}
func TestStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2223,6 +2270,7 @@
}
func TestDeviceAndHostSnapshotWithStubsLibrary(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2299,6 +2347,7 @@
}
func TestUniqueHostSoname(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
@@ -2364,6 +2413,7 @@
}
func TestNoSanitizerMembers(t *testing.T) {
+ t.Parallel()
result := testSdkWithCc(t, `
sdk {
name: "mysdk",
diff --git a/sdk/compat_config_sdk_test.go b/sdk/compat_config_sdk_test.go
index 75b5229..1737b3a 100644
--- a/sdk/compat_config_sdk_test.go
+++ b/sdk/compat_config_sdk_test.go
@@ -76,6 +76,7 @@
}
func TestSnapshotWithCompatConfig(t *testing.T) {
+ t.Parallel()
testSnapshotWithCompatConfig(t, `
sdk {
name: "mysdk",
@@ -85,6 +86,7 @@
}
func TestSnapshotWithCompatConfig_Apex(t *testing.T) {
+ t.Parallel()
testSnapshotWithCompatConfig(t, `
apex {
name: "myapex",
diff --git a/sdk/exports_test.go b/sdk/exports_test.go
index 9d0a242..5a7ce84 100644
--- a/sdk/exports_test.go
+++ b/sdk/exports_test.go
@@ -20,6 +20,7 @@
// Ensure that module_exports generates a module_exports_snapshot module.
func TestModuleExportsSnapshot(t *testing.T) {
+ t.Parallel()
packageBp := `
module_exports {
name: "myexports",
diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go
index 4db163c..1e545ce 100644
--- a/sdk/java_sdk_test.go
+++ b/sdk/java_sdk_test.go
@@ -51,6 +51,7 @@
// Contains tests for SDK members provided by the java package.
func TestSdkDependsOnSourceEvenWhenPrebuiltPreferred(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -77,6 +78,7 @@
}
func TestSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -126,6 +128,7 @@
}
func TestHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -178,6 +181,7 @@
}
func TestDeviceAndHostSnapshotWithJavaHeaderLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -228,6 +232,7 @@
}
func TestSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -277,6 +282,7 @@
}
func TestSnapshotWithJavaBootLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -328,6 +334,7 @@
}
func TestSnapshotWithJavaBootLibrary_UpdatableMedia(t *testing.T) {
+ t.Parallel()
runTest := func(t *testing.T, targetBuildRelease, expectedJarPath, expectedCopyRule string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
@@ -385,6 +392,7 @@
}
func TestSnapshotWithJavaLibrary_MinSdkVersion(t *testing.T) {
+ t.Parallel()
runTest := func(t *testing.T, targetBuildRelease, minSdkVersion, expectedMinSdkVersion string) {
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
@@ -457,6 +465,7 @@
}
func TestSnapshotWithJavaSystemserverLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl", nil),
@@ -509,6 +518,7 @@
}
func TestHostSnapshotWithJavaImplLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureAddFile("aidl/foo/bar/Test.aidl", nil),
@@ -561,6 +571,7 @@
}
func TestSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -603,6 +614,7 @@
}
func TestHostSnapshotWithJavaTest(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -650,6 +662,7 @@
}
func TestSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -853,6 +866,7 @@
}
func TestHostSnapshotWithJavaSystemModules(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -911,6 +925,7 @@
}
func TestDeviceAndHostSnapshotWithOsSpecificMembers(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJava).RunTestWithBp(t, `
module_exports {
name: "myexports",
@@ -1004,6 +1019,7 @@
}
func TestSnapshotWithJavaSdkLibrary(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1081,6 +1097,7 @@
}
func TestSnapshotWithJavaSdkLibrary_DistStem(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1136,6 +1153,7 @@
}
func TestSnapshotWithJavaSdkLibrary_UseSrcJar(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1192,6 +1210,7 @@
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1246,6 +1265,7 @@
}
func TestSnapshotWithJavaSdkLibrary_AnnotationsZip_PreT(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureMergeEnv(map[string]string{
@@ -1303,6 +1323,7 @@
}
func TestSnapshotWithJavaSdkLibrary_CompileDex(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.PrepareForTestWithBuildFlag("RELEASE_HIDDEN_API_EXPORTABLE_STUBS", "true"),
@@ -1385,6 +1406,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_None(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1435,6 +1457,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1488,6 +1511,7 @@
}
func TestSnapshotWithJavaSdkLibrary_ApiScopes(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1555,6 +1579,7 @@
}
func TestSnapshotWithJavaSdkLibrary_ModuleLib(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1636,6 +1661,7 @@
}
func TestSnapshotWithJavaSdkLibrary_SystemServer(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(prepareForSdkTestWithJavaSdkLibrary).RunTestWithBp(t, `
sdk {
name: "mysdk",
@@ -1703,6 +1729,7 @@
}
func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJavaSdkLibrary,
android.FixtureAddFile("docs/known_doctags", nil),
diff --git a/sdk/license_sdk_test.go b/sdk/license_sdk_test.go
index 754f019..eb8112b 100644
--- a/sdk/license_sdk_test.go
+++ b/sdk/license_sdk_test.go
@@ -21,6 +21,7 @@
)
func TestSnapshotWithPackageDefaultLicense(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.PrepareForTestWithLicenses,
diff --git a/sdk/member_trait_test.go b/sdk/member_trait_test.go
index 673d6fb..9b41e9b 100644
--- a/sdk/member_trait_test.go
+++ b/sdk/member_trait_test.go
@@ -116,6 +116,7 @@
}
func TestBasicTrait_WithoutTrait(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -154,6 +155,7 @@
}
func TestBasicTrait_MultipleTraits(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
@@ -262,6 +264,7 @@
}
func TestTraitUnsupportedByMemberType(t *testing.T) {
+ t.Parallel()
android.GroupFixturePreparers(
prepareForSdkTestWithJava,
android.FixtureWithRootAndroidBp(`
diff --git a/sdk/sdk_test.go b/sdk/sdk_test.go
index 2532a25..b525eb8 100644
--- a/sdk/sdk_test.go
+++ b/sdk/sdk_test.go
@@ -40,6 +40,7 @@
// Ensure that prebuilt modules have the same effective visibility as the source
// modules.
func TestSnapshotVisibility(t *testing.T) {
+ t.Parallel()
packageBp := `
package {
default_visibility: ["//other/foo"],
@@ -160,6 +161,7 @@
}
func TestSdkInstall(t *testing.T) {
+ t.Parallel()
sdk := `
sdk {
name: "mysdk",
@@ -326,6 +328,7 @@
// Ensure that sdk snapshot related environment variables work correctly.
func TestSnapshot_EnvConfiguration(t *testing.T) {
+ t.Parallel()
bp := `
sdk {
name: "mysdk",
@@ -352,6 +355,7 @@
}
t.Run("no env variables", func(t *testing.T) {
+ t.Parallel()
result := preparer.RunTest(t)
checkZipFile(t, result, "out/soong/.intermediates/mysdk/common_os/mysdk-current.zip")
@@ -377,6 +381,7 @@
})
t.Run("SOONG_SDK_SNAPSHOT_TARGET_BUILD_RELEASE=S", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
@@ -468,6 +473,7 @@
})
t.Run("test replacing exportable module", func(t *testing.T) {
+ t.Parallel()
result := android.GroupFixturePreparers(
prepareForSdkTestWithJava,
java.PrepareForTestWithJavaDefaultModules,
diff --git a/sdk/systemserverclasspath_fragment_sdk_test.go b/sdk/systemserverclasspath_fragment_sdk_test.go
index fd6c4e7..7ebdcd4 100644
--- a/sdk/systemserverclasspath_fragment_sdk_test.go
+++ b/sdk/systemserverclasspath_fragment_sdk_test.go
@@ -87,10 +87,23 @@
CheckSnapshot(t, result, "mysdk", "",
checkAndroidBpContents(expectedSdkSnapshot),
+ snapshotTestPreparer(checkSnapshotWithoutSource,
+ android.FixtureMergeMockFs(android.MockFS{
+ "myapex/Android.bp": []byte(`
+ apex {
+ name: "myapex",
+ key: "myapex.key",
+ min_sdk_version: "1",
+ }
+ `),
+ "myapex/apex_manifest.json": nil,
+ }),
+ ),
)
}
func TestSnapshotWithPartialSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -185,6 +198,7 @@
}
func TestSnapshotWithEmptySystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
apex {
name: "myapex",
@@ -231,6 +245,7 @@
}
func TestSnapshotWithSystemServerClasspathFragment(t *testing.T) {
+ t.Parallel()
commonSdk := `
sdk {
@@ -298,6 +313,7 @@
`
t.Run("target-s", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "S", `
// This is auto-generated. DO NOT EDIT.
@@ -319,6 +335,7 @@
})
t.Run("target-t", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "Tiramisu", `
// This is auto-generated. DO NOT EDIT.
@@ -361,6 +378,7 @@
})
t.Run("target-u", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, "UpsideDownCake", `
// This is auto-generated. DO NOT EDIT.
@@ -409,10 +427,12 @@
})
t.Run("added-directly", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, commonSdk, `latest`, expectedLatestSnapshot)
})
t.Run("added-via-apex", func(t *testing.T) {
+ t.Parallel()
testSnapshotWithSystemServerClasspathFragment(t, `
sdk {
name: "mysdk",
diff --git a/sdk/testing.go b/sdk/testing.go
index 21d457c..f5518c4 100644
--- a/sdk/testing.go
+++ b/sdk/testing.go
@@ -128,12 +128,11 @@
// generated, etc.
func getSdkSnapshotBuildInfo(t *testing.T, result *android.TestResult, sdk *sdk) *snapshotBuildInfo {
info := &snapshotBuildInfo{
- t: t,
- r: result,
- androidBpContents: sdk.GetAndroidBpContentsForTests(),
- infoContents: sdk.GetInfoContentsForTests(),
- snapshotTestCustomizations: map[snapshotTest]*snapshotTestCustomization{},
- targetBuildRelease: sdk.builderForTests.targetBuildRelease,
+ t: t,
+ r: result,
+ androidBpContents: sdk.GetAndroidBpContentsForTests(),
+ infoContents: sdk.GetInfoContentsForTests(),
+ targetBuildRelease: sdk.builderForTests.targetBuildRelease,
}
buildParams := sdk.BuildParamsForTests()
@@ -293,6 +292,7 @@
}
t.Run("snapshot without source", func(t *testing.T) {
+ t.Parallel()
// Remove the source Android.bp file to make sure it works without.
removeSourceAndroidBp := android.FixtureModifyMockFS(func(fs android.MockFS) {
delete(fs, "Android.bp")
@@ -302,10 +302,12 @@
})
t.Run("snapshot with source preferred", func(t *testing.T) {
+ t.Parallel()
runSnapshotTestWithCheckers(t, checkSnapshotWithSourcePreferred, android.NullFixturePreparer)
})
t.Run("snapshot preferred with source", func(t *testing.T) {
+ t.Parallel()
// Replace the snapshot/Android.bp file with one where "prefer: false," has been replaced with
// "prefer: true,"
preferPrebuilts := android.FixtureModifyMockFS(func(fs android.MockFS) {
@@ -469,19 +471,40 @@
targetBuildRelease *buildRelease
// The test specific customizations for each snapshot test.
- snapshotTestCustomizations map[snapshotTest]*snapshotTestCustomization
+ snapshotTestCustomizations snapshotTestCustomizationSet
+}
+
+type snapshotTestCustomizationSet struct {
+ snapshotWithoutSource *snapshotTestCustomization
+ snapshotWithSourcePreferred *snapshotTestCustomization
+ snapshotPreferredWithSource *snapshotTestCustomization
+}
+
+func (s *snapshotTestCustomizationSet) customization(snapshotTest snapshotTest) **snapshotTestCustomization {
+ var customization **snapshotTestCustomization
+ switch snapshotTest {
+ case checkSnapshotWithoutSource:
+
+ customization = &s.snapshotWithoutSource
+ case checkSnapshotWithSourcePreferred:
+ customization = &s.snapshotWithSourcePreferred
+ case checkSnapshotPreferredWithSource:
+ customization = &s.snapshotPreferredWithSource
+ default:
+ panic(fmt.Errorf("unsupported snapshotTest %v", snapshotTest))
+ }
+ return customization
}
// snapshotTestCustomization gets the test specific customization for the specified snapshotTest.
//
// If no customization was created previously then it creates a default customization.
func (i *snapshotBuildInfo) snapshotTestCustomization(snapshotTest snapshotTest) *snapshotTestCustomization {
- customization := i.snapshotTestCustomizations[snapshotTest]
- if customization == nil {
- customization = &snapshotTestCustomization{
+ customization := i.snapshotTestCustomizations.customization(snapshotTest)
+ if *customization == nil {
+ *customization = &snapshotTestCustomization{
errorHandler: android.FixtureExpectsNoErrors,
}
- i.snapshotTestCustomizations[snapshotTest] = customization
}
- return customization
+ return *customization
}
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index e230795..4ea8a0b 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -160,6 +160,7 @@
DeviceTemplate string
HostTemplate string
HostUnitTestTemplate string
+ StandaloneTest *bool
}
func AutoGenTestConfig(ctx android.ModuleContext, options AutoGenTestConfigOptions) android.Path {
@@ -178,6 +179,12 @@
autogenTemplate(ctx, name, autogenPath, templatePath.String(), configs, options.TestRunnerOptions, options.OutputFileName, options.TestInstallBase)
} else {
if ctx.Device() {
+ if Bool(options.StandaloneTest) {
+ options.TestRunnerOptions = append(options.TestRunnerOptions, Option{
+ Name: "ld-library-path",
+ Value: "{TEST_INSTALL_BASE}/" + name + "/" + ctx.Arch().ArchType.String() + "/standalone-libs",
+ })
+ }
autogenTemplate(ctx, name, autogenPath, options.DeviceTemplate, configs, options.TestRunnerOptions, options.OutputFileName, options.TestInstallBase)
} else {
if Bool(options.UnitTest) {
@@ -190,7 +197,10 @@
return autogenPath
}
if len(options.OptionsForAutogenerated) > 0 {
- ctx.ModuleErrorf("Extra tradefed configurations were provided for an autogenerated xml file, but the autogenerated xml file was not used.")
+ ctx.ModuleErrorf("Extra tradefed configurations (%v) were provided for an autogenerated xml file, but the autogenerated xml file was not used.", options.OptionsForAutogenerated)
+ }
+ if len(options.TestRunnerOptions) > 0 {
+ ctx.ModuleErrorf("Extra test runner options (%v) were provided for an autogenerated xml file, but the autogenerated xml file was not used.", options.TestRunnerOptions)
}
return path
}
diff --git a/ui/build/build.go b/ui/build/build.go
index ea86782..95d7831 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -427,6 +427,9 @@
if config.Checkbuild() {
what |= RunBuildTests
}
+ if value, ok := config.environ.Get("RUN_BUILD_TESTS"); ok && value == "true" {
+ what |= RunBuildTests
+ }
if !config.SkipConfig() {
what |= RunProductConfig
} else {
diff --git a/ui/build/config.go b/ui/build/config.go
index fdd15ff..2a00c41 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -1101,7 +1101,7 @@
func (c *configImpl) NinjaArgs() []string {
if c.skipKati {
- return c.arguments
+ return append(c.arguments, c.ninjaArgs...)
}
return c.ninjaArgs
}
diff --git a/ui/build/test_build.go b/ui/build/test_build.go
index 7a2fd16..87bec93 100644
--- a/ui/build/test_build.go
+++ b/ui/build/test_build.go
@@ -76,8 +76,10 @@
// treated as an source file.
dexpreoptConfigFilePath := filepath.Join(outDir, "soong", "dexpreopt.config")
- // out/build_date.txt is considered a "source file"
+ // out/build_(date|hostname|number).txt is considered a "source file"
buildDatetimeFilePath := filepath.Join(outDir, "build_date.txt")
+ buildHostnameFilePath := filepath.Join(outDir, "soong", "build_hostname.txt")
+ buildNumberFilePath := filepath.Join(outDir, "soong", "build_number.txt")
// release-config files are generated from the initial lunch or Kati phase
// before running soong and ninja.
@@ -102,6 +104,8 @@
line == extraVariablesFilePath ||
line == dexpreoptConfigFilePath ||
line == buildDatetimeFilePath ||
+ line == buildHostnameFilePath ||
+ line == buildNumberFilePath ||
strings.HasPrefix(line, releaseConfigDir) ||
buildFingerPrintFilePattern.MatchString(line) {
// Leaf node is in one of Soong's bootstrap directories, which do not have
diff --git a/vnames.json b/vnames.json
index 096260f..9e006bb 100644
--- a/vnames.json
+++ b/vnames.json
@@ -1,5 +1,17 @@
[
{
+ "pattern": "out/(.*)/srcjars.xref/frameworks/base/services/core/(.*)/android/server/am/(.*)",
+ "vname": {
+ "path": "frameworks/base/services/core/@2@/android/server/am/@3@"
+ }
+ },
+ {
+ "pattern": "out/(.*)/srcjars.xref/frameworks/base/services/core/(.*)/android/server/wm/(.*)",
+ "vname": {
+ "path": "frameworks/base/services/core/@2@/android/server/wm/@3@"
+ }
+ },
+ {
"pattern": "out/(.*)",
"vname": {
"root": "out",
diff --git a/zip/cmd/main.go b/zip/cmd/main.go
index 37537ab..831f6d4 100644
--- a/zip/cmd/main.go
+++ b/zip/cmd/main.go
@@ -164,6 +164,7 @@
directories := flags.Bool("d", false, "include directories in zip")
compLevel := flags.Int("L", 5, "deflate compression level (0-9)")
emulateJar := flags.Bool("jar", false, "modify the resultant .zip to emulate the output of 'jar'")
+ sortEntries := flags.Bool("sort_entries", false, "sort the zip entries")
writeIfChanged := flags.Bool("write_if_changed", false, "only update resultant .zip if it has changed")
ignoreMissingFiles := flags.Bool("ignore_missing_files", false, "continue if a requested file does not exist")
symlinks := flags.Bool("symlinks", true, "store symbolic links in zip instead of following them")
@@ -228,6 +229,7 @@
FileArgs: fileArgsBuilder.FileArgs(),
OutputFilePath: *out,
EmulateJar: *emulateJar,
+ SortEntries: *sortEntries,
SrcJar: *srcJar,
AddDirectoryEntriesToZip: *directories,
CompressionLevel: *compLevel,
diff --git a/zip/zip.go b/zip/zip.go
index f91a5f2..e4e9585 100644
--- a/zip/zip.go
+++ b/zip/zip.go
@@ -272,6 +272,7 @@
FileArgs []FileArg
OutputFilePath string
EmulateJar bool
+ SortEntries bool
SrcJar bool
AddDirectoryEntriesToZip bool
CompressionLevel int
@@ -394,7 +395,7 @@
}
}
- return z.write(w, pathMappings, args.ManifestSourcePath, args.EmulateJar, args.SrcJar, args.NumParallelJobs)
+ return z.write(w, pathMappings, args.ManifestSourcePath, args.EmulateJar, args.SortEntries, args.SrcJar, args.NumParallelJobs)
}
// Zip creates an output zip archive from given sources.
@@ -481,7 +482,8 @@
})
}
-func (z *ZipWriter) write(f io.Writer, pathMappings []pathMapping, manifest string, emulateJar, srcJar bool,
+func (z *ZipWriter) write(f io.Writer, pathMappings []pathMapping, manifest string,
+ emulateJar, sortEntries, srcJar bool,
parallelJobs int) error {
z.errors = make(chan error)
@@ -511,12 +513,20 @@
return errors.New("must specify --jar when specifying a manifest via -m")
}
+ if emulateJar && sortEntries {
+ return errors.New("Cannot specify both --jar and --sort_entries (--jar implies sorting with a different algorithm)")
+ }
if emulateJar {
// manifest may be empty, in which case addManifest will fill in a default
pathMappings = append(pathMappings, pathMapping{jar.ManifestFile, manifest, zip.Deflate})
jarSort(pathMappings)
}
+ if sortEntries {
+ sort.SliceStable(pathMappings, func(i int, j int) bool {
+ return pathMappings[i].dest < pathMappings[j].dest
+ })
+ }
go func() {
var err error