Make bazel action symlinks absolute paths

hardlinks are incompatible with sandboxing
relative links are incopatible with Soong's use of `cp -d`

Test: build/bazel/ci/mixed_libc.sh
Change-Id: I8c776cda6a27c680c51466d9a7af1b499f2f566d
This commit is contained in:
Liz Kammer
2021-11-04 10:56:13 -04:00
parent c24f0855d9
commit c773778bfe
2 changed files with 6 additions and 6 deletions

View File

@@ -245,9 +245,9 @@ func AqueryBuildStatements(aqueryJsonProto []byte) ([]BuildStatement, error) {
out := outputPaths[0]
outDir := proptools.ShellEscapeIncludingSpaces(filepath.Dir(out))
out = proptools.ShellEscapeIncludingSpaces(out)
in := proptools.ShellEscapeIncludingSpaces(inputPaths[0])
// Use hard links, because some soong actions expect real files (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)
in := filepath.Join("$PWD", proptools.ShellEscapeIncludingSpaces(inputPaths[0]))
// 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 -sf %[3]s %[2]s", outDir, out, in)
buildStatement.SymlinkPaths = outputPaths[:]
} else if len(actionEntry.Arguments) < 1 {
return nil, fmt.Errorf("received action with no command: [%v]", buildStatement)