File: batch-build

package info (click to toggle)
uhd 3.7.3-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 456,376 kB
  • ctags: 89,637
  • sloc: ansic: 51,090; cpp: 42,755; xml: 19,627; vhdl: 12,678; tcl: 5,944; python: 5,870; ada: 2,760; sh: 2,175; makefile: 615; pascal: 230; csh: 224; perl: 11
file content (45 lines) | stat: -rwxr-xr-x 1,164 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

iterations=1
directory="."
targets=""
name=""
outdir=${PWD}

for arg in "$@"; do
   if [[ $arg == "--help" ]]; then
      echo "Usage: batch-build [options] targets"
      echo "Options:"
      echo "   --runs=N [1]            Build the specified targets N times"
      echo "   --dir=<dir> [.]         Makefile directory"
      echo "   --name=<name> [<empty>] Name of this batch job. Used as a prefix for build output"
      echo "   --help                  Print the message and exit"
      echo ""
      exit 0
   elif [[ $arg =~ "--runs="([0-9]+) ]]; then
      iterations=${BASH_REMATCH[1]}
   elif [[ $arg =~ "--dir="(.+) ]]; then
      directory=${BASH_REMATCH[1]}
   elif [[ $arg =~ "--name="(.+) ]]; then
      name=${BASH_REMATCH[1]}"_"
   else
      targets=$targets$arg" "
   fi
done

cd $directory >/dev/null 2>&1
if [ $? -ne 0 ]; then
   echo "ERROR: Could not cd to $directory"
   exit
fi

for i in $(seq 1 $iterations); do
   make $targets
   if [ $? -ne 0 ]; then
      echo "ERROR: Build Failed!!! Stopping batch build."
      exit
   fi
   cp -rf build ${outdir}/${name}batch-build_$(date +'%Y-%m-%d_%H-%M-%S')
   make clean
done