1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00

build: Add -j to build.sh (#1961)

* Added -j and --jobs as command line options

* Added parallelizing option to the set_build_opts function

* Aligned parallel option to the previous options
This commit is contained in:
Nicholas Baron 2020-01-07 07:35:48 -08:00 committed by Patrick Ziegler
parent 98187debfb
commit 8db9c89e0b

View file

@ -40,6 +40,8 @@ usage() {
equal to -3 -a -p -n -m -c -i
${COLORS[GREEN]}-g, --gcc${COLORS[OFF]}
Use GCC even if Clang is installed; disabled by default.
${COLORS[GREEN]}-j, --jobs${COLORS[OFF]}
Use make -j to use make jobs with $(nproc) jobs; disabled by default.
${COLORS[GREEN]}-f${COLORS[OFF]}
Remove existing build dir; disabled by default.
${COLORS[GREEN]}-I, --no-install${COLORS[OFF]}
@ -105,6 +107,7 @@ set_build_opts() {
[[ -z "$ENABLE_MPD" ]] && ENABLE_MPD="OFF"
[[ -z "$ENABLE_CURL" ]] && ENABLE_CURL="OFF"
[[ -z "$ENABLE_IPC_MSG" ]] && ENABLE_IPC_MSG="OFF"
[[ -z "$JOB_COUNT" ]] && JOB_COUNT=1
fi
if [[ -z "$USE_GCC" ]]; then
@ -147,6 +150,11 @@ set_build_opts() {
[[ "${p^^}" != "Y" ]] && ENABLE_IPC_MSG="OFF" || ENABLE_IPC_MSG="ON"
fi
if [[ -z "$JOB_COUNT" ]]; then
read -r -p "$(msg "Parallelize the build using make -j$(nproc) --------------------------- [y/N]: ")" -n 1 p && echo
[[ "${p^^}" != "Y" ]] && JOB_COUNT=1 || JOB_COUNT=$(nproc)
fi
CXX="c++"
@ -196,7 +204,11 @@ main() {
.. || msg_err "Failed to generate build... read output to get a hint of what went wrong"
msg "Building project"
if [ -z ${JOB_COUNT} ]; then
make || msg_err "Failed to build project"
else
make -j$JOB_COUNT || msg_err "Failed to build project"
fi
install
msg "Build complete!"
@ -235,6 +247,8 @@ while [[ "$1" == -* ]]; do
-g|--gcc)
USE_GCC=ON; shift ;;
-j|--jobs)
JOB_COUNT=$(nproc); shift ;;
-f)
REMOVE_BUILD_DIR=ON; shift ;;
-I|--no-install)