Merge "Make bazel action symlinks absolute paths" am: 17acadbcb0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1880827 Change-Id: I108214d19baa07105f922b0a2e3f8b0eeb1eaf0d
This commit is contained in:
@@ -245,9 +245,9 @@ func AqueryBuildStatements(aqueryJsonProto []byte) ([]BuildStatement, error) {
|
|||||||
out := outputPaths[0]
|
out := outputPaths[0]
|
||||||
outDir := proptools.ShellEscapeIncludingSpaces(filepath.Dir(out))
|
outDir := proptools.ShellEscapeIncludingSpaces(filepath.Dir(out))
|
||||||
out = proptools.ShellEscapeIncludingSpaces(out)
|
out = proptools.ShellEscapeIncludingSpaces(out)
|
||||||
in := proptools.ShellEscapeIncludingSpaces(inputPaths[0])
|
in := filepath.Join("$PWD", proptools.ShellEscapeIncludingSpaces(inputPaths[0]))
|
||||||
// Use hard links, because some soong actions expect real files (for example, `cp -d`).
|
// Use absolute paths, because some soong actions don't play well with relative paths (for example, `cp -d`).
|
||||||
buildStatement.Command = fmt.Sprintf("mkdir -p %[1]s && rm -f %[2]s && ln -f %[3]s %[2]s", outDir, out, in)
|
buildStatement.Command = fmt.Sprintf("mkdir -p %[1]s && rm -f %[2]s && ln -sf %[3]s %[2]s", outDir, out, in)
|
||||||
buildStatement.SymlinkPaths = outputPaths[:]
|
buildStatement.SymlinkPaths = outputPaths[:]
|
||||||
} else if len(actionEntry.Arguments) < 1 {
|
} else if len(actionEntry.Arguments) < 1 {
|
||||||
return nil, fmt.Errorf("received action with no command: [%v]", buildStatement)
|
return nil, fmt.Errorf("received action with no command: [%v]", buildStatement)
|
||||||
|
@@ -859,7 +859,7 @@ func TestSimpleSymlink(t *testing.T) {
|
|||||||
BuildStatement{
|
BuildStatement{
|
||||||
Command: "mkdir -p one/symlink_subdir && " +
|
Command: "mkdir -p one/symlink_subdir && " +
|
||||||
"rm -f one/symlink_subdir/symlink && " +
|
"rm -f one/symlink_subdir/symlink && " +
|
||||||
"ln -f one/file_subdir/file one/symlink_subdir/symlink",
|
"ln -sf $PWD/one/file_subdir/file one/symlink_subdir/symlink",
|
||||||
InputPaths: []string{"one/file_subdir/file"},
|
InputPaths: []string{"one/file_subdir/file"},
|
||||||
OutputPaths: []string{"one/symlink_subdir/symlink"},
|
OutputPaths: []string{"one/symlink_subdir/symlink"},
|
||||||
SymlinkPaths: []string{"one/symlink_subdir/symlink"},
|
SymlinkPaths: []string{"one/symlink_subdir/symlink"},
|
||||||
@@ -923,14 +923,14 @@ func TestSymlinkQuotesPaths(t *testing.T) {
|
|||||||
BuildStatement{
|
BuildStatement{
|
||||||
Command: "mkdir -p 'one/symlink subdir' && " +
|
Command: "mkdir -p 'one/symlink subdir' && " +
|
||||||
"rm -f 'one/symlink subdir/symlink' && " +
|
"rm -f 'one/symlink subdir/symlink' && " +
|
||||||
"ln -f 'one/file subdir/file' 'one/symlink subdir/symlink'",
|
"ln -sf $PWD/'one/file subdir/file' 'one/symlink subdir/symlink'",
|
||||||
InputPaths: []string{"one/file subdir/file"},
|
InputPaths: []string{"one/file subdir/file"},
|
||||||
OutputPaths: []string{"one/symlink subdir/symlink"},
|
OutputPaths: []string{"one/symlink subdir/symlink"},
|
||||||
SymlinkPaths: []string{"one/symlink subdir/symlink"},
|
SymlinkPaths: []string{"one/symlink subdir/symlink"},
|
||||||
Mnemonic: "SolibSymlink",
|
Mnemonic: "SolibSymlink",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
assertBuildStatements(t, actual, expectedBuildStatements)
|
assertBuildStatements(t, expectedBuildStatements, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSymlinkMultipleInputs(t *testing.T) {
|
func TestSymlinkMultipleInputs(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user