1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

Toolchain: Replace inline nproc with get_number_of_processing_units()

This commit is contained in:
Kenneth Myhra 2023-05-02 21:05:04 +02:00 committed by Jelle Raaijmakers
parent 36c892ae14
commit 50413c2326
8 changed files with 17 additions and 55 deletions

View file

@ -14,18 +14,8 @@ PREFIX_DIR="$DIR/Local/cmake"
BUILD_DIR="$DIR/Build/cmake" BUILD_DIR="$DIR/Build/cmake"
TARBALLS_DIR="$DIR/Tarballs" TARBALLS_DIR="$DIR/Tarballs"
NPROC="nproc" NPROC=$(get_number_of_processing_units)
SYSTEM_NAME="$(uname -s)" [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
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)
check_sha() { check_sha() {
if [ $# -ne 2 ]; then if [ $# -ne 2 ]; then
@ -36,6 +26,7 @@ check_sha() {
FILE="${1}" FILE="${1}"
EXPECTED_HASH="${2}" EXPECTED_HASH="${2}"
SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "Darwin" ]; then if [ "$SYSTEM_NAME" = "Darwin" ]; then
SEEN_HASH="$(shasum -a 256 "${FILE}" | cut -d " " -f 1)" SEEN_HASH="$(shasum -a 256 "${FILE}" | cut -d " " -f 1)"
else else

View file

@ -19,7 +19,6 @@ ARCHS="$USERLAND_ARCHS aarch64"
MD5SUM="md5sum" MD5SUM="md5sum"
REALPATH="realpath" REALPATH="realpath"
NPROC="nproc"
INSTALL="install" INSTALL="install"
SED="sed" SED="sed"
@ -28,25 +27,20 @@ SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
REALPATH="readlink -f" REALPATH="readlink -f"
NPROC="sysctl -n hw.ncpuonline"
export CC=egcc export CC=egcc
export CXX=eg++ export CXX=eg++
export LDFLAGS=-Wl,-z,notext export LDFLAGS=-Wl,-z,notext
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
elif [ "$SYSTEM_NAME" = "Darwin" ]; then elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
REALPATH="grealpath" # GNU coreutils REALPATH="grealpath" # GNU coreutils
INSTALL="ginstall" # GNU coreutils INSTALL="ginstall" # GNU coreutils
SED="gsed" # GNU sed SED="gsed" # GNU sed
fi fi
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$($NPROC) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
if [ ! -d "$BUILD" ]; then if [ ! -d "$BUILD" ]; then
mkdir -p "$BUILD" mkdir -p "$BUILD"

View file

@ -21,30 +21,25 @@ PREFIX="$DIR/Local/$ARCH-gdb"
echo "Building GDB $GDB_VERSION for $TARGET" echo "Building GDB $GDB_VERSION for $TARGET"
MD5SUM="md5sum" MD5SUM="md5sum"
NPROC="nproc"
SYSTEM_NAME="$(uname -s)" SYSTEM_NAME="$(uname -s)"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpuonline"
export CC=egcc export CC=egcc
export CXX=eg++ export CXX=eg++
export with_gmp=/usr/local export with_gmp=/usr/local
export LDFLAGS=-Wl,-z,notext export LDFLAGS=-Wl,-z,notext
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
export with_gmp=/usr/local export with_gmp=/usr/local
export with_mpfr=/usr/local export with_mpfr=/usr/local
elif [ "$SYSTEM_NAME" = "Darwin" ]; then elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
fi fi
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$($NPROC) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
buildstep() { buildstep() {
NAME=$1 NAME=$1

View file

@ -21,7 +21,6 @@ SYSROOT="$BUILD/Root"
MAKE="make" MAKE="make"
MD5SUM="md5sum" MD5SUM="md5sum"
NPROC="nproc"
REALPATH="realpath" REALPATH="realpath"
if command -v ginstall &>/dev/null; then if command -v ginstall &>/dev/null; then
@ -41,7 +40,6 @@ export CXXFLAGS="-g0 -O2 -mtune=native"
if [ "$SYSTEM_NAME" = "OpenBSD" ]; then if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
MAKE=gmake MAKE=gmake
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpuonline"
REALPATH="readlink -f" REALPATH="readlink -f"
export CC=egcc export CC=egcc
export CXX=eg++ export CXX=eg++
@ -50,12 +48,10 @@ if [ "$SYSTEM_NAME" = "OpenBSD" ]; then
elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then elif [ "$SYSTEM_NAME" = "FreeBSD" ]; then
MAKE=gmake MAKE=gmake
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
export with_gmp=/usr/local export with_gmp=/usr/local
export with_mpfr=/usr/local export with_mpfr=/usr/local
elif [ "$SYSTEM_NAME" = "Darwin" ]; then elif [ "$SYSTEM_NAME" = "Darwin" ]; then
MD5SUM="md5 -q" MD5SUM="md5 -q"
NPROC="sysctl -n hw.ncpu"
fi fi
# On at least OpenBSD, the path must exist to call realpath(3) on it # On at least OpenBSD, the path must exist to call realpath(3) on it
@ -270,9 +266,8 @@ popd
rm -rf "$PREFIX" rm -rf "$PREFIX"
mkdir -p "$PREFIX" mkdir -p "$PREFIX"
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$($NPROC) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
mkdir -p "$DIR/Build/$ARCH" mkdir -p "$DIR/Build/$ARCH"

View file

@ -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" exit_if_running_as_root "Do not run BuildMold.sh as root, parts of your Toolchain directory will become root-owned"
NPROC="nproc" NPROC=$(get_number_of_processing_units)
SYSTEM_NAME="$(uname -s)" [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
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)
mkdir -p "$DIR"/Tarballs mkdir -p "$DIR"/Tarballs
pushd "$DIR"/Tarballs pushd "$DIR"/Tarballs

View file

@ -41,9 +41,8 @@ pushd "${TARBALLS_DIR}"
fi fi
popd popd
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$(nproc) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
mkdir -p "${PREFIX_DIR}" mkdir -p "${PREFIX_DIR}"
mkdir -p "${BUILD_DIR}" mkdir -p "${BUILD_DIR}"

View file

@ -55,9 +55,8 @@ popd
mkdir -p "$PREFIX" mkdir -p "$PREFIX"
mkdir -p "$DIR/Build/qemu" mkdir -p "$DIR/Build/qemu"
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$(nproc) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
EXTRA_ARGS="" EXTRA_ARGS=""
if [[ $(uname) == "Darwin" ]] if [[ $(uname) == "Darwin" ]]

View file

@ -41,9 +41,8 @@ pushd "${TARBALLS_DIR}"
fi fi
popd popd
if [ -z "$MAKEJOBS" ]; then NPROC=$(get_number_of_processing_units)
MAKEJOBS=$(nproc) [ -z "$MAKEJOBS" ] && MAKEJOBS=${NPROC}
fi
mkdir -p "${PREFIX_DIR}" mkdir -p "${PREFIX_DIR}"
mkdir -p "${BUILD_DIR}" mkdir -p "${BUILD_DIR}"