Add partial bp2build support for APEX targets. am: 22b606b5f0
am: 356b7ca109
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1733232 Change-Id: Ia301f78ab5e9ad38d0eee2a525a4eb2895ae5722
This commit is contained in:
committed by
Automerger Merge Worker
commit
50be2a3716
64
apex/apex.go
64
apex/apex.go
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/bpf"
|
||||
"android/soong/cc"
|
||||
prebuilt_etc "android/soong/etc"
|
||||
@@ -53,6 +54,8 @@ func registerApexBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.PreArchMutators(registerPreArchMutators)
|
||||
ctx.PreDepsMutators(RegisterPreDepsMutators)
|
||||
ctx.PostDepsMutators(RegisterPostDepsMutators)
|
||||
|
||||
android.RegisterBp2BuildMutator("apex", ApexBundleBp2Build)
|
||||
}
|
||||
|
||||
func registerPreArchMutators(ctx android.RegisterMutatorsContext) {
|
||||
@@ -322,6 +325,7 @@ type apexBundle struct {
|
||||
android.DefaultableModuleBase
|
||||
android.OverridableModuleBase
|
||||
android.SdkBase
|
||||
android.BazelModuleBase
|
||||
|
||||
// Properties
|
||||
properties apexBundleProperties
|
||||
@@ -3120,3 +3124,63 @@ func rModulesPackages() map[string][]string {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// For Bazel / bp2build
|
||||
|
||||
type bazelApexBundleAttributes struct {
|
||||
Manifest bazel.LabelAttribute
|
||||
}
|
||||
|
||||
type bazelApexBundle struct {
|
||||
android.BazelTargetModuleBase
|
||||
bazelApexBundleAttributes
|
||||
}
|
||||
|
||||
func BazelApexBundleFactory() android.Module {
|
||||
module := &bazelApexBundle{}
|
||||
module.AddProperties(&module.bazelApexBundleAttributes)
|
||||
android.InitBazelTargetModule(module)
|
||||
return module
|
||||
}
|
||||
|
||||
func ApexBundleBp2Build(ctx android.TopDownMutatorContext) {
|
||||
module, ok := ctx.Module().(*apexBundle)
|
||||
if !ok {
|
||||
// Not an APEX bundle
|
||||
return
|
||||
}
|
||||
if !module.ConvertWithBp2build(ctx) {
|
||||
return
|
||||
}
|
||||
if ctx.ModuleType() != "apex" {
|
||||
return
|
||||
}
|
||||
|
||||
apexBundleBp2BuildInternal(ctx, module)
|
||||
}
|
||||
|
||||
func apexBundleBp2BuildInternal(ctx android.TopDownMutatorContext, module *apexBundle) {
|
||||
var manifestLabelAttribute bazel.LabelAttribute
|
||||
|
||||
manifestStringPtr := module.properties.Manifest
|
||||
if module.properties.Manifest != nil {
|
||||
manifestLabelAttribute.SetValue(android.BazelLabelForModuleSrcSingle(ctx, *manifestStringPtr))
|
||||
}
|
||||
|
||||
attrs := &bazelApexBundleAttributes{
|
||||
Manifest: manifestLabelAttribute,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "apex",
|
||||
Bzl_load_location: "//build/bazel/rules:apex.bzl",
|
||||
}
|
||||
|
||||
ctx.CreateBazelTargetModule(BazelApexBundleFactory, module.Name(), props, attrs)
|
||||
}
|
||||
|
||||
func (m *bazelApexBundle) Name() string {
|
||||
return m.BaseModuleName()
|
||||
}
|
||||
|
||||
func (m *bazelApexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
|
||||
|
Reference in New Issue
Block a user