diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/aar_test.go | 5 | ||||
-rw-r--r-- | java/androidmk.go | 8 | ||||
-rw-r--r-- | java/app_import_test.go | 6 | ||||
-rw-r--r-- | java/app_test.go | 2 | ||||
-rw-r--r-- | java/boot_jars.go | 4 | ||||
-rw-r--r-- | java/bootclasspath.go | 5 | ||||
-rw-r--r-- | java/bootclasspath_fragment.go | 6 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 4 | ||||
-rw-r--r-- | java/droidstubs.go | 59 | ||||
-rw-r--r-- | java/droidstubs_test.go | 2 | ||||
-rw-r--r-- | java/fuzz.go | 2 | ||||
-rw-r--r-- | java/gen.go | 41 | ||||
-rw-r--r-- | java/hiddenapi_modular.go | 2 | ||||
-rw-r--r-- | java/jacoco.go | 2 | ||||
-rw-r--r-- | java/java.go | 1 | ||||
-rw-r--r-- | java/java_test.go | 1 | ||||
-rw-r--r-- | java/jdeps.go | 2 | ||||
-rw-r--r-- | java/lint.go | 4 | ||||
-rw-r--r-- | java/platform_compat_config.go | 3 | ||||
-rw-r--r-- | java/rro_test.go | 2 | ||||
-rw-r--r-- | java/sdk_library.go | 2 | ||||
-rw-r--r-- | java/sdk_library_test.go | 1 |
22 files changed, 92 insertions, 72 deletions
diff --git a/java/aar_test.go b/java/aar_test.go index d6dbe3c25..18efd2067 100644 --- a/java/aar_test.go +++ b/java/aar_test.go @@ -15,8 +15,9 @@ package java import ( - "android/soong/android" "testing" + + "android/soong/android" ) func TestAarImportProducesJniPackages(t *testing.T) { @@ -98,6 +99,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -105,6 +107,7 @@ func TestLibraryFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/androidmk.go b/java/androidmk.go index a52d43965..9cd0bafea 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -92,11 +92,7 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) { if len(library.logtagsSrcs) > 0 { - var logtags []string - for _, l := range library.logtagsSrcs { - logtags = append(logtags, l.Rel()) - } - entries.AddStrings("LOCAL_LOGTAGS_FILES", logtags...) + entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", library.logtagsSrcs.Strings()...) } if library.installFile == nil { @@ -457,6 +453,8 @@ func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries { if app.Name() != "framework-res" { android.SetAconfigFileMkEntries(&app.ModuleBase, entries, app.mergedAconfigFiles) } + + entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", app.logtagsSrcs.Strings()...) }, }, ExtraFooters: []android.AndroidMkExtraFootersFunc{ diff --git a/java/app_import_test.go b/java/app_import_test.go index 5de50e794..496fc1308 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -509,7 +509,7 @@ func TestAndroidAppImport_ArchVariants(t *testing.T) { variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -586,7 +586,7 @@ func TestAndroidAppImport_SoongConfigVariables(t *testing.T) { variant := ctx.ModuleForTests("foo", "android_common") if test.expected == "" { - if variant.Module().Enabled() { + if variant.Module().Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Error("module should have been disabled, but wasn't") } rule := variant.MaybeRule("genProvenanceMetaData") @@ -629,7 +629,7 @@ func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) { if !a.prebuilt.UsePrebuilt() { t.Errorf("prebuilt foo module is not active") } - if !a.Enabled() { + if !a.Enabled(android.PanickingConfigAndErrorContext(ctx)) { t.Errorf("prebuilt foo module is disabled") } } diff --git a/java/app_test.go b/java/app_test.go index eab40e7da..a7c48a1ed 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -4382,6 +4382,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -4389,6 +4390,7 @@ func TestAppFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/boot_jars.go b/java/boot_jars.go index 5d40ec389..6223dede8 100644 --- a/java/boot_jars.go +++ b/java/boot_jars.go @@ -21,8 +21,8 @@ import ( // isActiveModule returns true if the given module should be considered for boot // jars, i.e. if it's enabled and the preferred one in case of source and // prebuilt alternatives. -func isActiveModule(module android.Module) bool { - if !module.Enabled() { +func isActiveModule(ctx android.ConfigAndErrorContext, module android.Module) bool { + if !module.Enabled(ctx) { return false } return android.IsModulePreferred(module) diff --git a/java/bootclasspath.go b/java/bootclasspath.go index c7dc3afae..77ddf5c05 100644 --- a/java/bootclasspath.go +++ b/java/bootclasspath.go @@ -127,7 +127,10 @@ func reportMissingVariationDependency(ctx android.BottomUpMutatorContext, variat // added by addDependencyOntoApexModulePair. func gatherApexModulePairDepsWithTag(ctx android.BaseModuleContext, tag blueprint.DependencyTag) []android.Module { var modules []android.Module - ctx.VisitDirectDepsIf(isActiveModule, func(module android.Module) { + isActiveModulePred := func(module android.Module) bool { + return isActiveModule(ctx, module) + } + ctx.VisitDirectDepsIf(isActiveModulePred, func(module android.Module) { t := ctx.OtherModuleDependencyTag(module) if t == tag { modules = append(modules, module) diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index cc3da7656..82a34ca9d 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -474,7 +474,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // Only perform a consistency check if this module is the active module. That will prevent an // unused prebuilt that was created without instrumentation from breaking an instrumentation // build. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { b.bootclasspathFragmentPropertyCheck(ctx) } @@ -519,7 +519,7 @@ func (b *BootclasspathFragmentModule) GenerateAndroidBuildActions(ctx android.Mo // empty string if this module should not provide a boot image profile. func (b *BootclasspathFragmentModule) getProfileProviderApex(ctx android.BaseModuleContext) string { // Only use the profile from the module that is preferred. - if !isActiveModule(ctx.Module()) { + if !isActiveModule(ctx, ctx.Module()) { return "" } @@ -590,7 +590,7 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) // So ignore it even if it is not in PRODUCT_APEX_BOOT_JARS. // TODO(b/202896428): Add better way to handle this. _, unknown = android.RemoveFromList("android.car-module", unknown) - if isActiveModule(ctx.Module()) && len(unknown) > 0 { + if isActiveModule(ctx, ctx.Module()) && len(unknown) > 0 { ctx.ModuleErrorf("%s in contents must also be declared in PRODUCT_APEX_BOOT_JARS", unknown) } } diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index f7e3cb93a..7229ca02d 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -562,7 +562,7 @@ func gatherBootclasspathFragments(ctx android.ModuleContext) map[string]android. return ctx.Config().Once(dexBootJarsFragmentsKey, func() interface{} { fragments := make(map[string]android.Module) ctx.WalkDeps(func(child, parent android.Module) bool { - if !isActiveModule(child) { + if !isActiveModule(ctx, child) { return false } tag := ctx.OtherModuleDependencyTag(child) @@ -1125,7 +1125,7 @@ func buildBootImageVariant(ctx android.ModuleContext, image *bootImageVariant, p image.unstrippedInstalls = unstrippedInstalls // Only set the licenseMetadataFile from the active module. - if isActiveModule(ctx.Module()) { + if isActiveModule(ctx, ctx.Module()) { image.licenseMetadataFile = android.OptionalPathForPath(ctx.LicenseMetadataFile()) } diff --git a/java/droidstubs.go b/java/droidstubs.go index 08caf9109..730be14b0 100644 --- a/java/droidstubs.go +++ b/java/droidstubs.go @@ -604,6 +604,11 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a } } +// AndroidPlusUpdatableJar is the name of some extra jars added into `module-lib` and +// `system-server` directories that contain all the APIs provided by the platform and updatable +// modules because the `android.jar` files do not. See b/337836752. +const AndroidPlusUpdatableJar = "android-plus-updatable.jar" + func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand, stubsType StubsType, apiVersionsXml android.WritablePath) { if len(d.properties.Api_levels_annotations_dirs) == 0 { ctx.PropertyErrorf("api_levels_annotations_dirs", @@ -621,7 +626,8 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // privileged apps that are only defined since API level 21 (Lollipop), fallback to public stubs // for older releases. Similarly, module-lib falls back to system API. var sdkDirs []string - switch proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") { + apiLevelsSdkType := proptools.StringDefault(d.properties.Api_levels_sdk_type, "public") + switch apiLevelsSdkType { case "system-server": sdkDirs = []string{"system-server", "module-lib", "system", "public"} case "module-lib": @@ -635,9 +641,22 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an return } + // Construct a pattern to match the appropriate extensions that should be included in the + // generated api-versions.xml file. + // // Use the first item in the sdkDirs array as that is the sdk type for the target API levels // being generated but has the advantage over `Api_levels_sdk_type` as it has been validated. - extensionsPattern := fmt.Sprintf(`/extensions/[0-9]+/%s/.*\.jar`, sdkDirs[0]) + // The exception is for system-server which needs to include module-lib and system-server. That + // is because while system-server extends module-lib the system-server extension directory only + // contains service-* modules which provide system-server APIs it does not list the modules which + // only provide a module-lib, so they have to be included separately. + extensionSurfacesPattern := sdkDirs[0] + if apiLevelsSdkType == "system-server" { + // Take the first two items in sdkDirs, which are system-server and module-lib, and construct + // a pattern that will match either. + extensionSurfacesPattern = strings.Join(sdkDirs[0:2], "|") + } + extensionsPattern := fmt.Sprintf(`/extensions/[0-9]+/(%s)/.*\.jar`, extensionSurfacesPattern) var dirs []string var extensions_dir string @@ -648,16 +667,24 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an // Grab the first extensions_dir and we find while scanning ExportedDroiddocDir.deps; // ideally this should be read from prebuiltApis.properties.Extensions_* for _, dep := range t.deps { + // Check to see if it matches an extension first. + depBase := dep.Base() if extRegex.MatchString(dep.String()) && d.properties.Extensions_info_file != nil { if extensions_dir == "" { extensions_dir = t.dir.String() + "/extensions" } cmd.Implicit(dep) - } - if dep.Base() == filename { + } else if depBase == filename { + // Check to see if it matches a dessert release for an SDK, e.g. Android, Car, Wear, etc.. cmd.Implicit(dep) - } - if filename != "android.jar" && dep.Base() == "android.jar" { + } else if depBase == AndroidPlusUpdatableJar && d.properties.Extensions_info_file != nil { + // The output api-versions.xml has been requested to include information on SDK + // extensions. That means it also needs to include + // so + // The module-lib and system-server directories should use `android-plus-updatable.jar` + // instead of `android.jar`. See AndroidPlusUpdatableJar for more information. + cmd.Implicit(dep) + } else if filename != "android.jar" && depBase == "android.jar" { // Metalava implicitly searches these patterns: // prebuilts/tools/common/api-versions/android-%/android.jar // prebuilts/sdk/%/public/android.jar @@ -675,9 +702,25 @@ func (d *Droidstubs) apiLevelsGenerationFlags(ctx android.ModuleContext, cmd *an } }) + // Generate the list of --android-jar-pattern options. The order matters so the first one which + // matches will be the one that is used for a specific api level.. for _, sdkDir := range sdkDirs { for _, dir := range dirs { - cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, filename)) + addPattern := func(jarFilename string) { + cmd.FlagWithArg("--android-jar-pattern ", fmt.Sprintf("%s/%%/%s/%s", dir, sdkDir, jarFilename)) + } + + if sdkDir == "module-lib" || sdkDir == "system-server" { + // The module-lib and system-server android.jars do not include the updatable modules (as + // doing so in the source would introduce dependency cycles and the prebuilts have to + // match the sources). So, instead an additional `android-plus-updatable.jar` will be used + // that does include the updatable modules and this pattern will match that. This pattern + // is added in addition to the following pattern to decouple this change from the change + // to add the `android-plus-updatable.jar`. + addPattern(AndroidPlusUpdatableJar) + } + + addPattern(filename) } } @@ -1327,7 +1370,7 @@ func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) { // use a strict naming convention var ( droidstubsModuleNamingToSdkKind = map[string]android.SdkKind{ - //public is commented out since the core libraries use public in their java_sdk_library names + // public is commented out since the core libraries use public in their java_sdk_library names "intracore": android.SdkIntraCore, "intra.core": android.SdkIntraCore, "system_server": android.SdkSystemServer, diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go index 8da695f08..6a14f3645 100644 --- a/java/droidstubs_test.go +++ b/java/droidstubs_test.go @@ -379,6 +379,7 @@ func TestAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -434,6 +435,7 @@ func TestReleaseExportRuntimeApis(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/fuzz.go b/java/fuzz.go index fb31ce794..d37c55804 100644 --- a/java/fuzz.go +++ b/java/fuzz.go @@ -179,7 +179,7 @@ func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) { javaFuzzModule.ApexModuleBase, } - if ok := fuzz.IsValid(fuzzModuleValidator); !ok { + if ok := fuzz.IsValid(ctx, fuzzModuleValidator); !ok { return } diff --git a/java/gen.go b/java/gen.go index 68a9b53fe..1b4f4c7dc 100644 --- a/java/gen.go +++ b/java/gen.go @@ -27,7 +27,6 @@ import ( func init() { pctx.SourcePathVariable("logtagsCmd", "build/make/tools/java-event-log-tags.py") - pctx.SourcePathVariable("mergeLogtagsCmd", "build/make/tools/merge-event-log-tags.py") pctx.SourcePathVariable("logtagsLib", "build/make/tools/event_log_tags.py") } @@ -37,12 +36,6 @@ var ( Command: "$logtagsCmd -o $out $in", CommandDeps: []string{"$logtagsCmd", "$logtagsLib"}, }) - - mergeLogtags = pctx.AndroidStaticRule("mergeLogtags", - blueprint.RuleParams{ - Command: "$mergeLogtagsCmd -o $out $in", - CommandDeps: []string{"$mergeLogtagsCmd", "$logtagsLib"}, - }) ) func genAidl(ctx android.ModuleContext, aidlFiles android.Paths, aidlGlobalFlags string, aidlIndividualFlags map[string]string, deps android.Paths) android.Paths { @@ -178,37 +171,9 @@ func (j *Module) genSources(ctx android.ModuleContext, srcFiles android.Paths, outSrcFiles = append(outSrcFiles, srcJarFiles...) } - return outSrcFiles -} - -func LogtagsSingleton() android.Singleton { - return &logtagsSingleton{} -} - -type logtagsProducer interface { - logtags() android.Paths -} - -func (j *Module) logtags() android.Paths { - return j.logtagsSrcs -} - -var _ logtagsProducer = (*Module)(nil) - -type logtagsSingleton struct{} - -func (l *logtagsSingleton) GenerateBuildActions(ctx android.SingletonContext) { - var allLogtags android.Paths - ctx.VisitAllModules(func(module android.Module) { - if logtags, ok := module.(logtagsProducer); ok { - allLogtags = append(allLogtags, logtags.logtags()...) - } + android.SetProvider(ctx, android.LogtagsProviderKey, &android.LogtagsInfo{ + Logtags: j.logtagsSrcs, }) - ctx.Build(pctx, android.BuildParams{ - Rule: mergeLogtags, - Description: "merge logtags", - Output: android.PathForIntermediates(ctx, "all-event-log-tags.txt"), - Inputs: allLogtags, - }) + return outSrcFiles } diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index ae587eac3..cab5402e9 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -1428,7 +1428,7 @@ func deferReportingMissingBootDexJar(ctx android.ModuleContext, module android.M // should not contribute to anything. So, rather than have a missing dex jar cause a Soong // failure defer the error reporting to Ninja. Unless the prebuilt build target is explicitly // built Ninja should never use the dex jar file. - if !isActiveModule(module) { + if !isActiveModule(ctx, module) { return true } diff --git a/java/jacoco.go b/java/jacoco.go index a820b3855..696a0cc37 100644 --- a/java/jacoco.go +++ b/java/jacoco.go @@ -53,7 +53,7 @@ func jacocoDepsMutator(ctx android.BottomUpMutatorContext) { } j, ok := ctx.Module().(instrumentable) - if !ctx.Module().Enabled() || !ok { + if !ctx.Module().Enabled(ctx) || !ok { return } diff --git a/java/java.go b/java/java.go index 725e25abe..30581f265 100644 --- a/java/java.go +++ b/java/java.go @@ -75,7 +75,6 @@ func registerJavaBuildComponents(ctx android.RegistrationContext) { ctx.BottomUp("jacoco_deps", jacocoDepsMutator).Parallel() }) - ctx.RegisterParallelSingletonType("logtags", LogtagsSingleton) ctx.RegisterParallelSingletonType("kythe_java_extract", kytheExtractJavaFactory) } diff --git a/java/java_test.go b/java/java_test.go index a1192bb5f..2f2793202 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2801,6 +2801,7 @@ func TestApiLibraryAconfigDeclarations(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], diff --git a/java/jdeps.go b/java/jdeps.go index 91f7ce715..340026318 100644 --- a/java/jdeps.go +++ b/java/jdeps.go @@ -48,7 +48,7 @@ func (j *jdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCont moduleInfos := make(map[string]android.IdeInfo) ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } diff --git a/java/lint.go b/java/lint.go index 31e7f353d..82fac91cf 100644 --- a/java/lint.go +++ b/java/lint.go @@ -612,7 +612,7 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { apiVersionsDb := findModuleOrErr(ctx, files.apiVersionsModule) if apiVersionsDb == nil { if !ctx.Config().AllowMissingDependencies() { - ctx.Errorf("lint: missing module api_versions_public") + ctx.Errorf("lint: missing module %s", files.apiVersionsModule) } return } @@ -620,7 +620,7 @@ func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { sdkAnnotations := findModuleOrErr(ctx, files.annotationsModule) if sdkAnnotations == nil { if !ctx.Config().AllowMissingDependencies() { - ctx.Errorf("lint: missing module sdk-annotations.zip") + ctx.Errorf("lint: missing module %s", files.annotationsModule) } return } diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go index 2fc6c02a6..99fa092be 100644 --- a/java/platform_compat_config.go +++ b/java/platform_compat_config.go @@ -19,6 +19,7 @@ import ( "path/filepath" "android/soong/android" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" ) @@ -233,7 +234,7 @@ func (p *platformCompatConfigSingleton) GenerateBuildActions(ctx android.Singlet var compatConfigMetadata android.Paths ctx.VisitAllModules(func(module android.Module) { - if !module.Enabled() { + if !module.Enabled(ctx) { return } if c, ok := module.(platformCompatConfigMetadataProvider); ok { diff --git a/java/rro_test.go b/java/rro_test.go index d697ec627..742c83982 100644 --- a/java/rro_test.go +++ b/java/rro_test.go @@ -421,6 +421,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package.bar", + container: "com.android.foo", srcs: [ "bar.aconfig", ], @@ -428,6 +429,7 @@ func TestRuntimeResourceOverlayFlagsPackages(t *testing.T) { aconfig_declarations { name: "baz", package: "com.example.package.baz", + container: "com.android.foo", srcs: [ "baz.aconfig", ], diff --git a/java/sdk_library.go b/java/sdk_library.go index 113071fbb..2b6c8f8de 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -2294,7 +2294,7 @@ func (module *SdkLibrary) getApiDir() string { // once for public API level and once for system API level func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) { // If the module has been disabled then don't create any child modules. - if !module.Enabled() { + if !module.Enabled(mctx) { return } diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 0f163e6e0..34c63ac61 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1715,6 +1715,7 @@ func TestSdkLibraryExportableStubsLibrary(t *testing.T) { aconfig_declarations { name: "bar", package: "com.example.package", + container: "com.android.foo", srcs: [ "bar.aconfig", ], |