aboutsummaryrefslogtreecommitdiff
path: root/bin/build-all.sh
blob: c5bc19aef4cce9fbb78c7a787d1db907a04b02df (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh

# Usage: build-all.sh [pattern]
# If pattern given, only build targets which match.

if [ ! -z "$1" ]; then
  SEARCH="$1"
fi

# TODO: detect UI from $0
UI=anduril

mkdir -p hex

date '+#define VERSION_NUMBER "%Y-%m-%d"' > ui/$UI/version.h

PASS=0
FAIL=0
PASSED=''
FAILED=''

for TARGET in hw/*/*/cfg.h ; do

  # maybe limit builds to a specific pattern
  if [ ! -z "$SEARCH" ]; then
    echo "$TARGET" | grep -i "$SEARCH" > /dev/null
    if [ 0 != $? ]; then continue ; fi
  fi

  # friendly name for this build
  NAME=$(echo "$TARGET" | perl -ne 's|/|-|g; /hw-(.*)-cfg.h/ && print "$1\n";')
  echo "===== $NAME ====="

  # figure out MCU type
  #ATTINY=$(grep 'ATTINY:' $TARGET | awk '{ print $3 }')
  #if [ -z "$ATTINY" ]; then ATTINY=85 ; fi

  # try to compile
  #echo bin/build.sh "$UI" "$TARGET"
  bin/build.sh "$UI" "$TARGET"

  # track result, and rename compiled files
  if [ 0 = $? ] ; then
    mv -f "ui/$UI/$UI".hex hex/"$UI".$NAME.hex
    PASS=$(($PASS + 1))
    PASSED="$PASSED $NAME"
  else
    echo "ERROR: build failed"
    FAIL=$(($FAIL + 1))
    FAILED="$FAILED $NAME"
  fi

done

# summary
echo "===== $PASS builds succeeded, $FAIL failed ====="
#echo "PASS: $PASSED"
if [ 0 != $FAIL ]; then
  echo "FAIL:$FAILED"
fi