Enable parallelCompile since golang is now >= 1.9 am: ad7bcc7b50 am: 0ce4909fd2

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2469723

Change-Id: I0c1435a7800432bef5365ec506e9d88f9afb1691
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Kevin Dagostino 2023-03-06 18:34:50 +00:00 committed by Automerger Merge Worker
commit bcdf8aceda

View file

@ -16,7 +16,6 @@ package bootstrap
import ( import (
"fmt" "fmt"
"go/build"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
@ -33,21 +32,15 @@ var (
pluginGenSrcCmd = pctx.StaticVariable("pluginGenSrcCmd", filepath.Join("$ToolDir", "loadplugins")) pluginGenSrcCmd = pctx.StaticVariable("pluginGenSrcCmd", filepath.Join("$ToolDir", "loadplugins"))
parallelCompile = pctx.StaticVariable("parallelCompile", func() string { parallelCompile = pctx.StaticVariable("parallelCompile", func() string {
// Parallel compilation is only supported on >= go1.9 numCpu := runtime.NumCPU()
for _, r := range build.Default.ReleaseTags { // This will cause us to recompile all go programs if the
if r == "go1.9" { // number of cpus changes. We don't get a lot of benefit from
numCpu := runtime.NumCPU() // higher values, so cap this to make it cheaper to move trees
// This will cause us to recompile all go programs if the // between machines.
// number of cpus changes. We don't get a lot of benefit from if numCpu > 8 {
// higher values, so cap this to make it cheaper to move trees numCpu = 8
// between machines.
if numCpu > 8 {
numCpu = 8
}
return fmt.Sprintf("-c %d", numCpu)
}
} }
return "" return fmt.Sprintf("-c %d", numCpu)
}()) }())
compile = pctx.StaticRule("compile", compile = pctx.StaticRule("compile",