Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- TMPDIR="./tmp-build-all"
- BUILD_DIR="./builds"
- CONFIG="../../tools/configure"
- MAKE_FILE="Makefile"
- NOW=$(date +"%m-%d-%Y_%r")
- THREADS=" -j1"
- EXCLUDE="(wps)|(manual)|(sim)|(boot)"
- if [ "$2" = "RUNNING" ];
- then
- echo "Running"
- else
- echo "First Run"
- echo "#invocation $0 $*"
- echo "Logging to $(readlink -f $1.log)"
- echo "Builds stored in $(readlink -f $BUILD_DIR)"
- if [ "$2" = "clean" ];
- then
- echo "clean build, removing build root directory"
- if [ -d "$BUILD_DIR" ]; then
- rm -rf "$BUILD_DIR"
- fi
- fi
- echo "------------------------------------------"
- echo "Started $(date +"%m-%d-%Y_%r")" >$1.log
- #Push to new shell instance so we can log StdOut and StdErr
- #Only pipe StdErr to the current shell
- echo `$0 $1 RUNNING 2>&1 >>$1.log | tee --append $1.log >&2`
- exit 0
- fi
- usage ()
- {
- echo "Usage: $0 <build file>"
- echo "Example:"
- echo "$0 ../www/buildserver/builds"
- exit 1
- }
- # check number of arguments
- if [ $# -le 0 ]; then
- usage
- fi
- # print invocation, for reference
- echo "#invocation $0 $*"
- echo "\n\n"
- # build file
- BUILD_FILE="$1"
- # check build file
- #if [ ! -d "builds" ];
- if [ ! -e "$BUILD_FILE" ]; then
- echo "ERROR: build file doesn't exist $BUILD_FILE" 1>&2
- exit 2
- fi
- # remove build directory
- #rm -rf "$BUILD_DIR"
- if [ ! -d "$BUILD_DIR" ]; then
- echo "Build root directory doesn't exist, creating: $BUILD_DIR" 1>&2
- #create build directory
- mkdir "$BUILD_DIR"
- fi
- # cd into it
- cd "$BUILD_DIR"
- #Count items to build
- #--------------
- item_totals=0;
- while read line
- do
- #replace tools path with our own
- line=`echo $line | sed -e "s#../tools/configure#$CONFIG#"`
- # ignore wps and manual lines
- if `echo "$line" | grep -E "$EXCLUDE" > /dev/null 2>&1`; then
- continue
- fi
- item_totals=$(($item_totals+1))
- #item_totals=`expr $item_totals + 1`
- done < "../$BUILD_FILE"
- 1>&2 echo "$item_totals Items"
- #--------------
- # process lines in the build
- itemsproc=0;
- while read line
- do
- #replace tools path with our own
- line=`echo $line | sed -e "s#../tools/configure#$CONFIG#"`
- # ignore wps and manual lines
- if `echo "$line" | grep -E "$EXCLUDE" > /dev/null 2>&1`; then
- 1>&2 echo "Ignored"
- 1>&2 echo "$line"| awk 'BEGIN { FS=":" } { print $3 }'
- continue
- fi
- # format of each line: compiler:x:name:title:file:hint:command
- NAME=`echo "$line" | awk 'BEGIN { FS=":" } { print $3 }'`
- LN=$(wc -l < "../$1.log")
- 1>&2 echo "Line: $(($LN+1)), $BUILD_DIR/build_$NAME"
- CMD=`echo "$line$THREADS" | awk 'BEGIN { FS=":" } { print $7 }'`
- echo "$CMD"
- # remove temporary directory
- #rm -rf "$TMPDIR"
- # create name directory and cd into it
- if [ ! -d "build_$NAME" ]; then
- #create build directory
- mkdir "build_$NAME"
- #CMD="make$THREADS"
- else
- if [ -e "build_$NAME/$MAKE_FILE" ]; then
- echo "Make file already exists build_$NAME/$MAKE_FILE" 1>&2
- CMD=`echo "$line" | awk 'BEGIN { FS="&&" } { print $2 }'`
- CMD="make$THREADS && $CMD"
- echo "$CMD"
- fi
- fi
- cd "build_$NAME"
- # the command extract is of the form
- # ../tools/configure <options> && make <blabla>
- # try to run configure
- # it might error if the target compiler is not installed for example
- if eval $CMD >/dev/null; then # &>/dev/null # >/dev/null
- echo "$NAME: ok"
- else
- #print config error
- >&2 echo "$NAME: <config/build error>" 2>&1
- fi
- # cd back to build directory
- item_proc=$(($item_proc+1))
- 1>&2 echo "$item_proc / $item_totals Items processed"
- echo "\n\n"
- cd ..
- done < "../$BUILD_FILE"
- echo "Ended $(date +"%m-%d-%Y_%r")"
- # remove temp directory
- rm -rf "$TMPDIR"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement