Add USE_RBE support to soong.
Test: Built aosp_arm-user with and without USE_RBE. USE_RBE uses a proxy script in place of rewrapper. Change-Id: I5bf008a940513872d70b5b215bd6209f759826ae
This commit is contained in:
parent
2ca7a8835e
commit
bbf2567cc1
7 changed files with 88 additions and 1 deletions
|
@ -748,6 +748,10 @@ func (c *config) UseGoma() bool {
|
||||||
return Bool(c.productVariables.UseGoma)
|
return Bool(c.productVariables.UseGoma)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *config) UseRBE() bool {
|
||||||
|
return Bool(c.productVariables.UseRBE)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *config) RunErrorProne() bool {
|
func (c *config) RunErrorProne() bool {
|
||||||
return c.IsEnvTrue("RUN_ERROR_PRONE")
|
return c.IsEnvTrue("RUN_ERROR_PRONE")
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,6 +206,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"`
|
||||||
|
UseRBE *bool `json:",omitempty"`
|
||||||
Debuggable *bool `json:",omitempty"`
|
Debuggable *bool `json:",omitempty"`
|
||||||
Eng *bool `json:",omitempty"`
|
Eng *bool `json:",omitempty"`
|
||||||
Treble_linker_namespaces *bool `json:",omitempty"`
|
Treble_linker_namespaces *bool `json:",omitempty"`
|
||||||
|
|
|
@ -52,6 +52,7 @@ bootstrap_go_package {
|
||||||
"ninja.go",
|
"ninja.go",
|
||||||
"path.go",
|
"path.go",
|
||||||
"proc_sync.go",
|
"proc_sync.go",
|
||||||
|
"rbe.go",
|
||||||
"signal.go",
|
"signal.go",
|
||||||
"soong.go",
|
"soong.go",
|
||||||
"test_build.go",
|
"test_build.go",
|
||||||
|
|
|
@ -161,6 +161,11 @@ func Build(ctx Context, config Config, what int) {
|
||||||
startGoma(ctx, config)
|
startGoma(ctx, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.StartRBE() {
|
||||||
|
// Ensure RBE proxy is started
|
||||||
|
startRBE(ctx, config)
|
||||||
|
}
|
||||||
|
|
||||||
if what&BuildProductConfig != 0 {
|
if what&BuildProductConfig != 0 {
|
||||||
// Run make for product config
|
// Run make for product config
|
||||||
runMakeProductConfig(ctx, config)
|
runMakeProductConfig(ctx, config)
|
||||||
|
|
|
@ -715,6 +715,30 @@ func (c *configImpl) StartGoma() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) UseRBE() bool {
|
||||||
|
if v, ok := c.environ.Get("USE_RBE"); ok {
|
||||||
|
v = strings.TrimSpace(v)
|
||||||
|
if v != "" && v != "false" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *configImpl) StartRBE() bool {
|
||||||
|
if !c.UseRBE() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if v, ok := c.environ.Get("NOSTART_RBE"); ok {
|
||||||
|
v = strings.TrimSpace(v)
|
||||||
|
if v != "" && v != "false" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// RemoteParallel controls how many remote jobs (i.e., commands which contain
|
// RemoteParallel controls how many remote jobs (i.e., commands which contain
|
||||||
// gomacc) are run in parallel. Note the parallelism of all other jobs is
|
// gomacc) are run in parallel. Note the parallelism of all other jobs is
|
||||||
// still limited by Parallel()
|
// still limited by Parallel()
|
||||||
|
|
|
@ -43,7 +43,7 @@ func runNinja(ctx Context, config Config) {
|
||||||
args = append(args, config.NinjaArgs()...)
|
args = append(args, config.NinjaArgs()...)
|
||||||
|
|
||||||
var parallel int
|
var parallel int
|
||||||
if config.UseGoma() {
|
if config.UseGoma() || config.UseRBE() {
|
||||||
parallel = config.RemoteParallel()
|
parallel = config.RemoteParallel()
|
||||||
} else {
|
} else {
|
||||||
parallel = config.Parallel()
|
parallel = config.Parallel()
|
||||||
|
|
52
ui/build/rbe.go
Normal file
52
ui/build/rbe.go
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
// Copyright 2019 Google Inc. All rights reserved.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
package build
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"android/soong/ui/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
const bootstrapCmd = "bootstrap"
|
||||||
|
const rbeLeastNProcs = 2500
|
||||||
|
const rbeLeastNFiles = 16000
|
||||||
|
|
||||||
|
func startRBE(ctx Context, config Config) {
|
||||||
|
ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap")
|
||||||
|
defer ctx.EndTrace()
|
||||||
|
|
||||||
|
if u := ulimitOrFatal(ctx, config, "-u"); u < rbeLeastNProcs {
|
||||||
|
ctx.Fatalf("max user processes is insufficient: %d; want >= %d.\n", u, rbeLeastNProcs)
|
||||||
|
}
|
||||||
|
if n := ulimitOrFatal(ctx, config, "-n"); n < rbeLeastNFiles {
|
||||||
|
ctx.Fatalf("max open files is insufficient: %d; want >= %d.\n", n, rbeLeastNFiles)
|
||||||
|
}
|
||||||
|
|
||||||
|
var rbeBootstrap string
|
||||||
|
if rbeDir, ok := config.Environment().Get("RBE_DIR"); ok {
|
||||||
|
rbeBootstrap = filepath.Join(rbeDir, bootstrapCmd)
|
||||||
|
} else if home, ok := config.Environment().Get("HOME"); ok {
|
||||||
|
rbeBootstrap = filepath.Join(home, "rbe", bootstrapCmd)
|
||||||
|
} else {
|
||||||
|
ctx.Fatalln("rbe bootstrap not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := Command(ctx, config, "boostrap", rbeBootstrap)
|
||||||
|
|
||||||
|
if output, err := cmd.CombinedOutput(); err != nil {
|
||||||
|
ctx.Fatalf("rbe bootstrap failed with: %v\n%s\n", err, output)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue