summaryrefslogtreecommitdiff
path: root/linkerconfig
diff options
context:
space:
mode:
author Liz Kammer <eakammer@google.com> 2022-06-02 16:00:54 -0400
committer Alix <agespino@google.com> 2022-07-08 16:09:40 +0000
commit45faf8f4270b218e2af85592622c559da1536736 (patch)
tree98ac208bb0c20433efe56ba7990c33b91a276bfd /linkerconfig
parent01365d58907a367ec39154801fb47537d1e449c2 (diff)
Implement bp2build for linker_config
Pair: agespino Bug: 211666695 Test: TODO Change-Id: I479bcd7c53b1c57563fb4277ec39ad70b16030b8
Diffstat (limited to 'linkerconfig')
-rw-r--r--linkerconfig/linkerconfig.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index 003b27507..412a23b26 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -22,6 +22,7 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/bazel"
"android/soong/cc"
"android/soong/etc"
)
@@ -36,7 +37,7 @@ func init() {
}
func registerLinkerConfigBuildComponent(ctx android.RegistrationContext) {
- ctx.RegisterModuleType("linker_config", linkerConfigFactory)
+ ctx.RegisterModuleType("linker_config", LinkerConfigFactory)
}
type linkerConfigProperties struct {
@@ -52,6 +53,7 @@ type linkerConfigProperties struct {
type linkerConfig struct {
android.ModuleBase
+ android.BazelModuleBase
properties linkerConfigProperties
outputFilePath android.OutputPath
@@ -100,6 +102,28 @@ func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.InstallFile(l.installDirPath, l.outputFilePath.Base(), l.outputFilePath)
}
+type linkerConfigAttributes struct {
+ Src bazel.LabelAttribute
+}
+
+func (l *linkerConfig) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+ if l.properties.Src == nil {
+ ctx.PropertyErrorf("src", "empty src is not supported")
+ return
+ }
+ src := android.BazelLabelForModuleSrcSingle(ctx, *l.properties.Src)
+ targetModuleProperties := bazel.BazelTargetModuleProperties{
+ Rule_class: "linker_config",
+ Bzl_load_location: "//build/bazel/rules:linker_config.bzl",
+ }
+ ctx.CreateBazelTargetModule(
+ targetModuleProperties,
+ android.CommonAttributes{Name: l.Name()},
+ &linkerConfigAttributes{
+ Src: bazel.LabelAttribute{Value: &src},
+ })
+}
+
func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
input android.Path, otherModules []android.Module, output android.OutputPath) {
@@ -141,10 +165,11 @@ func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
// linker_config generates protobuf file from json file. This protobuf file will be used from
// linkerconfig while generating ld.config.txt. Format of this file can be found from
// https://android.googlesource.com/platform/system/linkerconfig/+/master/README.md
-func linkerConfigFactory() android.Module {
+func LinkerConfigFactory() android.Module {
m := &linkerConfig{}
m.AddProperties(&m.properties)
android.InitAndroidArchModule(m, android.HostAndDeviceSupported, android.MultilibFirst)
+ android.InitBazelModule(m)
return m
}