diff options
author | 2024-08-07 20:48:50 +0000 | |
---|---|---|
committer | 2024-08-07 20:48:50 +0000 | |
commit | d40aac13401a7826c31f50598bd1703ef3c75e67 (patch) | |
tree | dd48a01f7b11fd1f826f861b422a5ac82f10e581 /android/paths.go | |
parent | d6358b6a9b0b89ababf2bc24b3db3f6a77440ccd (diff) | |
parent | 7707b246efe17400aa27e843a507232bd02efd66 (diff) |
Merge "Don't hold on to WritablePath" into main
Diffstat (limited to 'android/paths.go')
-rw-r--r-- | android/paths.go | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/android/paths.go b/android/paths.go index dad70f770..d20b84a42 100644 --- a/android/paths.go +++ b/android/paths.go @@ -237,6 +237,9 @@ type Path interface { // directory, and OutputPath.Join("foo").Rel() would return "foo". Rel() string + // WithoutRel returns a new Path with no relative path, i.e. Rel() will return the same value as Base(). + WithoutRel() Path + // RelativeToTop returns a new path relative to the top, it is provided solely for use in tests. // // It is guaranteed to always return the same type as it is called on, e.g. if called on an @@ -1119,6 +1122,11 @@ func (p basePath) withRel(rel string) basePath { return p } +func (p basePath) withoutRel() basePath { + p.rel = filepath.Base(p.path) + return p +} + // SourcePath is a Path representing a file path rooted from SrcDir type SourcePath struct { basePath @@ -1278,6 +1286,11 @@ func (p SourcePath) String() string { return p.path } +func (p SourcePath) WithoutRel() Path { + p.basePath = p.basePath.withoutRel() + return p +} + // Join creates a new SourcePath with paths... joined with the current path. The // provided paths... may not use '..' to escape from the current path. func (p SourcePath) Join(ctx PathContext, paths ...string) SourcePath { @@ -1362,8 +1375,8 @@ func (p OutputPath) withRel(rel string) OutputPath { return p } -func (p OutputPath) WithoutRel() OutputPath { - p.basePath.rel = filepath.Base(p.basePath.path) +func (p OutputPath) WithoutRel() Path { + p.basePath = p.basePath.withoutRel() return p } @@ -1399,6 +1412,11 @@ type toolDepPath struct { basePath } +func (t toolDepPath) WithoutRel() Path { + t.basePath = t.basePath.withoutRel() + return t +} + func (t toolDepPath) RelativeToTop() Path { ensureTestOnly() return t @@ -1767,6 +1785,11 @@ func (p InstallPath) RelativeToTop() Path { return p } +func (p InstallPath) WithoutRel() Path { + p.basePath = p.basePath.withoutRel() + return p +} + func (p InstallPath) getSoongOutDir() string { return p.soongOutDir } @@ -2087,6 +2110,11 @@ func (p PhonyPath) RelativeToTop() Path { return p } +func (p PhonyPath) WithoutRel() Path { + p.basePath = p.basePath.withoutRel() + return p +} + func (p PhonyPath) ReplaceExtension(ctx PathContext, ext string) OutputPath { panic("Not implemented") } @@ -2103,6 +2131,11 @@ func (p testPath) RelativeToTop() Path { return p } +func (p testPath) WithoutRel() Path { + p.basePath = p.basePath.withoutRel() + return p +} + func (p testPath) String() string { return p.path } |