From ea1cd5ff3029315c1f89b98b820ceeebfba0e4df Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 21 Aug 2024 14:28:06 +0200 Subject: 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. --- pkg/build/linux.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'pkg/build/linux.go') 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 != "" { -- cgit mrf-deployment