Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 173256b0 authored by Spandan Das's avatar Spandan Das
Browse files

Use a boolean to determine if linker.config.pb should be generated

vendor and product generate a linker.config.pb even if
`PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS` or
`PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS` are empty respectively. This
CL introduces a new property to determine if a filesystem should
generate a linker.config.pb. The autogenerated vendor and product
filesystem modules will set this property to true.

Test: go test ./filesystem
Bug: 376515221

Change-Id: Ibd007df0d287034f4d227a6054bd83937570ec27
parent 8fe68dcf
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -147,9 +147,7 @@ type FilesystemProperties struct {

	Erofs ErofsProperties

	// List of files (in .json format) that will be converted to a linker config file (in .pb format).
	// The linker config file be installed in the filesystem at /etc/linker.config.pb
	Linker_config_srcs []string `android:"path"`
	Linkerconfig LinkerConfigProperties

	// Determines if the module is auto-generated from Soong or not. If the module is
	// auto-generated, its deps are exempted from visibility enforcement.
@@ -168,6 +166,16 @@ type ErofsProperties struct {
	Sparse *bool
}

type LinkerConfigProperties struct {

	// Build a linker.config.pb file
	Gen_linker_config *bool

	// List of files (in .json format) that will be converted to a linker config file (in .pb format).
	// The linker config file be installed in the filesystem at /etc/linker.config.pb
	Linker_config_srcs []string `android:"path"`
}

// android_filesystem packages a set of modules and their transitive dependencies into a filesystem
// image. The filesystem images are expected to be mounted in the target device, which means the
// modules in the filesystem image are built for the target device (i.e. Android, not Linux host).
@@ -690,13 +698,13 @@ func (f *filesystem) buildEventLogtagsFile(ctx android.ModuleContext, builder *a
}

func (f *filesystem) buildLinkerConfigFile(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
	if len(f.properties.Linker_config_srcs) == 0 {
	if !proptools.Bool(f.properties.Linkerconfig.Gen_linker_config) {
		return
	}

	provideModules, _ := f.getLibsForLinkerConfig(ctx)
	output := rebasedDir.Join(ctx, "etc", "linker.config.pb")
	linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linker_config_srcs), provideModules, nil, output)
	linkerconfig.BuildLinkerConfig(ctx, builder, android.PathsForModuleSrc(ctx, f.properties.Linkerconfig.Linker_config_srcs), provideModules, nil, output)

	f.appendToEntry(ctx, output)
}
+4 −1
Original line number Diff line number Diff line
@@ -670,7 +670,10 @@ func TestInstallLinkerConfigFile(t *testing.T) {
android_filesystem {
    name: "myfilesystem",
    deps: ["libfoo_has_no_stubs", "libfoo_has_stubs"],
    linkerconfig: {
	    gen_linker_config: true,
	    linker_config_srcs: ["linker.config.json"],
    },
    partition_type: "vendor",
}
cc_library {
+2 −1
Original line number Diff line number Diff line
@@ -475,7 +475,8 @@ func (f *filesystemCreator) createPartition(ctx android.LoadHookContext, partiti
	}

	if partitionType == "vendor" || partitionType == "product" {
		fsProps.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
		fsProps.Linkerconfig.Gen_linker_config = proptools.BoolPtr(true)
		fsProps.Linkerconfig.Linker_config_srcs = f.createLinkerConfigSourceFilegroups(ctx, partitionType)
	}

	var module android.Module