aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-03-01 23:39:27 -0600
committerRob Landley <rob@landley.net>2016-03-01 23:39:27 -0600
commit86f7c048254eab34d78ff105b54a5d31ec6ee9d3 (patch)
tree834723b7c1a4e8f939f6480cb73a75a0fa77d59e /scripts
parent5a44e4ae3487cf033a99b81263cd07bf9951a6a2 (diff)
downloadtoybox-86f7c048254eab34d78ff105b54a5d31ec6ee9d3.tar.gz
Use shell builtins instead of calling wc/awk/sed. (Fewer forks in build loop.)
Based on suggestions from Nicholas Boichat.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/make.sh11
1 files changed, 7 insertions, 4 deletions
diff --git a/scripts/make.sh b/scripts/make.sh
index c73a03df..8be4c3be 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -254,6 +254,7 @@ fi
PENDING=
LFILES=
DONE=0
+COUNT=0
for i in $FILES
do
# build each generated/obj/*.o file in parallel
@@ -265,16 +266,18 @@ do
[ "$OUT" -nt "$i" ] && continue
do_loudly $BUILD -c $i -o $OUT &
PENDING="$PENDING $!"
+ COUNT=$(($COUNT+1))
# ratelimit to $CPUS many parallel jobs, detecting errors
- while true
+ for j in $PENDING
do
- [ $(echo "$PENDING" | wc -w) -lt "$CPUS" ] && break;
+ [ "$COUNT" -lt "$CPUS" ] && break;
- wait $(echo "$PENDING" | awk '{print $1}')
+ wait $j
DONE=$(($DONE+$?))
- PENDING="$(echo "$PENDING" | sed 's/^ *[0-9]*//')"
+ COUNT=$(($COUNT-1))
+ PENDING="${PENDING## $j}"
done
[ $DONE -ne 0 ] && break
done