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

Commit 139a2e69 authored by Jiyong Park's avatar Jiyong Park
Browse files

Add filename property to prebuilt_etc

filename property is an optional property that specifies the name of the
installed file which is by default name of the module.

This will be used to APEXs to have ./etc/ld.config.txt files for their
own.

Test: m (prebuilt_etc_test.go added)
Change-Id: Ic8d0c0044c5bc2c6c33117fe2c19ef6ad75451a8
parent 397e55e0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ bootstrap_go_package {
        "android/neverallow_test.go",
        "android/paths_test.go",
        "android/prebuilt_test.go",
        "android/prebuilt_etc_test.go",
        "android/util_test.go",
        "android/variable_test.go",
    ],
+9 −2
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ type prebuiltEtcProperties struct {
	// optional subdirectory under which this file is installed into
	Sub_dir *string `android:"arch_variant"`

	// optional name for the installed file. If unspecified, name of the module is used as the file name
	Filename *string `android:"arch_variant"`

	// Make this module available when building for recovery.
	Recovery_available *bool

@@ -95,7 +98,11 @@ func (p *PrebuiltEtc) SubDir() string {

func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
	p.sourceFilePath = ctx.ExpandSource(String(p.properties.Src), "src")
	p.outputFilePath = PathForModuleOut(ctx, ctx.ModuleName()).OutputPath
	filename := String(p.properties.Filename)
	if filename == "" {
		filename = ctx.ModuleName()
	}
	p.outputFilePath = PathForModuleOut(ctx, filename).OutputPath
	p.installDirPath = PathForModuleInstall(ctx, "etc", String(p.properties.Sub_dir))

	// This ensures that outputFilePath has the same name as this module.
@@ -120,7 +127,7 @@ func (p *PrebuiltEtc) AndroidMk() AndroidMkData {
			fmt.Fprintln(w, "LOCAL_MODULE_TAGS := optional")
			fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", p.outputFilePath.String())
			fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
			fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", name)
			fmt.Fprintln(w, "LOCAL_INSTALLED_MODULE_STEM :=", p.outputFilePath.Base())
			if p.additionalDependencies != nil {
				fmt.Fprint(w, "LOCAL_ADDITIONAL_DEPENDENCIES :=")
				for _, path := range *p.additionalDependencies {
+15 −0
Original line number Diff line number Diff line
@@ -91,3 +91,18 @@ func TestPrebuiltEtcVariants(t *testing.T) {
		t.Errorf("expected 1, got %#v", bar_variants)
	}
}

func TestPrebuiltEtcOutputPath(t *testing.T) {
	ctx := testPrebuiltEtc(t, `
		prebuilt_etc {
			name: "foo.conf",
			src: "foo.conf",
			filename: "foo.installed.conf",
		}
	`)

	p := ctx.ModuleForTests("foo.conf", "android_common_core").Module().(*PrebuiltEtc)
	if p.outputFilePath.Base() != "foo.installed.conf" {
		t.Errorf("expected foo.installed.conf, got %q", p.outputFilePath.Base())
	}
}