Fix Rel() after ReplaceExtension or InSameDir
Copying p.rel doesn't work, as rel needs to match the end of the value in path. Apply the same transformation to p.rel as p.path. Test: paths_test.go Change-Id: I42d676c6c4fc18d9852c1a73f25e5a791d7553d0
This commit is contained in:
@@ -712,7 +712,7 @@ func (p OutputPath) ReplaceExtension(ctx PathContext, ext string) OutputPath {
|
||||
reportPathErrorf(ctx, "extension %q cannot contain /", ext)
|
||||
}
|
||||
ret := PathForOutput(ctx, pathtools.ReplaceExtension(p.path, ext))
|
||||
ret.rel = p.rel
|
||||
ret.rel = pathtools.ReplaceExtension(p.rel, ext)
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -724,7 +724,7 @@ func (p OutputPath) InSameDir(ctx PathContext, paths ...string) OutputPath {
|
||||
}
|
||||
|
||||
ret := PathForOutput(ctx, filepath.Dir(p.path), path)
|
||||
ret.rel = p.rel
|
||||
ret.rel = filepath.Join(filepath.Dir(p.rel), path)
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@@ -696,22 +696,26 @@ func ExampleOutputPath_ReplaceExtension() {
|
||||
ctx := &configErrorWrapper{
|
||||
config: TestConfig("out", nil),
|
||||
}
|
||||
p := PathForOutput(ctx, "system/framework/boot.art")
|
||||
p := PathForOutput(ctx, "system/framework").Join(ctx, "boot.art")
|
||||
p2 := p.ReplaceExtension(ctx, "oat")
|
||||
fmt.Println(p, p2)
|
||||
fmt.Println(p.Rel(), p2.Rel())
|
||||
|
||||
// Output:
|
||||
// out/system/framework/boot.art out/system/framework/boot.oat
|
||||
// boot.art boot.oat
|
||||
}
|
||||
|
||||
func ExampleOutputPath_FileInSameDir() {
|
||||
ctx := &configErrorWrapper{
|
||||
config: TestConfig("out", nil),
|
||||
}
|
||||
p := PathForOutput(ctx, "system/framework/boot.art")
|
||||
p := PathForOutput(ctx, "system/framework").Join(ctx, "boot.art")
|
||||
p2 := p.InSameDir(ctx, "oat", "arm", "boot.vdex")
|
||||
fmt.Println(p, p2)
|
||||
fmt.Println(p.Rel(), p2.Rel())
|
||||
|
||||
// Output:
|
||||
// out/system/framework/boot.art out/system/framework/oat/arm/boot.vdex
|
||||
// boot.art oat/arm/boot.vdex
|
||||
}
|
||||
|
@@ -64,7 +64,7 @@ func TestDexPreopt(t *testing.T) {
|
||||
{android.PathForOutput(ctx, "test/oat/arm/package.vdex"), "/system/app/test/oat/arm/test.vdex"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(rule.Installs(), wantInstalls) {
|
||||
if rule.Installs().String() != wantInstalls.String() {
|
||||
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func TestDexPreoptSystemOther(t *testing.T) {
|
||||
{android.PathForOutput(ctx, "test/oat/arm/package.vdex"), "/system_other/app/test/oat/arm/test.vdex"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(rule.Installs(), wantInstalls) {
|
||||
if rule.Installs().String() != wantInstalls.String() {
|
||||
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func TestDexPreoptProfile(t *testing.T) {
|
||||
{android.PathForOutput(ctx, "test/oat/arm/package.vdex"), "/system/app/test/oat/arm/test.vdex"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(rule.Installs(), wantInstalls) {
|
||||
if rule.Installs().String() != wantInstalls.String() {
|
||||
t.Errorf("\nwant installs:\n %v\ngot:\n %v", wantInstalls, rule.Installs())
|
||||
}
|
||||
}
|
||||
|
@@ -114,7 +114,7 @@ func defaultBootImageConfig(ctx android.PathContext) bootImageConfig {
|
||||
|
||||
for _, target := range ctx.Config().Targets[android.Android] {
|
||||
images[target.Arch.ArchType] = dir.Join(ctx,
|
||||
"system/framework", target.Arch.ArchType.String(), "boot.art")
|
||||
"system/framework", target.Arch.ArchType.String()).Join(ctx, "boot.art")
|
||||
}
|
||||
|
||||
return bootImageConfig{
|
||||
|
Reference in New Issue
Block a user