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:
@@ -16,13 +16,13 @@ package android
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"text/scanner"
|
||||
|
||||
"github.com/google/blueprint"
|
||||
"github.com/google/blueprint/pathtools"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
@@ -91,7 +91,8 @@ type EarlyModuleContext interface {
|
||||
|
||||
Glob(globPattern string, excludes []string) Paths
|
||||
GlobFiles(globPattern string, excludes []string) Paths
|
||||
Fs() pathtools.FileSystem
|
||||
IsSymlink(path Path) bool
|
||||
Readlink(path Path) string
|
||||
}
|
||||
|
||||
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
|
||||
@@ -1172,6 +1173,22 @@ func (e *earlyModuleContext) GlobFiles(globPattern string, excludes []string) Pa
|
||||
return pathsForModuleSrcFromFullPath(e, ret, false)
|
||||
}
|
||||
|
||||
func (b *earlyModuleContext) IsSymlink(path Path) bool {
|
||||
fileInfo, err := b.config.fs.Lstat(path.String())
|
||||
if err != nil {
|
||||
b.ModuleErrorf("os.Lstat(%q) failed: %s", path.String(), err)
|
||||
}
|
||||
return fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink
|
||||
}
|
||||
|
||||
func (b *earlyModuleContext) Readlink(path Path) string {
|
||||
dest, err := b.config.fs.Readlink(path.String())
|
||||
if err != nil {
|
||||
b.ModuleErrorf("os.Readlink(%q) failed: %s", path.String(), err)
|
||||
}
|
||||
return dest
|
||||
}
|
||||
|
||||
func (e *earlyModuleContext) Module() Module {
|
||||
module, _ := e.EarlyModuleContext.Module().(Module)
|
||||
return module
|
||||
|
Reference in New Issue
Block a user