Port module_partition logic for RRO from Make to Soong

The default partition for RRO is "product/" in Make, but it was
"system/" in Soong. This CL ports the logic from Make to Soong

To implement this, a new function PathForModuleInPartitionInstall is
created that enables callers to provide the relevant partition

Bug: 158407753
Test: from build/soong, ran go test ./java
Change-Id: I05b02eae7fe57189aaad5109c26cccc5823518ef
This commit is contained in:
Spandan Das
2021-06-03 19:36:41 +00:00
parent ad66593085
commit 5d1b929f21
3 changed files with 89 additions and 6 deletions

View File

@@ -1591,6 +1591,18 @@ func (p InstallPath) ToMakePath() InstallPath {
// PathForModuleInstall returns a Path representing the install path for the
// module appended with paths...
func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string) InstallPath {
os, arch := osAndArch(ctx)
partition := modulePartition(ctx, os)
return makePathForInstall(ctx, os, arch, partition, ctx.Debug(), pathComponents...)
}
// PathForModuleInPartitionInstall is similar to PathForModuleInstall but partition is provided by the caller
func PathForModuleInPartitionInstall(ctx ModuleInstallPathContext, partition string, pathComponents ...string) InstallPath {
os, arch := osAndArch(ctx)
return makePathForInstall(ctx, os, arch, partition, ctx.Debug(), pathComponents...)
}
func osAndArch(ctx ModuleInstallPathContext) (OsType, ArchType) {
os := ctx.Os()
arch := ctx.Arch().ArchType
forceOS, forceArch := ctx.InstallForceOS()
@@ -1600,14 +1612,14 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
if forceArch != nil {
arch = *forceArch
}
partition := modulePartition(ctx, os)
ret := pathForInstall(ctx, os, arch, partition, ctx.Debug(), pathComponents...)
return os, arch
}
func makePathForInstall(ctx ModuleInstallPathContext, os OsType, arch ArchType, partition string, debug bool, pathComponents ...string) InstallPath {
ret := pathForInstall(ctx, os, arch, partition, debug, pathComponents...)
if ctx.InstallBypassMake() && ctx.Config().KatiEnabled() {
ret = ret.ToMakePath()
}
return ret
}