diff options
Diffstat (limited to 'java')
-rw-r--r-- | java/aar.go | 2 | ||||
-rw-r--r-- | java/androidmk.go | 25 | ||||
-rwxr-xr-x | java/app.go | 81 | ||||
-rw-r--r-- | java/app_test.go | 4 | ||||
-rw-r--r-- | java/builder.go | 9 | ||||
-rw-r--r-- | java/device_host_converter.go | 2 | ||||
-rw-r--r-- | java/dexpreopt.go | 2 | ||||
-rw-r--r-- | java/dexpreopt_bootjars.go | 4 | ||||
-rw-r--r-- | java/droiddoc.go | 7 | ||||
-rw-r--r-- | java/hiddenapi_singleton.go | 2 | ||||
-rw-r--r-- | java/java.go | 80 | ||||
-rw-r--r-- | java/sdk.go | 49 | ||||
-rw-r--r-- | java/sdk_library.go | 22 | ||||
-rw-r--r-- | java/sdk_test.go | 2 |
14 files changed, 188 insertions, 103 deletions
diff --git a/java/aar.go b/java/aar.go index c8daf835b..7413c8082 100644 --- a/java/aar.go +++ b/java/aar.go @@ -730,7 +730,7 @@ func (a *AARImport) ImplementationAndResourcesJars() android.Paths { return android.Paths{a.classpathFile} } -func (a *AARImport) DexJar() android.Path { +func (a *AARImport) DexJarBuildPath() android.Path { return nil } diff --git a/java/androidmk.go b/java/androidmk.go index 6eb22fd93..62cf169fa 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -69,7 +69,26 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { if !library.ApexModuleBase.AvailableFor(android.AvailableToPlatform) { hideFromMake = true } - if !hideFromMake { + if hideFromMake { + // May still need to add some additional dependencies. This will be called + // once for the platform variant (even if it is not being used) and once each + // for the APEX specific variants. In order to avoid adding the dependency + // multiple times only add it for the platform variant. + checkedModulePaths := library.additionalCheckedModules + if library.IsForPlatform() && len(checkedModulePaths) != 0 { + mainEntries = android.AndroidMkEntries{ + Class: "FAKE", + // Need at least one output file in order for this to take effect. + OutputFile: android.OptionalPathForPath(checkedModulePaths[0]), + Include: "$(BUILD_PHONY_PACKAGE)", + ExtraEntries: []android.AndroidMkExtraEntriesFunc{ + func(entries *android.AndroidMkEntries) { + entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", checkedModulePaths.Strings()...) + }, + }, + } + } + } else { mainEntries = android.AndroidMkEntries{ Class: "JAVA_LIBRARIES", DistFile: android.OptionalPathForPath(library.distFile), @@ -104,6 +123,10 @@ func (library *Library) AndroidMkEntries() []android.AndroidMkEntries { entries.AddStrings("LOCAL_EXPORT_SDK_LIBRARIES", library.exportedSdkLibs...) + if len(library.additionalCheckedModules) != 0 { + entries.AddStrings("LOCAL_ADDITIONAL_CHECKED_MODULE", library.additionalCheckedModules.Strings()...) + } + if library.proguardDictionary != nil { entries.SetPath("LOCAL_SOONG_PROGUARD_DICT", library.proguardDictionary) } diff --git a/java/app.go b/java/app.go index a45ab6f99..24dde79f4 100755 --- a/java/app.go +++ b/java/app.go @@ -28,6 +28,7 @@ import ( "android/soong/android" "android/soong/cc" + "android/soong/dexpreopt" "android/soong/tradefed" ) @@ -96,6 +97,14 @@ func (as *AndroidAppSet) Privileged() bool { return Bool(as.properties.Privileged) } +func (as *AndroidAppSet) OutputFile() android.Path { + return as.packedOutput +} + +func (as *AndroidAppSet) MasterFile() string { + return as.masterFile +} + var TargetCpuAbi = map[string]string{ "arm": "ARMEABI_V7A", "arm64": "ARM64_V8A", @@ -120,7 +129,7 @@ func SupportedAbis(ctx android.ModuleContext) []string { } func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) { - as.packedOutput = android.PathForModuleOut(ctx, "extracted.zip") + as.packedOutput = android.PathForModuleOut(ctx, ctx.ModuleName()+".zip") // We are assuming here that the master file in the APK // set has `.apk` suffix. If it doesn't the build will fail. // APK sets containing APEX files are handled elsewhere. @@ -145,26 +154,17 @@ func (as *AndroidAppSet) GenerateAndroidBuildActions(ctx android.ModuleContext) "stem": ctx.ModuleName(), }, }) - // TODO(asmundak): add this (it's wrong now, will cause copying extracted.zip) - /* - var installDir android.InstallPath - if Bool(as.properties.Privileged) { - installDir = android.PathForModuleInstall(ctx, "priv-app", as.BaseModuleName()) - } else if ctx.InstallInTestcases() { - installDir = android.PathForModuleInstall(ctx, as.BaseModuleName(), ctx.DeviceConfig().DeviceArch()) - } else { - installDir = android.PathForModuleInstall(ctx, "app", as.BaseModuleName()) - } - ctx.InstallFile(installDir, as.masterFile", as.packedOutput) - */ } // android_app_set extracts a set of APKs based on the target device // configuration and installs this set as "split APKs". -// The set will always contain `base-master.apk` and every APK built -// to the target device. All density-specific APK will be included, too, -// unless PRODUCT_APPT_PREBUILT_DPI is defined (should contain comma-sepearated -// list of density names (LDPI, MDPI, HDPI, etc.) +// The extracted set always contains 'master' APK whose name is +// _module_name_.apk and every split APK matching target device. +// The extraction of the density-specific splits depends on +// PRODUCT_AAPT_PREBUILT_DPI variable. If present (its value should +// be a list density names: LDPI, MDPI, HDPI, etc.), only listed +// splits will be extracted. Otherwise all density-specific splits +// will be extracted. func AndroidApkSetFactory() android.Module { module := &AndroidAppSet{} module.AddProperties(&module.properties) @@ -335,7 +335,7 @@ type Certificate struct { presigned bool } -var presignedCertificate = Certificate{presigned: true} +var PresignedCertificate = Certificate{presigned: true} func (c Certificate) AndroidMkString() string { if c.presigned { @@ -445,8 +445,11 @@ func (a *AndroidApp) checkJniLibsSdkVersion(ctx android.ModuleContext, minSdkVer return } dep, _ := m.(*cc.Module) - jniSdkVersion, err := android.ApiStrToNum(ctx, dep.SdkVersion()) - if err != nil || int(minSdkVersion) < jniSdkVersion { + // The domain of cc.sdk_version is "current" and <number> + // We can rely on sdkSpec to convert it to <number> so that "current" is handled + // properly regardless of sdk finalization. + jniSdkVersion, err := sdkSpecFrom(dep.SdkVersion()).effectiveVersion(ctx) + if err != nil || minSdkVersion < jniSdkVersion { ctx.OtherModuleErrorf(dep, "sdk_version(%v) is higher than min_sdk_version(%v) of the containing android_app(%v)", dep.SdkVersion(), minSdkVersion, ctx.ModuleName()) return @@ -1186,7 +1189,7 @@ type OverrideAndroidApp struct { android.OverrideModuleBase } -func (i *OverrideAndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) { +func (i *OverrideAndroidApp) GenerateAndroidBuildActions(_ android.ModuleContext) { // All the overrides happen in the base module. // TODO(jungjw): Check the base module type. } @@ -1207,7 +1210,7 @@ type OverrideAndroidTest struct { android.OverrideModuleBase } -func (i *OverrideAndroidTest) GenerateAndroidBuildActions(ctx android.ModuleContext) { +func (i *OverrideAndroidTest) GenerateAndroidBuildActions(_ android.ModuleContext) { // All the overrides happen in the base module. // TODO(jungjw): Check the base module type. } @@ -1229,7 +1232,7 @@ type OverrideRuntimeResourceOverlay struct { android.OverrideModuleBase } -func (i *OverrideRuntimeResourceOverlay) GenerateAndroidBuildActions(ctx android.ModuleContext) { +func (i *OverrideRuntimeResourceOverlay) GenerateAndroidBuildActions(_ android.ModuleContext) { // All the overrides happen in the base module. // TODO(jungjw): Check the base module type. } @@ -1474,7 +1477,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext // Sign or align the package if package has not been preprocessed if a.preprocessed { a.outputFile = srcApk - a.certificate = presignedCertificate + a.certificate = PresignedCertificate } else if !Bool(a.properties.Presigned) { // If the certificate property is empty at this point, default_dev_cert must be set to true. // Which makes processMainCert's behavior for the empty cert string WAI. @@ -1494,7 +1497,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext alignedApk := android.PathForModuleOut(ctx, "zip-aligned", apkFilename) TransformZipAlign(ctx, alignedApk, dexOutput) a.outputFile = alignedApk - a.certificate = presignedCertificate + a.certificate = PresignedCertificate } // TODO: Optionally compress the output apk. @@ -1552,7 +1555,7 @@ func (a *AndroidAppImport) Privileged() bool { return Bool(a.properties.Privileged) } -func (a *AndroidAppImport) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { +func (a *AndroidAppImport) DepIsInSameApex(_ android.BaseModuleContext, _ android.Module) bool { // android_app_import might have extra dependencies via uses_libs property. // Don't track the dependency as we don't automatically add those libraries // to the classpath. It should be explicitly added to java_libs property of APEX @@ -1875,24 +1878,30 @@ func (u *usesLibrary) presentOptionalUsesLibs(ctx android.BaseModuleContext) []s return optionalUsesLibs } -// usesLibraryPaths returns a map of module names of shared library dependencies to the paths to their dex jars. -func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) map[string]android.Path { - usesLibPaths := make(map[string]android.Path) +// usesLibraryPaths returns a map of module names of shared library dependencies to the paths +// to their dex jars on host and on device. +func (u *usesLibrary) usesLibraryPaths(ctx android.ModuleContext) dexpreopt.LibraryPaths { + usesLibPaths := make(dexpreopt.LibraryPaths) if !ctx.Config().UnbundledBuild() { ctx.VisitDirectDepsWithTag(usesLibTag, func(m android.Module) { + dep := ctx.OtherModuleName(m) if lib, ok := m.(Dependency); ok { - if dexJar := lib.DexJar(); dexJar != nil { - usesLibPaths[ctx.OtherModuleName(m)] = dexJar + if dexJar := lib.DexJarBuildPath(); dexJar != nil { + usesLibPaths[dep] = &dexpreopt.LibraryPath{ + dexJar, + // TODO(b/132357300): propagate actual install paths here. + filepath.Join("/system/framework", dep+".jar"), + } } else { - ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must produce a dex jar, does it have installable: true?", - ctx.OtherModuleName(m)) + ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must"+ + " produce a dex jar, does it have installable: true?", dep) } } else if ctx.Config().AllowMissingDependencies() { - ctx.AddMissingDependencies([]string{ctx.OtherModuleName(m)}) + ctx.AddMissingDependencies([]string{dep}) } else { - ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be a java library", - ctx.OtherModuleName(m)) + ctx.ModuleErrorf("module %q in uses_libs or optional_uses_libs must be "+ + "a java library", dep) } }) } diff --git a/java/app_test.go b/java/app_test.go index eb583bea6..eeba161b3 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -149,7 +149,7 @@ func TestAndroidAppSet(t *testing.T) { prerelease: true, }`) module := ctx.ModuleForTests("foo", "android_common") - const packedSplitApks = "extracted.zip" + const packedSplitApks = "foo.zip" params := module.Output(packedSplitApks) if params.Rule == nil { t.Errorf("expected output %s is missing", packedSplitApks) @@ -218,7 +218,7 @@ func TestAndroidAppSet_Variants(t *testing.T) { ctx := testContext() run(t, ctx, config) module := ctx.ModuleForTests("foo", "android_common") - const packedSplitApks = "extracted.zip" + const packedSplitApks = "foo.zip" params := module.Output(packedSplitApks) for k, v := range test.expected { if actual := params.Args[k]; actual != v { diff --git a/java/builder.go b/java/builder.go index 640dba93b..a27e5c390 100644 --- a/java/builder.go +++ b/java/builder.go @@ -206,7 +206,7 @@ var ( blueprint.RuleParams{ Command: "rm -f $out && " + "${config.PackageCheckCmd} $in $packages && " + - "cp $in $out", + "touch $out", CommandDeps: []string{"${config.PackageCheckCmd}"}, }, "packages") @@ -547,9 +547,8 @@ func TransformJarJar(ctx android.ModuleContext, outputFile android.WritablePath, }) } -func CheckJarPackages(ctx android.ModuleContext, classesJar android.Path, permittedPackages []string) android.ModuleOutPath { - outputFile := android.PathForModuleOut(ctx, "package-check", classesJar.Base()) - +func CheckJarPackages(ctx android.ModuleContext, outputFile android.WritablePath, + classesJar android.Path, permittedPackages []string) { ctx.Build(pctx, android.BuildParams{ Rule: packageCheck, Description: "packageCheck", @@ -559,8 +558,6 @@ func CheckJarPackages(ctx android.ModuleContext, classesJar android.Path, permit "packages": strings.Join(permittedPackages, " "), }, }) - - return outputFile } func TransformJetifier(ctx android.ModuleContext, outputFile android.WritablePath, diff --git a/java/device_host_converter.go b/java/device_host_converter.go index b40ab9316..1ffb13f94 100644 --- a/java/device_host_converter.go +++ b/java/device_host_converter.go @@ -150,7 +150,7 @@ func (d *DeviceHostConverter) ImplementationAndResourcesJars() android.Paths { return d.implementationAndResourceJars } -func (d *DeviceHostConverter) DexJar() android.Path { +func (d *DeviceHostConverter) DexJarBuildPath() android.Path { return nil } diff --git a/java/dexpreopt.go b/java/dexpreopt.go index 4725b0781..2911fd9b9 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -37,7 +37,7 @@ type dexpreopter struct { usesLibs []string optionalUsesLibs []string enforceUsesLibs bool - libraryPaths map[string]android.Path + libraryPaths dexpreopt.LibraryPaths builtInstalled string } diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index ed61d4bd3..9d9383814 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -255,7 +255,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul return -1, nil } - jar, hasJar := module.(interface{ DexJar() android.Path }) + jar, hasJar := module.(interface{ DexJarBuildPath() android.Path }) if !hasJar { return -1, nil } @@ -296,7 +296,7 @@ func getBootImageJar(ctx android.SingletonContext, image *bootImageConfig, modul panic("unknown boot image: " + image.name) } - return index, jar.DexJar() + return index, jar.DexJarBuildPath() } // buildBootImage takes a bootImageConfig, creates rules to build it, and returns the image. diff --git a/java/droiddoc.go b/java/droiddoc.go index b16c9cd72..d61c62c60 100644 --- a/java/droiddoc.go +++ b/java/droiddoc.go @@ -1334,13 +1334,10 @@ func (d *Droidstubs) annotationsFlags(ctx android.ModuleContext, cmd *android.Ru d.annotationsZip = android.PathForModuleOut(ctx, ctx.ModuleName()+"_annotations.zip") cmd.FlagWithOutput("--extract-annotations ", d.annotationsZip) - if len(d.properties.Merge_annotations_dirs) == 0 { - ctx.PropertyErrorf("merge_annotations_dirs", - "has to be non-empty if annotations was enabled!") + if len(d.properties.Merge_annotations_dirs) != 0 { + d.mergeAnnoDirFlags(ctx, cmd) } - d.mergeAnnoDirFlags(ctx, cmd) - // TODO(tnorbye): find owners to fix these warnings when annotation was enabled. cmd.FlagWithArg("--hide ", "HiddenTypedefConstant"). FlagWithArg("--hide ", "SuperfluousPrefix"). diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index c7f7cbdfe..2f35798b5 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -147,7 +147,7 @@ func stubFlagsRule(ctx android.SingletonContext) { name := ctx.ModuleName(module) for moduleList, pathList := range moduleListToPathList { if i := android.IndexList(name, *moduleList); i != -1 { - pathList[i] = j.DexJar() + pathList[i] = j.DexJarBuildPath() } } } diff --git a/java/java.go b/java/java.go index 09df2ad43..0ba1f5a7a 100644 --- a/java/java.go +++ b/java/java.go @@ -463,6 +463,9 @@ type Module struct { // expanded Jarjar_rules expandJarjarRules android.Path + // list of additional targets for checkbuild + additionalCheckedModules android.Paths + // Extra files generated by the module type to be added as java resources. extraResources android.Paths @@ -498,7 +501,7 @@ type Dependency interface { ImplementationJars() android.Paths ResourceJars() android.Paths ImplementationAndResourcesJars() android.Paths - DexJar() android.Path + DexJarBuildPath() android.Path AidlIncludeDirs() android.Paths ExportedSdkLibs() []string ExportedPlugins() (android.Paths, []string) @@ -833,41 +836,46 @@ type linkTypeContext interface { } func (m *Module) getLinkType(name string) (ret linkType, stubs bool) { - ver := m.sdkVersion() - switch { - case name == "core.current.stubs" || name == "core.platform.api.stubs" || - name == "stub-annotations" || name == "private-stub-annotations-jar" || - name == "core-lambda-stubs" || name == "core-generated-annotation-stubs": + switch name { + case "core.current.stubs", "core.platform.api.stubs", "stub-annotations", + "private-stub-annotations-jar", "core-lambda-stubs", "core-generated-annotation-stubs": return javaCore, true - case ver.kind == sdkCore: - return javaCore, false - case name == "android_system_stubs_current": + case "android_stubs_current": + return javaSdk, true + case "android_system_stubs_current": return javaSystem, true - case ver.kind == sdkSystem: - return javaSystem, false - case name == "android_test_stubs_current": + case "android_module_lib_stubs_current": + return javaModule, true + case "android_system_server_stubs_current": + return javaSystemServer, true + case "android_test_stubs_current": return javaSystem, true - case ver.kind == sdkTest: - return javaPlatform, false - case name == "android_stubs_current": - return javaSdk, true - case ver.kind == sdkPublic: + } + + if stub, linkType := moduleStubLinkType(name); stub { + return linkType, true + } + + ver := m.sdkVersion() + switch ver.kind { + case sdkCore: + return javaCore, false + case sdkSystem: + return javaSystem, false + case sdkPublic: return javaSdk, false - case name == "android_module_lib_stubs_current": - return javaModule, true - case ver.kind == sdkModule: + case sdkModule: return javaModule, false - case name == "android_system_server_stubs_current": - return javaSystemServer, true - case ver.kind == sdkSystemServer: + case sdkSystemServer: return javaSystemServer, false - case ver.kind == sdkPrivate || ver.kind == sdkNone || ver.kind == sdkCorePlatform: + case sdkPrivate, sdkNone, sdkCorePlatform, sdkTest: return javaPlatform, false - case !ver.valid(): + } + + if !ver.valid() { panic(fmt.Errorf("sdk_version is invalid. got %q", ver.raw)) - default: - return javaSdk, false } + return javaSdk, false } func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext, tag dependencyTag) { @@ -1518,10 +1526,10 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) { // Check package restrictions if necessary. if len(j.properties.Permitted_packages) > 0 { - // Check packages and copy input to package-checked file. - // Use the file copied after a successful package check as the output file for this - // module so that any dependencies on this module will trigger the package check. - outputFile = CheckJarPackages(ctx, outputFile, j.properties.Permitted_packages) + // Check packages and copy to package-checked file. + pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp") + CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages) + j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile) if ctx.Failed() { return @@ -1736,7 +1744,7 @@ func (j *Module) ImplementationJars() android.Paths { return android.Paths{j.implementationJarFile} } -func (j *Module) DexJar() android.Path { +func (j *Module) DexJarBuildPath() android.Path { return j.dexJarFile } @@ -2562,7 +2570,7 @@ func (j *Import) ImplementationAndResourcesJars() android.Paths { return android.Paths{j.combinedClasspathFile} } -func (j *Import) DexJar() android.Path { +func (j *Import) DexJarBuildPath() android.Path { return nil } @@ -2688,6 +2696,10 @@ func (j *DexImport) Stem() string { return proptools.StringDefault(j.properties.Stem, j.ModuleBase.Name()) } +func (a *DexImport) JacocoReportClassesFile() android.Path { + return nil +} + func (j *DexImport) IsInstallable() bool { return true } @@ -2745,7 +2757,7 @@ func (j *DexImport) GenerateAndroidBuildActions(ctx android.ModuleContext) { j.Stem()+".jar", dexOutputFile) } -func (j *DexImport) DexJar() android.Path { +func (j *DexImport) DexJarBuildPath() android.Path { return j.dexJarFile } diff --git a/java/sdk.go b/java/sdk.go index 9310f7846..2a08f329e 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -35,6 +35,7 @@ func init() { var sdkVersionsKey = android.NewOnceKey("sdkVersionsKey") var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey") +var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey") var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey") type sdkContext interface { @@ -447,7 +448,7 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep return toModule([]string{"core.current.stubs"}, "", nil) case sdkModule: // TODO(146757305): provide .apk and .aidl that have more APIs for modules - return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx)) + return toModule([]string{"android_module_lib_stubs_current"}, "framework-res", nonUpdatableFrameworkAidlPath(ctx)) case sdkSystemServer: // TODO(146757305): provide .apk and .aidl that have more APIs for modules return toModule([]string{"android_system_server_stubs_current"}, "framework-res", sdkFrameworkAidlPath(ctx)) @@ -506,6 +507,7 @@ func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) { } createSdkFrameworkAidl(ctx) + createNonUpdatableFrameworkAidl(ctx) createAPIFingerprint(ctx) } @@ -517,6 +519,31 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { "android_system_stubs_current", } + combinedAidl := sdkFrameworkAidlPath(ctx) + tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") + + rule := createFrameworkAidl(stubsModules, tempPath, ctx) + + commitChangeForRestat(rule, tempPath, combinedAidl) + + rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl") +} + +// Creates a version of framework.aidl for the non-updatable part of the platform. +func createNonUpdatableFrameworkAidl(ctx android.SingletonContext) { + stubsModules := []string{"android_module_lib_stubs_current"} + + combinedAidl := nonUpdatableFrameworkAidlPath(ctx) + tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") + + rule := createFrameworkAidl(stubsModules, tempPath, ctx) + + commitChangeForRestat(rule, tempPath, combinedAidl) + + rule.Build(pctx, ctx, "framework_non_updatable_aidl", "generate framework_non_updatable.aidl") +} + +func createFrameworkAidl(stubsModules []string, path android.OutputPath, ctx android.SingletonContext) *android.RuleBuilder { stubsJars := make([]android.Paths, len(stubsModules)) ctx.VisitAllModules(func(module android.Module) { @@ -536,8 +563,7 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { if ctx.Config().AllowMissingDependencies() { missingDeps = append(missingDeps, stubsModules[i]) } else { - ctx.Errorf("failed to find dex jar path for module %q", - stubsModules[i]) + ctx.Errorf("failed to find dex jar path for module %q", stubsModules[i]) } } } @@ -561,20 +587,15 @@ func createSdkFrameworkAidl(ctx android.SingletonContext) { } } - combinedAidl := sdkFrameworkAidlPath(ctx) - tempPath := combinedAidl.ReplaceExtension(ctx, "aidl.tmp") - rule.Command(). - Text("rm -f").Output(tempPath) + Text("rm -f").Output(path) rule.Command(). Text("cat"). Inputs(aidls). Text("| sort -u >"). - Output(tempPath) + Output(path) - commitChangeForRestat(rule, tempPath, combinedAidl) - - rule.Build(pctx, ctx, "framework_aidl", "generate framework.aidl") + return rule } func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath { @@ -583,6 +604,12 @@ func sdkFrameworkAidlPath(ctx android.PathContext) android.OutputPath { }).(android.OutputPath) } +func nonUpdatableFrameworkAidlPath(ctx android.PathContext) android.OutputPath { + return ctx.Config().Once(nonUpdatableFrameworkAidlPathKey, func() interface{} { + return android.PathForOutput(ctx, "framework_non_updatable.aidl") + }).(android.OutputPath) +} + // Create api_fingerprint.txt func createAPIFingerprint(ctx android.SingletonContext) { out := ApiFingerprintPath(ctx) diff --git a/java/sdk_library.go b/java/sdk_library.go index 67b0bd603..de5ee03c4 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1113,7 +1113,9 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false) props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags - props.Java_version = module.properties.Java_version + // We compile the stubs for 1.8 in line with the main android.jar stubs, and potential + // interop with older developer tools that don't support 1.9. + props.Java_version = proptools.StringPtr("1.8") if module.deviceProperties.Compile_dex != nil { props.Compile_dex = module.deviceProperties.Compile_dex } @@ -1575,6 +1577,24 @@ func (s *frameworkModulesNamingScheme) apiModuleName(scope *apiScope, baseName s var _ sdkLibraryComponentNamingScheme = (*frameworkModulesNamingScheme)(nil) +func moduleStubLinkType(name string) (stub bool, ret linkType) { + // This suffix-based approach is fragile and could potentially mis-trigger. + // TODO(b/155164730): Clean this up when modules no longer reference sdk_lib stubs directly. + if strings.HasSuffix(name, ".stubs.public") || strings.HasSuffix(name, "-stubs-publicapi") { + return true, javaSdk + } + if strings.HasSuffix(name, ".stubs.system") || strings.HasSuffix(name, "-stubs-systemapi") { + return true, javaSystem + } + if strings.HasSuffix(name, ".stubs.module_lib") || strings.HasSuffix(name, "-stubs-module_libs_api") { + return true, javaModule + } + if strings.HasSuffix(name, ".stubs.test") { + return true, javaSystem + } + return false, javaPlatform +} + // java_sdk_library is a special Java library that provides optional platform APIs to apps. // In practice, it can be viewed as a combination of several modules: 1) stubs library that clients // are linked against to, 2) droiddoc module that internally generates API stubs source files, diff --git a/java/sdk_test.go b/java/sdk_test.go index fb8646313..52d2df552 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -252,7 +252,7 @@ func TestClasspath(t *testing.T) { bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"}, system: "core-current-stubs-system-modules", java9classpath: []string{"android_module_lib_stubs_current"}, - aidl: "-p" + buildDir + "/framework.aidl", + aidl: "-p" + buildDir + "/framework_non_updatable.aidl", }, { name: "system_server_current", |