summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/Android.bp1
-rw-r--r--java/base.go8
-rw-r--r--java/config/Android.bp4
-rw-r--r--java/dex.go14
-rw-r--r--java/dexpreopt.go36
-rw-r--r--java/java.go4
-rw-r--r--java/kotlin.go2
-rw-r--r--java/metalava/Android.bp1
-rw-r--r--java/platform_compat_config.go1
-rw-r--r--java/ravenwood.go24
-rw-r--r--java/ravenwood_test.go6
11 files changed, 72 insertions, 29 deletions
diff --git a/java/Android.bp b/java/Android.bp
index 9603815a1..926a294e9 100644
--- a/java/Android.bp
+++ b/java/Android.bp
@@ -120,4 +120,5 @@ bootstrap_go_package {
"test_spec_test.go",
],
pluginFor: ["soong_build"],
+ visibility: ["//visibility:public"],
}
diff --git a/java/base.go b/java/base.go
index ff7e06837..86ed0e745 100644
--- a/java/base.go
+++ b/java/base.go
@@ -1790,14 +1790,14 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath
classesJar: outputFile,
jarName: jarName,
}
- if j.GetProfileGuided() && j.optimizeOrObfuscateEnabled() && !j.EnableProfileRewriting() {
+ if j.GetProfileGuided(ctx) && j.optimizeOrObfuscateEnabled() && !j.EnableProfileRewriting(ctx) {
ctx.PropertyErrorf("enable_profile_rewriting",
"Enable_profile_rewriting must be true when profile_guided dexpreopt and R8 optimization/obfuscation is turned on. The attached profile should be sourced from an unoptimized/unobfuscated APK.",
)
}
- if j.EnableProfileRewriting() {
- profile := j.GetProfile()
- if profile == "" || !j.GetProfileGuided() {
+ if j.EnableProfileRewriting(ctx) {
+ profile := j.GetProfile(ctx)
+ if profile == "" || !j.GetProfileGuided(ctx) {
ctx.PropertyErrorf("enable_profile_rewriting", "Profile and Profile_guided must be set when enable_profile_rewriting is true")
}
params.artProfileInput = &profile
diff --git a/java/config/Android.bp b/java/config/Android.bp
index bfe83ab8c..6217390bb 100644
--- a/java/config/Android.bp
+++ b/java/config/Android.bp
@@ -17,4 +17,8 @@ bootstrap_go_package {
"kotlin.go",
"makevars.go",
],
+ visibility: [
+ "//build/soong:__subpackages__",
+ "//external/error_prone/soong",
+ ],
}
diff --git a/java/dex.go b/java/dex.go
index 7d42efc9c..e0e642c63 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -120,7 +120,7 @@ func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool
}
func (d *DexProperties) optimizedResourceShrinkingEnabled(ctx android.ModuleContext) bool {
- return d.resourceShrinkingEnabled(ctx) && Bool(d.Optimize.Optimized_shrink_resources)
+ return d.resourceShrinkingEnabled(ctx) && BoolDefault(d.Optimize.Optimized_shrink_resources, ctx.Config().UseOptimizedResourceShrinkingByDefault())
}
func (d *dexer) optimizeOrObfuscateEnabled() bool {
@@ -245,6 +245,16 @@ func (d *dexer) dexCommonFlags(ctx android.ModuleContext,
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "%s", err)
}
+ if !Bool(d.dexProperties.No_dex_container) && effectiveVersion.FinalOrFutureInt() >= 36 {
+ // W is 36, but we have not bumped the SDK version yet, so check for both.
+ if ctx.Config().PlatformSdkVersion().FinalInt() >= 36 ||
+ ctx.Config().PlatformSdkCodename() == "Wear" {
+ // TODO(b/329465418): Skip this module since it causes issue with app DRM
+ if ctx.ModuleName() != "framework-minus-apex" {
+ flags = append([]string{"-JDcom.android.tools.r8.dexContainerExperiment"}, flags...)
+ }
+ }
+ }
// If the specified SDK level is 10000, then configure the compiler to use the
// current platform SDK level and to compile the build as a platform build.
@@ -390,7 +400,7 @@ func (d *dexer) r8Flags(ctx android.ModuleContext, dexParams *compileDexParams)
r8Flags = append(r8Flags, "--resource-input", d.resourcesInput.Path().String())
r8Deps = append(r8Deps, d.resourcesInput.Path())
r8Flags = append(r8Flags, "--resource-output", d.resourcesOutput.Path().String())
- if Bool(opt.Optimized_shrink_resources) {
+ if d.dexProperties.optimizedResourceShrinkingEnabled(ctx) {
r8Flags = append(r8Flags, "--optimized-resource-shrinking")
}
}
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 4734357ab..63a863497 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -147,25 +147,25 @@ type dexpreopter struct {
type DexpreoptProperties struct {
Dex_preopt struct {
// If false, prevent dexpreopting. Defaults to true.
- Enabled *bool
+ Enabled proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If true, generate an app image (.art file) for this module.
- App_image *bool
+ App_image proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If true, use a checked-in profile to guide optimization. Defaults to false unless
// a matching profile is set or a profile is found in PRODUCT_DEX_PREOPT_PROFILE_DIR
// that matches the name of this module, in which case it is defaulted to true.
- Profile_guided *bool
+ Profile_guided proptools.Configurable[bool] `android:"replace_instead_of_append"`
// If set, provides the path to profile relative to the Android.bp file. If not set,
// defaults to searching for a file that matches the name of this module in the default
// profile location set by PRODUCT_DEX_PREOPT_PROFILE_DIR, or empty if not found.
- Profile *string `android:"path"`
+ Profile proptools.Configurable[string] `android:"path,replace_instead_of_append"`
// If set to true, r8/d8 will use `profile` as input to generate a new profile that matches
// the optimized dex.
// The new profile will be subsequently used as the profile to dexpreopt the dex file.
- Enable_profile_rewriting *bool
+ Enable_profile_rewriting proptools.Configurable[bool] `android:"replace_instead_of_append"`
}
Dex_preopt_result struct {
@@ -244,7 +244,7 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName s
return true
}
- if !BoolDefault(d.dexpreoptProperties.Dex_preopt.Enabled, true) {
+ if !d.dexpreoptProperties.Dex_preopt.Enabled.GetOrDefault(ctx, true) {
return true
}
@@ -433,12 +433,12 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
if d.inputProfilePathOnHost != nil {
profileClassListing = android.OptionalPathForPath(d.inputProfilePathOnHost)
- } else if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) && !forPrebuiltApex(ctx) {
+ } else if d.dexpreoptProperties.Dex_preopt.Profile_guided.GetOrDefault(ctx, true) && !forPrebuiltApex(ctx) {
// If enable_profile_rewriting is set, use the rewritten profile instead of the checked-in profile
- if d.EnableProfileRewriting() {
+ if d.EnableProfileRewriting(ctx) {
profileClassListing = android.OptionalPathForPath(d.GetRewrittenProfile())
profileIsTextListing = true
- } else if profile := d.GetProfile(); profile != "" {
+ } else if profile := d.GetProfile(ctx); profile != "" {
// If dex_preopt.profile_guided is not set, default it based on the existence of the
// dexprepot.profile option or the profile class listing.
profileClassListing = android.OptionalPathForPath(
@@ -458,6 +458,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
// Use the dexJar to create a unique scope for each
dexJarStem := strings.TrimSuffix(dexJarFile.Base(), dexJarFile.Ext())
+ appImage := d.dexpreoptProperties.Dex_preopt.App_image.Get(ctx)
+
// Full dexpreopt config, used to create dexpreopt build rules.
dexpreoptConfig := &dexpreopt.ModuleConfig{
Name: libName,
@@ -486,8 +488,8 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa
PreoptBootClassPathDexFiles: dexFiles.Paths(),
PreoptBootClassPathDexLocations: dexLocations,
- NoCreateAppImage: !BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, true),
- ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false),
+ NoCreateAppImage: !appImage.GetOrDefault(true),
+ ForceCreateAppImage: appImage.GetOrDefault(false),
PresignedPrebuilt: d.isPresignedPrebuilt,
}
@@ -657,16 +659,16 @@ func (d *dexpreopter) disableDexpreopt() {
d.shouldDisableDexpreopt = true
}
-func (d *dexpreopter) EnableProfileRewriting() bool {
- return proptools.Bool(d.dexpreoptProperties.Dex_preopt.Enable_profile_rewriting)
+func (d *dexpreopter) EnableProfileRewriting(ctx android.BaseModuleContext) bool {
+ return d.dexpreoptProperties.Dex_preopt.Enable_profile_rewriting.GetOrDefault(ctx, false)
}
-func (d *dexpreopter) GetProfile() string {
- return proptools.String(d.dexpreoptProperties.Dex_preopt.Profile)
+func (d *dexpreopter) GetProfile(ctx android.BaseModuleContext) string {
+ return d.dexpreoptProperties.Dex_preopt.Profile.GetOrDefault(ctx, "")
}
-func (d *dexpreopter) GetProfileGuided() bool {
- return proptools.Bool(d.dexpreoptProperties.Dex_preopt.Profile_guided)
+func (d *dexpreopter) GetProfileGuided(ctx android.BaseModuleContext) bool {
+ return d.dexpreoptProperties.Dex_preopt.Profile_guided.GetOrDefault(ctx, false)
}
func (d *dexpreopter) GetRewrittenProfile() android.Path {
diff --git a/java/java.go b/java/java.go
index cdd48d7bc..d63bbe6e1 100644
--- a/java/java.go
+++ b/java/java.go
@@ -3345,6 +3345,10 @@ func addCLCFromDep(ctx android.ModuleContext, depModule android.Module,
if lib, ok := depModule.(SdkLibraryDependency); ok && lib.sharedLibrary() {
// A shared SDK library. This should be added as a top-level CLC element.
sdkLib = &depName
+ } else if lib, ok := depModule.(SdkLibraryComponentDependency); ok && lib.OptionalSdkLibraryImplementation() != nil {
+ if depModule.Name() == proptools.String(lib.OptionalSdkLibraryImplementation())+".impl" {
+ sdkLib = lib.OptionalSdkLibraryImplementation()
+ }
} else if ulib, ok := depModule.(ProvidesUsesLib); ok {
// A non-SDK library disguised as an SDK library by the means of `provides_uses_lib`
// property. This should be handled in the same way as a shared SDK library.
diff --git a/java/kotlin.go b/java/kotlin.go
index 5a76df29d..f42d16304 100644
--- a/java/kotlin.go
+++ b/java/kotlin.go
@@ -162,7 +162,7 @@ func (j *Module) kotlinCompile(ctx android.ModuleContext, outputFile, headerOutp
"srcJarDir": android.PathForModuleOut(ctx, "kotlinc", "srcJars.xref").String(),
}
if commonSrcsList.Valid() {
- args["commonSrcFilesList"] = "--srcs @" + commonSrcsList.String()
+ args["commonSrcFilesList"] = "--common_srcs @" + commonSrcsList.String()
}
ctx.Build(pctx, android.BuildParams{
Rule: kotlinKytheExtract,
diff --git a/java/metalava/Android.bp b/java/metalava/Android.bp
index ccbd191d3..6bf183296 100644
--- a/java/metalava/Android.bp
+++ b/java/metalava/Android.bp
@@ -15,4 +15,5 @@
filegroup {
name: "metalava-config-files",
srcs: ["*-config.xml"],
+ visibility: ["//visibility:public"],
}
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index 67ed84e1d..5b145c658 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -110,6 +110,7 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon
p.installConfigFile = android.PathForModuleInstall(ctx, "etc", "compatconfig", p.configFile.Base())
rule.Build(configFileName, "Extract compat/compat_config.xml and install it")
ctx.InstallFile(p.installDirPath, p.configFile.Base(), p.configFile)
+ ctx.SetOutputFiles(android.Paths{p.configFile}, "")
}
func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries {
diff --git a/java/ravenwood.go b/java/ravenwood.go
index 3fa73e64d..9239bbd6b 100644
--- a/java/ravenwood.go
+++ b/java/ravenwood.go
@@ -34,6 +34,7 @@ var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"}
var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"}
var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"}
var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"}
+var ravenwoodTestInstResourceApkTag = dependencyTag{name: "ravenwoodtest-inst-res-apk"}
const ravenwoodUtilsName = "ravenwood-utils"
const ravenwoodRuntimeName = "ravenwood-runtime"
@@ -56,11 +57,17 @@ type ravenwoodTestProperties struct {
Jni_libs []string
// Specify another android_app module here to copy it to the test directory, so that
- // the ravenwood test can access it.
+ // the ravenwood test can access it. This APK will be loaded as resources of the test
+ // target app.
// TODO: For now, we simply refer to another android_app module and copy it to the
// test directory. Eventually, android_ravenwood_test should support all the resource
// related properties and build resources from the `res/` directory.
Resource_apk *string
+
+ // Specify another android_app module here to copy it to the test directory, so that
+ // the ravenwood test can access it. This APK will be loaded as resources of the test
+ // instrumentation app itself.
+ Inst_resource_apk *string
}
type ravenwoodTest struct {
@@ -127,6 +134,10 @@ func (r *ravenwoodTest) DepsMutator(ctx android.BottomUpMutatorContext) {
if resourceApk := proptools.String(r.ravenwoodTestProperties.Resource_apk); resourceApk != "" {
ctx.AddVariationDependencies(nil, ravenwoodTestResourceApkTag, resourceApk)
}
+
+ if resourceApk := proptools.String(r.ravenwoodTestProperties.Inst_resource_apk); resourceApk != "" {
+ ctx.AddVariationDependencies(nil, ravenwoodTestInstResourceApkTag, resourceApk)
+ }
}
func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
@@ -194,13 +205,16 @@ func (r *ravenwoodTest) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
resApkInstallPath := installPath.Join(ctx, "ravenwood-res-apks")
- if resApk := ctx.GetDirectDepsWithTag(ravenwoodTestResourceApkTag); len(resApk) > 0 {
- for _, installFile := range android.OtherModuleProviderOrDefault(
- ctx, resApk[0], android.InstallFilesProvider).InstallFiles {
- installResApk := ctx.InstallFile(resApkInstallPath, "ravenwood-res.apk", installFile)
+
+ copyResApk := func(tag blueprint.DependencyTag, toFileName string) {
+ if resApk := ctx.GetDirectDepsWithTag(tag); len(resApk) > 0 {
+ installFile := android.OutputFileForModule(ctx, resApk[0], "")
+ installResApk := ctx.InstallFile(resApkInstallPath, toFileName, installFile)
installDeps = append(installDeps, installResApk)
}
}
+ copyResApk(ravenwoodTestResourceApkTag, "ravenwood-res.apk")
+ copyResApk(ravenwoodTestInstResourceApkTag, "ravenwood-inst-res.apk")
// Install our JAR with all dependencies
ctx.InstallFile(installPath, ctx.ModuleName()+".jar", r.outputFile, installDeps...)
diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go
index 0a1b08926..753a118e9 100644
--- a/java/ravenwood_test.go
+++ b/java/ravenwood_test.go
@@ -66,6 +66,10 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers(
name: "app2",
sdk_version: "current",
}
+ android_app {
+ name: "app3",
+ sdk_version: "current",
+ }
prebuilt_font {
name: "Font.ttf",
src: "Font.ttf",
@@ -167,6 +171,7 @@ func TestRavenwoodTest(t *testing.T) {
"ravenwood-runtime-jni2",
],
resource_apk: "app2",
+ inst_resource_apk: "app3",
sdk_version: "test_current",
}
`)
@@ -194,6 +199,7 @@ func TestRavenwoodTest(t *testing.T) {
module.Output(installPathPrefix + "/ravenwood-test/lib64/libblue.so")
module.Output(installPathPrefix + "/ravenwood-test/lib64/libpink.so")
module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-res.apk")
+ module.Output(installPathPrefix + "/ravenwood-test/ravenwood-res-apks/ravenwood-inst-res.apk")
// ravenwood-runtime*.so are included in the runtime, so it shouldn't be emitted.
for _, o := range module.AllOutputs() {