Project

General

Profile

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 14065 aaronmk
isset() # `test "${var+isset}"` doesn't work for empty arrays
7 14089 aaronmk
{ declare -p "$1" &>/dev/null; }
8 14034 aaronmk
9 11416 aaronmk
main()
10 1952 aaronmk
{
11
    local self="${BASH_SOURCE[0]}"
12
    local selfDir="$(dirname -- "$self")"
13
14
    # Was run without initial ".", or with insufficient parameters
15 1953 aaronmk
    if test "${BASH_LINENO[1]}" = 0 -o "$#" -lt 1; then
16 11374 aaronmk
        echo "Usage: [hidden_srcs=1] [inputs=(inputs/src/ ...)]; . $self \
17
make_target [vars...] (note initial \".\")"|fold -s >&2
18 1952 aaronmk
        return 2
19
    fi
20 14034 aaronmk
    if ! isset inputs; then local inputs=(inputs/*/); fi
21 11456 aaronmk
    if test "$hidden_srcs"; then local inputs=(inputs/.[^as.]*/ "${inputs[@]}")
22
    fi # not . .. .svn .archive
23 1952 aaronmk
24 6202 aaronmk
    for input in "${inputs[@]}"; do
25 8836 aaronmk
        eval "yes|make ${input}$* &"
26 14088 aaronmk
        # don't disown so that it will be auto-killed if the shell is
27 1952 aaronmk
        sleep 2 # wait for initial output so that outputs don't become jumbled
28
    done
29
}
30 11416 aaronmk
main "$@"