summaryrefslogtreecommitdiff
path: root/Toolchain
diff options
context:
space:
mode:
authorKenneth Myhra <kennethmyhra@gmail.com>2023-05-02 21:05:04 +0200
committerJelle Raaijmakers <jelle@gmta.nl>2023-05-07 14:29:25 +0200
commit50413c23266926944c641a99bcd03461e5224a8b (patch)
treebfe06c9f00772e20b870f244b1f4bfa60ea34d5a /Toolchain
parent36c892ae14598f301cfc355087bed474c3823221 (diff)
downloadserenity-50413c23266926944c641a99bcd03461e5224a8b.zip
Toolchain: Replace inline nproc with get_number_of_processing_units()
Diffstat (limited to 'Toolchain')
-rwxr-xr-xToolchain/BuildCMake.sh15
-rwxr-xr-xToolchain/BuildClang.sh10
-rwxr-xr-xToolchain/BuildGDB.sh9
-rwxr-xr-xToolchain/BuildIt.sh9
-rwxr-xr-xToolchain/BuildMold.sh14
-rwxr-xr-xToolchain/BuildPython.sh5
-rwxr-xr-xToolchain/BuildQemu.sh5
-rwxr-xr-xToolchain/BuildRuby.sh5
8 files changed, 17 insertions, 55 deletions
diff --git a/Toolchain/BuildCMake.sh b/Toolchain/BuildCMake.sh
index 4371266010..fabee41c41 100755
--- a/Toolchain/BuildCMake.sh
+++ b/Toolchain/BuildCMake.sh
@@ -14,18 +14,8 @@ PREFIX_DIR="$DIR/Local/cmake"
BUILD_DIR="$DIR/Build/cmake"
TARBALLS_DIR="$DIR/Tarballs"
-NPROC="nproc"
-SYSTEM_NAME="$(uname -s)"
-
-if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
- NPROC="sysctl -n hw.ncpuonline"
-elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
- NPROC="sysctl -n hw.ncpu"
-elif [ "$SYSTEM_NAME" = "Darwin" ]; then
- NPROC="sysctl -n hw.ncpu"
-fi
-
-[ -z "$MAKEJOBS" ] && MAKEJOBS=$($NPROC)
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
check_sha() {
if [ $# -ne 2 ]; then
@@ -36,6 +26,7 @@ check_sha() {
FILE="${1}"
EXPECTED_HASH="${2}"
+ SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "Darwin" ]; then
SEEN_HASH="$(shasum -a 256 "${FILE}" | cut -d " " -f 1)"
else
diff --git a/Toolchain/BuildClang.sh b/Toolchain/BuildClang.sh
index ce0c247e9a..0bfb581b08 100755
--- a/Toolchain/BuildClang.sh
+++ b/Toolchain/BuildClang.sh
@@ -19,7 +19,6 @@ ARCHS="$USERLAND_ARCHS aarch64"
MD5SUM="md5sum"
REALPATH="realpath"
-NPROC="nproc"
INSTALL="install"
SED="sed"
@@ -28,25 +27,20 @@ SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MD5SUM="md5 -q"
REALPATH="readlink -f"
- NPROC="sysctl -n hw.ncpuonline"
export CC=egcc
export CXX=eg++
export LDFLAGS=-Wl,-z,notext
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
REALPATH="grealpath" # GNU coreutils
INSTALL="ginstall" # GNU coreutils
SED="gsed" # GNU sed
fi
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$($NPROC)
-fi
-
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
if [ ! -d "$BUILD" ]; then
mkdir -p "$BUILD"
diff --git a/Toolchain/BuildGDB.sh b/Toolchain/BuildGDB.sh
index fba89b0aa7..d8571d48c3 100755
--- a/Toolchain/BuildGDB.sh
+++ b/Toolchain/BuildGDB.sh
@@ -21,30 +21,25 @@ PREFIX="$DIR/Local/$ARCH-gdb"
echo "Building GDB $GDB_VERSION for $TARGET"
MD5SUM="md5sum"
-NPROC="nproc"
SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpuonline"
export CC=egcc
export CXX=eg++
export with_gmp=/usr/local
export LDFLAGS=-Wl,-z,notext
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
export with_gmp=/usr/local
export with_mpfr=/usr/local
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
fi
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$($NPROC)
-fi
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
buildstep() {
NAME=$1
diff --git a/Toolchain/BuildIt.sh b/Toolchain/BuildIt.sh
index 8147127714..1d0a12fedd 100755
--- a/Toolchain/BuildIt.sh
+++ b/Toolchain/BuildIt.sh
@@ -21,7 +21,6 @@ SYSROOT="$BUILD/Root"
MAKE="make"
MD5SUM="md5sum"
-NPROC="nproc"
REALPATH="realpath"
if command -v ginstall &>/dev/null; then
@@ -41,7 +40,6 @@ export CXXFLAGS="-g0 -O2 -mtune=native"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MAKE=gmake
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpuonline"
REALPATH="readlink -f"
export CC=egcc
export CXX=eg++
@@ -50,12 +48,10 @@ if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MAKE=gmake
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
export with_gmp=/usr/local
export with_mpfr=/usr/local
elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q"
- NPROC="sysctl -n hw.ncpu"
fi
# On at least OpenBSD, the path must exist to call realpath(3) on it
@@ -270,9 +266,8 @@ popd
rm -rf "$PREFIX"
mkdir -p "$PREFIX"
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$($NPROC)
-fi
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
mkdir -p "$DIR/Build/$ARCH"
diff --git a/Toolchain/BuildMold.sh b/Toolchain/BuildMold.sh
index 2ca4a144cc..a7b989d0d2 100755
--- a/Toolchain/BuildMold.sh
+++ b/Toolchain/BuildMold.sh
@@ -11,18 +11,8 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
exit_if_running_as_root "Do not run BuildMold.sh as root, parts of your Toolchain directory will become root-owned"
-NPROC="nproc"
-SYSTEM_NAME="$(uname -s)"
-
-if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
- NPROC="sysctl -n hw.ncpuonline"
-elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
- NPROC="sysctl -n hw.ncpu"
-elif [ "$SYSTEM_NAME" = "Darwin" ]; then
- NPROC="sysctl -n hw.ncpu"
-fi
-
-[ -z "$MAKEJOBS" ] && MAKEJOBS=$($NPROC)
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
mkdir -p "$DIR"/Tarballs
pushd "$DIR"/Tarballs
diff --git a/Toolchain/BuildPython.sh b/Toolchain/BuildPython.sh
index 8166a32835..c0d48c31d0 100755
--- a/Toolchain/BuildPython.sh
+++ b/Toolchain/BuildPython.sh
@@ -41,9 +41,8 @@ pushd "${TARBALLS_DIR}"
fi
popd
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$(nproc)
-fi
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
mkdir -p "${PREFIX_DIR}"
mkdir -p "${BUILD_DIR}"
diff --git a/Toolchain/BuildQemu.sh b/Toolchain/BuildQemu.sh
index 354f619dd6..91d0c4a272 100755
--- a/Toolchain/BuildQemu.sh
+++ b/Toolchain/BuildQemu.sh
@@ -55,9 +55,8 @@ popd
mkdir -p "$PREFIX"
mkdir -p "$DIR/Build/qemu"
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$(nproc)
-fi
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
EXTRA_ARGS=""
if [[ $(uname) == "Darwin" ]]
diff --git a/Toolchain/BuildRuby.sh b/Toolchain/BuildRuby.sh
index 2d2b94765f..1ac2988e89 100755
--- a/Toolchain/BuildRuby.sh
+++ b/Toolchain/BuildRuby.sh
@@ -41,9 +41,8 @@ pushd "${TARBALLS_DIR}"
fi
popd
-if [ -z "$MAKEJOBS" ]; then
- MAKEJOBS=$(nproc)
-fi
+NPROC=$(get_number_of_processing_units)
+[ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
mkdir -p "${PREFIX_DIR}"
mkdir -p "${BUILD_DIR}"