Project

General

Profile

1
#!/bin/bash
2
# Runs a make target on all inputs at once.
3
# Creates a job in the calling shell for each process.
4
# Must be run from the root svn directory.
5

    
6
isset() # `test "${var+isset}"` doesn't work for empty arrays
7
{ declare -p "$1" &>/dev/null; }
8

    
9
main()
10
{
11
    local self="${BASH_SOURCE[0]}"
12
    local selfDir="$(dirname -- "$self")"
13
    
14
    # Was run without initial ".", or with insufficient parameters
15
    if test "${BASH_LINENO[1]}" = 0 -o "$#" -lt 1; then
16
        echo "Usage: [hidden_srcs=1] [inputs=(inputs/src/ ...)]; . $self \
17
make_target [vars...] (note initial \".\")"|fold -s >&2
18
        return 2
19
    fi
20
    if ! isset inputs; then local inputs=(inputs/*/); fi
21
    if test "$hidden_srcs"; then local inputs=(inputs/.[^as.]*/ "${inputs[@]}")
22
    fi # not . .. .svn .archive
23
    
24
    for input in "${inputs[@]}"; do
25
        eval "yes|make ${input}$* &"
26
        # don't disown so that it will be auto-killed if the shell is
27
        sleep 2 # wait for initial output so that outputs don't become jumbled
28
    done
29
}
30
main "$@"
(85-85/87)