summaryrefslogtreecommitdiff
path: root/filesystem/system_image.go
diff options
context:
space:
mode:
author Kiyoung Kim <kiyoungkim@google.com> 2024-11-07 13:23:44 +0900
committer Kiyoung Kim <kiyoungkim@google.com> 2024-11-08 12:34:46 +0900
commit67118217ce5b17d5b48e3806595f3a62726a46cc (patch)
tree42d33f407aa4a8d713d23cc499e9b57f7d0560d3 /filesystem/system_image.go
parent45aeb5f9c08ae74dfb070640289721bbf1e81194 (diff)
Use common interface to build linker configuration
Current filesystem logic is quite separated with systemimage, so it can end up generating linker configuration twice which can end up an error case. This change creates a common interface and let both filesystem and systemimage can implement their own function to generate linker configuration. Bug: 324995772 Test: Compared linker.config.pb of generic_system_image with this patch Change-Id: Ic515e54deeafbae74fd02bb023661606aa7e0b7c
Diffstat (limited to 'filesystem/system_image.go')
-rw-r--r--filesystem/system_image.go37
1 files changed, 12 insertions, 25 deletions
diff --git a/filesystem/system_image.go b/filesystem/system_image.go
index 898987dbc..0d54ff585 100644
--- a/filesystem/system_image.go
+++ b/filesystem/system_image.go
@@ -17,27 +17,22 @@ package filesystem
import (
"android/soong/android"
"android/soong/linkerconfig"
+
+ "github.com/google/blueprint/proptools"
)
type systemImage struct {
filesystem
-
- properties systemImageProperties
}
-type systemImageProperties struct {
- // Path to the input linker config json file.
- Linker_config_src *string `android:"path"`
-}
+var _ filesystemBuilder = (*systemImage)(nil)
// android_system_image is a specialization of android_filesystem for the 'system' partition.
// Currently, the only difference is the inclusion of linker.config.pb file which specifies
// the provided and the required libraries to and from APEXes.
func SystemImageFactory() android.Module {
module := &systemImage{}
- module.AddProperties(&module.properties)
- module.filesystem.buildExtraFiles = module.buildExtraFiles
- module.filesystem.filterPackagingSpec = module.filterPackagingSpec
+ module.filesystemBuilder = module
initFilesystemModule(module, &module.filesystem)
return module
}
@@ -46,30 +41,22 @@ func (s systemImage) FsProps() FilesystemProperties {
return s.filesystem.properties
}
-func (s *systemImage) buildExtraFiles(ctx android.ModuleContext, root android.OutputPath) android.OutputPaths {
- if s.filesystem.properties.Partition_type != nil {
- ctx.PropertyErrorf("partition_type", "partition_type must be unset on an android_system_image module. It is assumed to be 'system'.")
+func (s *systemImage) BuildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
+ if !proptools.Bool(s.filesystem.properties.Linkerconfig.Gen_linker_config) {
+ return
}
- lc := s.buildLinkerConfigFile(ctx, root)
- // Add more files if needed
- return []android.OutputPath{lc}
-}
-
-func (s *systemImage) buildLinkerConfigFile(ctx android.ModuleContext, root android.OutputPath) android.OutputPath {
- input := android.PathForModuleSrc(ctx, android.String(s.properties.Linker_config_src))
- output := root.Join(ctx, "system", "etc", "linker.config.pb")
provideModules, requireModules := s.getLibsForLinkerConfig(ctx)
- builder := android.NewRuleBuilder(pctx, ctx)
- linkerconfig.BuildLinkerConfig(ctx, builder, android.Paths{input}, provideModules, requireModules, output)
- builder.Build("conv_linker_config", "Generate linker config protobuf "+output.String())
- return output
+ output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
+ linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, s.filesystem.properties.Linkerconfig.Linker_config_srcs), provideModules, requireModules, output)
+
+ s.appendToEntry(ctx, output)
}
// Filter the result of GatherPackagingSpecs to discard items targeting outside "system" / "root"
// partition. Note that "apex" module installs its contents to "apex"(fake partition) as well
// for symbol lookup by imitating "activated" paths.
-func (s *systemImage) filterPackagingSpec(ps android.PackagingSpec) bool {
+func (s *systemImage) FilterPackagingSpec(ps android.PackagingSpec) bool {
return !ps.SkipInstall() &&
(ps.Partition() == "system" || ps.Partition() == "root")
}