Merge changes from topics "nested-nsjail", "ro-api-surfaces-dir"
* changes: Special-case Soong finder to look in out/api_surfaces nsjail support verification should respect BUILD_BROKEN* flag for SrcDir
This commit is contained in:
@@ -243,6 +243,11 @@ func runApiBp2build(configuration android.Config, ctx *android.Context, extraNin
|
|||||||
// Exclude all src BUILD files
|
// Exclude all src BUILD files
|
||||||
excludes = append(excludes, apiBuildFileExcludes()...)
|
excludes = append(excludes, apiBuildFileExcludes()...)
|
||||||
|
|
||||||
|
// Android.bp files for api surfaces are mounted to out/, but out/ should not be a
|
||||||
|
// dep for api_bp2build.
|
||||||
|
// Otherwise api_bp2build will be run every single time
|
||||||
|
excludes = append(excludes, configuration.OutDir())
|
||||||
|
|
||||||
// Create the symlink forest
|
// Create the symlink forest
|
||||||
symlinkDeps := bp2build.PlantSymlinkForest(
|
symlinkDeps := bp2build.PlantSymlinkForest(
|
||||||
configuration.IsEnvTrue("BP2BUILD_VERBOSE"),
|
configuration.IsEnvTrue("BP2BUILD_VERBOSE"),
|
||||||
|
@@ -82,6 +82,7 @@ type configImpl struct {
|
|||||||
skipSoong bool
|
skipSoong bool
|
||||||
skipNinja bool
|
skipNinja bool
|
||||||
skipSoongTests bool
|
skipSoongTests bool
|
||||||
|
searchApiDir bool // Scan the Android.bp files generated in out/api_surfaces
|
||||||
|
|
||||||
// From the product config
|
// From the product config
|
||||||
katiArgs []string
|
katiArgs []string
|
||||||
@@ -738,6 +739,8 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|||||||
c.bazelDevMode = true
|
c.bazelDevMode = true
|
||||||
} else if arg == "--bazel-mode-staging" {
|
} else if arg == "--bazel-mode-staging" {
|
||||||
c.bazelStagingMode = true
|
c.bazelStagingMode = true
|
||||||
|
} else if arg == "--search-api-dir" {
|
||||||
|
c.searchApiDir = true
|
||||||
} else if len(arg) > 0 && arg[0] == '-' {
|
} else if len(arg) > 0 && arg[0] == '-' {
|
||||||
parseArgNum := func(def int) int {
|
parseArgNum := func(def int) int {
|
||||||
if len(arg) > 2 {
|
if len(arg) > 2 {
|
||||||
@@ -904,6 +907,10 @@ func (c *configImpl) SoongOutDir() string {
|
|||||||
return filepath.Join(c.OutDir(), "soong")
|
return filepath.Join(c.OutDir(), "soong")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) ApiSurfacesOutDir() string {
|
||||||
|
return filepath.Join(c.OutDir(), "api_surfaces")
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) PrebuiltOS() string {
|
func (c *configImpl) PrebuiltOS() string {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "linux":
|
case "linux":
|
||||||
|
@@ -63,7 +63,7 @@ func NewSourceFinder(ctx Context, config Config) (f *finder.Finder) {
|
|||||||
// Set up configuration parameters for the Finder cache.
|
// Set up configuration parameters for the Finder cache.
|
||||||
cacheParams := finder.CacheParams{
|
cacheParams := finder.CacheParams{
|
||||||
WorkingDirectory: dir,
|
WorkingDirectory: dir,
|
||||||
RootDirs: []string{"."},
|
RootDirs: androidBpSearchDirs(config),
|
||||||
FollowSymlinks: config.environ.IsEnvTrue("ALLOW_BP_UNDER_SYMLINKS"),
|
FollowSymlinks: config.environ.IsEnvTrue("ALLOW_BP_UNDER_SYMLINKS"),
|
||||||
ExcludeDirs: []string{".git", ".repo"},
|
ExcludeDirs: []string{".git", ".repo"},
|
||||||
PruneFiles: pruneFiles,
|
PruneFiles: pruneFiles,
|
||||||
@@ -100,6 +100,15 @@ func NewSourceFinder(ctx Context, config Config) (f *finder.Finder) {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func androidBpSearchDirs(config Config) []string {
|
||||||
|
dirs := []string{"."} // always search from root of source tree.
|
||||||
|
if config.searchApiDir {
|
||||||
|
// Search in out/api_surfaces
|
||||||
|
dirs = append(dirs, config.ApiSurfacesOutDir())
|
||||||
|
}
|
||||||
|
return dirs
|
||||||
|
}
|
||||||
|
|
||||||
// Finds the list of Bazel-related files (BUILD, WORKSPACE and Starlark) in the tree.
|
// Finds the list of Bazel-related files (BUILD, WORKSPACE and Starlark) in the tree.
|
||||||
func findBazelFiles(entries finder.DirEntries) (dirNames []string, fileNames []string) {
|
func findBazelFiles(entries finder.DirEntries) (dirNames []string, fileNames []string) {
|
||||||
matches := []string{}
|
matches := []string{}
|
||||||
|
@@ -27,6 +27,15 @@ func (sc *SandboxConfig) SrcDirIsRO() bool {
|
|||||||
return sc.srcDirIsRO
|
return sc.srcDirIsRO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the mount flag of the source directory in the nsjail command
|
||||||
|
func (sc *SandboxConfig) SrcDirMountFlag() string {
|
||||||
|
ret := "-B" // Read-write
|
||||||
|
if sc.SrcDirIsRO() {
|
||||||
|
ret = "-R" // Read-only
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (sc *SandboxConfig) SetSrcDirRWAllowlist(allowlist []string) {
|
func (sc *SandboxConfig) SetSrcDirRWAllowlist(allowlist []string) {
|
||||||
sc.srcDirRWAllowlist = allowlist
|
sc.srcDirRWAllowlist = allowlist
|
||||||
}
|
}
|
||||||
|
@@ -101,7 +101,7 @@ func (c *Cmd) sandboxSupported() bool {
|
|||||||
// srcDir is /tmp/.* in integration tests, which is a child dir of /tmp
|
// srcDir is /tmp/.* in integration tests, which is a child dir of /tmp
|
||||||
// nsjail throws an error if a child dir is mounted before its parent
|
// nsjail throws an error if a child dir is mounted before its parent
|
||||||
"-B", "/tmp",
|
"-B", "/tmp",
|
||||||
"-B", sandboxConfig.srcDir,
|
c.config.sandboxConfig.SrcDirMountFlag(), sandboxConfig.srcDir,
|
||||||
"-B", sandboxConfig.outDir,
|
"-B", sandboxConfig.outDir,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,13 +148,6 @@ func (c *Cmd) sandboxSupported() bool {
|
|||||||
func (c *Cmd) wrapSandbox() {
|
func (c *Cmd) wrapSandbox() {
|
||||||
wd, _ := os.Getwd()
|
wd, _ := os.Getwd()
|
||||||
|
|
||||||
var srcDirMountFlag string
|
|
||||||
if c.config.sandboxConfig.SrcDirIsRO() {
|
|
||||||
srcDirMountFlag = "-R"
|
|
||||||
} else {
|
|
||||||
srcDirMountFlag = "-B" //Read-Write
|
|
||||||
}
|
|
||||||
|
|
||||||
sandboxArgs := []string{
|
sandboxArgs := []string{
|
||||||
// The executable to run
|
// The executable to run
|
||||||
"-x", c.Path,
|
"-x", c.Path,
|
||||||
@@ -195,7 +188,7 @@ func (c *Cmd) wrapSandbox() {
|
|||||||
"-B", "/tmp",
|
"-B", "/tmp",
|
||||||
|
|
||||||
// Mount source
|
// Mount source
|
||||||
srcDirMountFlag, sandboxConfig.srcDir,
|
c.config.sandboxConfig.SrcDirMountFlag(), sandboxConfig.srcDir,
|
||||||
|
|
||||||
//Mount out dir as read-write
|
//Mount out dir as read-write
|
||||||
"-B", sandboxConfig.outDir,
|
"-B", sandboxConfig.outDir,
|
||||||
|
Reference in New Issue
Block a user