Allow parallel make when the -j option is passed to build.sh.
Based on a patch to the UQM Mega-Mod by Ala-lala.
This commit is contained in:
+18
-2
@@ -58,6 +58,22 @@ fi
|
|||||||
# Load the configuration functions
|
# Load the configuration functions
|
||||||
. build/unix/build.config
|
. build/unix/build.config
|
||||||
|
|
||||||
|
BUILD_THREADS=""
|
||||||
|
for i in "$@"; do
|
||||||
|
shift
|
||||||
|
if [ "`printf "%s" "$i" | cut -c1-2`" = "-j" ]; then
|
||||||
|
num="`printf "%s" "$i" | cut -c3-`"
|
||||||
|
if [ -z "$num" ] || [ "$num" -gt 0 ] 2>/dev/null; then
|
||||||
|
BUILD_THREADS="-j$num"
|
||||||
|
else
|
||||||
|
usage 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
set -- "$@" "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
cleanall)
|
cleanall)
|
||||||
build_cleanall
|
build_cleanall
|
||||||
@@ -93,7 +109,7 @@ export "${BUILD_PROJECT}_OBJS"
|
|||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
build_check_config
|
build_check_config
|
||||||
build_check_dependencies
|
build_check_dependencies
|
||||||
build_compile
|
build_compile $BUILD_THREADS
|
||||||
exit $?
|
exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -115,7 +131,7 @@ case "$2" in
|
|||||||
install)
|
install)
|
||||||
build_check_config
|
build_check_config
|
||||||
build_check_dependencies
|
build_check_dependencies
|
||||||
build_check_compile
|
build_check_compile $BUILD_THREADS
|
||||||
build_install
|
build_install
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ usage() {
|
|||||||
echo "Main build script"
|
echo "Main build script"
|
||||||
echo
|
echo
|
||||||
echo "Syntax:"
|
echo "Syntax:"
|
||||||
echo " ./build.sh <target>"
|
echo " ./build.sh [-j[#JOBS]] <target>"
|
||||||
echo " ./build.sh <target> config"
|
echo " ./build.sh <target> config"
|
||||||
echo " ./build.sh <target> depend"
|
echo " ./build.sh <target> depend"
|
||||||
echo " ./build.sh <target> clean"
|
echo " ./build.sh <target> clean"
|
||||||
echo " ./build.sh <target> install"
|
echo " ./build.sh [-j[#JOBS]] <target> install"
|
||||||
echo " ./build.sh cleanall"
|
echo " ./build.sh cleanall"
|
||||||
echo " ./build.sh distclean"
|
echo " ./build.sh distclean"
|
||||||
echo
|
echo
|
||||||
@@ -103,6 +103,8 @@ build_depend() {
|
|||||||
|
|
||||||
# Compile the lot.
|
# Compile the lot.
|
||||||
# With the depend info set up, we can leave everything to make.
|
# With the depend info set up, we can leave everything to make.
|
||||||
|
# $1 - additional arguments to pass to make (at the moment just
|
||||||
|
# an optional -j arg for parallel builds).
|
||||||
build_compile() {
|
build_compile() {
|
||||||
local CFLAGS LDFLAGS TARGET_FILE DEPEND_FILE OBJDIR
|
local CFLAGS LDFLAGS TARGET_FILE DEPEND_FILE OBJDIR
|
||||||
|
|
||||||
@@ -119,7 +121,7 @@ build_compile() {
|
|||||||
BUILD_ROOT= \
|
BUILD_ROOT= \
|
||||||
TARGET_FILE=$TARGET_FILE DEPEND_FILE=$DEPEND_FILE \
|
TARGET_FILE=$TARGET_FILE DEPEND_FILE=$DEPEND_FILE \
|
||||||
SED=$SED \
|
SED=$SED \
|
||||||
$MAKE -f Makefile.build "$TARGET_FILE"
|
$MAKE $1 -f Makefile.build "$TARGET_FILE"
|
||||||
|
|
||||||
eval "${TARGET}_post_build"
|
eval "${TARGET}_post_build"
|
||||||
}
|
}
|
||||||
@@ -170,12 +172,14 @@ build_check_dependencies() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Description: check if the program is compiled, and otherwise compile
|
# Description: check if the program is compiled, and otherwise compile
|
||||||
|
# $1 - additional arguments to pass to make (at the moment just
|
||||||
|
# an optional -j arg for parallel builds).
|
||||||
build_check_compile() {
|
build_check_compile() {
|
||||||
local NAME
|
local NAME
|
||||||
eval NAME="\${${BUILD_PROJECT}_NAME}"
|
eval NAME="\${${BUILD_PROJECT}_NAME}"
|
||||||
[ ! -e "$NAME" ] || return
|
[ ! -e "$NAME" ] || return
|
||||||
|
|
||||||
build_compile || exit $?
|
build_compile "$1" || exit $?
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make a directory path, with mode and owner specified.
|
# Make a directory path, with mode and owner specified.
|
||||||
|
|||||||
Reference in New Issue
Block a user