Loading android/paths.go +16 −19 Original line number Diff line number Diff line Loading @@ -821,17 +821,6 @@ func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath { return OutputPath{basePath{path, ctx.Config(), ""}} } // pathForInstallInMakeDir is used by PathForModuleInstall when the module returns true // for InstallBypassMake to produce an OutputPath that installs to $OUT_DIR instead of // $OUT_DIR/soong. func pathForInstallInMakeDir(ctx PathContext, pathComponents ...string) InstallPath { path, err := validatePath(pathComponents...) if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{"../" + path, ctx.Config(), ""}} } // PathsForOutput returns Paths rooted from buildDir func PathsForOutput(ctx PathContext, paths []string) WritablePaths { ret := make(WritablePaths, len(paths)) Loading Loading @@ -1118,12 +1107,14 @@ func PathForModuleRes(ctx ModuleContext, pathComponents ...string) ModuleResPath // InstallPath is a Path representing a installed file path rooted from the build directory type InstallPath struct { basePath baseDir string // "../" for Make paths to convert "out/soong" to "out", "" for Soong paths } func (p InstallPath) writablePath() {} func (p InstallPath) String() string { return filepath.Join(p.config.buildDir, p.path) return filepath.Join(p.config.buildDir, p.baseDir, p.path) } // Join creates a new InstallPath with paths... joined with the current path. The Loading @@ -1141,8 +1132,11 @@ func (p InstallPath) withRel(rel string) InstallPath { return p } func (p InstallPath) RelPathString() string { return p.path // ToMakePath returns a new InstallPath that points to Make's install directory instead of Soong's, // i.e. out/ instead of out/soong/. func (p InstallPath) ToMakePath() InstallPath { p.baseDir = "../" return p } // PathForModuleInstall returns a Path representing the install path for the Loading @@ -1167,15 +1161,18 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string outPaths = append([]string{"debug"}, outPaths...) } outPaths = append(outPaths, pathComponents...) if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() { return pathForInstallInMakeDir(ctx, outPaths...) } path, err := validatePath(outPaths...) if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{path, ctx.Config(), ""}} ret := InstallPath{basePath{path, ctx.Config(), ""}, ""} if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() { ret = ret.ToMakePath() } return ret } func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath { Loading @@ -1184,7 +1181,7 @@ func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath { if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{path, ctx.Config(), ""}} return InstallPath{basePath{path, ctx.Config(), ""}, ""} } func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string { Loading android/prebuilt_etc.go +1 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries { ExtraEntries: []AndroidMkExtraEntriesFunc{ func(entries *AndroidMkEntries) { entries.SetString("LOCAL_MODULE_TAGS", "optional") entries.SetString("LOCAL_MODULE_PATH", "$(OUT_DIR)/"+p.installDirPath.RelPathString()) entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String()) entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) entries.SetString("LOCAL_UNINSTALLABLE_MODULE", strconv.FormatBool(!p.Installable())) if p.additionalDependencies != nil { Loading android/prebuilt_etc_test.go +11 −11 Original line number Diff line number Diff line Loading @@ -182,9 +182,9 @@ func TestPrebuiltUserShareInstallDirPath(t *testing.T) { `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/usr/share/bar" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := buildDir + "/target/product/test_device/system/usr/share/bar" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } Loading @@ -199,9 +199,9 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) { buildOS := BuildOs.String() p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc) expected := filepath.Join("host", config.PrebuiltOS(), "usr", "share", "bar") if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := filepath.Join(buildDir, "host", config.PrebuiltOS(), "usr", "share", "bar") if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } Loading @@ -214,14 +214,14 @@ func TestPrebuiltFontInstallDirPath(t *testing.T) { `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/fonts" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := buildDir + "/target/product/test_device/system/fonts" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } func TestPrebuiltFirmwareDirPath(t *testing.T) { targetPath := "target/product/test_device" targetPath := buildDir + "/target/product/test_device" tests := []struct { description string config string Loading Loading @@ -249,7 +249,7 @@ func TestPrebuiltFirmwareDirPath(t *testing.T) { t.Run(tt.description, func(t *testing.T) { ctx, _ := testPrebuiltEtc(t, tt.config) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) if p.installDirPath.RelPathString() != tt.expectedPath { if p.installDirPath.String() != tt.expectedPath { t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath) } }) Loading apex/apex.go +5 −5 Original line number Diff line number Diff line Loading @@ -1625,8 +1625,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex proptools.StringDefault(a.properties.Apex_name, name), fi.installDir) if a.properties.Flattened && apexType.image() { // /system/apex/<name>/{lib|framework|...} fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), name, fi.installDir)) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(), name, fi.installDir)) if !a.isFlattenedVariant() { fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated) } Loading Loading @@ -1735,7 +1735,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD fmt.Fprintln(w, "LOCAL_MODULE :=", name) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class? fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFiles[apexType].String()) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString())) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) if len(moduleNames) > 0 { Loading @@ -1746,7 +1746,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD } if a.prebuiltFileToDelete != "" { fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", "rm -rf "+ filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), a.prebuiltFileToDelete)) filepath.Join(a.installDir.ToMakePath().String(), a.prebuiltFileToDelete)) } fmt.Fprintln(w, "include $(BUILD_PREBUILT)") Loading Loading @@ -1987,7 +1987,7 @@ func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries { Include: "$(BUILD_PREBUILT)", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(entries *android.AndroidMkEntries) { entries.SetString("LOCAL_MODULE_PATH", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString())) entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String()) entries.SetString("LOCAL_MODULE_STEM", p.installFilename) entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...) Loading apex/apex_test.go +3 −2 Original line number Diff line number Diff line Loading @@ -1382,6 +1382,7 @@ func TestVndkApexVersion(t *testing.T) { vndk: { enabled: true, }, target_arch: "arm64", srcs: ["libvndk27.so"], } `, withFiles(map[string][]byte{ Loading Loading @@ -1864,8 +1865,8 @@ func TestApexInProductPartition(t *testing.T) { `) apex := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) expected := "target/product/test_device/product/apex" actual := apex.installDir.RelPathString() expected := buildDir + "/target/product/test_device/product/apex" actual := apex.installDir.String() if actual != expected { t.Errorf("wrong install path. expected %q. actual %q", expected, actual) } Loading Loading
android/paths.go +16 −19 Original line number Diff line number Diff line Loading @@ -821,17 +821,6 @@ func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath { return OutputPath{basePath{path, ctx.Config(), ""}} } // pathForInstallInMakeDir is used by PathForModuleInstall when the module returns true // for InstallBypassMake to produce an OutputPath that installs to $OUT_DIR instead of // $OUT_DIR/soong. func pathForInstallInMakeDir(ctx PathContext, pathComponents ...string) InstallPath { path, err := validatePath(pathComponents...) if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{"../" + path, ctx.Config(), ""}} } // PathsForOutput returns Paths rooted from buildDir func PathsForOutput(ctx PathContext, paths []string) WritablePaths { ret := make(WritablePaths, len(paths)) Loading Loading @@ -1118,12 +1107,14 @@ func PathForModuleRes(ctx ModuleContext, pathComponents ...string) ModuleResPath // InstallPath is a Path representing a installed file path rooted from the build directory type InstallPath struct { basePath baseDir string // "../" for Make paths to convert "out/soong" to "out", "" for Soong paths } func (p InstallPath) writablePath() {} func (p InstallPath) String() string { return filepath.Join(p.config.buildDir, p.path) return filepath.Join(p.config.buildDir, p.baseDir, p.path) } // Join creates a new InstallPath with paths... joined with the current path. The Loading @@ -1141,8 +1132,11 @@ func (p InstallPath) withRel(rel string) InstallPath { return p } func (p InstallPath) RelPathString() string { return p.path // ToMakePath returns a new InstallPath that points to Make's install directory instead of Soong's, // i.e. out/ instead of out/soong/. func (p InstallPath) ToMakePath() InstallPath { p.baseDir = "../" return p } // PathForModuleInstall returns a Path representing the install path for the Loading @@ -1167,15 +1161,18 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string outPaths = append([]string{"debug"}, outPaths...) } outPaths = append(outPaths, pathComponents...) if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() { return pathForInstallInMakeDir(ctx, outPaths...) } path, err := validatePath(outPaths...) if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{path, ctx.Config(), ""}} ret := InstallPath{basePath{path, ctx.Config(), ""}, ""} if ctx.InstallBypassMake() && ctx.Config().EmbeddedInMake() { ret = ret.ToMakePath() } return ret } func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath { Loading @@ -1184,7 +1181,7 @@ func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath { if err != nil { reportPathError(ctx, err) } return InstallPath{basePath{path, ctx.Config(), ""}} return InstallPath{basePath{path, ctx.Config(), ""}, ""} } func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string { Loading
android/prebuilt_etc.go +1 −1 Original line number Diff line number Diff line Loading @@ -158,7 +158,7 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries { ExtraEntries: []AndroidMkExtraEntriesFunc{ func(entries *AndroidMkEntries) { entries.SetString("LOCAL_MODULE_TAGS", "optional") entries.SetString("LOCAL_MODULE_PATH", "$(OUT_DIR)/"+p.installDirPath.RelPathString()) entries.SetString("LOCAL_MODULE_PATH", p.installDirPath.ToMakePath().String()) entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) entries.SetString("LOCAL_UNINSTALLABLE_MODULE", strconv.FormatBool(!p.Installable())) if p.additionalDependencies != nil { Loading
android/prebuilt_etc_test.go +11 −11 Original line number Diff line number Diff line Loading @@ -182,9 +182,9 @@ func TestPrebuiltUserShareInstallDirPath(t *testing.T) { `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/usr/share/bar" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := buildDir + "/target/product/test_device/system/usr/share/bar" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } Loading @@ -199,9 +199,9 @@ func TestPrebuiltUserShareHostInstallDirPath(t *testing.T) { buildOS := BuildOs.String() p := ctx.ModuleForTests("foo.conf", buildOS+"_common").Module().(*PrebuiltEtc) expected := filepath.Join("host", config.PrebuiltOS(), "usr", "share", "bar") if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := filepath.Join(buildDir, "host", config.PrebuiltOS(), "usr", "share", "bar") if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } Loading @@ -214,14 +214,14 @@ func TestPrebuiltFontInstallDirPath(t *testing.T) { `) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) expected := "target/product/test_device/system/fonts" if p.installDirPath.RelPathString() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.RelPathString()) expected := buildDir + "/target/product/test_device/system/fonts" if p.installDirPath.String() != expected { t.Errorf("expected %q, got %q", expected, p.installDirPath.String()) } } func TestPrebuiltFirmwareDirPath(t *testing.T) { targetPath := "target/product/test_device" targetPath := buildDir + "/target/product/test_device" tests := []struct { description string config string Loading Loading @@ -249,7 +249,7 @@ func TestPrebuiltFirmwareDirPath(t *testing.T) { t.Run(tt.description, func(t *testing.T) { ctx, _ := testPrebuiltEtc(t, tt.config) p := ctx.ModuleForTests("foo.conf", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) if p.installDirPath.RelPathString() != tt.expectedPath { if p.installDirPath.String() != tt.expectedPath { t.Errorf("expected %q, got %q", tt.expectedPath, p.installDirPath) } }) Loading
apex/apex.go +5 −5 Original line number Diff line number Diff line Loading @@ -1625,8 +1625,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex proptools.StringDefault(a.properties.Apex_name, name), fi.installDir) if a.properties.Flattened && apexType.image() { // /system/apex/<name>/{lib|framework|...} fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), name, fi.installDir)) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(), name, fi.installDir)) if !a.isFlattenedVariant() { fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated) } Loading Loading @@ -1735,7 +1735,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD fmt.Fprintln(w, "LOCAL_MODULE :=", name) fmt.Fprintln(w, "LOCAL_MODULE_CLASS := ETC") // do we need a new class? fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", a.outputFiles[apexType].String()) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join("$(OUT_DIR)", a.installDir.RelPathString())) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", a.installDir.ToMakePath().String()) fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix()) fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable()) if len(moduleNames) > 0 { Loading @@ -1746,7 +1746,7 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD } if a.prebuiltFileToDelete != "" { fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", "rm -rf "+ filepath.Join("$(OUT_DIR)", a.installDir.RelPathString(), a.prebuiltFileToDelete)) filepath.Join(a.installDir.ToMakePath().String(), a.prebuiltFileToDelete)) } fmt.Fprintln(w, "include $(BUILD_PREBUILT)") Loading Loading @@ -1987,7 +1987,7 @@ func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries { Include: "$(BUILD_PREBUILT)", ExtraEntries: []android.AndroidMkExtraEntriesFunc{ func(entries *android.AndroidMkEntries) { entries.SetString("LOCAL_MODULE_PATH", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString())) entries.SetString("LOCAL_MODULE_PATH", p.installDir.ToMakePath().String()) entries.SetString("LOCAL_MODULE_STEM", p.installFilename) entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...) Loading
apex/apex_test.go +3 −2 Original line number Diff line number Diff line Loading @@ -1382,6 +1382,7 @@ func TestVndkApexVersion(t *testing.T) { vndk: { enabled: true, }, target_arch: "arm64", srcs: ["libvndk27.so"], } `, withFiles(map[string][]byte{ Loading Loading @@ -1864,8 +1865,8 @@ func TestApexInProductPartition(t *testing.T) { `) apex := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*apexBundle) expected := "target/product/test_device/product/apex" actual := apex.installDir.RelPathString() expected := buildDir + "/target/product/test_device/product/apex" actual := apex.installDir.String() if actual != expected { t.Errorf("wrong install path. expected %q. actual %q", expected, actual) } Loading