Sandbox soong_build by changing to root directory

This relands I12a0f907753fefd1997ab8b4ea2ac331234093cf along with
a fix to blueprint for absolute paths.

Store the current working directory and then change to the root
directory so that all file accesses must go through helpers in
the android package that properly track dependencies.

Change-Id: I24ac485677aa102eec1a2521d16820da6ee1ae77
Fixes: 146437378
Test: m checkbuild
Test: m OUT_DIR=/tmp/out nothing
This commit is contained in:
Colin Cross
2020-01-11 01:11:46 +00:00
parent 47e4f9e1e8
commit 988414c2cf
23 changed files with 208 additions and 130 deletions

View File

@@ -16,7 +16,6 @@ package cc
import (
"fmt"
"os"
"path/filepath"
"strings"
@@ -255,16 +254,8 @@ func processHeadersWithVersioner(ctx android.ModuleContext, srcDir, outDir andro
depsPath := android.PathForSource(ctx, "bionic/libc/versioner-dependencies")
depsGlob := ctx.Glob(filepath.Join(depsPath.String(), "**/*"), nil)
for i, path := range depsGlob {
fileInfo, err := os.Lstat(path.String())
if err != nil {
ctx.ModuleErrorf("os.Lstat(%q) failed: %s", path.String, err)
}
if fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink {
dest, err := os.Readlink(path.String())
if err != nil {
ctx.ModuleErrorf("os.Readlink(%q) failed: %s",
path.String, err)
}
if ctx.IsSymlink(path) {
dest := ctx.Readlink(path)
// Additional .. to account for the symlink itself.
depsGlob[i] = android.PathForSource(
ctx, filepath.Clean(filepath.Join(path.String(), "..", dest)))