1 |
1947
|
aaronmk
|
#!/bin/bash
|
2 |
|
|
# Runs a make target on all inputs at once.
|
3 |
|
|
# Creates a job in the calling shell for each process.
|
4 |
1956
|
aaronmk
|
# Must be run from the root svn directory.
|
5 |
1947
|
aaronmk
|
|
6 |
14034
|
aaronmk
|
isset() { declare -p "$1" &>-; } # "${var+isset}" doesn't work for empty arrays
|
7 |
|
|
|
8 |
11416
|
aaronmk
|
main()
|
9 |
1952
|
aaronmk
|
{
|
10 |
|
|
local self="${BASH_SOURCE[0]}"
|
11 |
|
|
local selfDir="$(dirname -- "$self")"
|
12 |
|
|
|
13 |
|
|
# Was run without initial ".", or with insufficient parameters
|
14 |
1953
|
aaronmk
|
if test "${BASH_LINENO[1]}" = 0 -o "$#" -lt 1; then
|
15 |
11374
|
aaronmk
|
echo "Usage: [hidden_srcs=1] [inputs=(inputs/src/ ...)]; . $self \
|
16 |
|
|
make_target [vars...] (note initial \".\")"|fold -s >&2
|
17 |
1952
|
aaronmk
|
return 2
|
18 |
|
|
fi
|
19 |
14034
|
aaronmk
|
declare -p inputs
|
20 |
|
|
if ! isset inputs; then local inputs=(inputs/*/); fi
|
21 |
|
|
declare -p inputs
|
22 |
11456
|
aaronmk
|
if test "$hidden_srcs"; then local inputs=(inputs/.[^as.]*/ "${inputs[@]}")
|
23 |
|
|
fi # not . .. .svn .archive
|
24 |
1952
|
aaronmk
|
|
25 |
6202
|
aaronmk
|
for input in "${inputs[@]}"; do
|
26 |
8836
|
aaronmk
|
eval "yes|make ${input}$* &"
|
27 |
1952
|
aaronmk
|
disown -h "$(jobs|tail -1|"$selfDir/jobspecs")" # ignore SIGHUP
|
28 |
|
|
sleep 2 # wait for initial output so that outputs don't become jumbled
|
29 |
|
|
done
|
30 |
|
|
}
|
31 |
11416
|
aaronmk
|
main "$@"
|