Sandbox soong_build by changing to root directory
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. Fixes: 146437378 Test: m checkbuild Change-Id: I12a0f907753fefd1997ab8b4ea2ac331234093cf
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