diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/Android.bp | 1 | ||||
| -rwxr-xr-x | java/app.go | 64 | ||||
| -rw-r--r-- | java/app_test.go | 2 | ||||
| -rw-r--r-- | java/base.go | 2 | ||||
| -rw-r--r-- | java/bootclasspath_fragment.go | 64 | ||||
| -rw-r--r-- | java/classpath_fragment.go | 6 | ||||
| -rw-r--r-- | java/config/config.go | 2 | ||||
| -rw-r--r-- | java/dex.go | 28 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars.go | 16 | ||||
| -rw-r--r-- | java/dexpreopt_config.go | 38 | ||||
| -rw-r--r-- | java/dexpreopt_test.go | 5 | ||||
| -rw-r--r-- | java/hiddenapi.go | 10 | ||||
| -rw-r--r-- | java/hiddenapi_modular.go | 98 | ||||
| -rw-r--r-- | java/hiddenapi_monolithic.go | 64 | ||||
| -rw-r--r-- | java/java.go | 2 | ||||
| -rw-r--r-- | java/java_test.go | 10 | ||||
| -rw-r--r-- | java/kotlin_test.go | 7 | ||||
| -rw-r--r-- | java/lint_defaults.txt | 44 | ||||
| -rw-r--r-- | java/platform_bootclasspath.go | 69 | ||||
| -rw-r--r-- | java/plugin_test.go | 5 | ||||
| -rw-r--r-- | java/robolectric.go | 16 | ||||
| -rw-r--r-- | java/sdk_library.go | 2 | ||||
| -rw-r--r-- | java/sdk_test.go | 14 | ||||
| -rw-r--r-- | java/systemserver_classpath_fragment.go | 8 | ||||
| -rw-r--r-- | java/testing.go | 8 |
25 files changed, 361 insertions, 224 deletions
diff --git a/java/Android.bp b/java/Android.bp index e5b8f9604..9ffa12384 100644 --- a/java/Android.bp +++ b/java/Android.bp @@ -10,6 +10,7 @@ bootstrap_go_package { "blueprint-pathtools", "soong", "soong-android", + "soong-bazel", "soong-cc", "soong-dexpreopt", "soong-genrule", diff --git a/java/app.go b/java/app.go index 4e967ad45..35ed27f52 100755 --- a/java/app.go +++ b/java/app.go @@ -26,6 +26,7 @@ import ( "github.com/google/blueprint/proptools" "android/soong/android" + "android/soong/bazel" "android/soong/cc" "android/soong/dexpreopt" "android/soong/tradefed" @@ -42,6 +43,8 @@ func RegisterAppBuildComponents(ctx android.RegistrationContext) { ctx.RegisterModuleType("android_app_certificate", AndroidAppCertificateFactory) ctx.RegisterModuleType("override_android_app", OverrideAndroidAppModuleFactory) ctx.RegisterModuleType("override_android_test", OverrideAndroidTestModuleFactory) + + android.RegisterBp2BuildMutator("android_app_certificate", AndroidAppCertificateBp2Build) } // AndroidManifest.xml merging @@ -1104,6 +1107,8 @@ func AndroidTestHelperAppFactory() android.Module { type AndroidAppCertificate struct { android.ModuleBase + android.BazelModuleBase + properties AndroidAppCertificateProperties Certificate Certificate } @@ -1119,6 +1124,7 @@ func AndroidAppCertificateFactory() android.Module { module := &AndroidAppCertificate{} module.AddProperties(&module.properties) android.InitAndroidModule(module) + android.InitBazelModule(module) return module } @@ -1368,3 +1374,61 @@ func (u *usesLibrary) verifyUsesLibrariesAPK(ctx android.ModuleContext, apk andr outputFile := android.PathForModuleOut(ctx, "verify_uses_libraries", apk.Base()) return outputFile } + +// For Bazel / bp2build + +type bazelAndroidAppCertificateAttributes struct { + Certificate string +} + +type bazelAndroidAppCertificate struct { + android.BazelTargetModuleBase + bazelAndroidAppCertificateAttributes +} + +func BazelAndroidAppCertificateFactory() android.Module { + module := &bazelAndroidAppCertificate{} + module.AddProperties(&module.bazelAndroidAppCertificateAttributes) + android.InitBazelTargetModule(module) + return module +} + +func AndroidAppCertificateBp2Build(ctx android.TopDownMutatorContext) { + module, ok := ctx.Module().(*AndroidAppCertificate) + if !ok { + // Not an Android app certificate + return + } + if !module.ConvertWithBp2build(ctx) { + return + } + if ctx.ModuleType() != "android_app_certificate" { + return + } + + androidAppCertificateBp2BuildInternal(ctx, module) +} + +func androidAppCertificateBp2BuildInternal(ctx android.TopDownMutatorContext, module *AndroidAppCertificate) { + var certificate string + if module.properties.Certificate != nil { + certificate = *module.properties.Certificate + } + + attrs := &bazelAndroidAppCertificateAttributes{ + Certificate: certificate, + } + + props := bazel.BazelTargetModuleProperties{ + Rule_class: "android_app_certificate", + Bzl_load_location: "//build/bazel/rules:android_app_certificate.bzl", + } + + ctx.CreateBazelTargetModule(BazelAndroidAppCertificateFactory, module.Name(), props, attrs) +} + +func (m *bazelAndroidAppCertificate) Name() string { + return m.BaseModuleName() +} + +func (m *bazelAndroidAppCertificate) GenerateAndroidBuildActions(ctx android.ModuleContext) {} diff --git a/java/app_test.go b/java/app_test.go index a99ac62da..7997f7ad8 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2471,7 +2471,7 @@ func TestDexpreoptBcp(t *testing.T) { PrepareForTestWithJavaSdkLibraryFiles, FixtureWithLastReleaseApis("runtime-library", "foo", "bar"), dexpreopt.FixtureSetBootJars("platform:foo"), - dexpreopt.FixtureSetUpdatableBootJars("platform:bar"), + dexpreopt.FixtureSetApexBootJars("platform:bar"), dexpreopt.FixtureSetPreoptWithUpdatableBcp(test.with), ).RunTestWithBp(t, bp) diff --git a/java/base.go b/java/base.go index 6b8119619..d8cd6b3c1 100644 --- a/java/base.go +++ b/java/base.go @@ -1230,7 +1230,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { } // Dex compilation var dexOutputFile android.OutputPath - dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(ctx), outputFile, jarName) + dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(ctx), implementationAndResourcesJar, jarName) if ctx.Failed() { return } diff --git a/java/bootclasspath_fragment.go b/java/bootclasspath_fragment.go index 503c31fd7..bb542c49c 100644 --- a/java/bootclasspath_fragment.go +++ b/java/bootclasspath_fragment.go @@ -537,15 +537,11 @@ func (b *BootclasspathFragmentModule) configuredJars(ctx android.ModuleContext) global := dexpreopt.GetGlobalConfig(ctx) - possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag) - - // Only create configs for updatable boot jars. Non-updatable boot jars must be part of the - // platform_bootclasspath's classpath proto config to guarantee that they come before any - // updatable jars at runtime. - jars := global.UpdatableBootJars.Filter(possibleUpdatableModules) + possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, b.properties.Contents, bootclasspathFragmentContentDepTag) + jars := global.ApexBootJars.Filter(possibleUpdatableModules) // TODO(satayev): for apex_test we want to include all contents unconditionally to classpaths - // config. However, any test specific jars would not be present in UpdatableBootJars. Instead, + // config. However, any test specific jars would not be present in ApexBootJars. Instead, // we should check if we are creating a config for apex_test via ApexInfo and amend the values. // This is an exception to support end-to-end test for SdkExtensions, until such support exists. if android.InList("test_framework-sdkextensions", possibleUpdatableModules) { @@ -583,6 +579,14 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android. common := ctx.Module().(commonBootclasspathFragment) output := common.produceHiddenAPIOutput(ctx, contents, input) + // If the source or prebuilts module does not provide a signature patterns file then generate one + // from the flags. + // TODO(b/192868581): Remove once the source and prebuilts provide a signature patterns file of + // their own. + if output.SignaturePatternsPath == nil { + output.SignaturePatternsPath = buildRuleSignaturePatternsFile(ctx, output.AllFlagsPath) + } + // Initialize a HiddenAPIInfo structure. hiddenAPIInfo := HiddenAPIInfo{ // The monolithic hidden API processing needs access to the flag files that override the default @@ -599,7 +603,7 @@ func (b *BootclasspathFragmentModule) generateHiddenAPIBuildActions(ctx android. // The monolithic hidden API processing also needs access to all the output files produced by // hidden API processing of this fragment. - hiddenAPIInfo.HiddenAPIFlagOutput = (*output).HiddenAPIFlagOutput + hiddenAPIInfo.HiddenAPIFlagOutput = output.HiddenAPIFlagOutput // Provide it for use by other modules. ctx.SetProvider(HiddenAPIInfoProvider, hiddenAPIInfo) @@ -748,9 +752,6 @@ type bootclasspathFragmentSdkMemberProperties struct { // Flag files by *hiddenAPIFlagFileCategory Flag_files_by_category FlagFilesByCategory - // The path to the generated stub-flags.csv file. - Stub_flags_path android.OptionalPath - // The path to the generated annotation-flags.csv file. Annotation_flags_path android.OptionalPath @@ -760,6 +761,12 @@ type bootclasspathFragmentSdkMemberProperties struct { // The path to the generated index.csv file. Index_path android.OptionalPath + // The path to the generated signature-patterns.csv file. + Signature_patterns_path android.OptionalPath + + // The path to the generated stub-flags.csv file. + Stub_flags_path android.OptionalPath + // The path to the generated all-flags.csv file. All_flags_path android.OptionalPath } @@ -776,10 +783,12 @@ func (b *bootclasspathFragmentSdkMemberProperties) PopulateFromVariant(ctx andro b.Flag_files_by_category = hiddenAPIInfo.FlagFilesByCategory // Copy all the generated file paths. - b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath) b.Annotation_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AnnotationFlagsPath) b.Metadata_path = android.OptionalPathForPath(hiddenAPIInfo.MetadataPath) b.Index_path = android.OptionalPathForPath(hiddenAPIInfo.IndexPath) + + b.Signature_patterns_path = android.OptionalPathForPath(hiddenAPIInfo.SignaturePatternsPath) + b.Stub_flags_path = android.OptionalPathForPath(hiddenAPIInfo.StubFlagsPath) b.All_flags_path = android.OptionalPathForPath(hiddenAPIInfo.AllFlagsPath) // Copy stub_libs properties. @@ -843,10 +852,11 @@ func (b *bootclasspathFragmentSdkMemberProperties) AddToPropertySet(ctx android. } // Copy all the generated files, if available. - copyOptionalPath(b.Stub_flags_path, "stub_flags") copyOptionalPath(b.Annotation_flags_path, "annotation_flags") copyOptionalPath(b.Metadata_path, "metadata") copyOptionalPath(b.Index_path, "index") + copyOptionalPath(b.Signature_patterns_path, "signature_patterns") + copyOptionalPath(b.Stub_flags_path, "stub_flags") copyOptionalPath(b.All_flags_path, "all_flags") } @@ -856,9 +866,6 @@ var _ android.SdkMemberType = (*bootclasspathFragmentMemberType)(nil) // specific properties. type prebuiltBootclasspathFragmentProperties struct { Hidden_api struct { - // The path to the stub-flags.csv file created by the bootclasspath_fragment. - Stub_flags *string `android:"path"` - // The path to the annotation-flags.csv file created by the bootclasspath_fragment. Annotation_flags *string `android:"path"` @@ -868,6 +875,12 @@ type prebuiltBootclasspathFragmentProperties struct { // The path to the index.csv file created by the bootclasspath_fragment. Index *string `android:"path"` + // The path to the signature-patterns.csv file created by the bootclasspath_fragment. + Signature_patterns *string `android:"path"` + + // The path to the stub-flags.csv file created by the bootclasspath_fragment. + Stub_flags *string `android:"path"` + // The path to the all-flags.csv file created by the bootclasspath_fragment. All_flags *string `android:"path"` } @@ -898,11 +911,17 @@ func (module *prebuiltBootclasspathFragmentModule) Name() string { func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleContext, contents []android.Module, input HiddenAPIFlagInput) *HiddenAPIOutput { pathForOptionalSrc := func(src *string) android.Path { if src == nil { - // TODO(b/179354495): Fail if this is not provided once prebuilts have been updated. return nil } return android.PathForModuleSrc(ctx, *src) } + pathForSrc := func(property string, src *string) android.Path { + if src == nil { + ctx.PropertyErrorf(property, "is required but was not specified") + return android.PathForModuleSrc(ctx, "missing", property) + } + return android.PathForModuleSrc(ctx, *src) + } // Retrieve the dex files directly from the content modules. They in turn should retrieve the // encoded dex jars from the prebuilt .apex files. @@ -910,11 +929,12 @@ func (module *prebuiltBootclasspathFragmentModule) produceHiddenAPIOutput(ctx an output := HiddenAPIOutput{ HiddenAPIFlagOutput: HiddenAPIFlagOutput{ - StubFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Stub_flags), - AnnotationFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Annotation_flags), - MetadataPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Metadata), - IndexPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Index), - AllFlagsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.All_flags), + AnnotationFlagsPath: pathForSrc("hidden_api.annotation_flags", module.prebuiltProperties.Hidden_api.Annotation_flags), + MetadataPath: pathForSrc("hidden_api.metadata", module.prebuiltProperties.Hidden_api.Metadata), + IndexPath: pathForSrc("hidden_api.index", module.prebuiltProperties.Hidden_api.Index), + SignaturePatternsPath: pathForOptionalSrc(module.prebuiltProperties.Hidden_api.Signature_patterns), + StubFlagsPath: pathForSrc("hidden_api.stub_flags", module.prebuiltProperties.Hidden_api.Stub_flags), + AllFlagsPath: pathForSrc("hidden_api.all_flags", module.prebuiltProperties.Hidden_api.All_flags), }, EncodedBootDexFilesByModule: encodedBootDexJarsByModule, } diff --git a/java/classpath_fragment.go b/java/classpath_fragment.go index 12bb71174..f63d81d6e 100644 --- a/java/classpath_fragment.go +++ b/java/classpath_fragment.go @@ -91,8 +91,8 @@ type classpathJar struct { maxSdkVersion int32 } -// gatherPossibleUpdatableModuleNamesAndStems returns a set of module and stem names from the -// supplied contents that may be in the updatable boot jars. +// gatherPossibleApexModuleNamesAndStems returns a set of module and stem names from the +// supplied contents that may be in the apex boot jars. // // The module names are included because sometimes the stem is set to just change the name of // the installed file and it expects the configuration to still use the actual module name. @@ -100,7 +100,7 @@ type classpathJar struct { // The stem names are included because sometimes the stem is set to change the effective name of the // module that is used in the configuration as well,e .g. when a test library is overriding an // actual boot jar -func gatherPossibleUpdatableModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string { +func gatherPossibleApexModuleNamesAndStems(ctx android.ModuleContext, contents []string, tag blueprint.DependencyTag) []string { set := map[string]struct{}{} for _, name := range contents { dep := ctx.GetDirectDepWithTag(name, tag) diff --git a/java/config/config.go b/java/config/config.go index 273084c85..30c6f91aa 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -69,8 +69,6 @@ func init() { pctx.StaticVariable("JavacHeapSize", "2048M") pctx.StaticVariable("JavacHeapFlags", "-J-Xmx${JavacHeapSize}") pctx.StaticVariable("DexFlags", "-JXX:OnError='cat hs_err_pid%p.log' -JXX:CICompilerCount=6 -JXX:+UseDynamicNumberOfGCThreads") - // TODO(b/181095653): remove duplicated flags. - pctx.StaticVariable("DexJavaFlags", "-XX:OnError='cat hs_err_pid%p.log' -XX:CICompilerCount=6 -XX:+UseDynamicNumberOfGCThreads -Xmx2G") pctx.StaticVariable("CommonJdkFlags", strings.Join([]string{ `-Xmaxerrs 9999999`, diff --git a/java/dex.go b/java/dex.go index 6bf0143b1..667800f8a 100644 --- a/java/dex.go +++ b/java/dex.go @@ -84,19 +84,17 @@ func (d *dexer) effectiveOptimizeEnabled() bool { return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault) } -func init() { - pctx.HostBinToolVariable("runWithTimeoutCmd", "run_with_timeout") - pctx.SourcePathVariable("jstackCmd", "${config.JavaToolchain}/jstack") -} - var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", blueprint.RuleParams{ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` + - `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $in && ` + + `mkdir -p $$(dirname $tmpJar) && ` + + `${config.Zip2ZipCmd} -i $in -o $tmpJar -x '**/*.dex' && ` + + `$d8Template${config.D8Cmd} ${config.DexFlags} --output $outDir $d8Flags $tmpJar && ` + `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ "${config.D8Cmd}", + "${config.Zip2ZipCmd}", "${config.SoongZipCmd}", "${config.MergeZipsCmd}", }, @@ -115,17 +113,16 @@ var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8", ExecStrategy: "${config.RED8ExecStrategy}", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, - }, []string{"outDir", "d8Flags", "zipFlags"}, nil) + }, []string{"outDir", "d8Flags", "zipFlags", "tmpJar"}, nil) var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", blueprint.RuleParams{ Command: `rm -rf "$outDir" && mkdir -p "$outDir" && ` + `rm -f "$outDict" && rm -rf "${outUsageDir}" && ` + `mkdir -p $$(dirname ${outUsage}) && ` + - // TODO(b/181095653): remove R8 timeout and go back to config.R8Cmd. - `${runWithTimeoutCmd} -timeout 30m -on_timeout '${jstackCmd} $$PID' -- ` + - `$r8Template${config.JavaCmd} ${config.DexJavaFlags} -cp ${config.R8Jar} ` + - `com.android.tools.r8.compatproguard.CompatProguard -injars $in --output $outDir ` + + `mkdir -p $$(dirname $tmpJar) && ` + + `${config.Zip2ZipCmd} -i $in -o $tmpJar -x '**/*.dex' && ` + + `$r8Template${config.R8Cmd} ${config.DexFlags} -injars $tmpJar --output $outDir ` + `--no-data-resources ` + `-printmapping ${outDict} ` + `-printusage ${outUsage} ` + @@ -136,10 +133,10 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", `$zipTemplate${config.SoongZipCmd} $zipFlags -o $outDir/classes.dex.jar -C $outDir -f "$outDir/classes*.dex" && ` + `${config.MergeZipsCmd} -D -stripFile "**/*.class" $out $outDir/classes.dex.jar $in`, CommandDeps: []string{ - "${config.R8Jar}", + "${config.R8Cmd}", + "${config.Zip2ZipCmd}", "${config.SoongZipCmd}", "${config.MergeZipsCmd}", - "${runWithTimeoutCmd}", }, }, map[string]*remoteexec.REParams{ "$r8Template": &remoteexec.REParams{ @@ -165,7 +162,7 @@ var r8, r8RE = pctx.MultiCommandRemoteStaticRules("r8", Platform: map[string]string{remoteexec.PoolKey: "${config.REJavaPool}"}, }, }, []string{"outDir", "outDict", "outUsage", "outUsageZip", "outUsageDir", - "r8Flags", "zipFlags"}, []string{"implicits"}) + "r8Flags", "zipFlags", "tmpJar"}, []string{"implicits"}) func (d *dexer) dexCommonFlags(ctx android.ModuleContext, minSdkVersion android.SdkSpec) []string { flags := d.dexProperties.Dxflags @@ -282,6 +279,7 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi // Compile classes.jar into classes.dex and then javalib.jar javalibJar := android.PathForModuleOut(ctx, "dex", jarName).OutputPath outDir := android.PathForModuleOut(ctx, "dex") + tmpJar := android.PathForModuleOut(ctx, "withres-withoutdex", jarName) zipFlags := "--ignore_missing_files" if proptools.Bool(d.dexProperties.Uncompress_dex) { @@ -309,6 +307,7 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi "outUsage": proguardUsage.String(), "outUsageZip": proguardUsageZip.String(), "outDir": outDir.String(), + "tmpJar": tmpJar.String(), } if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8") { rule = r8RE @@ -339,6 +338,7 @@ func (d *dexer) compileDex(ctx android.ModuleContext, flags javaBuilderFlags, mi "d8Flags": strings.Join(append(commonFlags, d8Flags...), " "), "zipFlags": zipFlags, "outDir": outDir.String(), + "tmpJar": tmpJar.String(), }, }) } diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index dff9543e4..1019b4c85 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -167,10 +167,10 @@ import ( // regardless which APEX goes into the product. See also android.ApexInfo.ApexVariationName and // apex.apexBundleProperties.Apex_name. // -// A related variable PRODUCT_UPDATABLE_BOOT_JARS contains bootclasspath libraries that are in -// APEXes. They are not included in the boot image. The only exception here is core-icu4j.jar that -// has been historically part of the boot image and is now in a non updatable apex; it is treated -// as being part of PRODUCT_BOOT_JARS and is in the boot image. +// A related variable PRODUCT_APEX_BOOT_JARS contains bootclasspath libraries that are in APEXes. +// They are not included in the boot image. The only exception here are ART jars and core-icu4j.jar +// that have been historically part of the boot image and are now in apexes; they are in boot images +// and core-icu4j.jar is generally treated as being part of PRODUCT_BOOT_JARS. // // One exception to the above rules are "coverage" builds (a special build flavor which requires // setting environment variable EMMA_INSTRUMENT_FRAMEWORK=true). In coverage builds the Java code in @@ -523,14 +523,14 @@ func buildBootImageVariantsForAndroidOs(ctx android.ModuleContext, image *bootIm } // buildBootImageVariantsForBuildOs generates rules to build the boot image variants for the -// android.BuildOs OsType, i.e. the type of OS on which the build is being running. +// config.BuildOS OsType, i.e. the type of OS on which the build is being running. // // The files need to be generated into their predefined location because they are used from there // both within Soong and outside, e.g. for ART based host side testing and also for use by some // cloud based tools. However, they are not needed by callers of this function and so the paths do // not need to be returned from this func, unlike the buildBootImageVariantsForAndroidOs func. func buildBootImageVariantsForBuildOs(ctx android.ModuleContext, image *bootImageConfig, profile android.WritablePath) { - buildBootImageForOsType(ctx, image, profile, android.BuildOs) + buildBootImageForOsType(ctx, image, profile, ctx.Config().BuildOS) } // buildBootImageForOsType takes a bootImageConfig, a profile file and an android.OsType @@ -810,10 +810,10 @@ func bootFrameworkProfileRule(ctx android.ModuleContext, image *bootImageConfig) // generateUpdatableBcpPackagesRule generates the rule to create the updatable-bcp-packages.txt file // and returns a path to the generated file. -func generateUpdatableBcpPackagesRule(ctx android.ModuleContext, image *bootImageConfig, updatableModules []android.Module) android.WritablePath { +func generateUpdatableBcpPackagesRule(ctx android.ModuleContext, image *bootImageConfig, apexModules []android.Module) android.WritablePath { // Collect `permitted_packages` for updatable boot jars. var updatablePackages []string - for _, module := range updatableModules { + for _, module := range apexModules { if j, ok := module.(PermittedPackagesForUpdatableBootJars); ok { pp := j.PermittedPackagesForUpdatableBootJars() if len(pp) > 0 { diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index b13955fba..415a1d4e7 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -32,7 +32,7 @@ func dexpreoptTargets(ctx android.PathContext) []android.Target { } } // We may also need the images on host in order to run host-based tests. - for _, target := range ctx.Config().Targets[android.BuildOs] { + for _, target := range ctx.Config().Targets[ctx.Config().BuildOS] { targets = append(targets, target) } @@ -142,14 +142,14 @@ func defaultBootImageConfig(ctx android.PathContext) *bootImageConfig { return genBootImageConfigs(ctx)[frameworkBootImageName] } -// Updatable boot config allows to access build/install paths of updatable boot jars without going +// Apex boot config allows to access build/install paths of apex boot jars without going // through the usual trouble of registering dependencies on those modules and extracting build paths // from those dependencies. -type updatableBootConfig struct { - // A list of updatable boot jars. +type apexBootConfig struct { + // A list of apex boot jars. modules android.ConfiguredJarList - // A list of predefined build paths to updatable boot jars. They are configured very early, + // A list of predefined build paths to apex boot jars. They are configured very early, // before the modules for these jars are processed and the actual paths are generated, and // later on a singleton adds commands to copy actual jars to the predefined paths. dexPaths android.WritablePaths @@ -161,21 +161,21 @@ type updatableBootConfig struct { dexLocations []string } -var updatableBootConfigKey = android.NewOnceKey("updatableBootConfig") +var updatableBootConfigKey = android.NewOnceKey("apexBootConfig") -// Returns updatable boot config. -func GetUpdatableBootConfig(ctx android.PathContext) updatableBootConfig { +// Returns apex boot config. +func GetApexBootConfig(ctx android.PathContext) apexBootConfig { return ctx.Config().Once(updatableBootConfigKey, func() interface{} { - updatableBootJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + apexBootJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars - dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "updatable_bootjars") - dexPaths := updatableBootJars.BuildPaths(ctx, dir) - dexPathsByModuleName := updatableBootJars.BuildPathsByModule(ctx, dir) + dir := android.PathForOutput(ctx, ctx.Config().DeviceName(), "apex_bootjars") + dexPaths := apexBootJars.BuildPaths(ctx, dir) + dexPathsByModuleName := apexBootJars.BuildPathsByModule(ctx, dir) - dexLocations := updatableBootJars.DevicePaths(ctx.Config(), android.Android) + dexLocations := apexBootJars.DevicePaths(ctx.Config(), android.Android) - return updatableBootConfig{updatableBootJars, dexPaths, dexPathsByModuleName, dexLocations} - }).(updatableBootConfig) + return apexBootConfig{apexBootJars, dexPaths, dexPathsByModuleName, dexLocations} + }).(apexBootConfig) } // Returns a list of paths and a list of locations for the boot jars used in dexpreopt (to be @@ -188,10 +188,10 @@ func bcpForDexpreopt(ctx android.PathContext, withUpdatable bool) (android.Writa dexLocations := bootImage.getAnyAndroidVariant().dexLocationsDeps if withUpdatable { - // Updatable boot jars (they are used only in dexpreopt, but not in the boot image). - updBootConfig := GetUpdatableBootConfig(ctx) - dexPaths = append(dexPaths, updBootConfig.dexPaths...) - dexLocations = append(dexLocations, updBootConfig.dexLocations...) + // Apex boot jars (they are used only in dexpreopt, but not in the boot image). + apexBootConfig := GetApexBootConfig(ctx) + dexPaths = append(dexPaths, apexBootConfig.dexPaths...) + dexLocations = append(dexLocations, apexBootConfig.dexLocations...) } return dexPaths, dexLocations diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go index b25deceac..8dc7b798a 100644 --- a/java/dexpreopt_test.go +++ b/java/dexpreopt_test.go @@ -16,6 +16,7 @@ package java import ( "fmt" + "runtime" "testing" "android/soong/android" @@ -173,9 +174,9 @@ func enabledString(enabled bool) string { } func TestDex2oatToolDeps(t *testing.T) { - if android.BuildOs != android.Linux { + if runtime.GOOS != "linux" { // The host binary paths checked below are build OS dependent. - t.Skipf("Unsupported build OS %s", android.BuildOs) + t.Skipf("Unsupported build OS %s", runtime.GOOS) } preparers := android.GroupFixturePreparers( diff --git a/java/hiddenapi.go b/java/hiddenapi.go index f901434a0..30683daa0 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -118,11 +118,11 @@ func (h *hiddenAPI) initHiddenAPI(ctx android.ModuleContext, dexJar, classesJar } func isModuleInBootClassPath(ctx android.BaseModuleContext, module android.Module) bool { - // Get the configured non-updatable and updatable boot jars. - nonUpdatableBootJars := ctx.Config().NonUpdatableBootJars() - updatableBootJars := ctx.Config().UpdatableBootJars() - active := isModuleInConfiguredList(ctx, module, nonUpdatableBootJars) || - isModuleInConfiguredList(ctx, module, updatableBootJars) + // Get the configured platform and apex boot jars. + nonApexBootJars := ctx.Config().NonApexBootJars() + apexBootJars := ctx.Config().ApexBootJars() + active := isModuleInConfiguredList(ctx, module, nonApexBootJars) || + isModuleInConfiguredList(ctx, module, apexBootJars) return active } diff --git a/java/hiddenapi_modular.go b/java/hiddenapi_modular.go index 654ebb743..8a06a9969 100644 --- a/java/hiddenapi_modular.go +++ b/java/hiddenapi_modular.go @@ -297,7 +297,7 @@ func hiddenAPIRetrieveDexJarBuildPath(ctx android.ModuleContext, module android. // // The rule is initialized but not built so that the caller can modify it and select an appropriate // name. -func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, desc string, outputPath android.WritablePath, bootDexJars android.Paths, input HiddenAPIFlagInput, moduleStubFlagsPaths android.Paths) { +func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, desc string, outputPath android.WritablePath, bootDexJars android.Paths, input HiddenAPIFlagInput, stubFlagSubsets SignatureCsvSubsets) { // Singleton rule which applies hiddenapi on all boot class path dex files. rule := android.NewRuleBuilder(pctx, ctx) @@ -317,7 +317,7 @@ func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, // If no module stub flags paths are provided then this must be being called for a // bootclasspath_fragment and not the whole platform_bootclasspath. - if moduleStubFlagsPaths == nil { + if stubFlagSubsets == nil { // This is being run on a fragment of the bootclasspath. command.Flag("--fragment") } @@ -342,8 +342,8 @@ func buildRuleToGenerateHiddenAPIStubFlagsFile(ctx android.BuilderContext, name, // If there are stub flag files that have been generated by fragments on which this depends then // use them to validate the stub flag file generated by the rules created by this method. - if len(moduleStubFlagsPaths) > 0 { - validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, moduleStubFlagsPaths) + if len(stubFlagSubsets) > 0 { + validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, stubFlagSubsets) // Add the file that indicates that the file generated by this is valid. // @@ -510,14 +510,6 @@ func (s FlagFilesByCategory) append(other FlagFilesByCategory) { } } -// dedup removes duplicates in the flag files, while maintaining the order in which they were -// appended. -func (s FlagFilesByCategory) dedup() { - for category, paths := range s { - s[category] = android.FirstUniquePaths(paths) - } -} - // HiddenAPIInfo contains information provided by the hidden API processing. // // That includes paths resolved from HiddenAPIFlagFileProperties and also generated by hidden API @@ -554,6 +546,20 @@ func (i *HiddenAPIInfo) mergeFromFragmentDeps(ctx android.ModuleContext, fragmen } } +// StubFlagSubset returns a SignatureCsvSubset that contains a path to a stub-flags.csv file and a +// path to a signature-patterns.csv file that defines a subset of the monolithic stub flags file, +// i.e. out/soong/hiddenapi/hiddenapi-stub-flags.txt, against which it will be compared. +func (i *HiddenAPIInfo) StubFlagSubset() SignatureCsvSubset { + return SignatureCsvSubset{i.StubFlagsPath, i.SignaturePatternsPath} +} + +// FlagSubset returns a SignatureCsvSubset that contains a path to an all-flags.csv file and a +// path to a signature-patterns.csv file that defines a subset of the monolithic flags file, i.e. +// out/soong/hiddenapi/hiddenapi-flags.csv, against which it will be compared. +func (i *HiddenAPIInfo) FlagSubset() SignatureCsvSubset { + return SignatureCsvSubset{i.AllFlagsPath, i.SignaturePatternsPath} +} + var HiddenAPIInfoProvider = blueprint.NewProvider(HiddenAPIInfo{}) // ModuleStubDexJars contains the stub dex jars provided by a single module. @@ -790,6 +796,10 @@ type HiddenAPIFlagOutput struct { // The path to the generated all-flags.csv file. AllFlagsPath android.Path + + // The path to the generated signature-patterns.txt file which defines the subset of the + // monolithic hidden API files provided in this. + SignaturePatternsPath android.Path } // bootDexJarByModule is a map from base module name (without prebuilt_ prefix) to the boot dex @@ -856,7 +866,7 @@ func pathForValidation(ctx android.PathContext, path android.WritablePath) andro // the annotationFlags. func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc string, outputPath android.WritablePath, baseFlagsPath android.Path, annotationFlagPaths android.Paths, - flagFilesByCategory FlagFilesByCategory, allFlagsPaths android.Paths, generatedRemovedDexSignatures android.OptionalPath) { + flagFilesByCategory FlagFilesByCategory, flagSubsets SignatureCsvSubsets, generatedRemovedDexSignatures android.OptionalPath) { // Create the rule that will generate the flag files. tempPath := tempPathForRestat(ctx, outputPath) @@ -885,8 +895,8 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st // If there are flag files that have been generated by fragments on which this depends then use // them to validate the flag file generated by the rules created by this method. - if len(allFlagsPaths) > 0 { - validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, allFlagsPaths) + if len(flagSubsets) > 0 { + validFile := buildRuleValidateOverlappingCsvFiles(ctx, name, desc, outputPath, flagSubsets) // Add the file that indicates that the file generated by this is valid. // @@ -898,20 +908,66 @@ func buildRuleToGenerateHiddenApiFlags(ctx android.BuilderContext, name, desc st rule.Build(name, desc) } +// SignatureCsvSubset describes a subset of a monolithic flags file, i.e. either +// out/soong/hiddenapi/hiddenapi-stub-flags.txt or out/soong/hiddenapi/hiddenapi-flags.csv +type SignatureCsvSubset struct { + // The path to the CSV file containing hidden API flags. + // + // It has the dex member signature as the first column, with flags, one per column, in the + // subsequent columns. + CsvFile android.Path + + // The path to the CSV file containing the signature patterns. + // + // It is a single column CSV file with the column containing a signature pattern. + SignaturePatternsFile android.Path +} + +type SignatureCsvSubsets []SignatureCsvSubset + +func (s SignatureCsvSubsets) RelativeToTop() []string { + result := []string{} + for _, subset := range s { + result = append(result, fmt.Sprintf("%s:%s", subset.CsvFile.RelativeToTop(), subset.SignaturePatternsFile.RelativeToTop())) + } + return result +} + +// buildRuleSignaturePatternsFile creates a rule to generate a file containing the set of signature +// patterns that will select a subset of the monolithic flags. +func buildRuleSignaturePatternsFile(ctx android.ModuleContext, flagsPath android.Path) android.Path { + patternsFile := android.PathForModuleOut(ctx, "modular-hiddenapi", "signature-patterns.csv") + // Create a rule to validate the output from the following rule. + rule := android.NewRuleBuilder(pctx, ctx) + rule.Command(). + BuiltTool("signature_patterns"). + FlagWithInput("--flags ", flagsPath). + FlagWithOutput("--output ", patternsFile) + rule.Build("hiddenAPISignaturePatterns", "hidden API signature patterns") + + return patternsFile +} + // buildRuleValidateOverlappingCsvFiles checks that the modular CSV files, i.e. the files generated // by the individual bootclasspath_fragment modules are subsets of the monolithic CSV file. -func buildRuleValidateOverlappingCsvFiles(ctx android.BuilderContext, name string, desc string, monolithicFilePath android.WritablePath, modularFilePaths android.Paths) android.WritablePath { +func buildRuleValidateOverlappingCsvFiles(ctx android.BuilderContext, name string, desc string, monolithicFilePath android.WritablePath, csvSubsets SignatureCsvSubsets) android.WritablePath { // The file which is used to record that the flags file is valid. validFile := pathForValidation(ctx, monolithicFilePath) // Create a rule to validate the output from the following rule. rule := android.NewRuleBuilder(pctx, ctx) - rule.Command(). + command := rule.Command(). BuiltTool("verify_overlaps"). - Input(monolithicFilePath). - Inputs(modularFilePaths). - // If validation passes then update the file that records that. - Text("&& touch").Output(validFile) + Input(monolithicFilePath) + + for _, subset := range csvSubsets { + command. + Textf("%s:%s", subset.CsvFile, subset.SignaturePatternsFile). + Implicit(subset.CsvFile).Implicit(subset.SignaturePatternsFile) + } + + // If validation passes then update the file that records that. + command.Text("&& touch").Output(validFile) rule.Build(name+"Validation", desc+" validation") return validFile diff --git a/java/hiddenapi_monolithic.go b/java/hiddenapi_monolithic.go index 52f0770f3..5956e3c6c 100644 --- a/java/hiddenapi_monolithic.go +++ b/java/hiddenapi_monolithic.go @@ -29,9 +29,6 @@ type MonolithicHiddenAPIInfo struct { // that category. FlagsFilesByCategory FlagFilesByCategory - // The paths to the generated stub-flags.csv files. - StubFlagsPaths android.Paths - // The paths to the generated annotation-flags.csv files. AnnotationFlagsPaths android.Paths @@ -41,8 +38,13 @@ type MonolithicHiddenAPIInfo struct { // The paths to the generated index.csv files. IndexPaths android.Paths - // The paths to the generated all-flags.csv files. - AllFlagsPaths android.Paths + // The subsets of the monolithic hiddenapi-stubs-flags.txt file that are provided by each + // bootclasspath_fragment modules. + StubFlagSubsets SignatureCsvSubsets + + // The subsets of the monolithic hiddenapi-flags.csv file that are provided by each + // bootclasspath_fragment modules. + FlagSubsets SignatureCsvSubsets // The classes jars from the libraries on the platform bootclasspath. ClassesJars android.Paths @@ -58,68 +60,34 @@ func newMonolithicHiddenAPIInfo(ctx android.ModuleContext, flagFilesByCategory F // Merge all the information from the classpathElements. The fragments form a DAG so it is possible that // this will introduce duplicates so they will be resolved after processing all the classpathElements. for _, element := range classpathElements { - var classesJars android.Paths switch e := element.(type) { case *ClasspathLibraryElement: - classesJars = retrieveClassesJarsFromModule(e.Module()) + classesJars := retrieveClassesJarsFromModule(e.Module()) + monolithicInfo.ClassesJars = append(monolithicInfo.ClassesJars, classesJars...) case *ClasspathFragmentElement: fragment := e.Module() if ctx.OtherModuleHasProvider(fragment, HiddenAPIInfoProvider) { info := ctx.OtherModuleProvider(fragment, HiddenAPIInfoProvider).(HiddenAPIInfo) monolithicInfo.append(&info) - - // If the bootclasspath fragment actually perform hidden API processing itself then use the - // CSV files it provides and do not bother processing the classesJars files. This ensures - // consistent behavior between source and prebuilt as prebuilt modules do not provide - // classesJars. - if info.AllFlagsPath != nil { - continue - } + } else { + ctx.ModuleErrorf("%s does not provide hidden API information", fragment) } - - classesJars = extractClassesJarsFromModules(e.Contents) } - - monolithicInfo.ClassesJars = append(monolithicInfo.ClassesJars, classesJars...) } - // Dedup paths. - monolithicInfo.dedup() - return monolithicInfo } // append appends all the files from the supplied info to the corresponding files in this struct. func (i *MonolithicHiddenAPIInfo) append(other *HiddenAPIInfo) { i.FlagsFilesByCategory.append(other.FlagFilesByCategory) + i.AnnotationFlagsPaths = append(i.AnnotationFlagsPaths, other.AnnotationFlagsPath) + i.MetadataPaths = append(i.MetadataPaths, other.MetadataPath) + i.IndexPaths = append(i.IndexPaths, other.IndexPath) - // The output may not be set if the bootclasspath_fragment has not yet been updated to support - // hidden API processing. - // TODO(b/179354495): Switch back to append once all bootclasspath_fragment modules have been - // updated to support hidden API processing properly. - appendIfNotNil := func(paths android.Paths, path android.Path) android.Paths { - if path == nil { - return paths - } - return append(paths, path) - } - i.StubFlagsPaths = appendIfNotNil(i.StubFlagsPaths, other.StubFlagsPath) - i.AnnotationFlagsPaths = appendIfNotNil(i.AnnotationFlagsPaths, other.AnnotationFlagsPath) - i.MetadataPaths = appendIfNotNil(i.MetadataPaths, other.MetadataPath) - i.IndexPaths = appendIfNotNil(i.IndexPaths, other.IndexPath) - i.AllFlagsPaths = appendIfNotNil(i.AllFlagsPaths, other.AllFlagsPath) -} - -// dedup removes duplicates in all the paths, while maintaining the order in which they were -// appended. -func (i *MonolithicHiddenAPIInfo) dedup() { - i.FlagsFilesByCategory.dedup() - i.StubFlagsPaths = android.FirstUniquePaths(i.StubFlagsPaths) - i.AnnotationFlagsPaths = android.FirstUniquePaths(i.AnnotationFlagsPaths) - i.MetadataPaths = android.FirstUniquePaths(i.MetadataPaths) - i.IndexPaths = android.FirstUniquePaths(i.IndexPaths) - i.AllFlagsPaths = android.FirstUniquePaths(i.AllFlagsPaths) + i.StubFlagSubsets = append(i.StubFlagSubsets, other.StubFlagSubset()) + i.FlagSubsets = append(i.FlagSubsets, other.FlagSubset()) } var MonolithicHiddenAPIInfoProvider = blueprint.NewProvider(MonolithicHiddenAPIInfo{}) diff --git a/java/java.go b/java/java.go index e38a7143b..b6e2a5425 100644 --- a/java/java.go +++ b/java/java.go @@ -457,7 +457,7 @@ type Library struct { var _ android.ApexModule = (*Library)(nil) -// Provides access to the list of permitted packages from updatable boot jars. +// Provides access to the list of permitted packages from apex boot jars. type PermittedPackagesForUpdatableBootJars interface { PermittedPackagesForUpdatableBootJars() []string } diff --git a/java/java_test.go b/java/java_test.go index 0f9965d03..b6780c20c 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -441,7 +441,7 @@ func TestBinary(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() bar := ctx.ModuleForTests("bar", buildOS+"_common") barJar := bar.Output("bar.jar").Output.String() @@ -478,7 +478,7 @@ func TestTest(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() foo := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) @@ -523,7 +523,7 @@ func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) { } // check that -g is not overridden for host modules - buildOS := android.BuildOs.String() + buildOS := result.Config.BuildOS.String() hostBinary := result.ModuleForTests("host_binary", buildOS+"_common") hostJavaFlags := hostBinary.Module().VariablesForTests()["javacFlags"] if strings.Contains(hostJavaFlags, "-g:source,lines") { @@ -1371,7 +1371,7 @@ func TestDataNativeBinaries(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() test := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) entries := android.AndroidMkEntriesForTest(t, ctx, test)[0] @@ -1387,7 +1387,7 @@ func TestDefaultInstallable(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() module := ctx.ModuleForTests("foo", buildOS+"_common").Module().(*TestHost) assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true), module.properties.Installable) diff --git a/java/kotlin_test.go b/java/kotlin_test.go index fd2f3ca61..db3069693 100644 --- a/java/kotlin_test.go +++ b/java/kotlin_test.go @@ -15,10 +15,11 @@ package java import ( - "android/soong/android" "strconv" "strings" "testing" + + "android/soong/android" ) func TestKotlin(t *testing.T) { @@ -114,7 +115,7 @@ func TestKapt(t *testing.T) { t.Run("", func(t *testing.T) { ctx, _ := testJava(t, bp) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() kapt := ctx.ModuleForTests("foo", "android_common").Rule("kapt") kotlinc := ctx.ModuleForTests("foo", "android_common").Rule("kotlinc") @@ -182,7 +183,7 @@ func TestKapt(t *testing.T) { android.FixtureMergeEnv(env), ).RunTestWithBp(t, bp) - buildOS := android.BuildOs.String() + buildOS := result.Config.BuildOS.String() kapt := result.ModuleForTests("foo", "android_common").Rule("kapt") javac := result.ModuleForTests("foo", "android_common").Description("javac") diff --git a/java/lint_defaults.txt b/java/lint_defaults.txt index 75de7dc6c..4bc0c5fd4 100644 --- a/java/lint_defaults.txt +++ b/java/lint_defaults.txt @@ -1,10 +1,37 @@ # Treat LintError as fatal to catch invocation errors --fatal_check LintError +# Checks which do not apply to the platform (implementation +# in lint assumes that it's running on app code) + +--disable_check AnimatorKeep +--disable_check AppBundleLocaleChanges +--disable_check BlockedPrivateApi +--disable_check CustomSplashScreen +--disable_check CustomX509TrustManager +--disable_check Deprecated +--disable_check ExifInterface +--disable_check HardwareIds +--disable_check InvalidWakeLockTag +--disable_check LibraryCustomView +--disable_check MissingPermission +--disable_check NonConstantResourceId +--disable_check OldTargetApi +--disable_check Override +--disable_check PackageManagerGetSignatures +--disable_check PrivateApi +--disable_check ProtectedPermissions +--disable_check QueryPermissionsNeeded +--disable_check ScopedStorage +--disable_check ServiceCast +--disable_check SoonBlockedPrivateApi +--disable_check SuspiciousImport +--disable_check UnusedResources +--disable_check ViewConstructor + # Downgrade existing errors to warnings --warning_check AppCompatResource # 55 occurences in 10 modules --warning_check AppLinkUrlError # 111 occurences in 53 modules ---warning_check BlockedPrivateApi # 2 occurences in 2 modules --warning_check ByteOrderMark # 2 occurences in 2 modules --warning_check DuplicateActivity # 3 occurences in 3 modules --warning_check DuplicateDefinition # 3623 occurences in 48 modules @@ -22,9 +49,7 @@ --warning_check Instantiatable # 145 occurences in 19 modules --warning_check InvalidPermission # 6 occurences in 4 modules --warning_check InvalidUsesTagAttribute # 6 occurences in 2 modules ---warning_check InvalidWakeLockTag # 111 occurences in 37 modules --warning_check JavascriptInterface # 3 occurences in 2 modules ---warning_check LibraryCustomView # 9 occurences in 4 modules --warning_check LogTagMismatch # 81 occurences in 13 modules --warning_check LongLogTag # 249 occurences in 12 modules --warning_check MenuTitle # 5 occurences in 4 modules @@ -35,7 +60,6 @@ --warning_check MissingLeanbackLauncher # 3 occurences in 3 modules --warning_check MissingLeanbackSupport # 2 occurences in 2 modules --warning_check MissingOnPlayFromSearch # 1 occurences in 1 modules ---warning_check MissingPermission # 2071 occurences in 150 modules --warning_check MissingPrefix # 46 occurences in 41 modules --warning_check MissingQuantity # 100 occurences in 1 modules --warning_check MissingSuperCall # 121 occurences in 36 modules @@ -47,9 +71,7 @@ --warning_check ObjectAnimatorBinding # 14 occurences in 5 modules --warning_check OnClick # 49 occurences in 21 modules --warning_check Orientation # 77 occurences in 19 modules ---warning_check Override # 385 occurences in 36 modules --warning_check ParcelCreator # 23 occurences in 2 modules ---warning_check ProtectedPermissions # 2413 occurences in 381 modules --warning_check Range # 80 occurences in 28 modules --warning_check RecyclerView # 1 occurences in 1 modules --warning_check ReferenceType # 4 occurences in 1 modules @@ -60,8 +82,6 @@ --warning_check ResourceType # 137 occurences in 36 modules --warning_check RestrictedApi # 28 occurences in 5 modules --warning_check RtlCompat # 9 occurences in 6 modules ---warning_check ServiceCast # 3 occurences in 1 modules ---warning_check SoonBlockedPrivateApi # 5 occurences in 3 modules --warning_check StringFormatInvalid # 148 occurences in 11 modules --warning_check StringFormatMatches # 4800 occurences in 30 modules --warning_check UnknownId # 8 occurences in 7 modules @@ -74,11 +94,9 @@ --warning_check WrongThread # 14 occurences in 6 modules --warning_check WrongViewCast # 1 occurences in 1 modules -# TODO(b/158390965): remove this when lint doesn't crash ---disable_check HardcodedDebugMode - ---warning_check QueryAllPackagesPermission - --warning_check CoarseFineLocation --warning_check IntentFilterExportedReceiver +--warning_check QueryAllPackagesPermission --warning_check RemoteViewLayout +--warning_check SupportAnnotationUsage +--warning_check UniqueConstants diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go index 8bed3e9e5..36baf7e78 100644 --- a/java/platform_bootclasspath.go +++ b/java/platform_bootclasspath.go @@ -32,9 +32,9 @@ func registerPlatformBootclasspathBuildComponents(ctx android.RegistrationContex // The tags used for the dependencies between the platform bootclasspath and any configured boot // jars. var ( - platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"} - platformBootclasspathNonUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "non-updatable-boot-jar"} - platformBootclasspathUpdatableBootJarDepTag = bootclasspathDependencyTag{name: "updatable-boot-jar"} + platformBootclasspathArtBootJarDepTag = bootclasspathDependencyTag{name: "art-boot-jar"} + platformBootclasspathBootJarDepTag = bootclasspathDependencyTag{name: "platform-boot-jar"} + platformBootclasspathApexBootJarDepTag = bootclasspathDependencyTag{name: "apex-boot-jar"} ) type platformBootclasspathModule struct { @@ -131,11 +131,11 @@ func (b *platformBootclasspathModule) BootclasspathDepsMutator(ctx android.Botto // Add dependencies on all the non-updatable module configured in the "boot" boot image. That does // not include modules configured in the "art" boot image. bootImageConfig := b.getImageConfig(ctx) - addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathNonUpdatableBootJarDepTag) + addDependenciesOntoBootImageModules(ctx, bootImageConfig.modules, platformBootclasspathBootJarDepTag) - // Add dependencies on all the updatable modules. - updatableModules := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars - addDependenciesOntoBootImageModules(ctx, updatableModules, platformBootclasspathUpdatableBootJarDepTag) + // Add dependencies on all the apex jars. + apexJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars + addDependenciesOntoBootImageModules(ctx, apexJars, platformBootclasspathApexBootJarDepTag) // Add dependencies on all the fragments. b.properties.BootclasspathFragmentsDepsProperties.addDependenciesOntoFragments(ctx) @@ -163,16 +163,16 @@ func (d *platformBootclasspathModule) MakeVars(ctx android.MakeVarsContext) { } func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { - // Gather all the dependencies from the art, updatable and non-updatable boot jars. + // Gather all the dependencies from the art, platform, and apex boot jars. artModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathArtBootJarDepTag) - nonUpdatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathNonUpdatableBootJarDepTag) - updatableModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathUpdatableBootJarDepTag) + platformModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathBootJarDepTag) + apexModules := gatherApexModulePairDepsWithTag(ctx, platformBootclasspathApexBootJarDepTag) // Concatenate them all, in order as they would appear on the bootclasspath. var allModules []android.Module allModules = append(allModules, artModules...) - allModules = append(allModules, nonUpdatableModules...) - allModules = append(allModules, updatableModules...) + allModules = append(allModules, platformModules...) + allModules = append(allModules, apexModules...) b.configuredModules = allModules // Gather all the fragments dependencies. @@ -180,8 +180,8 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo // Check the configuration of the boot modules. // ART modules are checked by the art-bootclasspath-fragment. - b.checkNonUpdatableModules(ctx, nonUpdatableModules) - b.checkUpdatableModules(ctx, updatableModules) + b.checkPlatformModules(ctx, platformModules) + b.checkApexModules(ctx, apexModules) b.generateClasspathProtoBuildActions(ctx) @@ -193,7 +193,7 @@ func (b *platformBootclasspathModule) GenerateAndroidBuildActions(ctx android.Mo return } - b.generateBootImageBuildActions(ctx, nonUpdatableModules, updatableModules) + b.generateBootImageBuildActions(ctx, platformModules, apexModules) } // Generate classpaths.proto config @@ -209,7 +209,7 @@ func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) jars := b.getImageConfig(ctx).modules // Include jars from APEXes that don't populate their classpath proto config. - remainingJars := dexpreopt.GetGlobalConfig(ctx).UpdatableBootJars + remainingJars := dexpreopt.GetGlobalConfig(ctx).ApexBootJars for _, fragment := range b.fragments { info := ctx.OtherModuleProvider(fragment, ClasspathFragmentProtoContentInfoProvider).(ClasspathFragmentProtoContentInfo) if info.ClasspathFragmentProtoGenerated { @@ -223,9 +223,10 @@ func (b *platformBootclasspathModule) configuredJars(ctx android.ModuleContext) return jars } -// checkNonUpdatableModules ensures that the non-updatable modules supplied are not part of an -// updatable module. -func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.ModuleContext, modules []android.Module) { +// checkPlatformModules ensures that the non-updatable modules supplied are not part of an +// apex module. +func (b *platformBootclasspathModule) checkPlatformModules(ctx android.ModuleContext, modules []android.Module) { + // TODO(satayev): change this check to only allow core-icu4j, all apex jars should not be here. for _, m := range modules { apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo) fromUpdatableApex := apexInfo.Updatable @@ -238,8 +239,8 @@ func (b *platformBootclasspathModule) checkNonUpdatableModules(ctx android.Modul } } -// checkUpdatableModules ensures that the updatable modules supplied are not from the platform. -func (b *platformBootclasspathModule) checkUpdatableModules(ctx android.ModuleContext, modules []android.Module) { +// checkApexModules ensures that the apex modules supplied are not from the platform. +func (b *platformBootclasspathModule) checkApexModules(ctx android.ModuleContext, modules []android.Module) { for _, m := range modules { apexInfo := ctx.OtherModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo) fromUpdatableApex := apexInfo.Updatable @@ -255,12 +256,12 @@ func (b *platformBootclasspathModule) checkUpdatableModules(ctx android.ModuleCo // modules is complete. if !ctx.Config().AlwaysUsePrebuiltSdks() { // error: this jar is part of the platform - ctx.ModuleErrorf("module %q from platform is not allowed in the updatable boot jars list", name) + ctx.ModuleErrorf("module %q from platform is not allowed in the apex boot jars list", name) } } else { // TODO(b/177892522): Treat this as an error. // Cannot do that at the moment because framework-wifi and framework-tethering are in the - // PRODUCT_UPDATABLE_BOOT_JARS but not marked as updatable in AOSP. + // PRODUCT_APEX_BOOT_JARS but not marked as updatable in AOSP. } } } @@ -315,7 +316,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android. // Generate the monolithic stub-flags.csv file. stubFlags := hiddenAPISingletonPaths(ctx).stubFlags - buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags", stubFlags, bootDexJarByModule.bootDexJars(), input, monolithicInfo.StubFlagsPaths) + buildRuleToGenerateHiddenAPIStubFlagsFile(ctx, "platform-bootclasspath-monolithic-hiddenapi-stub-flags", "monolithic hidden API stub flags", stubFlags, bootDexJarByModule.bootDexJars(), input, monolithicInfo.StubFlagSubsets) // Generate the annotation-flags.csv file from all the module annotations. annotationFlags := android.PathForModuleOut(ctx, "hiddenapi-monolithic", "annotation-flags-from-classes.csv") @@ -328,7 +329,7 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android. allAnnotationFlagFiles := android.Paths{annotationFlags} allAnnotationFlagFiles = append(allAnnotationFlagFiles, monolithicInfo.AnnotationFlagsPaths...) allFlags := hiddenAPISingletonPaths(ctx).flags - buildRuleToGenerateHiddenApiFlags(ctx, "hiddenAPIFlagsFile", "monolithic hidden API flags", allFlags, stubFlags, allAnnotationFlagFiles, monolithicInfo.FlagsFilesByCategory, monolithicInfo.AllFlagsPaths, android.OptionalPath{}) + buildRuleToGenerateHiddenApiFlags(ctx, "hiddenAPIFlagsFile", "monolithic hidden API flags", allFlags, stubFlags, allAnnotationFlagFiles, monolithicInfo.FlagsFilesByCategory, monolithicInfo.FlagSubsets, android.OptionalPath{}) // Generate an intermediate monolithic hiddenapi-metadata.csv file directly from the annotations // in the source code. @@ -405,7 +406,7 @@ func (b *platformBootclasspathModule) generateHiddenApiMakeVars(ctx android.Make } // generateBootImageBuildActions generates ninja rules related to the boot image creation. -func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, nonUpdatableModules, updatableModules []android.Module) { +func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android.ModuleContext, platformModules, apexModules []android.Module) { // Force the GlobalSoongConfig to be created and cached for use by the dex_bootjars // GenerateSingletonBuildActions method as it cannot create it for itself. dexpreopt.GetGlobalSoongConfig(ctx) @@ -428,17 +429,17 @@ func (b *platformBootclasspathModule) generateBootImageBuildActions(ctx android. // TODO(b/193889859): Remove when the prebuilts have been updated. if !ctx.Config().AlwaysUsePrebuiltSdks() { // Generate the updatable bootclasspath packages rule. - generateUpdatableBcpPackagesRule(ctx, imageConfig, updatableModules) + generateUpdatableBcpPackagesRule(ctx, imageConfig, apexModules) } - // Copy non-updatable module dex jars to their predefined locations. - nonUpdatableBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, nonUpdatableModules) - copyBootJarsToPredefinedLocations(ctx, nonUpdatableBootDexJarsByModule, imageConfig.dexPathsByModule) + // Copy platform module dex jars to their predefined locations. + platformBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, platformModules) + copyBootJarsToPredefinedLocations(ctx, platformBootDexJarsByModule, imageConfig.dexPathsByModule) - // Copy updatable module dex jars to their predefined locations. - config := GetUpdatableBootConfig(ctx) - updatableBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, updatableModules) - copyBootJarsToPredefinedLocations(ctx, updatableBootDexJarsByModule, config.dexPathsByModule) + // Copy apex module dex jars to their predefined locations. + config := GetApexBootConfig(ctx) + apexBootDexJarsByModule := extractEncodedDexJarsFromModules(ctx, apexModules) + copyBootJarsToPredefinedLocations(ctx, apexBootDexJarsByModule, config.dexPathsByModule) // Build a profile for the image config and then use that to build the boot image. profile := bootImageProfileRule(ctx, imageConfig) diff --git a/java/plugin_test.go b/java/plugin_test.go index c7913d3db..dc29b1c3e 100644 --- a/java/plugin_test.go +++ b/java/plugin_test.go @@ -15,7 +15,6 @@ package java import ( - "android/soong/android" "testing" ) @@ -58,7 +57,7 @@ func TestPlugin(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine") @@ -98,7 +97,7 @@ func TestPluginGeneratesApi(t *testing.T) { } `) - buildOS := android.BuildOs.String() + buildOS := ctx.Config().BuildOS.String() javac := ctx.ModuleForTests("foo", "android_common").Rule("javac") turbine := ctx.ModuleForTests("foo", "android_common").MaybeRule("turbine") diff --git a/java/robolectric.go b/java/robolectric.go index a37a118f6..a0c9c7fcd 100644 --- a/java/robolectric.go +++ b/java/robolectric.go @@ -83,6 +83,9 @@ type robolectricTest struct { testConfig android.Path data android.Paths + + forceOSType android.OsType + forceArchType android.ArchType } func (r *robolectricTest) TestSuites() []string { @@ -115,6 +118,9 @@ func (r *robolectricTest) DepsMutator(ctx android.BottomUpMutatorContext) { } func (r *robolectricTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + r.testConfig = tradefed.AutoGenRobolectricTestConfig(ctx, r.testProperties.Test_config, r.testProperties.Test_config_template, r.testProperties.Test_suites, r.testProperties.Auto_gen_config) @@ -345,7 +351,7 @@ func RobolectricTestFactory() android.Module { func (r *robolectricTest) InstallBypassMake() bool { return true } func (r *robolectricTest) InstallInTestcases() bool { return true } func (r *robolectricTest) InstallForceOS() (*android.OsType, *android.ArchType) { - return &android.BuildOs, &android.BuildArch + return &r.forceOSType, &r.forceArchType } func robolectricRuntimesFactory() android.Module { @@ -366,6 +372,9 @@ type robolectricRuntimes struct { props robolectricRuntimesProperties runtimes []android.InstallPath + + forceOSType android.OsType + forceArchType android.ArchType } func (r *robolectricRuntimes) TestSuites() []string { @@ -385,6 +394,9 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont return } + r.forceOSType = ctx.Config().BuildOS + r.forceArchType = ctx.Config().BuildArch + files := android.PathsForModuleSrc(ctx, r.props.Jars) androidAllDir := android.PathForModuleInstall(ctx, "android-all") @@ -417,5 +429,5 @@ func (r *robolectricRuntimes) GenerateAndroidBuildActions(ctx android.ModuleCont func (r *robolectricRuntimes) InstallBypassMake() bool { return true } func (r *robolectricRuntimes) InstallInTestcases() bool { return true } func (r *robolectricRuntimes) InstallForceOS() (*android.OsType, *android.ArchType) { - return &android.BuildOs, &android.BuildArch + return &r.forceOSType, &r.forceArchType } diff --git a/java/sdk_library.go b/java/sdk_library.go index 268e7970d..c50e07779 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -419,7 +419,7 @@ type sdkLibraryProperties struct { // local files that are used within user customized droiddoc options. Droiddoc_option_files []string - // additional droiddoc options + // additional droiddoc options. // Available variables for substitution: // // $(location <label>): the path to the droiddoc_option_files with name <label> diff --git a/java/sdk_test.go b/java/sdk_test.go index bb595a54e..6d6213011 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -255,9 +255,11 @@ func TestClasspath(t *testing.T) { ` + testcase.properties + ` }` - variant := "android_common" - if testcase.host == android.Host { - variant = android.BuildOs.String() + "_common" + variant := func(result *android.TestResult) string { + if testcase.host == android.Host { + return result.Config.BuildOS.String() + "_common" + } + return "android_common" } convertModulesToPaths := func(cp []string) []string { @@ -312,7 +314,7 @@ func TestClasspath(t *testing.T) { } checkClasspath := func(t *testing.T, result *android.TestResult, isJava8 bool) { - foo := result.ModuleForTests("foo", variant) + foo := result.ModuleForTests("foo", variant(result)) javac := foo.Rule("javac") var deps []string @@ -376,7 +378,7 @@ func TestClasspath(t *testing.T) { checkClasspath(t, result, true /* isJava8 */) if testcase.host != android.Host { - aidl := result.ModuleForTests("foo", variant).Rule("aidl") + aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") } @@ -389,7 +391,7 @@ func TestClasspath(t *testing.T) { checkClasspath(t, result, false /* isJava8 */) if testcase.host != android.Host { - aidl := result.ModuleForTests("foo", variant).Rule("aidl") + aidl := result.ModuleForTests("foo", variant(result)).Rule("aidl") android.AssertStringDoesContain(t, "aidl command", aidl.RuleParams.Command, testcase.aidl+" -I.") } diff --git a/java/systemserver_classpath_fragment.go b/java/systemserver_classpath_fragment.go index 28a5a2cf2..6c2a5b58b 100644 --- a/java/systemserver_classpath_fragment.go +++ b/java/systemserver_classpath_fragment.go @@ -106,12 +106,8 @@ func (s *SystemServerClasspathModule) GenerateAndroidBuildActions(ctx android.Mo func (s *SystemServerClasspathModule) configuredJars(ctx android.ModuleContext) android.ConfiguredJarList { global := dexpreopt.GetGlobalConfig(ctx) - possibleUpdatableModules := gatherPossibleUpdatableModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) - - // Only create configs for updatable boot jars. Non-updatable system server jars must be part of the - // platform_systemserverclasspath's classpath proto config to guarantee that they come before any - // updatable jars at runtime. - return global.UpdatableSystemServerJars.Filter(possibleUpdatableModules) + possibleUpdatableModules := gatherPossibleApexModuleNamesAndStems(ctx, s.properties.Contents, systemServerClasspathFragmentContentDepTag) + return global.ApexSystemServerJars.Filter(possibleUpdatableModules) } type systemServerClasspathFragmentContentDependencyTag struct { diff --git a/java/testing.go b/java/testing.go index e2ff5cd12..8860b45fa 100644 --- a/java/testing.go +++ b/java/testing.go @@ -214,15 +214,15 @@ func FixtureConfigureBootJars(bootJars ...string) android.FixturePreparer { ) } -// FixtureConfigureUpdatableBootJars configures the updatable boot jars in both the +// FixtureConfigureApexBootJars configures the apex boot jars in both the // dexpreopt.GlobalConfig and Config.productVariables structs. As a side effect that enables // dexpreopt. -func FixtureConfigureUpdatableBootJars(bootJars ...string) android.FixturePreparer { +func FixtureConfigureApexBootJars(bootJars ...string) android.FixturePreparer { return android.GroupFixturePreparers( android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { - variables.UpdatableBootJars = android.CreateTestConfiguredJarList(bootJars) + variables.ApexBootJars = android.CreateTestConfiguredJarList(bootJars) }), - dexpreopt.FixtureSetUpdatableBootJars(bootJars...), + dexpreopt.FixtureSetApexBootJars(bootJars...), // Add a fake dex2oatd module. dexpreopt.PrepareForTestWithFakeDex2oatd, |