diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/aapt2.go | 20 | ||||
| -rw-r--r-- | java/aar.go | 44 | ||||
| -rw-r--r-- | java/app.go | 86 | ||||
| -rw-r--r-- | java/app_test.go | 334 | ||||
| -rw-r--r-- | java/device_host_converter_test.go | 2 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars.go | 4 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars_test.go | 1 | ||||
| -rw-r--r-- | java/dexpreopt_config.go | 3 | ||||
| -rw-r--r-- | java/droiddoc.go | 7 | ||||
| -rw-r--r-- | java/java.go | 9 | ||||
| -rw-r--r-- | java/java_test.go | 4 | ||||
| -rw-r--r-- | java/sdk.go | 17 | ||||
| -rw-r--r-- | java/sdk_test.go | 8 | ||||
| -rw-r--r-- | java/system_modules.go | 2 |
14 files changed, 300 insertions, 241 deletions
diff --git a/java/aapt2.go b/java/aapt2.go index a8151608f..f0eb99cee 100644 --- a/java/aapt2.go +++ b/java/aapt2.go @@ -55,12 +55,14 @@ func pathsToAapt2Paths(ctx android.ModuleContext, resPaths android.Paths) androi var aapt2CompileRule = pctx.AndroidStaticRule("aapt2Compile", blueprint.RuleParams{ - Command: `${config.Aapt2Cmd} compile -o $outDir $cFlags --legacy $in`, + Command: `${config.Aapt2Cmd} compile -o $outDir $cFlags $in`, CommandDeps: []string{"${config.Aapt2Cmd}"}, }, "outDir", "cFlags") -func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Paths) android.WritablePaths { +func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Paths, + flags []string) android.WritablePaths { + shards := shardPaths(paths, AAPT2_SHARD_SIZE) ret := make(android.WritablePaths, 0, len(paths)) @@ -81,9 +83,7 @@ func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Pat Outputs: outPaths, Args: map[string]string{ "outDir": android.PathForModuleOut(ctx, "aapt2", dir.String()).String(), - // Always set --pseudo-localize, it will be stripped out later for release - // builds that don't want it. - "cFlags": "--pseudo-localize", + "cFlags": strings.Join(flags, " "), }, }) } @@ -97,14 +97,16 @@ func aapt2Compile(ctx android.ModuleContext, dir android.Path, paths android.Pat var aapt2CompileZipRule = pctx.AndroidStaticRule("aapt2CompileZip", blueprint.RuleParams{ Command: `${config.ZipSyncCmd} -d $resZipDir $zipSyncFlags $in && ` + - `${config.Aapt2Cmd} compile -o $out $cFlags --legacy --dir $resZipDir`, + `${config.Aapt2Cmd} compile -o $out $cFlags --dir $resZipDir`, CommandDeps: []string{ "${config.Aapt2Cmd}", "${config.ZipSyncCmd}", }, }, "cFlags", "resZipDir", "zipSyncFlags") -func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip android.Path, zipPrefix string) { +func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip android.Path, zipPrefix string, + flags []string) { + if zipPrefix != "" { zipPrefix = "--zip-prefix " + zipPrefix } @@ -114,9 +116,7 @@ func aapt2CompileZip(ctx android.ModuleContext, flata android.WritablePath, zip Input: zip, Output: flata, Args: map[string]string{ - // Always set --pseudo-localize, it will be stripped out later for release - // builds that don't want it. - "cFlags": "--pseudo-localize", + "cFlags": strings.Join(flags, " "), "resZipDir": android.PathForModuleOut(ctx, "aapt2", "reszip", flata.Base()).String(), "zipSyncFlags": zipPrefix, }, diff --git a/java/aar.go b/java/aar.go index a2c203fcb..ce3d1263c 100644 --- a/java/aar.go +++ b/java/aar.go @@ -17,6 +17,7 @@ package java import ( "android/soong/android" "fmt" + "path/filepath" "strings" "github.com/google/blueprint" @@ -80,6 +81,7 @@ type aapt struct { rTxt android.Path extraAaptPackagesFile android.Path mergedManifestFile android.Path + noticeFile android.OptionalPath isLibrary bool useEmbeddedNativeLibs bool useEmbeddedDex bool @@ -111,8 +113,9 @@ func (a *aapt) ExportedManifests() android.Paths { return a.transitiveManifestPaths } -func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, manifestPath android.Path) (flags []string, - deps android.Paths, resDirs, overlayDirs []globbedResourceDir, rroDirs []rroDir, resZips android.Paths) { +func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, + manifestPath android.Path) (compileFlags, linkFlags []string, linkDeps android.Paths, + resDirs, overlayDirs []globbedResourceDir, rroDirs []rroDir, resZips android.Paths) { hasVersionCode := false hasVersionName := false @@ -124,8 +127,6 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani } } - var linkFlags []string - // Flags specified in Android.bp linkFlags = append(linkFlags, a.aaptProperties.Aaptflags...) @@ -136,8 +137,6 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani resourceDirs := android.PathsWithOptionalDefaultForModuleSrc(ctx, a.aaptProperties.Resource_dirs, "res") resourceZips := android.PathsForModuleSrc(ctx, a.aaptProperties.Resource_zips) - var linkDeps android.Paths - // Glob directories into lists of paths for _, dir := range resourceDirs { resDirs = append(resDirs, globbedResourceDir{ @@ -154,10 +153,16 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani assetFiles = append(assetFiles, androidResourceGlob(ctx, dir)...) } + assetDirStrings := assetDirs.Strings() + if a.noticeFile.Valid() { + assetDirStrings = append(assetDirStrings, filepath.Dir(a.noticeFile.Path().String())) + assetFiles = append(assetFiles, a.noticeFile.Path()) + } + linkFlags = append(linkFlags, "--manifest "+manifestPath.String()) linkDeps = append(linkDeps, manifestPath) - linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirs.Strings(), "-A ")) + linkFlags = append(linkFlags, android.JoinWithPrefix(assetDirStrings, "-A ")) linkDeps = append(linkDeps, assetFiles...) // SDK version flags @@ -185,7 +190,13 @@ func (a *aapt) aapt2Flags(ctx android.ModuleContext, sdkContext sdkContext, mani linkFlags = append(linkFlags, "--version-name ", versionName) } - return linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips + linkFlags, compileFlags = android.FilterList(linkFlags, []string{"--legacy"}) + + // Always set --pseudo-localize, it will be stripped out later for release + // builds that don't want it. + compileFlags = append(compileFlags, "--pseudo-localize") + + return compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resourceZips } func (a *aapt) deps(ctx android.BottomUpMutatorContext, sdkDep sdkDep) { @@ -220,7 +231,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex a.mergedManifestFile = manifestPath } - linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, sdkContext, manifestPath) + compileFlags, linkFlags, linkDeps, resDirs, overlayDirs, rroDirs, resZips := a.aapt2Flags(ctx, sdkContext, manifestPath) rroDirs = append(rroDirs, staticRRODirs...) linkFlags = append(linkFlags, libFlags...) @@ -239,12 +250,12 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex var compiledResDirs []android.Paths for _, dir := range resDirs { - compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files).Paths()) + compiledResDirs = append(compiledResDirs, aapt2Compile(ctx, dir.dir, dir.files, compileFlags).Paths()) } for i, zip := range resZips { flata := android.PathForModuleOut(ctx, fmt.Sprintf("reszip.%d.flata", i)) - aapt2CompileZip(ctx, flata, zip, "") + aapt2CompileZip(ctx, flata, zip, "", compileFlags) compiledResDirs = append(compiledResDirs, android.Paths{flata}) } @@ -273,7 +284,7 @@ func (a *aapt) buildActions(ctx android.ModuleContext, sdkContext sdkContext, ex } for _, dir := range overlayDirs { - compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files).Paths()...) + compiledOverlay = append(compiledOverlay, aapt2Compile(ctx, dir.dir, dir.files, compileFlags).Paths()...) } var splitPackages android.WritablePaths @@ -513,10 +524,6 @@ func (a *AARImport) targetSdkVersion() string { return a.sdkVersion() } -func (a *AARImport) noFrameworkLibs() bool { - return false -} - var _ AndroidLibraryDependency = (*AARImport)(nil) func (a *AARImport) ExportPackage() android.Path { @@ -598,9 +605,12 @@ func (a *AARImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { }, }) + // Always set --pseudo-localize, it will be stripped out later for release + // builds that don't want it. + compileFlags := []string{"--pseudo-localize"} compiledResDir := android.PathForModuleOut(ctx, "flat-res") flata := compiledResDir.Join(ctx, "gen_res.flata") - aapt2CompileZip(ctx, flata, aar, "res") + aapt2CompileZip(ctx, flata, aar, "res", compileFlags) a.exportPackage = android.PathForModuleOut(ctx, "package-res.apk") srcJar := android.PathForModuleGen(ctx, "R.jar") diff --git a/java/app.go b/java/app.go index cab97de45..f58b0f836 100644 --- a/java/app.go +++ b/java/app.go @@ -19,6 +19,7 @@ package java import ( "path/filepath" "reflect" + "sort" "strings" "github.com/google/blueprint" @@ -103,6 +104,10 @@ type appProperties struct { // Use_embedded_native_libs still selects whether they are stored uncompressed and aligned or compressed. // True for android_test* modules. AlwaysPackageNativeLibs bool `blueprint:"mutated"` + + // If set, find and merge all NOTICE files that this module and its dependencies have and store + // it in the APK as an asset. + Embed_notices *bool } // android_app properties that can be overridden by override_android_app @@ -224,15 +229,16 @@ func (a *AndroidApp) shouldUncompressDex(ctx android.ModuleContext) bool { return true } - if ctx.Config().UnbundledBuild() { - return false - } - - // Uncompress dex in APKs of privileged apps + // Uncompress dex in APKs of privileged apps (even for unbundled builds, they may + // be preinstalled as prebuilts). if ctx.Config().UncompressPrivAppDex() && Bool(a.appProperties.Privileged) { return true } + if ctx.Config().UnbundledBuild() { + return false + } + return shouldUncompressDex(ctx, &a.dexpreopter) } @@ -351,6 +357,54 @@ func (a *AndroidApp) jniBuildActions(jniLibs []jniLib, ctx android.ModuleContext return jniJarFile } +func (a *AndroidApp) noticeBuildActions(ctx android.ModuleContext, installDir android.OutputPath) android.OptionalPath { + if !Bool(a.appProperties.Embed_notices) && !ctx.Config().IsEnvTrue("ALWAYS_EMBED_NOTICES") { + return android.OptionalPath{} + } + + // Collect NOTICE files from all dependencies. + seenModules := make(map[android.Module]bool) + noticePathSet := make(map[android.Path]bool) + + ctx.WalkDeps(func(child android.Module, parent android.Module) bool { + // Have we already seen this? + if _, ok := seenModules[child]; ok { + return false + } + seenModules[child] = true + + // Skip host modules. + if child.Target().Os.Class == android.Host || child.Target().Os.Class == android.HostCross { + return false + } + + path := child.(android.Module).NoticeFile() + if path.Valid() { + noticePathSet[path.Path()] = true + } + return true + }) + + // If the app has one, add it too. + if a.NoticeFile().Valid() { + noticePathSet[a.NoticeFile().Path()] = true + } + + if len(noticePathSet) == 0 { + return android.OptionalPath{} + } + var noticePaths []android.Path + for path := range noticePathSet { + noticePaths = append(noticePaths, path) + } + sort.Slice(noticePaths, func(i, j int) bool { + return noticePaths[i].String() < noticePaths[j].String() + }) + noticeFile := android.BuildNoticeOutput(ctx, installDir, a.installApkName+".apk", noticePaths) + + return android.OptionalPathForPath(noticeFile) +} + // Reads and prepends a main cert from the default cert dir if it hasn't been set already, i.e. it // isn't a cert module reference. Also checks and enforces system cert restriction if applicable. func processMainCert(m android.ModuleBase, certPropValue string, certificates []Certificate, ctx android.ModuleContext) []Certificate { @@ -391,6 +445,18 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { // Check if the install APK name needs to be overridden. a.installApkName = ctx.DeviceConfig().OverridePackageNameFor(a.Name()) + var installDir android.OutputPath + if ctx.ModuleName() == "framework-res" { + // framework-res.apk is installed as system/framework/framework-res.apk + installDir = android.PathForModuleInstall(ctx, "framework") + } else if Bool(a.appProperties.Privileged) { + installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName) + } else { + installDir = android.PathForModuleInstall(ctx, "app", a.installApkName) + } + + a.aapt.noticeFile = a.noticeBuildActions(ctx, installDir) + // Process all building blocks, from AAPT to certificates. a.aaptBuildActions(ctx) @@ -432,16 +498,6 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) { a.bundleFile = bundleFile // Install the app package. - var installDir android.OutputPath - if ctx.ModuleName() == "framework-res" { - // framework-res.apk is installed as system/framework/framework-res.apk - installDir = android.PathForModuleInstall(ctx, "framework") - } else if Bool(a.appProperties.Privileged) { - installDir = android.PathForModuleInstall(ctx, "priv-app", a.installApkName) - } else { - installDir = android.PathForModuleInstall(ctx, "app", a.installApkName) - } - ctx.InstallFile(installDir, a.installApkName+".apk", a.outputFile) for _, split := range a.aapt.splits { ctx.InstallFile(installDir, a.installApkName+"_"+split.suffix+".apk", split.path) diff --git a/java/app_test.go b/java/app_test.go index 27802cd21..c7ea338b1 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -546,79 +546,6 @@ func TestAppSdkVersion(t *testing.T) { } } -func TestJNIABI_no_framework_libs_true(t *testing.T) { - ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` - cc_library { - name: "libjni", - system_shared_libs: [], - stl: "none", - } - - android_test { - name: "test", - no_framework_libs: true, - jni_libs: ["libjni"], - } - - android_test { - name: "test_first", - no_framework_libs: true, - compile_multilib: "first", - jni_libs: ["libjni"], - } - - android_test { - name: "test_both", - no_framework_libs: true, - compile_multilib: "both", - jni_libs: ["libjni"], - } - - android_test { - name: "test_32", - no_framework_libs: true, - compile_multilib: "32", - jni_libs: ["libjni"], - } - - android_test { - name: "test_64", - no_framework_libs: true, - compile_multilib: "64", - jni_libs: ["libjni"], - } - `) - - testCases := []struct { - name string - abis []string - }{ - {"test", []string{"arm64-v8a"}}, - {"test_first", []string{"arm64-v8a"}}, - {"test_both", []string{"arm64-v8a", "armeabi-v7a"}}, - {"test_32", []string{"armeabi-v7a"}}, - {"test_64", []string{"arm64-v8a"}}, - } - - for _, test := range testCases { - t.Run(test.name, func(t *testing.T) { - app := ctx.ModuleForTests(test.name, "android_common") - jniLibZip := app.Output("jnilibs.zip") - var abis []string - args := strings.Fields(jniLibZip.Args["jarArgs"]) - for i := 0; i < len(args); i++ { - if args[i] == "-P" { - abis = append(abis, filepath.Base(args[i+1])) - i++ - } - } - if !reflect.DeepEqual(abis, test.abis) { - t.Errorf("want abis %v, got %v", test.abis, abis) - } - }) - } -} - func TestJNIABI(t *testing.T) { ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` cc_library { @@ -692,89 +619,6 @@ func TestJNIABI(t *testing.T) { } } -func TestJNIPackaging_no_framework_libs_true(t *testing.T) { - ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` - cc_library { - name: "libjni", - system_shared_libs: [], - stl: "none", - } - - android_app { - name: "app", - jni_libs: ["libjni"], - } - - android_app { - name: "app_noembed", - jni_libs: ["libjni"], - use_embedded_native_libs: false, - } - - android_app { - name: "app_embed", - jni_libs: ["libjni"], - use_embedded_native_libs: true, - } - - android_test { - name: "test", - no_framework_libs: true, - jni_libs: ["libjni"], - } - - android_test { - name: "test_noembed", - no_framework_libs: true, - jni_libs: ["libjni"], - use_embedded_native_libs: false, - } - - android_test_helper_app { - name: "test_helper", - no_framework_libs: true, - jni_libs: ["libjni"], - } - - android_test_helper_app { - name: "test_helper_noembed", - no_framework_libs: true, - jni_libs: ["libjni"], - use_embedded_native_libs: false, - } - `) - - testCases := []struct { - name string - packaged bool - compressed bool - }{ - {"app", false, false}, - {"app_noembed", false, false}, - {"app_embed", true, false}, - {"test", true, false}, - {"test_noembed", true, true}, - {"test_helper", true, false}, - {"test_helper_noembed", true, true}, - } - - for _, test := range testCases { - t.Run(test.name, func(t *testing.T) { - app := ctx.ModuleForTests(test.name, "android_common") - jniLibZip := app.MaybeOutput("jnilibs.zip") - if g, w := (jniLibZip.Rule != nil), test.packaged; g != w { - t.Errorf("expected jni packaged %v, got %v", w, g) - } - - if jniLibZip.Rule != nil { - if g, w := !strings.Contains(jniLibZip.Args["jarArgs"], "-L 0"), test.compressed; g != w { - t.Errorf("expected jni compressed %v, got %v", w, g) - } - } - }) - } -} - func TestJNIPackaging(t *testing.T) { ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` cc_library { @@ -1552,3 +1396,181 @@ func TestCodelessApp(t *testing.T) { }) } } + +func TestEmbedNotice(t *testing.T) { + ctx := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+` + android_app { + name: "foo", + srcs: ["a.java"], + static_libs: ["javalib"], + jni_libs: ["libjni"], + notice: "APP_NOTICE", + embed_notices: true, + } + + // No embed_notice flag + android_app { + name: "bar", + srcs: ["a.java"], + jni_libs: ["libjni"], + notice: "APP_NOTICE", + } + + // No NOTICE files + android_app { + name: "baz", + srcs: ["a.java"], + embed_notices: true, + } + + cc_library { + name: "libjni", + system_shared_libs: [], + stl: "none", + notice: "LIB_NOTICE", + } + + java_library { + name: "javalib", + srcs: [ + ":gen", + ], + } + + genrule { + name: "gen", + tools: ["gentool"], + out: ["gen.java"], + notice: "GENRULE_NOTICE", + } + + java_binary_host { + name: "gentool", + srcs: ["b.java"], + notice: "TOOL_NOTICE", + } + `) + + // foo has NOTICE files to process, and embed_notices is true. + foo := ctx.ModuleForTests("foo", "android_common") + // verify merge notices rule. + mergeNotices := foo.Rule("mergeNoticesRule") + noticeInputs := mergeNotices.Inputs.Strings() + // TOOL_NOTICE should be excluded as it's a host module. + if len(mergeNotices.Inputs) != 3 { + t.Errorf("number of input notice files: expected = 3, actual = %q", noticeInputs) + } + if !inList("APP_NOTICE", noticeInputs) { + t.Errorf("APP_NOTICE is missing from notice files, %q", noticeInputs) + } + if !inList("LIB_NOTICE", noticeInputs) { + t.Errorf("LIB_NOTICE is missing from notice files, %q", noticeInputs) + } + if !inList("GENRULE_NOTICE", noticeInputs) { + t.Errorf("GENRULE_NOTICE is missing from notice files, %q", noticeInputs) + } + // aapt2 flags should include -A <NOTICE dir> so that its contents are put in the APK's /assets. + res := foo.Output("package-res.apk") + aapt2Flags := res.Args["flags"] + e := "-A " + buildDir + "/.intermediates/foo/android_common/NOTICE" + if !strings.Contains(aapt2Flags, e) { + t.Errorf("asset dir flag for NOTICE, %q is missing in aapt2 link flags, %q", e, aapt2Flags) + } + + // bar has NOTICE files to process, but embed_notices is not set. + bar := ctx.ModuleForTests("bar", "android_common") + mergeNotices = bar.MaybeRule("mergeNoticesRule") + if mergeNotices.Rule != nil { + t.Errorf("mergeNotices shouldn't have run for bar") + } + + // baz's embed_notice is true, but it doesn't have any NOTICE files. + baz := ctx.ModuleForTests("baz", "android_common") + mergeNotices = baz.MaybeRule("mergeNoticesRule") + if mergeNotices.Rule != nil { + t.Errorf("mergeNotices shouldn't have run for baz") + } +} + +func TestUncompressDex(t *testing.T) { + testCases := []struct { + name string + bp string + + uncompressedPlatform bool + uncompressedUnbundled bool + }{ + { + name: "normal", + bp: ` + android_app { + name: "foo", + srcs: ["a.java"], + } + `, + uncompressedPlatform: true, + uncompressedUnbundled: false, + }, + { + name: "use_embedded_dex", + bp: ` + android_app { + name: "foo", + use_embedded_dex: true, + srcs: ["a.java"], + } + `, + uncompressedPlatform: true, + uncompressedUnbundled: true, + }, + { + name: "privileged", + bp: ` + android_app { + name: "foo", + privileged: true, + srcs: ["a.java"], + } + `, + uncompressedPlatform: true, + uncompressedUnbundled: true, + }, + } + + test := func(t *testing.T, bp string, want bool, unbundled bool) { + t.Helper() + + config := testConfig(nil) + if unbundled { + config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true) + } + + ctx := testAppContext(config, bp, nil) + + run(t, ctx, config) + + foo := ctx.ModuleForTests("foo", "android_common") + dex := foo.Rule("r8") + uncompressedInDexJar := strings.Contains(dex.Args["zipFlags"], "-L 0") + aligned := foo.MaybeRule("zipalign").Rule != nil + + if uncompressedInDexJar != want { + t.Errorf("want uncompressed in dex %v, got %v", want, uncompressedInDexJar) + } + + if aligned != want { + t.Errorf("want aligned %v, got %v", want, aligned) + } + } + + for _, tt := range testCases { + t.Run(tt.name, func(t *testing.T) { + t.Run("platform", func(t *testing.T) { + test(t, tt.bp, tt.uncompressedPlatform, false) + }) + t.Run("unbundled", func(t *testing.T) { + test(t, tt.bp, tt.uncompressedUnbundled, true) + }) + }) + } +} diff --git a/java/device_host_converter_test.go b/java/device_host_converter_test.go index 146bf6f40..9b9d0d899 100644 --- a/java/device_host_converter_test.go +++ b/java/device_host_converter_test.go @@ -126,7 +126,7 @@ func TestHostForDevice(t *testing.T) { java_library { name: "device_module", - no_framework_libs: true, + sdk_version: "core_platform", srcs: ["b.java"], java_resources: ["java-res/b/b"], static_libs: ["host_for_device_module"], diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index eb735c162..fe468a9e0 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -286,8 +286,6 @@ func buildBootImageRuleForArch(ctx android.SingletonContext, image *bootImage, if profile != nil { cmd.FlagWithArg("--compiler-filter=", "speed-profile") cmd.FlagWithInput("--profile-file=", profile) - } else if global.PreloadedClasses.Valid() { - cmd.FlagWithInput("--image-classes=", global.PreloadedClasses.Path()) } if global.DirtyImageObjects.Valid() { @@ -374,7 +372,7 @@ Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see func bootImageProfileRule(ctx android.SingletonContext, image *bootImage, missingDeps []string) android.WritablePath { global := dexpreoptGlobalConfig(ctx) - if !global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { + if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { return nil } return ctx.Config().Once(bootImageProfileRuleKey, func() interface{} { diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go index cbb52f15c..f91ff6925 100644 --- a/java/dexpreopt_bootjars_test.go +++ b/java/dexpreopt_bootjars_test.go @@ -62,6 +62,7 @@ func TestDexpreoptBootJars(t *testing.T) { bootArt := dexpreoptBootJars.Output("boot.art") expectedInputs := []string{ + "dex_bootjars/boot.prof", "dex_bootjars_input/foo.jar", "dex_bootjars_input/bar.jar", "dex_bootjars_input/baz.jar", diff --git a/java/dexpreopt_config.go b/java/dexpreopt_config.go index c396d3ea0..4a4d6d573 100644 --- a/java/dexpreopt_config.go +++ b/java/dexpreopt_config.go @@ -49,7 +49,8 @@ func dexpreoptGlobalConfigRaw(ctx android.PathContext) globalConfigAndRaw { return ctx.Config().Once(dexpreoptTestGlobalConfigKey, func() interface{} { // Nope, return a config with preopting disabled return globalConfigAndRaw{dexpreopt.GlobalConfig{ - DisablePreopt: true, + DisablePreopt: true, + DisableGenerateProfile: true, }, nil} }) }).(globalConfigAndRaw) diff --git a/java/droiddoc.go b/java/droiddoc.go index 18f337a26..25101de81 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -172,9 +172,6 @@ type JavadocProperties struct { // list of java libraries that will be in the classpath. Libs []string `android:"arch_variant"` - // don't build against the framework libraries (ext, and framework for device targets) - No_framework_libs *bool - // the java library (in classpath) for documentation that provides java srcs and srcjars. Srcs_lib *string @@ -535,10 +532,6 @@ func (j *Javadoc) targetSdkVersion() string { return j.sdkVersion() } -func (j *Javadoc) noFrameworkLibs() bool { - return Bool(j.properties.No_framework_libs) -} - func (j *Javadoc) addDeps(ctx android.BottomUpMutatorContext) { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) diff --git a/java/java.go b/java/java.go index 037843686..7c84e766f 100644 --- a/java/java.go +++ b/java/java.go @@ -82,9 +82,6 @@ type CompilerProperties struct { // list of files that should be excluded from java_resources and java_resource_dirs Exclude_java_resources []string `android:"path,arch_variant"` - // don't build against the framework libraries (ext, and framework for device targets) - No_framework_libs *bool - // list of module-specific flags that will be used for javac compiles Javacflags []string `android:"arch_variant"` @@ -494,10 +491,6 @@ func (j *Module) targetSdkVersion() string { return j.sdkVersion() } -func (j *Module) noFrameworkLibs() bool { - return Bool(j.properties.No_framework_libs) -} - func (j *Module) deps(ctx android.BottomUpMutatorContext) { if ctx.Device() { sdkDep := decodeSdkDep(ctx, sdkContext(j)) @@ -518,7 +511,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) { } } else if j.deviceProperties.System_modules == nil { ctx.PropertyErrorf("sdk_version", - `system_modules is required to be set when sdk_version is "none", did you mean no_framework_libs?`) + `system_modules is required to be set when sdk_version is "none", did you mean "core_platform"`) } else if *j.deviceProperties.System_modules != "none" { ctx.AddVariationDependencies(nil, systemModulesTag, *j.deviceProperties.System_modules) } diff --git a/java/java_test.go b/java/java_test.go index 628fec3f8..677174d39 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -121,6 +121,10 @@ func testContext(config android.Config, bp string, "b.kt": nil, "a.jar": nil, "b.jar": nil, + "APP_NOTICE": nil, + "GENRULE_NOTICE": nil, + "LIB_NOTICE": nil, + "TOOL_NOTICE": nil, "java-res/a/a": nil, "java-res/b/b": nil, "java-res2/a": nil, diff --git a/java/sdk.go b/java/sdk.go index 6ffe399fb..7b79a49f2 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -44,9 +44,6 @@ type sdkContext interface { minSdkVersion() string // targetSdkVersion returns the target_sdk_version property of the current module, or sdkVersion() if it is not set. targetSdkVersion() string - - // Temporarily provide access to the no_frameworks_libs property (where present). - noFrameworkLibs() bool } func sdkVersionOrDefault(ctx android.BaseModuleContext, v string) string { @@ -84,6 +81,7 @@ func sdkVersionToNumberAsString(ctx android.BaseModuleContext, v string) (string func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { v := sdkContext.sdkVersion() + // For PDK builds, use the latest SDK version instead of "current" if ctx.Config().IsPdkBuild() && (v == "" || v == "current") { sdkVersions := ctx.Config().Get(sdkVersionsKey).([]int) @@ -141,9 +139,6 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { useFiles: true, jars: android.Paths{jarPath.Path(), lambdaStubsPath}, aidl: android.OptionalPathForPath(aidlPath.Path()), - - // Pass value straight through for now to match previous behavior. - noFrameworksLibs: sdkContext.noFrameworkLibs(), } } @@ -154,15 +149,12 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { systemModules: m + "_system_modules", frameworkResModule: r, aidl: android.OptionalPathForPath(aidl), - - // Pass value straight through for now to match previous behavior. - noFrameworksLibs: sdkContext.noFrameworkLibs(), } if m == "core.current.stubs" { ret.systemModules = "core-current-stubs-system-modules" - } else if m == "core.platform.api.stubs" { - ret.systemModules = "core-platform-api-stubs-system-modules" + // core_current does not include framework classes. + ret.noFrameworksLibs = true } return ret } @@ -192,9 +184,6 @@ func decodeSdkDep(ctx android.BaseModuleContext, sdkContext sdkContext) sdkDep { return sdkDep{ useDefaultLibs: true, frameworkResModule: "framework-res", - - // Pass value straight through for now to match previous behavior. - noFrameworksLibs: sdkContext.noFrameworkLibs(), } case "none": return sdkDep{ diff --git a/java/sdk_test.go b/java/sdk_test.go index 953c3722f..f82a4fba9 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -47,14 +47,6 @@ func TestClasspath(t *testing.T) { aidl: "-Iframework/aidl", }, { - name: "no_framework_libs:true", - properties: `no_framework_libs:true`, - bootclasspath: config.DefaultBootclasspathLibraries, - system: config.DefaultSystemModules, - classpath: []string{}, - aidl: "", - }, - { name: `sdk_version:"core_platform"`, properties: `sdk_version:"core_platform"`, bootclasspath: config.DefaultBootclasspathLibraries, diff --git a/java/system_modules.go b/java/system_modules.go index f71f4523f..c616249d5 100644 --- a/java/system_modules.go +++ b/java/system_modules.go @@ -138,7 +138,7 @@ func (system *SystemModules) AndroidMk() android.AndroidMkData { fmt.Fprintln(w, makevar, ":=$=", strings.Join(system.properties.Libs, " ")) fmt.Fprintln(w) - makevar = "SOONG_SYSTEM_MODULE_DEPS_" + name + makevar = "SOONG_SYSTEM_MODULES_DEPS_" + name fmt.Fprintln(w, makevar, ":=$=", strings.Join(system.outputDeps.Strings(), " ")) fmt.Fprintln(w) |