-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'build_tools/master'
- Loading branch information
Showing
7 changed files
with
354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
This directory contains tools used (and related to) automatic builds. | ||
|
||
---------- | ||
dir_get_builder.sh | ||
get_builder_type.sh | ||
|
||
- These scripts will return, in order of precedence, 'ant' as what should | ||
be used to build. dir_get_builder.sh takes a directory name. get_builder_type.sh is used by | ||
the other scripts and simply takes a list of filenames. It could be extended to recognize | ||
new build tools. Please see the next section for more about new build tools. | ||
|
||
---------- | ||
build_ant.sh | ||
|
||
- These scripts will build the type of project given in their name. If new build tools are | ||
introduced, they would be supported by adding a "build_<newtool>.sh" script. Their | ||
parameters are: | ||
src_dir - The directory where the project is located | ||
obj_dir - The directory to build 'disposable' items; these may be safely deleted in the future | ||
sym_dir - The directory to build the symboled items; these are not shipped, but useful for | ||
debugging. | ||
dst_dir - The directory to build the shipped items | ||
build_id - The identifier for the build (e.g., my_project-123) | ||
|
||
---------- | ||
package_tar.sh | ||
|
||
- This script will tar up a given directory in a given location with a versioned name. | ||
src_dir - The directory that will be tar'ed up. | ||
dest_dir - The directory where "<project_name>-<version>.tar.gz" will be created. | ||
tar_name - The name used to name the tar file. | ||
|
||
---------- | ||
dir_build.sh | ||
|
||
- This script builds the given directory. Namely it uses get_builder_type.sh and | ||
build_<tool>.sh. It logs its output. It doesn't use package_tar.sh. | ||
<src_dir> - An optional directory to build. If nothing is supplied, the current directory | ||
is used. | ||
|
||
---------- | ||
git_build.sh | ||
|
||
- Use this script to build from a git directory. The project_name is the src_dir. The | ||
revision is obtained from the git log long commit hash. It uses a selection of | ||
the above tools to determine if the given revision can be automatically built with one | ||
of the supported tools, exporting a fresh directory to build, building the directory with | ||
the proper tool, and creating a compressed tar file of the result. All of the work it does | ||
is logged into a text file. It will create all of this into the environment variable | ||
BUILD_DIR. If it is not set, it will set BUILD_DIR to "/tmp/git-build/<process_id>". | ||
<src_dir> - An optional directory to build. If nothing is supplied, the current directory | ||
is used. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/sh | ||
|
||
usage () | ||
{ | ||
echo "$0 src_dir obj_dir sym_dir dst_dir build_id" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
if_failure () | ||
{ | ||
if [ "$?" -ne 0 ] ; then | ||
echo "$0: Failure Error: $1" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
SRC_DIR=$1 | ||
if [ -z "$SRC_DIR" ] ; then | ||
usage "No source directory." | ||
fi | ||
if [ ! -d "${SRC_DIR}" ] ; then | ||
usage "No $SRC_DIR" | ||
fi | ||
SRC_DIR=`cd "$SRC_DIR" && pwd` | ||
OBJ_DIR=$2 | ||
if [ -z "$OBJ_DIR" ] ; then | ||
usage "No objects directory." | ||
fi | ||
SYM_DIR=$3 | ||
if [ -z "$SYM_DIR" ] ; then | ||
usage "No symbols directory." | ||
fi | ||
DST_DIR=$4 | ||
if [ -z "$DST_DIR" ] ; then | ||
usage "No destination directory." | ||
fi | ||
BUILD_ID=$5 | ||
if [ -z "$BUILD_ID" ] ; then | ||
BUILD_ID=$USER-internal | ||
fi | ||
|
||
if [ -z "$ANT_PATH" ] ; then | ||
ANT_PATH=$HOME/Documents/code/java_libs/apache-ant-1.9.3/bin/ant | ||
fi | ||
|
||
ARGS="-Dsym.dir=$SYM_DIR -Dobj.dir=$OBJ_DIR -Ddst.dir=$DST_DIR -Dbuild.id=$BUILD_ID" | ||
echo "$ANT_PATH build.xml $ARGS" 1>&2 | ||
|
||
cd $SRC_DIR ; $ANT_PATH $ARGS 1>&2 | ||
if_failure "Ant Build Failure!" | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/sh | ||
|
||
usage () | ||
{ | ||
echo "$0 src_dir (pwd used if not set)" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
if_failure () | ||
{ | ||
if [ "$?" -ne 0 ] ; then | ||
echo "$0: Failure Error: $1" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
LOG_FILE=/tmp/build-$USER-$$.log | ||
( | ||
exec 2>&1 | ||
|
||
SRC_DIR=$1 | ||
if [ -z "$SRC_DIR" ] ; then | ||
SRC_DIR=`pwd` | ||
fi | ||
SRC_DIR=`cd "$SRC_DIR" && pwd` | ||
if [ ! -d "${SRC_DIR}" ] ; then | ||
usage "No $SRC_DIR" | ||
fi | ||
|
||
PRG="$0" | ||
PROG_HOME=`dirname "$PRG"` | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
REVIS=$USER-internal-$$ | ||
|
||
BUILD_DIR=$SRC_DIR/build-$REVIS/ | ||
|
||
mkdir -p $BUILD_DIR | ||
|
||
# This will start logging to a unique log file, but once we know | ||
# our build location we want it to log there. The following | ||
# command makes these two files the same, and the 'tmp' log | ||
# file location is removed at the end of the script. | ||
ln $LOG_FILE $BUILD_DIR/build_log.txt | ||
|
||
GET_BUILDER=$PROG_HOME/dir_get_builder.sh | ||
BUILD_TYPE=`$GET_BUILDER $SRC_DIR` | ||
if_failure "Can't get build type for $SRC_DIR" | ||
|
||
BUILDER=$PROG_HOME/build_$BUILD_TYPE.sh | ||
|
||
OBJ_DIR=$BUILD_DIR/obj | ||
SYM_DIR=$BUILD_DIR/sym | ||
DST_DIR=$BUILD_DIR/dst | ||
|
||
`$BUILDER $SRC_DIR $OBJ_DIR $SYM_DIR $DST_DIR $REVIS` | ||
if_failure "Can't build $BUILDER $SRC_DIR $OBJ_DIR $SYM_DIR $DST_DIR $REVIS" | ||
|
||
echo "Build $BUILD_DIR Succeeded!" | ||
) | tee -a $LOG_FILE | ||
|
||
rm $LOG_FILE | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
|
||
usage () | ||
{ | ||
echo "$0 src_dir" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
SRC_DIR=$1 | ||
if [ -z "$SRC_DIR" ] ; then | ||
usage "No repository." | ||
fi | ||
SRC_DIR=`cd "$SRC_DIR" && pwd` | ||
if [ ! -d "${SRC_DIR}" ] ; then | ||
usage "No $SRC_DIR" | ||
fi | ||
|
||
PRG="$0" | ||
PROG_HOME=`dirname "$PRG"` | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
GET_BUILDER_TYPE=$PROG_HOME/get_builder_type.sh | ||
|
||
TEST_FILES=`ls -1 $SRC_DIR` | ||
if [ "$?" -eq 0 ] ; then | ||
TYPE=`$GET_BUILDER_TYPE $TEST_FILES` | ||
if [ "$?" -eq 0 ] ; then | ||
echo $TYPE | ||
exit 0 | ||
fi | ||
exit 1 | ||
fi | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
usage () | ||
{ | ||
echo "$0 <file list>" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
# The preferred order is build.xml | ||
|
||
TEST_FILES="$@" | ||
|
||
for word in $TEST_FILES ; do | ||
if [ $word = build.xml ] ; then | ||
echo ant | ||
exit 0 | ||
fi | ||
done | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/sh | ||
|
||
usage () | ||
{ | ||
echo "$0 src_dir (pwd used if not set)" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
if_failure () | ||
{ | ||
if [ "$?" -ne 0 ] ; then | ||
echo "$0: Failure Error: $1" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
LOG_FILE=/tmp/build-$USER-$$.log | ||
( | ||
exec 2>&1 | ||
|
||
SRC_DIR=$1 | ||
if [ -z "$SRC_DIR" ] ; then | ||
SRC_DIR=`pwd` | ||
fi | ||
SRC_DIR=`cd "$SRC_DIR" && pwd` | ||
if [ ! -d "${SRC_DIR}" ] ; then | ||
usage "No $SRC_DIR" | ||
fi | ||
|
||
PRG="$0" | ||
PROG_HOME=`dirname "$PRG"` | ||
PROG_HOME=`cd "$PROG_HOME" && pwd` | ||
|
||
if [ -z "$BUILD_DIR" ] ; then | ||
BUILD_DIR=$HOME/Documents/code/BUILDS | ||
fi | ||
|
||
pushd $SRC_DIR | ||
REVIS=`git log -1 --pretty=format:'%H'` | ||
if_failure "Cannot get git log for $SRC_DIR" | ||
popd | ||
|
||
PROJ_NAME=`basename $SRC_DIR` | ||
BUILD_DIR=$BUILD_DIR/$PROJ_NAME-$REVIS | ||
|
||
mkdir -p $BUILD_DIR | ||
|
||
# This will start logging to a unique log file, but once we know | ||
# our build location we want it to log there. The following | ||
# command makes these two files the same, and the 'tmp' log | ||
# file location is removed at the end of the script. | ||
ln $LOG_FILE $BUILD_DIR/build_log.txt | ||
|
||
GET_BUILDER=$PROG_HOME/dir_get_builder.sh | ||
BUILD_TYPE=`$GET_BUILDER $SRC_DIR` | ||
if_failure "Can't get build type for $SRC_DIR" | ||
|
||
BUILDER=$PROG_HOME/build_$BUILD_TYPE.sh | ||
|
||
OBJ_DIR=$BUILD_DIR/obj | ||
SYM_DIR=$BUILD_DIR/sym | ||
DST_DIR=$BUILD_DIR/dst | ||
|
||
`$BUILDER $SRC_DIR $OBJ_DIR $SYM_DIR $DST_DIR $REVIS` | ||
if_failure "Can't build $BUILDER $SRC_DIR $OBJ_DIR $SYM_DIR $DST_DIR $REVIS" | ||
|
||
PACKAGE_TAR=$PROG_HOME/package_tar.sh | ||
`$PACKAGE_TAR $DST_DIR $BUILD_DIR $PROJ_NAME-$REVIS` | ||
if_failure "Can't package tar file $PACKAGE_TAR $DST_DIR $BUILD_DIR $PROJ_NAME-$REVIS" | ||
|
||
echo "Build $BUILD_DIR Succeeded!" | ||
) | tee -a $LOG_FILE | ||
|
||
rm $LOG_FILE | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
|
||
usage() | ||
{ | ||
echo "$0 src_dir dest_dir tar_name" 1>&2 | ||
echo "$0: Usage Error: $1" 1>&2 | ||
exit 1 | ||
} | ||
|
||
if_failure () | ||
{ | ||
if [ "$?" -ne 0 ] ; then | ||
echo "$0: Failure Error: $1" 1>&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
SRC_DIR=$1 | ||
if [ -z "$SRC_DIR" ] ; then | ||
usage "No src_dir." | ||
fi | ||
SRC_DIR=`cd "$SRC_DIR" && pwd` | ||
if [ ! -d "${SRC_DIR}" ] ; then | ||
usage "No $SRC_DIR" | ||
fi | ||
|
||
DEST_DIR=$2 | ||
if [ -z "$DEST_DIR" ] ; then | ||
usage "No dest_dir." | ||
fi | ||
DEST_DIR=`cd "$DEST_DIR" && pwd` | ||
if [ ! -d "${DEST_DIR}" ] ; then | ||
usage "No $DEST_DIR" | ||
fi | ||
|
||
TAR_NAME=$3 | ||
if [ -z "$TAR_NAME" ] ; then | ||
usage "No tar_name." | ||
fi | ||
|
||
cd $SRC_DIR/.. ; ln -s $SRC_DIR $TAR_NAME | ||
if_failure "symlink failed $SRC_DIR $TAR_NAME" | ||
|
||
echo "Creating $DEST_DIR/$TAR_NAME.tar.gz" 1>&2 | ||
|
||
cd $SRC_DIR/.. ; tar czfhv $DEST_DIR/$TAR_NAME.tar.gz $TAR_NAME 1>&2 | ||
if_failure "tar $DEST_DIR/$TAR_NAME.tar.gz failed" | ||
|
||
cd $SRC_DIR/.. ; rm $TAR_NAME | ||
|
||
exit 0 |