Merge "Add ABFS (Android Build Filesystem) configuration option to Soong" into main
This commit is contained in:
@@ -1195,6 +1195,10 @@ func (c *config) UseGoma() bool {
|
|||||||
return Bool(c.productVariables.UseGoma)
|
return Bool(c.productVariables.UseGoma)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) UseABFS() bool {
|
||||||
|
return Bool(c.productVariables.UseABFS)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *config) UseRBE() bool {
|
func (c *config) UseRBE() bool {
|
||||||
return Bool(c.productVariables.UseRBE)
|
return Bool(c.productVariables.UseRBE)
|
||||||
}
|
}
|
||||||
|
@@ -294,6 +294,7 @@ type ProductVariables struct {
|
|||||||
HostStaticBinaries *bool `json:",omitempty"`
|
HostStaticBinaries *bool `json:",omitempty"`
|
||||||
Binder32bit *bool `json:",omitempty"`
|
Binder32bit *bool `json:",omitempty"`
|
||||||
UseGoma *bool `json:",omitempty"`
|
UseGoma *bool `json:",omitempty"`
|
||||||
|
UseABFS *bool `json:",omitempty"`
|
||||||
UseRBE *bool `json:",omitempty"`
|
UseRBE *bool `json:",omitempty"`
|
||||||
UseRBEJAVAC *bool `json:",omitempty"`
|
UseRBEJAVAC *bool `json:",omitempty"`
|
||||||
UseRBER8 *bool `json:",omitempty"`
|
UseRBER8 *bool `json:",omitempty"`
|
||||||
|
@@ -211,9 +211,38 @@ func checkRAM(ctx Context, config Config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func abfsBuildStarted(ctx Context, config Config) {
|
||||||
|
abfsBox := config.PrebuiltBuildTool("abfsbox")
|
||||||
|
cmdArgs := []string{"build-started", "--"}
|
||||||
|
cmdArgs = append(cmdArgs, config.Arguments()...)
|
||||||
|
cmd := Command(ctx, config, "abfsbox", abfsBox, cmdArgs...)
|
||||||
|
cmd.Sandbox = noSandbox
|
||||||
|
cmd.RunAndPrintOrFatal()
|
||||||
|
}
|
||||||
|
|
||||||
|
func abfsBuildFinished(ctx Context, config Config, finished bool) {
|
||||||
|
var errMsg string
|
||||||
|
if !finished {
|
||||||
|
errMsg = "build was interrupted"
|
||||||
|
}
|
||||||
|
abfsBox := config.PrebuiltBuildTool("abfsbox")
|
||||||
|
cmdArgs := []string{"build-finished", "-e", errMsg, "--"}
|
||||||
|
cmdArgs = append(cmdArgs, config.Arguments()...)
|
||||||
|
cmd := Command(ctx, config, "abfsbox", abfsBox, cmdArgs...)
|
||||||
|
cmd.RunAndPrintOrFatal()
|
||||||
|
}
|
||||||
|
|
||||||
// Build the tree. Various flags in `config` govern which components of
|
// Build the tree. Various flags in `config` govern which components of
|
||||||
// the build to run.
|
// the build to run.
|
||||||
func Build(ctx Context, config Config) {
|
func Build(ctx Context, config Config) {
|
||||||
|
done := false
|
||||||
|
if config.UseABFS() {
|
||||||
|
abfsBuildStarted(ctx, config)
|
||||||
|
defer func() {
|
||||||
|
abfsBuildFinished(ctx, config, done)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Verboseln("Starting build with args:", config.Arguments())
|
ctx.Verboseln("Starting build with args:", config.Arguments())
|
||||||
ctx.Verboseln("Environment:", config.Environment().Environ())
|
ctx.Verboseln("Environment:", config.Environment().Environ())
|
||||||
|
|
||||||
@@ -351,6 +380,7 @@ func Build(ctx Context, config Config) {
|
|||||||
if what&RunDistActions != 0 {
|
if what&RunDistActions != 0 {
|
||||||
runDistActions(ctx, config)
|
runDistActions(ctx, config)
|
||||||
}
|
}
|
||||||
|
done = true
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateBuildIdDir(ctx Context, config Config) {
|
func updateBuildIdDir(ctx Context, config Config) {
|
||||||
|
@@ -1270,9 +1270,25 @@ func (c *configImpl) canSupportRBE() bool {
|
|||||||
if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") {
|
if !c.StubbyExists() && strings.Contains(authType, "use_google_prod_creds") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if c.UseABFS() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) UseABFS() bool {
|
||||||
|
if v, ok := c.environ.Get("NO_ABFS"); ok {
|
||||||
|
v = strings.ToLower(strings.TrimSpace(v))
|
||||||
|
if v == "true" || v == "1" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abfsBox := c.PrebuiltBuildTool("abfsbox")
|
||||||
|
err := exec.Command(abfsBox, "hash", srcDirFileCheck).Run()
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) UseRBE() bool {
|
func (c *configImpl) UseRBE() bool {
|
||||||
// These alternate modes of running Soong do not use RBE / reclient.
|
// These alternate modes of running Soong do not use RBE / reclient.
|
||||||
if c.Queryview() || c.JsonModuleGraph() {
|
if c.Queryview() || c.JsonModuleGraph() {
|
||||||
@@ -1585,6 +1601,23 @@ func (c *configImpl) HostPrebuiltTag() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) KatiBin() string {
|
||||||
|
binName := "ckati"
|
||||||
|
if c.UseABFS() {
|
||||||
|
binName = "ckati-wrap"
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.PrebuiltBuildTool(binName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) NinjaBin() string {
|
||||||
|
binName := "ninja"
|
||||||
|
if c.UseABFS() {
|
||||||
|
binName = "ninjago"
|
||||||
|
}
|
||||||
|
return c.PrebuiltBuildTool(binName)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *configImpl) PrebuiltBuildTool(name string) string {
|
func (c *configImpl) PrebuiltBuildTool(name string) string {
|
||||||
if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
|
if v, ok := c.environ.Get("SANITIZE_HOST"); ok {
|
||||||
if sanitize := strings.Fields(v); inList("address", sanitize) {
|
if sanitize := strings.Fields(v); inList("address", sanitize) {
|
||||||
|
@@ -93,7 +93,7 @@ func dumpMakeVars(ctx Context, config Config, goals, vars []string, write_soong_
|
|||||||
defer tool.Finish()
|
defer tool.Finish()
|
||||||
|
|
||||||
cmd := Command(ctx, config, "dumpvars",
|
cmd := Command(ctx, config, "dumpvars",
|
||||||
config.PrebuiltBuildTool("ckati"),
|
config.KatiBin(),
|
||||||
"-f", "build/make/core/config.mk",
|
"-f", "build/make/core/config.mk",
|
||||||
"--color_warnings",
|
"--color_warnings",
|
||||||
"--kati_stats",
|
"--kati_stats",
|
||||||
|
@@ -84,7 +84,7 @@ func writeValueIfChanged(ctx Context, config Config, dir string, filename string
|
|||||||
// arguments, and a custom function closure to mutate the environment Kati runs
|
// arguments, and a custom function closure to mutate the environment Kati runs
|
||||||
// in.
|
// in.
|
||||||
func runKati(ctx Context, config Config, extraSuffix string, args []string, envFunc func(*Environment)) {
|
func runKati(ctx Context, config Config, extraSuffix string, args []string, envFunc func(*Environment)) {
|
||||||
executable := config.PrebuiltBuildTool("ckati")
|
executable := config.KatiBin()
|
||||||
// cKati arguments.
|
// cKati arguments.
|
||||||
args = append([]string{
|
args = append([]string{
|
||||||
// Instead of executing commands directly, generate a Ninja file.
|
// Instead of executing commands directly, generate a Ninja file.
|
||||||
|
@@ -49,7 +49,7 @@ func runNinjaForBuild(ctx Context, config Config) {
|
|||||||
nr := status.NewNinjaReader(ctx, ctx.Status.StartTool(), fifo)
|
nr := status.NewNinjaReader(ctx, ctx.Status.StartTool(), fifo)
|
||||||
defer nr.Close()
|
defer nr.Close()
|
||||||
|
|
||||||
executable := config.PrebuiltBuildTool("ninja")
|
executable := config.NinjaBin()
|
||||||
args := []string{
|
args := []string{
|
||||||
"-d", "keepdepfile",
|
"-d", "keepdepfile",
|
||||||
"-d", "keeprsp",
|
"-d", "keeprsp",
|
||||||
|
@@ -200,6 +200,9 @@ func (c *Cmd) wrapSandbox() {
|
|||||||
// Only log important warnings / errors
|
// Only log important warnings / errors
|
||||||
"-q",
|
"-q",
|
||||||
}
|
}
|
||||||
|
if c.config.UseABFS() {
|
||||||
|
sandboxArgs = append(sandboxArgs, "-B", "{ABFS_DIR}")
|
||||||
|
}
|
||||||
|
|
||||||
// Mount srcDir RW allowlists as Read-Write
|
// Mount srcDir RW allowlists as Read-Write
|
||||||
if len(c.config.sandboxConfig.SrcDirRWAllowlist()) > 0 && !c.config.sandboxConfig.SrcDirIsRO() {
|
if len(c.config.sandboxConfig.SrcDirRWAllowlist()) > 0 && !c.config.sandboxConfig.SrcDirIsRO() {
|
||||||
|
@@ -661,7 +661,7 @@ func runSoong(ctx Context, config Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ninjaArgs = append(ninjaArgs, targets...)
|
ninjaArgs = append(ninjaArgs, targets...)
|
||||||
ninjaCmd := config.PrebuiltBuildTool("ninja")
|
ninjaCmd := config.NinjaBin()
|
||||||
if config.useN2 {
|
if config.useN2 {
|
||||||
ninjaCmd = config.PrebuiltBuildTool("n2")
|
ninjaCmd = config.PrebuiltBuildTool("n2")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user