diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/Android.bp | 1 | ||||
| -rw-r--r-- | java/base.go | 13 | ||||
| -rw-r--r-- | java/config/Android.bp | 4 | ||||
| -rw-r--r-- | java/config/config.go | 1 | ||||
| -rw-r--r-- | java/config/kotlin.go | 7 | ||||
| -rw-r--r-- | java/dex.go | 14 | ||||
| -rw-r--r-- | java/dexpreopt.go | 36 | ||||
| -rw-r--r-- | java/java.go | 14 | ||||
| -rw-r--r-- | java/java_test.go | 2 | ||||
| -rw-r--r-- | java/kotlin.go | 49 | ||||
| -rw-r--r-- | java/metalava/Android.bp | 1 | ||||
| -rw-r--r-- | java/platform_compat_config.go | 1 | ||||
| -rw-r--r-- | java/ravenwood.go | 44 | ||||
| -rw-r--r-- | java/ravenwood_test.go | 65 | ||||
| -rw-r--r-- | java/sdk_library.go | 96 | ||||
| -rw-r--r-- | java/sdk_library_test.go | 2 |
16 files changed, 207 insertions, 143 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 ef299b279..86ed0e745 100644 --- a/java/base.go +++ b/java/base.go @@ -535,7 +535,8 @@ type Module struct { linter // list of the xref extraction files - kytheFiles android.Paths + kytheFiles android.Paths + kytheKotlinFiles android.Paths hideApexVariantFromMake bool @@ -1370,7 +1371,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars, extraClasspath kotlinJar := android.PathForModuleOut(ctx, "kotlin", jarName) kotlinHeaderJar := android.PathForModuleOut(ctx, "kotlin_headers", jarName) - kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags) + j.kotlinCompile(ctx, kotlinJar, kotlinHeaderJar, uniqueSrcFiles, kotlinCommonSrcFiles, srcJars, flags) if ctx.Failed() { return } @@ -1789,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/config/config.go b/java/config/config.go index c28e07032..4c1c72393 100644 --- a/java/config/config.go +++ b/java/config/config.go @@ -145,6 +145,7 @@ func init() { pctx.SourcePathVariable("JmodCmd", "${JavaToolchain}/jmod") pctx.SourcePathVariable("JrtFsJar", "${JavaHome}/lib/jrt-fs.jar") pctx.SourcePathVariable("JavaKytheExtractorJar", "prebuilts/build-tools/common/framework/javac_extractor.jar") + pctx.SourcePathVariable("KotlinKytheExtractor", "prebuilts/build-tools/${hostPrebuiltTag}/bin/kotlinc_extractor") pctx.SourcePathVariable("Ziptime", "prebuilts/build-tools/${hostPrebuiltTag}/bin/ziptime") pctx.SourcePathVariable("ResourceProcessorBusyBox", "prebuilts/bazel/common/android_tools/android_tools/all_android_tools_deploy.jar") diff --git a/java/config/kotlin.go b/java/config/kotlin.go index e5e187cad..302d021db 100644 --- a/java/config/kotlin.go +++ b/java/config/kotlin.go @@ -50,4 +50,11 @@ func init() { }, " ")) pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{}, " ")) + // Use KotlincKytheGlobalFlags to prevent kotlinc version skew issues between android and + // g3 kythe indexers. + // This is necessary because there might be instances of kotlin code in android + // platform that are not fully compatible with the kotlinc used in g3 kythe indexers. + // e.g. uninitialized variables are a warning in 1.*, but an error in 2.* + // https://github.com/JetBrains/kotlin/blob/master/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt#L748 + pctx.StaticVariable("KotlincKytheGlobalFlags", strings.Join([]string{"-language-version 1.9"}, " ")) } 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 95f4fd892..d63bbe6e1 100644 --- a/java/java.go +++ b/java/java.go @@ -356,12 +356,17 @@ type UsesLibraryDependency interface { // TODO(jungjw): Move this to kythe.go once it's created. type xref interface { XrefJavaFiles() android.Paths + XrefKotlinFiles() android.Paths } func (j *Module) XrefJavaFiles() android.Paths { return j.kytheFiles } +func (j *Module) XrefKotlinFiles() android.Paths { + return j.kytheKotlinFiles +} + func (d dependencyTag) PropagateAconfigValidation() bool { return d.static } @@ -3304,15 +3309,20 @@ type kytheExtractJavaSingleton struct { func (ks *kytheExtractJavaSingleton) GenerateBuildActions(ctx android.SingletonContext) { var xrefTargets android.Paths + var xrefKotlinTargets android.Paths ctx.VisitAllModules(func(module android.Module) { if javaModule, ok := module.(xref); ok { xrefTargets = append(xrefTargets, javaModule.XrefJavaFiles()...) + xrefKotlinTargets = append(xrefKotlinTargets, javaModule.XrefKotlinFiles()...) } }) // TODO(asmundak): perhaps emit a rule to output a warning if there were no xrefTargets if len(xrefTargets) > 0 { ctx.Phony("xref_java", xrefTargets...) } + if len(xrefKotlinTargets) > 0 { + ctx.Phony("xref_kotlin", xrefKotlinTargets...) + } } var Bool = proptools.Bool @@ -3335,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/java_test.go b/java/java_test.go index e4e6bca9c..c13db3e30 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -2674,7 +2674,7 @@ func TestDisableFromTextStubForCoverageBuild(t *testing.T) { android.AssertBoolEquals(t, "stub module expected to depend on from-source stub", true, CheckModuleHasDependency(t, result.TestContext, apiScopePublic.stubsLibraryModuleName("foo"), "android_common", - apiScopePublic.sourceStubLibraryModuleName("foo"))) + apiScopePublic.sourceStubsLibraryModuleName("foo"))) android.AssertBoolEquals(t, "stub module expected to not depend on from-text stub", false, CheckModuleHasDependency(t, result.TestContext, diff --git a/java/kotlin.go b/java/kotlin.go index c28bc3f54..f42d16304 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -64,6 +64,28 @@ var kotlinc = pctx.AndroidRemoteStaticRule("kotlinc", android.RemoteRuleSupports "kotlincFlags", "classpath", "srcJars", "commonSrcFilesArg", "srcJarDir", "classesDir", "headerClassesDir", "headerJar", "kotlinJvmTarget", "kotlinBuildFile", "emptyDir", "name") +var kotlinKytheExtract = pctx.AndroidStaticRule("kotlinKythe", + blueprint.RuleParams{ + Command: `rm -rf "$srcJarDir" && mkdir -p "$srcJarDir" && ` + + `${config.ZipSyncCmd} -d $srcJarDir -l $srcJarDir/list -f "*.java" -f "*.kt" $srcJars && ` + + `${config.KotlinKytheExtractor} -corpus ${kytheCorpus} --srcs @$out.rsp --srcs @"$srcJarDir/list" $commonSrcFilesList --cp @$classpath -o $out --kotlin_out $outJar ` + + // wrap the additional kotlin args. + // Skip Xbuild file, pass the cp explicitly. + // Skip header jars, those should not have an effect on kythe results. + ` --args '${config.KotlincGlobalFlags} ` + + ` ${config.KotlincSuppressJDK9Warnings} ${config.JavacHeapFlags} ` + + ` $kotlincFlags -jvm-target $kotlinJvmTarget ` + + `${config.KotlincKytheGlobalFlags}'`, + CommandDeps: []string{ + "${config.KotlinKytheExtractor}", + "${config.ZipSyncCmd}", + }, + Rspfile: "$out.rsp", + RspfileContent: "$in", + }, + "classpath", "kotlincFlags", "commonSrcFilesList", "kotlinJvmTarget", "outJar", "srcJars", "srcJarDir", +) + func kotlinCommonSrcsList(ctx android.ModuleContext, commonSrcFiles android.Paths) android.OptionalPath { if len(commonSrcFiles) > 0 { // The list of common_srcs may be too long to put on the command line, but @@ -81,7 +103,7 @@ func kotlinCommonSrcsList(ctx android.ModuleContext, commonSrcFiles android.Path } // kotlinCompile takes .java and .kt sources and srcJars, and compiles the .kt sources into a classes jar in outputFile. -func kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile android.WritablePath, +func (j *Module) kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile android.WritablePath, srcFiles, commonSrcFiles, srcJars android.Paths, flags javaBuilderFlags) { @@ -127,6 +149,31 @@ func kotlinCompile(ctx android.ModuleContext, outputFile, headerOutputFile andro "name": kotlinName, }, }) + + // Emit kythe xref rule + if (ctx.Config().EmitXrefRules()) && ctx.Module() == ctx.PrimaryModule() { + extractionFile := outputFile.ReplaceExtension(ctx, "kzip") + args := map[string]string{ + "classpath": classpathRspFile.String(), + "kotlincFlags": flags.kotlincFlags, + "kotlinJvmTarget": flags.javaVersion.StringForKotlinc(), + "outJar": outputFile.String(), + "srcJars": strings.Join(srcJars.Strings(), " "), + "srcJarDir": android.PathForModuleOut(ctx, "kotlinc", "srcJars.xref").String(), + } + if commonSrcsList.Valid() { + args["commonSrcFilesList"] = "--common_srcs @" + commonSrcsList.String() + } + ctx.Build(pctx, android.BuildParams{ + Rule: kotlinKytheExtract, + Description: "kotlinKythe", + Output: extractionFile, + Inputs: srcFiles, + Implicits: deps, + Args: args, + }) + j.kytheKotlinFiles = append(j.kytheKotlinFiles, extractionFile) + } } var kaptStubs = pctx.AndroidRemoteStaticRule("kaptStubs", android.RemoteRuleSupports{Goma: true}, 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 bb136cf6e..9239bbd6b 100644 --- a/java/ravenwood.go +++ b/java/ravenwood.go @@ -33,8 +33,8 @@ func RegisterRavenwoodBuildComponents(ctx android.RegistrationContext) { var ravenwoodLibContentTag = dependencyTag{name: "ravenwoodlibcontent"} var ravenwoodUtilsTag = dependencyTag{name: "ravenwoodutils"} var ravenwoodRuntimeTag = dependencyTag{name: "ravenwoodruntime"} -var ravenwoodDataTag = dependencyTag{name: "ravenwooddata"} var ravenwoodTestResourceApkTag = dependencyTag{name: "ravenwoodtestresapk"} +var ravenwoodTestInstResourceApkTag = dependencyTag{name: "ravenwoodtest-inst-res-apk"} const ravenwoodUtilsName = "ravenwood-utils" const ravenwoodRuntimeName = "ravenwood-runtime" @@ -57,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 { @@ -128,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) { @@ -195,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...) @@ -228,7 +241,10 @@ type ravenwoodLibgroupProperties struct { Jni_libs []string // We use this to copy framework-res.apk to the ravenwood runtime directory. - Data []string + Data []string `android:"path,arch_variant"` + + // We use this to copy font files to the ravenwood runtime directory. + Fonts []string `android:"path,arch_variant"` } type ravenwoodLibgroup struct { @@ -267,9 +283,6 @@ func (r *ravenwoodLibgroup) DepsMutator(ctx android.BottomUpMutatorContext) { for _, lib := range r.ravenwoodLibgroupProperties.Jni_libs { ctx.AddVariationDependencies(ctx.Config().BuildOSTarget.Variations(), jniLibTag, lib) } - for _, data := range r.ravenwoodLibgroupProperties.Data { - ctx.AddVariationDependencies(nil, ravenwoodDataTag, data) - } } func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { @@ -309,12 +322,17 @@ func (r *ravenwoodLibgroup) GenerateAndroidBuildActions(ctx android.ModuleContex } dataInstallPath := installPath.Join(ctx, "ravenwood-data") - for _, data := range r.ravenwoodLibgroupProperties.Data { - libModule := ctx.GetDirectDepWithTag(data, ravenwoodDataTag) - file := android.OutputFileForModule(ctx, libModule, "") + data := android.PathsForModuleSrc(ctx, r.ravenwoodLibgroupProperties.Data) + for _, file := range data { ctx.InstallFile(dataInstallPath, file.Base(), file) } + fontsInstallPath := installPath.Join(ctx, "fonts") + fonts := android.PathsForModuleSrc(ctx, r.ravenwoodLibgroupProperties.Fonts) + for _, file := range fonts { + ctx.InstallFile(fontsInstallPath, file.Base(), file) + } + // Normal build should perform install steps ctx.Phony(r.BaseModuleName(), android.PathForPhony(ctx, r.BaseModuleName()+"-install")) } diff --git a/java/ravenwood_test.go b/java/ravenwood_test.go index d26db930d..753a118e9 100644 --- a/java/ravenwood_test.go +++ b/java/ravenwood_test.go @@ -19,6 +19,7 @@ import ( "testing" "android/soong/android" + "android/soong/etc" ) var prepareRavenwoodRuntime = android.GroupFixturePreparers( @@ -59,11 +60,19 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers( } android_app { name: "app1", - sdk_version: "current", + sdk_version: "current", } android_app { name: "app2", - sdk_version: "current", + sdk_version: "current", + } + android_app { + name: "app3", + sdk_version: "current", + } + prebuilt_font { + name: "Font.ttf", + src: "Font.ttf", } android_ravenwood_libgroup { name: "ravenwood-runtime", @@ -76,7 +85,10 @@ var prepareRavenwoodRuntime = android.GroupFixturePreparers( "ravenwood-runtime-jni2", ], data: [ - "app1", + ":app1", + ], + fonts: [ + ":Font.ttf" ], } android_ravenwood_libgroup { @@ -97,6 +109,7 @@ func TestRavenwoodRuntime(t *testing.T) { ctx := android.GroupFixturePreparers( PrepareForIntegrationTestWithJava, + etc.PrepareForTestWithPrebuiltEtc, prepareRavenwoodRuntime, ).RunTest(t) @@ -114,6 +127,7 @@ func TestRavenwoodRuntime(t *testing.T) { runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/libred.so") runtime.Output(installPathPrefix + "/ravenwood-runtime/lib64/ravenwood-runtime-jni3.so") runtime.Output(installPathPrefix + "/ravenwood-runtime/ravenwood-data/app1.apk") + runtime.Output(installPathPrefix + "/ravenwood-runtime/fonts/Font.ttf") utils := ctx.ModuleForTests("ravenwood-utils", "android_common") utils.Output(installPathPrefix + "/ravenwood-utils/framework-rules.ravenwood.jar") } @@ -125,29 +139,30 @@ func TestRavenwoodTest(t *testing.T) { ctx := android.GroupFixturePreparers( PrepareForIntegrationTestWithJava, + etc.PrepareForTestWithPrebuiltEtc, prepareRavenwoodRuntime, ).RunTestWithBp(t, ` - cc_library_shared { - name: "jni-lib1", - host_supported: true, - srcs: ["jni.cpp"], - } - cc_library_shared { - name: "jni-lib2", - host_supported: true, - srcs: ["jni.cpp"], - stem: "libblue", - shared_libs: [ - "jni-lib3", - ], - } - cc_library_shared { - name: "jni-lib3", - host_supported: true, - srcs: ["jni.cpp"], - stem: "libpink", - } - android_ravenwood_test { + cc_library_shared { + name: "jni-lib1", + host_supported: true, + srcs: ["jni.cpp"], + } + cc_library_shared { + name: "jni-lib2", + host_supported: true, + srcs: ["jni.cpp"], + stem: "libblue", + shared_libs: [ + "jni-lib3", + ], + } + cc_library_shared { + name: "jni-lib3", + host_supported: true, + srcs: ["jni.cpp"], + stem: "libpink", + } + android_ravenwood_test { name: "ravenwood-test", srcs: ["Test.java"], jni_libs: [ @@ -156,6 +171,7 @@ func TestRavenwoodTest(t *testing.T) { "ravenwood-runtime-jni2", ], resource_apk: "app2", + inst_resource_apk: "app3", sdk_version: "test_current", } `) @@ -183,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() { diff --git a/java/sdk_library.go b/java/sdk_library.go index b7aa4e56d..9f0564a9c 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -248,7 +248,7 @@ func (scope *apiScope) apiLibraryModuleName(baseName string) string { return scope.stubsLibraryModuleName(baseName) + ".from-text" } -func (scope *apiScope) sourceStubLibraryModuleName(baseName string) string { +func (scope *apiScope) sourceStubsLibraryModuleName(baseName string) string { return scope.stubsLibraryModuleName(baseName) + ".from-source" } @@ -830,16 +830,6 @@ func (paths *scopePaths) extractLatestRemovedApiPath(ctx android.ModuleContext, } type commonToSdkLibraryAndImportProperties struct { - // The naming scheme to use for the components that this module creates. - // - // If not specified then it defaults to "default". - // - // This is a temporary mechanism to simplify conversion from separate modules for each - // component that follow a different naming pattern to the default one. - // - // TODO(b/155480189) - Remove once naming inconsistencies have been resolved. - Naming_scheme *string - // Specifies whether this module can be used as an Android shared library; defaults // to true. // @@ -915,8 +905,6 @@ type commonToSdkLibraryAndImport struct { scopePaths map[*apiScope]*scopePaths - namingScheme sdkLibraryComponentNamingScheme - commonSdkLibraryProperties commonToSdkLibraryAndImportProperties // Paths to commonSdkLibraryProperties.Doctag_files @@ -944,15 +932,6 @@ func (c *commonToSdkLibraryAndImport) initCommon(module commonSdkLibraryAndImpor } func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android.DefaultableHookContext) bool { - schemeProperty := proptools.StringDefault(c.commonSdkLibraryProperties.Naming_scheme, "default") - switch schemeProperty { - case "default": - c.namingScheme = &defaultNamingScheme{} - default: - ctx.PropertyErrorf("naming_scheme", "expected 'default' but was %q", schemeProperty) - return false - } - namePtr := proptools.StringPtr(c.module.RootLibraryName()) c.sdkLibraryComponentProperties.SdkLibraryName = namePtr @@ -995,41 +974,41 @@ func (c *commonToSdkLibraryAndImport) xmlPermissionsModuleName() string { // Name of the java_library module that compiles the stubs source. func (c *commonToSdkLibraryAndImport) stubsLibraryModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.stubsLibraryModuleName(apiScope, baseName) + return apiScope.stubsLibraryModuleName(baseName) } // Name of the java_library module that compiles the exportable stubs source. func (c *commonToSdkLibraryAndImport) exportableStubsLibraryModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.exportableStubsLibraryModuleName(apiScope, baseName) + return apiScope.exportableStubsLibraryModuleName(baseName) } // Name of the droidstubs module that generates the stubs source and may also // generate/check the API. func (c *commonToSdkLibraryAndImport) stubsSourceModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.stubsSourceModuleName(apiScope, baseName) + return apiScope.stubsSourceModuleName(baseName) } // Name of the java_api_library module that generates the from-text stubs source // and compiles to a jar file. func (c *commonToSdkLibraryAndImport) apiLibraryModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.apiLibraryModuleName(apiScope, baseName) + return apiScope.apiLibraryModuleName(baseName) } // Name of the java_library module that compiles the stubs // generated from source Java files. func (c *commonToSdkLibraryAndImport) sourceStubsLibraryModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.sourceStubsLibraryModuleName(apiScope, baseName) + return apiScope.sourceStubsLibraryModuleName(baseName) } // Name of the java_library module that compiles the exportable stubs // generated from source Java files. func (c *commonToSdkLibraryAndImport) exportableSourceStubsLibraryModuleName(apiScope *apiScope) string { baseName := c.module.RootLibraryName() - return c.namingScheme.exportableSourceStubsLibraryModuleName(apiScope, baseName) + return apiScope.exportableSourceStubsLibraryModuleName(baseName) } // The component names for different outputs of the java_sdk_library. @@ -1748,6 +1727,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) staticLibs.AppendSimpleValue(module.sdkLibraryProperties.Impl_only_static_libs) props := struct { Name *string + Enabled proptools.Configurable[bool] Visibility []string Libs []string Static_libs proptools.Configurable[[]string] @@ -1755,6 +1735,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) Stem *string }{ Name: proptools.StringPtr(module.implLibraryModuleName()), + Enabled: module.EnabledProperty(), Visibility: visibility, Libs: append(module.properties.Libs, module.sdkLibraryProperties.Impl_only_libs...), @@ -1783,6 +1764,7 @@ func (module *SdkLibrary) createImplLibrary(mctx android.DefaultableHookContext) type libraryProperties struct { Name *string + Enabled proptools.Configurable[bool] Visibility []string Srcs []string Installable *bool @@ -1809,6 +1791,7 @@ type libraryProperties struct { func (module *SdkLibrary) stubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope) libraryProperties { props := libraryProperties{} + props.Enabled = module.EnabledProperty() props.Visibility = []string{"//visibility:override", "//visibility:private"} // sources are generated from the droiddoc sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope) @@ -1859,6 +1842,7 @@ func (module *SdkLibrary) createExportableStubsLibrary(mctx android.DefaultableH func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookContext, apiScope *apiScope, name string, scopeSpecificDroidstubsArgs []string) { props := struct { Name *string + Enabled proptools.Configurable[bool] Visibility []string Srcs []string Installable *bool @@ -1900,6 +1884,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC // * libs (static_libs/libs) props.Name = proptools.StringPtr(name) + props.Enabled = module.EnabledProperty() props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_source_visibility) props.Srcs = append(props.Srcs, module.properties.Srcs...) props.Srcs = append(props.Srcs, module.sdkLibraryProperties.Api_srcs...) @@ -2025,6 +2010,7 @@ func (module *SdkLibrary) createStubsSourcesAndApi(mctx android.DefaultableHookC func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, apiScope *apiScope) { props := struct { Name *string + Enabled proptools.Configurable[bool] Visibility []string Api_contributions []string Libs proptools.Configurable[[]string] @@ -2037,6 +2023,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, }{} props.Name = proptools.StringPtr(module.apiLibraryModuleName(apiScope)) + props.Enabled = module.EnabledProperty() props.Visibility = []string{"//visibility:override", "//visibility:private"} apiContributions := []string{} @@ -2087,6 +2074,7 @@ func (module *SdkLibrary) createApiLibrary(mctx android.DefaultableHookContext, func (module *SdkLibrary) topLevelStubsLibraryProps(mctx android.DefaultableHookContext, apiScope *apiScope, doDist bool) libraryProperties { props := libraryProperties{} + props.Enabled = module.EnabledProperty() props.Visibility = childModuleVisibility(module.sdkLibraryProperties.Stubs_library_visibility) sdkVersion := module.sdkVersionForStubsLibrary(mctx, apiScope) props.Sdk_version = proptools.StringPtr(sdkVersion) @@ -2179,6 +2167,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { } props := struct { Name *string + Enabled proptools.Configurable[bool] Lib_name *string Apex_available []string On_bootclasspath_since *string @@ -2189,6 +2178,7 @@ func (module *SdkLibrary) createXmlFile(mctx android.DefaultableHookContext) { Uses_libs_dependencies []string }{ Name: proptools.StringPtr(module.xmlPermissionsModuleName()), + Enabled: module.EnabledProperty(), Lib_name: proptools.StringPtr(module.BaseModuleName()), Apex_available: module.ApexProperties.Apex_available, On_bootclasspath_since: module.commonSdkLibraryProperties.On_bootclasspath_since, @@ -2284,11 +2274,6 @@ func (module *SdkLibrary) getApiDir() string { // runtime libs and xml file. If requested, the stubs and docs are created twice // once for public API level and once for system API level func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookContext) { - // If the module has been disabled then don't create any child modules. - if !module.Enabled(mctx) { - return - } - if len(module.properties.Srcs) == 0 { mctx.PropertyErrorf("srcs", "java_sdk_library must specify srcs") return @@ -2395,50 +2380,6 @@ func (module *SdkLibrary) defaultsToStubs() bool { return proptools.Bool(module.sdkLibraryProperties.Default_to_stubs) } -// Defines how to name the individual component modules the sdk library creates. -type sdkLibraryComponentNamingScheme interface { - stubsLibraryModuleName(scope *apiScope, baseName string) string - - stubsSourceModuleName(scope *apiScope, baseName string) string - - apiLibraryModuleName(scope *apiScope, baseName string) string - - sourceStubsLibraryModuleName(scope *apiScope, baseName string) string - - exportableStubsLibraryModuleName(scope *apiScope, baseName string) string - - exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string -} - -type defaultNamingScheme struct { -} - -func (s *defaultNamingScheme) stubsLibraryModuleName(scope *apiScope, baseName string) string { - return scope.stubsLibraryModuleName(baseName) -} - -func (s *defaultNamingScheme) stubsSourceModuleName(scope *apiScope, baseName string) string { - return scope.stubsSourceModuleName(baseName) -} - -func (s *defaultNamingScheme) apiLibraryModuleName(scope *apiScope, baseName string) string { - return scope.apiLibraryModuleName(baseName) -} - -func (s *defaultNamingScheme) sourceStubsLibraryModuleName(scope *apiScope, baseName string) string { - return scope.sourceStubLibraryModuleName(baseName) -} - -func (s *defaultNamingScheme) exportableStubsLibraryModuleName(scope *apiScope, baseName string) string { - return scope.exportableStubsLibraryModuleName(baseName) -} - -func (s *defaultNamingScheme) exportableSourceStubsLibraryModuleName(scope *apiScope, baseName string) string { - return scope.exportableSourceStubsLibraryModuleName(baseName) -} - -var _ sdkLibraryComponentNamingScheme = (*defaultNamingScheme)(nil) - func moduleStubLinkType(j *Module) (stub bool, ret sdkLinkType) { kind := android.ToSdkKind(proptools.String(j.properties.Stub_contributing_api)) switch kind { @@ -3510,7 +3451,6 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe } } - s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary()) s.Compile_dex = sdk.dexProperties.Compile_dex s.Doctag_paths = sdk.doctagPaths diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index bb6331506..31fbc5a58 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -422,7 +422,7 @@ func TestJavaSdkLibrary_StubOrImplOnlyLibs(t *testing.T) { for _, expectation := range expectations { verify("sdklib.impl", expectation.lib, expectation.on_impl_classpath, expectation.in_impl_combined) - stubName := apiScopePublic.sourceStubLibraryModuleName("sdklib") + stubName := apiScopePublic.sourceStubsLibraryModuleName("sdklib") verify(stubName, expectation.lib, expectation.on_stub_classpath, expectation.in_stub_combined) } } |