Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature to execute BuildPackages.sh in parallel mode by adding --parallel #3922

Merged
merged 1 commit into from
Apr 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion bin/BuildPackages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ CURDIR="$(pwd)"
GAPROOT="$(cd .. && pwd)"
COLORS=yes
STRICT=no # exit with non-zero exit code when encountering any failures
PARALLEL=no
PACKAGES=()

# If output does not go into a terminal (but rather into a log file),
Expand All @@ -45,6 +46,7 @@ while [[ "$#" -ge 1 ]]; do
case "$option" in
--with-gaproot) GAPROOT="$1"; shift ;;
--with-gaproot=*) GAPROOT=${option#--with-gaproot=}; ;;
--parallel) PARALLEL=yes; ;;

--no-color) COLORS=no ;;
--color) COLORS=yes ;;
Expand All @@ -58,6 +60,10 @@ while [[ "$#" -ge 1 ]]; do
esac
done

if [ "x$PARALLEL" = "xyes" ]; then
export MAKEFLAGS="${MAKEFLAGS:--j3}"
fi;

# If user specified no packages to build, build all packages in subdirectories.
if [[ ${#PACKAGES[@]} == 0 ]]
then
Expand Down Expand Up @@ -241,7 +247,8 @@ build_one_package() {

date >> "$LOGDIR/fail.log"
for PKG in "${PACKAGES[@]}"
do
do
(
# cut off the ending slash (if exists)
PKG="${PKG%/}"
# cut off everything before the first slash to only keep the package name
Expand Down Expand Up @@ -278,7 +285,19 @@ do
echo
warning "$PKG does not seem to be a package directory, skipping"
fi
) &
if [ "x$PARALLEL" != "xyes" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errr, wait, this check is the wrong way around, isn't it?

# If more than 4 background jobs are running, wait for one to finish
if [[ $(jobs -r -p | wc -l) -gt 4 ]]; then
wait -n
fi
else
# wait for this package to finish building
wait
fi;
done
# Wait until all packages are built, if in parallel
wait

echo "" >> "$LOGDIR/fail.log"
echo ""
Expand Down