bp2build support for framework-res
Change-Id: I5b32a702e02b5f1ec08d5608d766a8a0c08d845c Bug: 276928228 Bug: 297356405
This commit is contained in:
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)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user