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:
parent
98187debfb
commit
8db9c89e0b
16
build.sh
16
build.sh
@ -40,6 +40,8 @@ usage() {
|
|||||||
equal to -3 -a -p -n -m -c -i
|
equal to -3 -a -p -n -m -c -i
|
||||||
${COLORS[GREEN]}-g, --gcc${COLORS[OFF]}
|
${COLORS[GREEN]}-g, --gcc${COLORS[OFF]}
|
||||||
Use GCC even if Clang is installed; disabled by default.
|
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]}
|
${COLORS[GREEN]}-f${COLORS[OFF]}
|
||||||
Remove existing build dir; disabled by default.
|
Remove existing build dir; disabled by default.
|
||||||
${COLORS[GREEN]}-I, --no-install${COLORS[OFF]}
|
${COLORS[GREEN]}-I, --no-install${COLORS[OFF]}
|
||||||
@ -105,6 +107,7 @@ set_build_opts() {
|
|||||||
[[ -z "$ENABLE_MPD" ]] && ENABLE_MPD="OFF"
|
[[ -z "$ENABLE_MPD" ]] && ENABLE_MPD="OFF"
|
||||||
[[ -z "$ENABLE_CURL" ]] && ENABLE_CURL="OFF"
|
[[ -z "$ENABLE_CURL" ]] && ENABLE_CURL="OFF"
|
||||||
[[ -z "$ENABLE_IPC_MSG" ]] && ENABLE_IPC_MSG="OFF"
|
[[ -z "$ENABLE_IPC_MSG" ]] && ENABLE_IPC_MSG="OFF"
|
||||||
|
[[ -z "$JOB_COUNT" ]] && JOB_COUNT=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$USE_GCC" ]]; then
|
if [[ -z "$USE_GCC" ]]; then
|
||||||
@ -146,6 +149,11 @@ set_build_opts() {
|
|||||||
read -r -p "$(msg "Build \"polybar-msg\" used to send ipc messages ------------------ [y/N]: ")" -n 1 p && echo
|
read -r -p "$(msg "Build \"polybar-msg\" used to send ipc messages ------------------ [y/N]: ")" -n 1 p && echo
|
||||||
[[ "${p^^}" != "Y" ]] && ENABLE_IPC_MSG="OFF" || ENABLE_IPC_MSG="ON"
|
[[ "${p^^}" != "Y" ]] && ENABLE_IPC_MSG="OFF" || ENABLE_IPC_MSG="ON"
|
||||||
fi
|
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++"
|
CXX="c++"
|
||||||
@ -196,7 +204,11 @@ main() {
|
|||||||
.. || msg_err "Failed to generate build... read output to get a hint of what went wrong"
|
.. || msg_err "Failed to generate build... read output to get a hint of what went wrong"
|
||||||
|
|
||||||
msg "Building project"
|
msg "Building project"
|
||||||
make || msg_err "Failed to build 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
|
install
|
||||||
msg "Build complete!"
|
msg "Build complete!"
|
||||||
|
|
||||||
@ -235,6 +247,8 @@ while [[ "$1" == -* ]]; do
|
|||||||
|
|
||||||
-g|--gcc)
|
-g|--gcc)
|
||||||
USE_GCC=ON; shift ;;
|
USE_GCC=ON; shift ;;
|
||||||
|
-j|--jobs)
|
||||||
|
JOB_COUNT=$(nproc); shift ;;
|
||||||
-f)
|
-f)
|
||||||
REMOVE_BUILD_DIR=ON; shift ;;
|
REMOVE_BUILD_DIR=ON; shift ;;
|
||||||
-I|--no-install)
|
-I|--no-install)
|
||||||
|
Loading…
Reference in New Issue
Block a user