From e5677eab7e358f2fd4ec7b3899d4be4e323c544a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Apr 2026 19:15:09 +0000 Subject: [PATCH] Default build menu jobs to CPU count --- contrib/agrarian-build-menu.sh | 13 ++++++++++++- doc/build-menu.md | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/contrib/agrarian-build-menu.sh b/contrib/agrarian-build-menu.sh index 9a95533e..b6050cf3 100755 --- a/contrib/agrarian-build-menu.sh +++ b/contrib/agrarian-build-menu.sh @@ -3,7 +3,6 @@ set -euo pipefail REPO_URL="${REPO_URL:-https://github.com/pacificao/agrarian.git}" WORKDIR="${WORKDIR:-$HOME/agrarian}" -JOBS="${JOBS:-1}" HOST_WIN64="${HOST_WIN64:-x86_64-w64-mingw32}" MENU_CHOICE="" @@ -21,6 +20,18 @@ if [[ -z "${BRANCH:-}" ]]; then fi BRANCH="${BRANCH:-main}" +detect_build_jobs() { + if command -v nproc >/dev/null 2>&1; then + nproc + elif command -v getconf >/dev/null 2>&1; then + getconf _NPROCESSORS_ONLN + else + echo 1 + fi +} + +JOBS="${JOBS:-$(detect_build_jobs)}" + if [[ "${EUID:-$(id -u)}" -eq 0 && "${ALLOW_ROOT_BUILD_MENU:-0}" != "1" ]]; then cat >&2 < WORKDIR=$HOME/agrarian - JOBS=1 + JOBS= Example: