diff options
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 } |