diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-08-21 14:28:06 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-08-22 09:49:03 +0000 |
| commit | ea1cd5ff3029315c1f89b98b820ceeebfba0e4df (patch) | |
| tree | ead4b8475abce2fecb5a30f3cc1d6d62a2bac982 /pkg/build/linux.go | |
| parent | aa99fc3349e97ea596c31624efde306de4136241 (diff) | |
pkg/build: introduce the build jobs parameter
This parameter defines the number of cores dedicated to the kernel build
process. By default, it's equal to the number of available CPUs.
Diffstat (limited to 'pkg/build/linux.go')
| -rw-r--r-- | pkg/build/linux.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pkg/build/linux.go b/pkg/build/linux.go index 4069e0202..b68a87bc1 100644 --- a/pkg/build/linux.go +++ b/pkg/build/linux.go @@ -142,7 +142,7 @@ func (linux) createImage(params Params, kernelPath string) error { } func (linux) clean(kernelDir, targetArch string) error { - return runMakeImpl(targetArch, "", "", "", kernelDir, []string{"distclean"}) + return runMakeImpl(targetArch, "", "", "", kernelDir, runtime.NumCPU(), []string{"distclean"}) } func (linux) writeFile(file string, data []byte) error { @@ -152,9 +152,9 @@ func (linux) writeFile(file string, data []byte) error { return osutil.SandboxChown(file) } -func runMakeImpl(arch, compiler, linker, ccache, kernelDir string, extraArgs []string) error { +func runMakeImpl(arch, compiler, linker, ccache, kernelDir string, jobs int, extraArgs []string) error { target := targets.Get(targets.Linux, arch) - args := LinuxMakeArgs(target, compiler, linker, ccache, "") + args := LinuxMakeArgs(target, compiler, linker, ccache, "", jobs) args = append(args, extraArgs...) cmd := osutil.Command("make", args...) if err := osutil.Sandbox(cmd, true, true); err != nil { @@ -179,12 +179,13 @@ func runMakeImpl(arch, compiler, linker, ccache, kernelDir string, extraArgs []s } func runMake(params Params, extraArgs ...string) error { - return runMakeImpl(params.TargetArch, params.Compiler, params.Linker, params.Ccache, params.KernelDir, extraArgs) + return runMakeImpl(params.TargetArch, params.Compiler, params.Linker, params.Ccache, + params.KernelDir, params.BuildJobs, extraArgs) } -func LinuxMakeArgs(target *targets.Target, compiler, linker, ccache, buildDir string) []string { +func LinuxMakeArgs(target *targets.Target, compiler, linker, ccache, buildDir string, jobs int) []string { args := []string{ - "-j", fmt.Sprint(runtime.NumCPU()), + "-j", fmt.Sprint(jobs), "ARCH=" + target.KernelArch, } if target.Triple != "" { |
