diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/aar.go | 4 | ||||
| -rwxr-xr-x | java/app.go | 18 | ||||
| -rw-r--r-- | java/app_test.go | 18 | ||||
| -rw-r--r-- | java/dexpreopt.go | 2 | ||||
| -rw-r--r-- | java/droiddoc.go | 1 | ||||
| -rw-r--r-- | java/java.go | 30 | ||||
| -rw-r--r-- | java/lint.go | 21 | ||||
| -rw-r--r-- | java/sdk_library.go | 10 |
8 files changed, 88 insertions, 16 deletions
diff --git a/java/aar.go b/java/aar.go index 074ead470..500788f48 100644 --- a/java/aar.go +++ b/java/aar.go @@ -762,6 +762,10 @@ func (a *AARImport) DepIsInSameApex(ctx android.BaseModuleContext, dep android.M return a.depIsInSameApex(ctx, dep) } +func (g *AARImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + return nil +} + var _ android.PrebuiltInterface = (*Import)(nil) // android_library_import imports an `.aar` file into the build graph as if it was built with android_library. diff --git a/java/app.go b/java/app.go index c568516eb..37a6453cd 100755 --- a/java/app.go +++ b/java/app.go @@ -421,8 +421,10 @@ func (a *AndroidApp) checkAppSdkVersions(ctx android.ModuleContext) { if String(a.deviceProperties.Min_sdk_version) == "" { ctx.PropertyErrorf("updatable", "updatable apps must set min_sdk_version.") } + if minSdkVersion, err := a.minSdkVersion().effectiveVersion(ctx); err == nil { a.checkJniLibsSdkVersion(ctx, minSdkVersion) + android.CheckMinSdkVersion(a, ctx, int(minSdkVersion)) } else { ctx.PropertyErrorf("min_sdk_version", "%s", err.Error()) } @@ -862,13 +864,13 @@ func collectAppDeps(ctx android.ModuleContext, app appDepsInterface, return jniLibs, certificates } -func (a *AndroidApp) walkPayloadDeps(ctx android.ModuleContext, - do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) { - +func (a *AndroidApp) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) { ctx.WalkDeps(func(child, parent android.Module) bool { isExternal := !a.DepIsInSameApex(ctx, child) if am, ok := child.(android.ApexModule); ok { - do(ctx, parent, am, isExternal) + if !do(ctx, parent, am, isExternal) { + return false + } } return !isExternal }) @@ -880,7 +882,7 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) { } depsInfo := android.DepNameToDepInfoMap{} - a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) { + a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { depName := to.Name() if info, exist := depsInfo[depName]; exist { info.From = append(info.From, from.Name()) @@ -900,6 +902,7 @@ func (a *AndroidApp) buildAppDependencyInfo(ctx android.ModuleContext) { MinSdkVersion: toMinSdkVersion, } } + return true }) a.ApexBundleDepsInfo.BuildDepsInfoLists(ctx, a.MinSdkVersion(), depsInfo) @@ -1563,6 +1566,11 @@ func (a *AndroidAppImport) minSdkVersion() sdkSpec { return sdkSpecFrom("") } +func (j *AndroidAppImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + // Do not check for prebuilts against the min_sdk_version of enclosing APEX + return nil +} + func createVariantGroupType(variants []string, variantGroupName string) reflect.Type { props := reflect.TypeOf((*AndroidAppImportProperties)(nil)) diff --git a/java/app_test.go b/java/app_test.go index e45ba70d5..120dc00a6 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -473,6 +473,24 @@ func TestUpdatableApps(t *testing.T) { } } +func TestUpdatableApps_TransitiveDepsShouldSetMinSdkVersion(t *testing.T) { + testJavaError(t, `module "bar".*: should support min_sdk_version\(29\)`, cc.GatherRequiredDepsForTest(android.Android)+` + android_app { + name: "foo", + srcs: ["a.java"], + updatable: true, + sdk_version: "current", + min_sdk_version: "29", + static_libs: ["bar"], + } + + java_library { + name: "bar", + sdk_version: "current", + } + `) +} + func TestUpdatableApps_JniLibsShouldShouldSupportMinSdkVersion(t *testing.T) { testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` android_app { diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 7f1afd667..f1b717874 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -173,7 +173,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo profileBootListing = android.ExistentPathForSource(ctx, ctx.ModuleDir(), String(d.dexpreoptProperties.Dex_preopt.Profile)+"-boot") profileIsTextListing = true - } else { + } else if global.ProfileDir != "" { profileClassListing = android.ExistentPathForSource(ctx, global.ProfileDir, ctx.ModuleName()+".prof") } diff --git a/java/droiddoc.go b/java/droiddoc.go index a0b7edfea..73b897ad0 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -1325,7 +1325,6 @@ func (d *Droidstubs) stubsFlags(ctx android.ModuleContext, cmd *android.RuleBuil cmd.Flag("--exclude-documentation-from-stubs") } } - cmd.FlagWithArg("--hide ", "ShowingMemberInHiddenClass") // b/159121253 -- remove it once all the violations are fixed. } func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) { diff --git a/java/java.go b/java/java.go index 7a4255745..5b3163087 100644 --- a/java/java.go +++ b/java/java.go @@ -44,7 +44,7 @@ func init() { PropertyName: "java_libs", }, func(j *Library) android.Path { - implementationJars := j.ImplementationJars() + implementationJars := j.ImplementationAndResourcesJars() if len(implementationJars) != 1 { panic(fmt.Errorf("there must be only one implementation jar from %q", j.Name())) } @@ -1887,6 +1887,24 @@ func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu return j.depIsInSameApex(ctx, dep) } +func (j *Module) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + sdkSpec := j.minSdkVersion() + if !sdkSpec.specified() { + return fmt.Errorf("min_sdk_version is not specified") + } + if sdkSpec.kind == sdkCore { + return nil + } + ver, err := sdkSpec.effectiveVersion(ctx) + if err != nil { + return err + } + if int(ver) > sdkVersion { + return fmt.Errorf("newer SDK(%v)", ver) + } + return nil +} + func (j *Module) Stem() string { return proptools.StringDefault(j.deviceProperties.Stem, j.Name()) } @@ -2651,6 +2669,11 @@ func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Modu return j.depIsInSameApex(ctx, dep) } +func (j *Import) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + // Do not check for prebuilts against the min_sdk_version of enclosing APEX + return nil +} + // Add compile time check for interface implementation var _ android.IDEInfo = (*Import)(nil) var _ android.IDECustomizedModuleName = (*Import)(nil) @@ -2820,6 +2843,11 @@ func (j *DexImport) DexJarBuildPath() android.Path { return j.dexJarFile } +func (j *DexImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + // we don't check prebuilt modules for sdk_version + return nil +} + // dex_import imports a `.jar` file containing classes.dex files. // // A dex_import module cannot be used as a dependency of a java_* or android_* module, it can only be installed diff --git a/java/lint.go b/java/lint.go index fac9a1983..b73d6a51a 100644 --- a/java/lint.go +++ b/java/lint.go @@ -88,7 +88,7 @@ func (l *linter) deps(ctx android.BottomUpMutatorContext) { } func (l *linter) writeLintProjectXML(ctx android.ModuleContext, - rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir android.WritablePath, deps android.Paths) { + rule *android.RuleBuilder) (projectXMLPath, configXMLPath, cacheDir, homeDir android.WritablePath, deps android.Paths) { var resourcesList android.WritablePath if len(l.resources) > 0 { @@ -106,6 +106,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, // Lint looks for a lint.xml file next to the project.xml file, give it one. configXMLPath = android.PathForModuleOut(ctx, "lint", "lint.xml") cacheDir = android.PathForModuleOut(ctx, "lint", "cache") + homeDir = android.PathForModuleOut(ctx, "lint", "home") srcJarDir := android.PathForModuleOut(ctx, "lint-srcjars") srcJarList := zipSyncCmd(ctx, rule, srcJarDir, l.srcJars) @@ -154,8 +155,11 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, cmd.FlagForEachArg("--extra_checks_jar ", l.extraLintCheckJars.Strings()) deps = append(deps, l.extraLintCheckJars...) - // The cache tag in project.xml is relative to the project.xml file. - cmd.FlagWithArg("--cache_dir ", "cache") + cmd.FlagWithArg("--root_dir ", "$PWD") + + // The cache tag in project.xml is relative to the root dir, or the project.xml file if + // the root dir is not set. + cmd.FlagWithArg("--cache_dir ", cacheDir.String()) cmd.FlagWithInput("@", android.PathForSource(ctx, "build/soong/java/lint_defaults.txt")) @@ -165,7 +169,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) - return projectXMLPath, configXMLPath, cacheDir, deps + return projectXMLPath, configXMLPath, cacheDir, homeDir, deps } // generateManifest adds a command to the rule to write a dummy manifest cat contains the @@ -207,18 +211,19 @@ func (l *linter) lint(ctx android.ModuleContext) { l.manifest = manifest } - projectXML, lintXML, cacheDir, deps := l.writeLintProjectXML(ctx, rule) + projectXML, lintXML, cacheDir, homeDir, deps := l.writeLintProjectXML(ctx, rule) l.outputs.html = android.PathForModuleOut(ctx, "lint-report.html") l.outputs.text = android.PathForModuleOut(ctx, "lint-report.txt") l.outputs.xml = android.PathForModuleOut(ctx, "lint-report.xml") - rule.Command().Text("rm -rf").Flag(cacheDir.String()) - rule.Command().Text("mkdir -p").Flag(cacheDir.String()) + rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String()) + rule.Command().Text("mkdir -p").Flag(cacheDir.String()).Flag(homeDir.String()) rule.Command(). Text("("). Flag("JAVA_OPTS=-Xmx2048m"). + FlagWithArg("ANDROID_SDK_HOME=", homeDir.String()). FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath(ctx)). FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXmlPath(ctx)). Tool(android.PathForSource(ctx, "prebuilts/cmdline-tools/tools/bin/lint")). @@ -239,7 +244,7 @@ func (l *linter) lint(ctx android.ModuleContext) { Text("|| (").Text("cat").Input(l.outputs.text).Text("; exit 7)"). Text(")") - rule.Command().Text("rm -rf").Flag(cacheDir.String()) + rule.Command().Text("rm -rf").Flag(cacheDir.String()).Flag(homeDir.String()) rule.Build(pctx, ctx, "lint", "lint") } diff --git a/java/sdk_library.go b/java/sdk_library.go index 676557e64..91869ed57 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1905,6 +1905,11 @@ func (module *SdkLibraryImport) DepIsInSameApex(mctx android.BaseModuleContext, return false } +func (module *SdkLibraryImport) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + // we don't check prebuilt modules for sdk_version + return nil +} + func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) { return module.commonOutputFiles(tag) } @@ -2071,6 +2076,11 @@ func (module *sdkLibraryXml) DepsMutator(ctx android.BottomUpMutatorContext) { // do nothing } +func (module *sdkLibraryXml) ShouldSupportSdkVersion(ctx android.BaseModuleContext, sdkVersion int) error { + // sdkLibraryXml doesn't need to be checked separately because java_sdk_library is checked + return nil +} + // File path to the runtime implementation library func (module *sdkLibraryXml) implPath() string { implName := proptools.String(module.properties.Lib_name) |