Replace RelPathString() with ToMakePath()

Add a ToMakePath() method that returns a new path that points out
out/ instead of out/soong/, and replace the
"$(OUT_DIR)/" + path.RelPathString()
pattern with
path.ToMakePath().String()

Bug: 141877526
Test: m checkbuild
Change-Id: I391b9f2ed78c83a58d905d48355ce9b01d610d16
diff --git a/android/paths.go b/android/paths.go
index b89edba..8dbb086 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -821,17 +821,6 @@
 	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))
@@ -1118,12 +1107,14 @@
 // 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
@@ -1141,8 +1132,11 @@
 	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
@@ -1167,15 +1161,18 @@
 		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 {
@@ -1184,7 +1181,7 @@
 	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 {