Advertisement
Guest User

Rockbox BuildAll Script

a guest
Oct 9th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.81 KB | None | 0 0
  1. #!/bin/sh
  2. TMPDIR="./tmp-build-all"
  3. BUILD_DIR="./builds"
  4. CONFIG="../../tools/configure"
  5. MAKE_FILE="Makefile"
  6. NOW=$(date +"%m-%d-%Y_%r")
  7. THREADS=" -j1"
  8. EXCLUDE="(wps)|(manual)|(sim)|(boot)"
  9. if [ "$2" = "RUNNING" ];
  10. then
  11.     echo "Running"
  12.  
  13. else
  14.     echo "First Run"
  15.     echo "#invocation $0 $*"
  16.     echo "Logging to $(readlink -f $1.log)"
  17.     echo "Builds stored in $(readlink -f $BUILD_DIR)"
  18.     if [ "$2" = "clean" ];
  19.     then
  20.         echo "clean build, removing build root directory"
  21.         if [ -d "$BUILD_DIR" ]; then
  22.             rm -rf "$BUILD_DIR"
  23.         fi
  24.     fi
  25.  
  26.     echo "------------------------------------------"
  27.     echo "Started $(date +"%m-%d-%Y_%r")" >$1.log
  28.     #Push to new shell instance so we can log StdOut and StdErr
  29.     #Only pipe StdErr to the current shell
  30.     echo `$0 $1 RUNNING 2>&1 >>$1.log | tee --append $1.log >&2`
  31.     exit 0
  32. fi
  33.  
  34. usage ()
  35. {
  36.     echo "Usage: $0 <build file>"
  37.     echo "Example:"
  38.     echo "$0 ../www/buildserver/builds"
  39.     exit 1
  40. }
  41.  
  42. # check number of arguments
  43. if [ $# -le 0 ]; then
  44.     usage
  45. fi
  46.  
  47. # print invocation, for reference
  48. echo "#invocation $0 $*"
  49. echo "\n\n"
  50. # build file
  51. BUILD_FILE="$1"
  52.  
  53. # check build file
  54. #if [ ! -d "builds" ];
  55. if [ ! -e "$BUILD_FILE" ]; then
  56.     echo "ERROR: build file doesn't exist $BUILD_FILE" 1>&2
  57.     exit 2
  58. fi
  59. # remove build directory
  60. #rm -rf "$BUILD_DIR"
  61. if [ ! -d "$BUILD_DIR" ]; then
  62.     echo "Build root directory doesn't exist, creating: $BUILD_DIR" 1>&2
  63.     #create build directory
  64.     mkdir "$BUILD_DIR"
  65. fi
  66. # cd into it
  67. cd "$BUILD_DIR"
  68.  
  69. #Count items to build
  70. #--------------
  71. item_totals=0;
  72. while read line
  73. do
  74.  
  75.     #replace tools path with our own
  76.      line=`echo $line | sed -e "s#../tools/configure#$CONFIG#"`
  77.     # ignore wps and manual lines
  78.      if `echo "$line" | grep -E "$EXCLUDE" > /dev/null 2>&1`; then
  79.         continue
  80.      fi
  81. item_totals=$(($item_totals+1))
  82. #item_totals=`expr $item_totals + 1`
  83. done < "../$BUILD_FILE"
  84. 1>&2 echo "$item_totals Items"
  85. #--------------
  86.  
  87. # process lines in the build
  88. itemsproc=0;
  89. while read line
  90. do
  91.  
  92.     #replace tools path with our own
  93.      line=`echo $line | sed -e "s#../tools/configure#$CONFIG#"`
  94.     # ignore wps and manual lines
  95.      if `echo "$line" | grep -E "$EXCLUDE" > /dev/null 2>&1`; then
  96.      1>&2 echo "Ignored"
  97.      1>&2 echo "$line"| awk 'BEGIN { FS=":" } { print $3 }'
  98.      continue
  99.    fi
  100.     # format of each line: compiler:x:name:title:file:hint:command
  101.     NAME=`echo "$line" | awk 'BEGIN { FS=":" } { print $3 }'`
  102.     LN=$(wc -l < "../$1.log")
  103.     1>&2 echo "Line: $(($LN+1)), $BUILD_DIR/build_$NAME"
  104.     CMD=`echo "$line$THREADS" | awk 'BEGIN { FS=":" } { print $7 }'`
  105.     echo "$CMD"
  106.     # remove temporary directory
  107.     #rm -rf "$TMPDIR"
  108.     # create name directory and cd into it
  109. if [ ! -d "build_$NAME" ]; then
  110.     #create build directory
  111.     mkdir "build_$NAME"
  112.     #CMD="make$THREADS"
  113. else
  114.     if [ -e "build_$NAME/$MAKE_FILE" ]; then
  115.         echo "Make file already exists build_$NAME/$MAKE_FILE" 1>&2
  116.         CMD=`echo "$line" | awk 'BEGIN { FS="&&" } { print $2 }'`
  117.         CMD="make$THREADS && $CMD"
  118.         echo "$CMD"
  119.     fi
  120.  
  121.  
  122. fi
  123.  
  124.     cd "build_$NAME"
  125.     # the command extract is of the form
  126.     # ../tools/configure <options> && make <blabla>
  127.     # try to run configure
  128.     # it might error if the target compiler is not installed for example
  129.  
  130.     if eval $CMD >/dev/null; then # &>/dev/null # >/dev/null
  131.  
  132.         echo "$NAME: ok"
  133.  
  134.     else
  135.         #print config error
  136.  
  137.         >&2 echo "$NAME: <config/build error>" 2>&1
  138.  
  139.  
  140.     fi
  141.     # cd back to build directory
  142.     item_proc=$(($item_proc+1))
  143.     1>&2 echo "$item_proc / $item_totals Items processed"
  144.     echo "\n\n"
  145.     cd ..
  146.  
  147. done < "../$BUILD_FILE"
  148. echo "Ended $(date +"%m-%d-%Y_%r")"
  149. # remove temp directory
  150. rm -rf "$TMPDIR"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement