diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/aar.go | 21 | ||||
| -rwxr-xr-x | java/app.go | 3 | ||||
| -rw-r--r-- | java/app_import.go | 30 | ||||
| -rw-r--r-- | java/app_import_test.go | 73 | ||||
| -rw-r--r-- | java/device_host_converter.go | 12 | ||||
| -rw-r--r-- | java/java.go | 33 | ||||
| -rw-r--r-- | java/proto.go | 13 | ||||
| -rw-r--r-- | java/testing.go | 19 |
8 files changed, 69 insertions, 135 deletions
diff --git a/java/aar.go b/java/aar.go index 47e6efae3..f1b137de1 100644 --- a/java/aar.go +++ b/java/aar.go @@ -1015,9 +1015,10 @@ type bazelAndroidLibrary struct { } type bazelAndroidLibraryImport struct { - Aar bazel.Label - Deps bazel.LabelListAttribute - Exports bazel.LabelListAttribute + Aar bazel.Label + Deps bazel.LabelListAttribute + Exports bazel.LabelListAttribute + Sdk_version bazel.StringAttribute } func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.TopDownMutatorContext) *bazelAapt { @@ -1059,9 +1060,10 @@ func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) { }, android.CommonAttributes{Name: name}, &bazelAndroidLibraryImport{ - Aar: aars.Includes[0], - Deps: bazel.MakeLabelListAttribute(deps), - Exports: bazel.MakeLabelListAttribute(exports), + Aar: aars.Includes[0], + Deps: bazel.MakeLabelListAttribute(deps), + Exports: bazel.MakeLabelListAttribute(exports), + Sdk_version: bazel.StringAttribute{Value: a.properties.Sdk_version}, }, ) @@ -1073,6 +1075,9 @@ func (a *AARImport) ConvertWithBp2build(ctx android.TopDownMutatorContext) { javaLibraryAttributes: &javaLibraryAttributes{ Neverlink: bazel.BoolAttribute{Value: &neverlink}, Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), + javaCommonAttributes: &javaCommonAttributes{ + Sdk_version: bazel.StringAttribute{Value: a.properties.Sdk_version}, + }, }, }, ) @@ -1119,6 +1124,10 @@ func (a *AndroidLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) javaLibraryAttributes: &javaLibraryAttributes{ Neverlink: bazel.BoolAttribute{Value: &neverlink}, Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), + javaCommonAttributes: &javaCommonAttributes{ + Sdk_version: bazel.StringAttribute{Value: a.deviceProperties.Sdk_version}, + Java_version: bazel.StringAttribute{Value: a.properties.Java_version}, + }, }, }, ) diff --git a/java/app.go b/java/app.go index 52caf6d38..03e233059 100755 --- a/java/app.go +++ b/java/app.go @@ -1565,6 +1565,9 @@ func (a *AndroidApp) ConvertWithBp2build(ctx android.TopDownMutatorContext) { appAttrs.bazelAapt = &bazelAapt{Manifest: aapt.Manifest} appAttrs.Deps = bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + ktName}) + appAttrs.javaCommonAttributes = &javaCommonAttributes{ + Sdk_version: commonAttrs.Sdk_version, + } } ctx.CreateBazelTargetModule( diff --git a/java/app_import.go b/java/app_import.go index c1de66745..85b35ebaa 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -17,9 +17,10 @@ package java // This file contains the module implementations for android_app_import and android_test_import. import ( - "github.com/google/blueprint" "reflect" + "github.com/google/blueprint" + "github.com/google/blueprint/proptools" "android/soong/android" @@ -177,10 +178,6 @@ func MergePropertiesFromVariant(ctx android.EarlyModuleContext, } } -func (a *AndroidAppImport) isPrebuiltFrameworkRes() bool { - return a.Name() == "prebuilt_framework-res" -} - func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) { cert := android.SrcIsModule(String(a.properties.Certificate)) if cert != "" { @@ -197,7 +194,7 @@ func (a *AndroidAppImport) DepsMutator(ctx android.BottomUpMutatorContext) { } } - a.usesLibrary.deps(ctx, !a.isPrebuiltFrameworkRes()) + a.usesLibrary.deps(ctx, true) } func (a *AndroidAppImport) uncompressEmbeddedJniLibs( @@ -243,6 +240,10 @@ func (a *AndroidAppImport) InstallApkName() string { } func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext) { + if a.Name() == "prebuilt_framework-res" { + ctx.ModuleErrorf("prebuilt_framework-res found. This used to have special handling in soong, but was removed due to prebuilt_framework-res no longer existing. This check is to ensure it doesn't come back without readding the special handling.") + } + apexInfo := ctx.Provider(android.ApexInfoProvider).(android.ApexInfo) if !apexInfo.IsForPlatform() { a.hideApexVariantFromMake = true @@ -278,14 +279,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext var pathFragments []string relInstallPath := String(a.properties.Relative_install_path) - if a.isPrebuiltFrameworkRes() { - // framework-res.apk is installed as system/framework/framework-res.apk - if relInstallPath != "" { - ctx.PropertyErrorf("relative_install_path", "Relative_install_path cannot be set for framework-res") - } - pathFragments = []string{"framework"} - a.preprocessed = true - } else if Bool(a.properties.Privileged) { + if Bool(a.properties.Privileged) { pathFragments = []string{"priv-app", relInstallPath, a.BaseModuleName()} } else if ctx.InstallInTestcases() { pathFragments = []string{relInstallPath, a.BaseModuleName(), ctx.DeviceConfig().DeviceArch()} @@ -323,13 +317,7 @@ func (a *AndroidAppImport) generateAndroidBuildActions(ctx android.ModuleContext // Sign or align the package if package has not been preprocessed - if a.isPrebuiltFrameworkRes() { - a.outputFile = srcApk - a.certificate, certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx) - if len(certificates) != 1 { - ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates) - } - } else if a.preprocessed { + if a.preprocessed { a.outputFile = srcApk a.certificate = PresignedCertificate } else if !Bool(a.properties.Presigned) { diff --git a/java/app_import_test.go b/java/app_import_test.go index 528fffe94..80930248e 100644 --- a/java/app_import_test.go +++ b/java/app_import_test.go @@ -505,67 +505,6 @@ func TestAndroidAppImport_overridesDisabledAndroidApp(t *testing.T) { } } -func TestAndroidAppImport_frameworkRes(t *testing.T) { - ctx, _ := testJava(t, ` - android_app_import { - name: "framework-res", - certificate: "platform", - apk: "package-res.apk", - prefer: true, - export_package_resources: true, - // Disable dexpreopt and verify_uses_libraries check as the app - // contains no Java code to be dexpreopted. - enforce_uses_libs: false, - dex_preopt: { - enabled: false, - }, - } - `) - - mod := ctx.ModuleForTests("prebuilt_framework-res", "android_common").Module() - a := mod.(*AndroidAppImport) - - if !a.preprocessed { - t.Errorf("prebuilt framework-res is not preprocessed") - } - - expectedInstallPath := "out/soong/target/product/test_device/system/framework/framework-res.apk" - - android.AssertPathRelativeToTopEquals(t, "prebuilt framework-res install location", expectedInstallPath, a.dexpreopter.installPath) - - entries := android.AndroidMkEntriesForTest(t, ctx, mod)[0] - - expectedPath := "." - // From apk property above, in the root of the source tree. - expectedPrebuiltModuleFile := "package-res.apk" - // Verify that the apk is preprocessed: The export package is the same - // as the prebuilt. - expectedSoongResourceExportPackage := expectedPrebuiltModuleFile - - actualPath := entries.EntryMap["LOCAL_PATH"] - actualPrebuiltModuleFile := entries.EntryMap["LOCAL_PREBUILT_MODULE_FILE"] - actualSoongResourceExportPackage := entries.EntryMap["LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE"] - - if len(actualPath) != 1 { - t.Errorf("LOCAL_PATH incorrect len %d", len(actualPath)) - } else if actualPath[0] != expectedPath { - t.Errorf("LOCAL_PATH mismatch, actual: %s, expected: %s", actualPath[0], expectedPath) - } - - if len(actualPrebuiltModuleFile) != 1 { - t.Errorf("LOCAL_PREBUILT_MODULE_FILE incorrect len %d", len(actualPrebuiltModuleFile)) - } else if actualPrebuiltModuleFile[0] != expectedPrebuiltModuleFile { - t.Errorf("LOCAL_PREBUILT_MODULE_FILE mismatch, actual: %s, expected: %s", actualPrebuiltModuleFile[0], expectedPrebuiltModuleFile) - } - - if len(actualSoongResourceExportPackage) != 1 { - t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE incorrect len %d", len(actualSoongResourceExportPackage)) - } else if actualSoongResourceExportPackage[0] != expectedSoongResourceExportPackage { - t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE mismatch, actual: %s, expected: %s", actualSoongResourceExportPackage[0], expectedSoongResourceExportPackage) - } - android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "android_app_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0]) -} - func TestAndroidAppImport_relativeInstallPath(t *testing.T) { bp := ` android_app_import { @@ -582,13 +521,6 @@ func TestAndroidAppImport_relativeInstallPath(t *testing.T) { } android_app_import { - name: "framework-res", - apk: "prebuilts/apk/app.apk", - presigned: true, - prefer: true, - } - - android_app_import { name: "privileged_relative_install_path", apk: "prebuilts/apk/app.apk", presigned: true, @@ -612,11 +544,6 @@ func TestAndroidAppImport_relativeInstallPath(t *testing.T) { errorMessage: "Install path is not correct for app when relative_install_path is present", }, { - name: "prebuilt_framework-res", - expectedInstallPath: "out/soong/target/product/test_device/system/framework/framework-res.apk", - errorMessage: "Install path is not correct for framework-res", - }, - { name: "privileged_relative_install_path", expectedInstallPath: "out/soong/target/product/test_device/system/priv-app/my/path/privileged_relative_install_path/privileged_relative_install_path.apk", errorMessage: "Install path is not correct for privileged app when relative_install_path is present", diff --git a/java/device_host_converter.go b/java/device_host_converter.go index 656c866ed..3581040f8 100644 --- a/java/device_host_converter.go +++ b/java/device_host_converter.go @@ -21,6 +21,8 @@ import ( "android/soong/android" "android/soong/bazel" "android/soong/dexpreopt" + + "github.com/google/blueprint/proptools" ) type DeviceHostConverter struct { @@ -191,7 +193,7 @@ func (d *DeviceHostConverter) AndroidMk() android.AndroidMkData { } type bazelDeviceHostConverterAttributes struct { - Deps bazel.LabelListAttribute + Exports bazel.LabelListAttribute } func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorContext) { @@ -202,13 +204,15 @@ func (d *DeviceHostConverter) ConvertWithBp2build(ctx android.TopDownMutatorCont }, android.CommonAttributes{Name: d.Name()}, &bazelDeviceHostConverterAttributes{ - Deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, d.properties.Libs)), + Exports: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, d.properties.Libs)), }, ) - neverlinkProp := true neverLinkAttrs := &javaLibraryAttributes{ Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + d.Name()}), - Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, + Neverlink: bazel.BoolAttribute{Value: proptools.BoolPtr(true)}, + javaCommonAttributes: &javaCommonAttributes{ + Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")}, + }, } ctx.CreateBazelTargetModule( javaLibraryBazelTargetModuleProperties(), diff --git a/java/java.go b/java/java.go index d400b0cfb..2de4ea97e 100644 --- a/java/java.go +++ b/java/java.go @@ -2740,9 +2740,11 @@ func (m *Library) convertJavaResourcesAttributes(ctx android.TopDownMutatorConte type javaCommonAttributes struct { *javaResourcesAttributes *kotlinAttributes - Srcs bazel.LabelListAttribute - Plugins bazel.LabelListAttribute - Javacopts bazel.StringListAttribute + Srcs bazel.LabelListAttribute + Plugins bazel.LabelListAttribute + Javacopts bazel.StringListAttribute + Sdk_version bazel.StringAttribute + Java_version bazel.StringAttribute } type javaDependencyLabels struct { @@ -2873,10 +2875,6 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) if m.properties.Javacflags != nil { javacopts = append(javacopts, m.properties.Javacflags...) } - if m.properties.Java_version != nil { - javaVersion := normalizeJavaVersion(ctx, *m.properties.Java_version).String() - javacopts = append(javacopts, fmt.Sprintf("-source %s -target %s", javaVersion, javaVersion)) - } epEnabled := m.properties.Errorprone.Enabled //TODO(b/227504307) add configuration that depends on RUN_ERROR_PRONE environment variable @@ -2890,7 +2888,9 @@ func (m *Library) convertLibraryAttrsBp2Build(ctx android.TopDownMutatorContext) Plugins: bazel.MakeLabelListAttribute( android.BazelLabelForModuleDeps(ctx, m.properties.Plugins), ), - Javacopts: bazel.MakeStringListAttribute(javacopts), + Javacopts: bazel.MakeStringListAttribute(javacopts), + Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, + Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, } for axis, configToProps := range archVariantProps { @@ -2981,19 +2981,9 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { deps := depLabels.Deps if !commonAttrs.Srcs.IsEmpty() { deps.Append(depLabels.StaticDeps) // we should only append these if there are sources to use them - - sdkVersion := m.SdkVersion(ctx) - if sdkVersion.Kind == android.SdkPublic && sdkVersion.ApiLevel == android.FutureApiLevel { - // TODO(b/220869005) remove forced dependency on current public android.jar - deps.Add(bazel.MakeLabelAttribute("//prebuilts/sdk:public_current_android_sdk_java_import")) - } else if sdkVersion.Kind == android.SdkSystem && sdkVersion.ApiLevel == android.FutureApiLevel { - // TODO(b/215230098) remove forced dependency on current public android.jar - deps.Add(bazel.MakeLabelAttribute("//prebuilts/sdk:system_current_android_sdk_java_import")) - } } else if !deps.IsEmpty() { ctx.ModuleErrorf("Module has direct dependencies but no sources. Bazel will not allow this.") } - var props bazel.BazelTargetModuleProperties attrs := &javaLibraryAttributes{ javaCommonAttributes: commonAttrs, @@ -3013,6 +3003,10 @@ func javaLibraryBp2Build(ctx android.TopDownMutatorContext, m *Library) { neverLinkAttrs := &javaLibraryAttributes{ Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), Neverlink: bazel.BoolAttribute{Value: &neverlinkProp}, + javaCommonAttributes: &javaCommonAttributes{ + Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, + Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, + }, } ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name + "-neverlink"}, neverLinkAttrs) @@ -3152,6 +3146,9 @@ func (i *Import) ConvertWithBp2build(ctx android.TopDownMutatorContext) { neverlinkAttrs := &javaLibraryAttributes{ Neverlink: bazel.BoolAttribute{Value: &neverlink}, Exports: bazel.MakeSingleLabelListAttribute(bazel.Label{Label: ":" + name}), + javaCommonAttributes: &javaCommonAttributes{ + Sdk_version: bazel.StringAttribute{Value: proptools.StringPtr("none")}, + }, } ctx.CreateBazelTargetModule( javaLibraryBazelTargetModuleProperties(), diff --git a/java/proto.go b/java/proto.go index 5280077f1..c732d9842 100644 --- a/java/proto.go +++ b/java/proto.go @@ -143,7 +143,9 @@ func protoFlags(ctx android.ModuleContext, j *CommonProperties, p *android.Proto } type protoAttributes struct { - Deps bazel.LabelListAttribute + Deps bazel.LabelListAttribute + Sdk_version bazel.StringAttribute + Java_version bazel.StringAttribute } func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs bazel.LabelListAttribute) *bazel.Label { @@ -175,8 +177,11 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze } protoLabel := bazel.Label{Label: ":" + m.Name() + "_proto"} - var protoAttrs protoAttributes - protoAttrs.Deps.SetValue(bazel.LabelList{Includes: []bazel.Label{protoLabel}}) + protoAttrs := &protoAttributes{ + Deps: bazel.MakeSingleLabelListAttribute(protoLabel), + Java_version: bazel.StringAttribute{Value: m.properties.Java_version}, + Sdk_version: bazel.StringAttribute{Value: m.deviceProperties.Sdk_version}, + } name := m.Name() + suffix @@ -186,7 +191,7 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze Bzl_load_location: "//build/bazel/rules/java:proto.bzl", }, android.CommonAttributes{Name: name}, - &protoAttrs) + protoAttrs) return &bazel.Label{Label: ":" + name} } diff --git a/java/testing.go b/java/testing.go index 0764d264a..f68e12ff4 100644 --- a/java/testing.go +++ b/java/testing.go @@ -389,15 +389,16 @@ func gatherRequiredDepsForTest() string { } extraApiLibraryModules := map[string]string{ - "android_stubs_current.from-text": "api/current.txt", - "android_system_stubs_current.from-text": "api/system-current.txt", - "android_test_stubs_current.from-text": "api/test-current.txt", - "android_module_lib_stubs_current.from-text": "api/module-lib-current.txt", - "android_system_server_stubs_current.from-text": "api/system-server-current.txt", - "core.current.stubs.from-text": "api/current.txt", - "legacy.core.platform.api.stubs.from-text": "api/current.txt", - "stable.core.platform.api.stubs.from-text": "api/current.txt", - "core-lambda-stubs.from-text": "api/current.txt", + "android_stubs_current.from-text": "api/current.txt", + "android_system_stubs_current.from-text": "api/system-current.txt", + "android_test_stubs_current.from-text": "api/test-current.txt", + "android_module_lib_stubs_current.from-text": "api/module-lib-current.txt", + "android_module_lib_stubs_current_full.from-text": "api/module-lib-current.txt", + "android_system_server_stubs_current.from-text": "api/system-server-current.txt", + "core.current.stubs.from-text": "api/current.txt", + "legacy.core.platform.api.stubs.from-text": "api/current.txt", + "stable.core.platform.api.stubs.from-text": "api/current.txt", + "core-lambda-stubs.from-text": "api/current.txt", } for libName, apiFile := range extraApiLibraryModules { |