Merge changes from topic "bazel_framework_res" into main am: 641b62b205
am: b0e61183f3
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2720593 Change-Id: I982a8d244d21dba4d09d2e568f03fecf1ac1d508 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
f1a3d7a303
6 changed files with 84 additions and 9 deletions
|
@ -234,6 +234,7 @@ var (
|
|||
"frameworks/av/services/minijail": Bp2BuildDefaultTrueRecursively,
|
||||
"frameworks/base/apex/jobscheduler/service/jni": Bp2BuildDefaultTrueRecursively,
|
||||
"frameworks/base/core/java": Bp2BuildDefaultTrue,
|
||||
"frameworks/base/core/res": Bp2BuildDefaultTrueRecursively,
|
||||
"frameworks/base/libs/androidfw": Bp2BuildDefaultTrue,
|
||||
"frameworks/base/libs/services": Bp2BuildDefaultTrue,
|
||||
"frameworks/base/media/tests/MediaDump": Bp2BuildDefaultTrue,
|
||||
|
@ -476,6 +477,7 @@ var (
|
|||
"external/bazelbuild-rules_go":/* recursive = */ true,
|
||||
"external/bazelbuild-rules_python":/* recursive = */ true,
|
||||
"external/bazelbuild-rules_rust":/* recursive = */ true,
|
||||
"external/bazelbuild-rules_testing":/* recursive = */ true,
|
||||
"external/bazelbuild-kotlin-rules":/* recursive = */ true,
|
||||
"external/bazel-skylib":/* recursive = */ true,
|
||||
"external/protobuf":/* recursive = */ false,
|
||||
|
@ -569,10 +571,6 @@ var (
|
|||
// ext
|
||||
"tagsoup",
|
||||
|
||||
// framework-res
|
||||
"remote-color-resources-compile-public",
|
||||
"remote-color-resources-compile-colors",
|
||||
|
||||
// framework-minus-apex
|
||||
"ImmutabilityAnnotationProcessor",
|
||||
"debian.mime.types.minimized",
|
||||
|
@ -583,7 +581,6 @@ var (
|
|||
"apache-commons-math",
|
||||
"cbor-java",
|
||||
"icu4j_calendar_astronomer",
|
||||
"remote-color-resources-compile-public",
|
||||
"statslog-art-java-gen",
|
||||
|
||||
"AndroidCommonLint",
|
||||
|
|
|
@ -442,6 +442,9 @@ func getOtherModuleLabel(ctx BazelConversionPathContext, dep, tag string,
|
|||
otherLabel := labelFromModule(ctx, m)
|
||||
|
||||
// TODO(b/165114590): Convert tag (":name{.tag}") to corresponding Bazel implicit output targets.
|
||||
if tag != "" && m.Name() == "framework-res" {
|
||||
otherLabel += tag
|
||||
}
|
||||
|
||||
if samePackage(label, otherLabel) {
|
||||
otherLabel = bazelShortLabel(otherLabel)
|
||||
|
|
|
@ -478,3 +478,41 @@ android_app {
|
|||
}),
|
||||
}})
|
||||
}
|
||||
|
||||
func TestFrameworkResConversion(t *testing.T) {
|
||||
runAndroidAppTestCase(t, Bp2buildTestCase{
|
||||
Description: "Framework Res custom conversion",
|
||||
ModuleTypeUnderTest: "android_app",
|
||||
ModuleTypeUnderTestFactory: java.AndroidAppFactory,
|
||||
Filesystem: map[string]string{
|
||||
"res/values/attrs.xml": "",
|
||||
"resource_zip.zip": "",
|
||||
},
|
||||
Blueprint: `
|
||||
android_app {
|
||||
name: "framework-res",
|
||||
resource_zips: [
|
||||
"resource_zip.zip",
|
||||
],
|
||||
certificate: "platform",
|
||||
}
|
||||
|
||||
filegroup {
|
||||
name: "framework-res-package-jar",
|
||||
srcs: [":framework-res{.export-package.apk}"],
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("framework_resources", "framework-res", AttrNameToString{
|
||||
"certificate_name": `"platform"`,
|
||||
"manifest": `"AndroidManifest.xml"`,
|
||||
"resource_files": `["res/values/attrs.xml"]`,
|
||||
"resource_zips": `["resource_zip.zip"]`,
|
||||
"target_compatible_with": `["//build/bazel/platforms/os:android"]`,
|
||||
}),
|
||||
MakeBazelTargetNoRestrictions("filegroup", "framework-res-package-jar", AttrNameToString{
|
||||
"srcs": `[":framework-res.export-package.apk"]`,
|
||||
}),
|
||||
}})
|
||||
|
||||
}
|
||||
|
|
|
@ -267,11 +267,22 @@ func platformMappingSingleProduct(
|
|||
defaultAppCertificateFilegroup = "@//" + filepath.Dir(proptools.String(productVariables.DefaultAppCertificate)) + ":generated_android_certificate_directory"
|
||||
}
|
||||
|
||||
// TODO: b/301598690 - commas can't be escaped in a string-list passed in a platform mapping,
|
||||
// so commas are switched for ":" here, and must be back-substituted into commas
|
||||
// wherever the AAPTCharacteristics product config variable is used.
|
||||
AAPTConfig := []string{}
|
||||
for _, conf := range productVariables.AAPTConfig {
|
||||
AAPTConfig = append(AAPTConfig, strings.Replace(conf, ",", ":", -1))
|
||||
}
|
||||
|
||||
for _, suffix := range bazelPlatformSuffixes {
|
||||
result.WriteString(" ")
|
||||
result.WriteString(label.String())
|
||||
result.WriteString(suffix)
|
||||
result.WriteString("\n")
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:aapt_characteristics=%s\n", proptools.String(productVariables.AAPTCharacteristics)))
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:aapt_config=%s\n", strings.Join(AAPTConfig, ",")))
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:aapt_preferred_config=%s\n", proptools.String(productVariables.AAPTPreferredConfig)))
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:always_use_prebuilt_sdks=%t\n", proptools.Bool(productVariables.Always_use_prebuilt_sdks)))
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:arc=%t\n", proptools.Bool(productVariables.Arc)))
|
||||
result.WriteString(fmt.Sprintf(" --//build/bazel/product_config:apex_global_min_sdk_version_override=%s\n", proptools.String(productVariables.ApexGlobalMinSdkVersionOverride)))
|
||||
|
|
12
java/aar.go
12
java/aar.go
|
@ -1223,6 +1223,7 @@ func AARImportFactory() android.Module {
|
|||
type bazelAapt struct {
|
||||
Manifest bazel.Label
|
||||
Resource_files bazel.LabelListAttribute
|
||||
Resource_zips bazel.LabelListAttribute
|
||||
Assets_dir bazel.StringAttribute
|
||||
Assets bazel.LabelListAttribute
|
||||
}
|
||||
|
@ -1267,9 +1268,20 @@ func (a *aapt) convertAaptAttrsWithBp2Build(ctx android.Bp2buildMutatorContext)
|
|||
assets = bazel.MakeLabelList(android.RootToModuleRelativePaths(ctx, androidResourceGlob(ctx, dir)))
|
||||
|
||||
}
|
||||
var resourceZips bazel.LabelList
|
||||
if len(a.aaptProperties.Resource_zips) > 0 {
|
||||
if ctx.ModuleName() == "framework-res" {
|
||||
resourceZips = android.BazelLabelForModuleSrc(ctx, a.aaptProperties.Resource_zips)
|
||||
} else {
|
||||
//TODO: b/301593550 - Implement support for this
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_PROPERTY_UNSUPPORTED, "resource_zips")
|
||||
return &bazelAapt{}, false
|
||||
}
|
||||
}
|
||||
return &bazelAapt{
|
||||
android.BazelLabelForModuleSrcSingle(ctx, manifest),
|
||||
bazel.MakeLabelListAttribute(resourceFiles),
|
||||
bazel.MakeLabelListAttribute(resourceZips),
|
||||
assetsDir,
|
||||
bazel.MakeLabelListAttribute(assets),
|
||||
}, true
|
||||
|
|
22
java/app.go
22
java/app.go
|
@ -1683,6 +1683,13 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
|
|||
Updatable: a.appProperties.Updatable,
|
||||
}
|
||||
|
||||
// As framework-res has no sources, no deps in the Bazel sense, and java compilation, dexing and optimization is skipped by
|
||||
// Soong specifically for it, return early here before any of the conversion work for the above is attempted.
|
||||
if ctx.ModuleName() == "framework-res" {
|
||||
appAttrs.bazelAapt = aapt
|
||||
return true, android.CommonAttributes{Name: a.Name(), SkipData: proptools.BoolPtr(true)}, appAttrs
|
||||
}
|
||||
|
||||
// Optimization is..
|
||||
// - enabled by default for android_app, android_test_helper_app
|
||||
// - disabled by default for android_test
|
||||
|
@ -1784,11 +1791,18 @@ func convertWithBp2build(ctx android.Bp2buildMutatorContext, a *AndroidApp) (boo
|
|||
// ConvertWithBp2build is used to convert android_app to Bazel.
|
||||
func (a *AndroidApp) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
||||
if ok, commonAttrs, appAttrs := convertWithBp2build(ctx, a); ok {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "android_binary",
|
||||
Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
|
||||
var props bazel.BazelTargetModuleProperties
|
||||
if ctx.ModuleName() == "framework-res" {
|
||||
props = bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "framework_resources",
|
||||
Bzl_load_location: "//build/bazel/rules/android:framework_resources.bzl",
|
||||
}
|
||||
} else {
|
||||
props = bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "android_binary",
|
||||
Bzl_load_location: "//build/bazel/rules/android:android_binary.bzl",
|
||||
}
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(props, commonAttrs, appAttrs)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue