summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-12-13 14:10:31 -0800
committer Cole Faust <colefaust@google.com> 2024-12-13 14:47:21 -0800
commitfee270187d49304460e1db46c0a29fd0e97a832c (patch)
tree13f26f974d962b772a5f2d3d295933e2946d8734
parentc6f264854e38c6f4964409902eb20832d764d2d4 (diff)
Make BuildLinkerConfig run in its own action
We should probably do this change for more parts of the filesystem RuleBuilder. Moving the linker config action out of the filesystem rulebuilder allows it to run in parallel with opther actions, and not rerun every time the filesystem is rebuilt. Bug: 384091387 Test: Presubmits Change-Id: Ic7305c555260fb5d9900c6c709b6c81dc0708d2b
-rw-r--r--filesystem/filesystem.go4
-rw-r--r--filesystem/filesystem_test.go9
-rw-r--r--filesystem/system_image.go4
-rw-r--r--linkerconfig/linkerconfig.go16
4 files changed, 19 insertions, 14 deletions
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index bff0a1014..eb39a78c6 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -886,8 +886,10 @@ func (f *filesystem) BuildLinkerConfigFile(ctx android.ModuleContext, builder *a
}
provideModules, _ := f.getLibsForLinkerConfig(ctx)
+ intermediateOutput := android.PathForModuleOut(ctx, "linker.config.pb")
+ linkerconfig.BuildLinkerConfig(ctx, android.PathsForModuleSrc(ctx, f.properties.Linker_config.Linker_config_srcs), provideModules, nil, intermediateOutput)
output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
- linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linker_config.Linker_config_srcs), provideModules, nil, output)
+ builder.Command().Text("cp").Input(intermediateOutput).Output(output)
f.appendToEntry(ctx, output)
}
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 2dcb23d3f..33cddf87d 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -16,7 +16,6 @@ package filesystem
import (
"os"
- "strings"
"testing"
"android/soong/android"
@@ -181,11 +180,9 @@ func TestFileSystemFillsLinkerConfigWithStubLibs(t *testing.T) {
`)
module := result.ModuleForTests("myfilesystem", "android_common")
- output := module.Output("out/soong/.intermediates/myfilesystem/android_common/myfilesystem/system/etc/linker.config.pb")
+ output := module.Output("out/soong/.intermediates/myfilesystem/android_common/linker.config.pb")
- fullCommand := output.RuleParams.Command
- startIndex := strings.Index(fullCommand, "conv_linker_config")
- linkerConfigCommand := fullCommand[startIndex:]
+ linkerConfigCommand := output.RuleParams.Command
android.AssertStringDoesContain(t, "linker.config.pb should have libfoo",
linkerConfigCommand, "libfoo.so")
@@ -735,7 +732,7 @@ cc_library {
}
`)
- linkerConfigCmd := result.ModuleForTests("myfilesystem", "android_common").Rule("build_filesystem_image").RuleParams.Command
+ linkerConfigCmd := result.ModuleForTests("myfilesystem", "android_common").Output("out/soong/.intermediates/myfilesystem/android_common/linker.config.pb").RuleParams.Command
android.AssertStringDoesContain(t, "Could not find linker.config.json file in cmd", linkerConfigCmd, "conv_linker_config proto --force -s linker.config.json")
android.AssertStringDoesContain(t, "Could not find stub in `provideLibs`", linkerConfigCmd, "--key provideLibs --value libfoo_has_stubs.so")
}
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 60a513346..57ce10f68 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -49,8 +49,10 @@ func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *
}
provideModules, requireModules := s.getLibsForLinkerConfig(ctx)
+ intermediateOutput := android.PathForModuleOut(ctx, "linker.config.pb")
+ linkerconfig.BuildLinkerConfig(ctx, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, intermediateOutput)
output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
- linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linker_config.Linker_config_srcs), provideModules, requireModules, output)
+ builder.Command().Text("cp").Input(intermediateOutput).Output(output)
s.appendToEntry(ctx, output)
}
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index d42287113..7684db288 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -76,9 +76,7 @@ func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
input := android.PathForModuleSrc(ctx, android.String(l.properties.Src))
output := android.PathForModuleOut(ctx, "linker.config.pb").OutputPath
- builder := android.NewRuleBuilder(pctx, ctx)
- BuildLinkerConfig(ctx, builder, android.Paths{input}, nil, nil, output)
- builder.Build("conv_linker_config", "Generate linker config protobuf "+output.String())
+ BuildLinkerConfig(ctx, android.Paths{input}, nil, nil, output)
l.outputFilePath = output
l.installDirPath = android.PathForModuleInstall(ctx, "etc")
@@ -90,10 +88,15 @@ func (l *linkerConfig) GenerateAndroidBuildActions(ctx android.ModuleContext) {
ctx.SetOutputFiles(android.Paths{l.outputFilePath}, "")
}
-func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
- inputs android.Paths, provideModules []android.Module, requireModules []android.Module, output android.OutputPath) {
-
+func BuildLinkerConfig(
+ ctx android.ModuleContext,
+ inputs android.Paths,
+ provideModules []android.Module,
+ requireModules []android.Module,
+ output android.WritablePath,
+) {
// First, convert the input json to protobuf format
+ builder := android.NewRuleBuilder(pctx, ctx)
interimOutput := android.PathForModuleOut(ctx, "temp.pb")
cmd := builder.Command().
BuiltTool("conv_linker_config").
@@ -157,6 +160,7 @@ func BuildLinkerConfig(ctx android.ModuleContext, builder *android.RuleBuilder,
builder.Temporary(interimOutput)
builder.DeleteTemporaryFiles()
+ builder.Build("conv_linker_config_"+output.String(), "Generate linker config protobuf "+output.String())
}
// linker_config generates protobuf file from json file. This protobuf file will be used from