summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-03-08 15:29:27 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-03-08 16:09:33 -0400
commit7b2d75904c8f93cbec40bdc3905ba81f48f84853 (patch)
tree66810cfc85ec4f27bea3e3ecab470aa49d13b38a
parentdb70bb1d044a867cd517728fdf03a1b12f27bbc8 (diff)
downloadfork-ledger-7b2d75904c8f93cbec40bdc3905ba81f48f84853.tar.gz
fork-ledger-7b2d75904c8f93cbec40bdc3905ba81f48f84853.tar.bz2
fork-ledger-7b2d75904c8f93cbec40bdc3905ba81f48f84853.zip
Several improvements to how directories are chosen
-rwxr-xr-xtools/build9
-rwxr-xr-xtools/myacprep57
-rwxr-xr-xtools/outdir12
-rwxr-xr-xtools/pre-commit14
-rwxr-xr-xtools/proof22
5 files changed, 60 insertions, 54 deletions
diff --git a/tools/build b/tools/build
index 05c7d75a..d2753a11 100755
--- a/tools/build
+++ b/tools/build
@@ -3,9 +3,12 @@
set -e
SRCDIR=$(pwd)
+OUTPUT=$(tools/outdir)
+SWITCHES=""
-if [ -d ~/Products/ledger ]; then
- cd ~/Products/ledger
+if [ -n "$OUTPUT" -a -d "$OUTPUT" ]; then
+ cd "$OUTPUT"
+ SWITCHES="--output $OUTPUT"
fi
if [ ! -f Makefile -o \
@@ -13,7 +16,7 @@ if [ ! -f Makefile -o \
$SRCDIR/configure.ac -nt Makefile -o \
$SRCDIR/acprep -nt Makefile -o \
$SRCDIR/myacprep -nt Makefile ]; then
- (cd $SRCDIR && tools/myacprep)
+ (cd $SRCDIR && tools/myacprep "$SWITCHES")
fi
make "$@"
diff --git a/tools/myacprep b/tools/myacprep
index deea104e..5f25a5c7 100755
--- a/tools/myacprep
+++ b/tools/myacprep
@@ -1,44 +1,37 @@
#!/bin/sh
-OUT=$HOME/Products
-SWITCHES=""
+OUTPUT=$(tools/outdir)
+PRODUCTS=$(dirname "$OUTPUT")
+SWITCHES="--pch --warn --devel --debug"
-saw_opt=false
while [ -n "$1" ]; do
case "$1" in
--local)
- OUT=""
SWITCHES="$SWITCHES --local"
shift 1 ;;
--output)
- OUT=""
shift 1
SWITCHES="$SWITCHES --output $1"
shift 1 ;;
--gprof)
- OUT="$OUT/ledger-gprof"
- SWITCHES="$SWITCHES $1 --release --pch"
- saw_opt=true
+ SWITCHES="$1 --release --pch"
+ SWITCHES="$SWITCHES --output $PRODUCTS/ledger-gprof"
shift 1 ;;
--gcov)
- OUT="$OUT/ledger-gcov"
- SWITCHES="$SWITCHES $1 --release --pch"
- saw_opt=true
+ SWITCHES="$1 --release --pch"
+ SWITCHES="$SWITCHES --output $PRODUCTS/ledger-gcov"
shift 1 ;;
--opt)
- OUT="$OUT/ledger-opt"
- SWITCHES="$SWITCHES $1 --release --pch --warn"
- saw_opt=true
- shift 1 ;;
- --std)
- OUT="$OUT/ledger-std"
- SWITCHES="$SWITCHES --release --pch --warn"
- saw_opt=true
+ SWITCHES="$1 --release --pch --warn"
+ SWITCHES="$SWITCHES --output $PRODUCTS/ledger-opt"
shift 1 ;;
--debug)
- OUT="$OUT/ledger-debug"
- SWITCHES="$SWITCHES $1 --pch --warn --devel"
- saw_opt=true
+ SWITCHES="$1 --pch --warn --devel"
+ SWITCHES="$SWITCHES --output $PRODUCTS/ledger-debug"
+ shift 1 ;;
+ --std)
+ SWITCHES="--release --pch --warn"
+ SWITCHES="$SWITCHES --output $PRODUCTS/ledger-std"
shift 1 ;;
*)
SWITCHES="$SWITCHES $1"
@@ -46,24 +39,10 @@ while [ -n "$1" ]; do
esac
done
-if [ $saw_opt = false ]; then
- SWITCHES="$SWITCHES --pch" # build using pre-compiled headers
- SWITCHES="$SWITCHES --warn" # show full compiler warnings
- SWITCHES="$SWITCHES --debug" # enable debug code generation
- SWITCHES="$SWITCHES --devel" # use GLIBCXX_DEBUG if possible
- if [ -n "$OUT" ]; then
- OUT="$OUT/ledger"
+if [ -n "$OUTPUT" ]; then
+ if echo "$SWITCHES" | egrep -qv '(output|local)'; then
+ SWITCHES="$SWITCHES --output $OUTPUT"
fi
fi
-if [ -n "$OUT" ]; then
- [ -d "$OUT" ] || mkdir -p "$OUT"
- SWITCHES="$SWITCHES --output $OUT"
-fi
-
./acprep $SWITCHES
-
-if [ $saw_opt = false -a -n "$OUT" ]; then
- ln -sf $OUT/TAGS .
- ln -sf $OUT/ledger .
-fi
diff --git a/tools/outdir b/tools/outdir
new file mode 100755
index 00000000..3c51e354
--- /dev/null
+++ b/tools/outdir
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+PRODUCTS=$HOME/Products
+
+SRCDIR=$(pwd)
+BASE=$(basename "$SRCDIR")
+
+OUTPUT="$PRODUCTS/$BASE"
+
+if [ -d "$OUTPUT" ]; then
+ echo $OUTPUT
+fi
diff --git a/tools/pre-commit b/tools/pre-commit
index 3508958d..b04b895c 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -10,8 +10,18 @@ if [ $(git rev-parse --symbolic-full-name HEAD) = refs/heads/test ]; then
fi
# These are the locations I keep my temporary source and build trees in
-TMPDIR=$HOME/Products/ledger-pre-commit
-MIRROR=$HOME/Products/ledger-pre-commit-mirror
+OUTPUT=$(tools/outdir) # generates a build directory name such as
+ # ~/Products/ledger
+PRODUCTS=$(dirname "$OUTPUT")
+BASE=$(basename "$OUTPUT")
+
+if [ -z "$BASE" ]; then
+ TMPDIR=$PWD/pre-commit
+ MIRROR=$PWD/pre-commit-mirror
+else
+ TMPDIR=$PRODUCTS/$BASE-pre-commit
+ MIRROR=$PRODUCTS/$BASE-pre-commit-mirror
+fi
# Exit with status 1 if any command below fails
set -e
diff --git a/tools/proof b/tools/proof
index aaf8a6b6..9cd1dc3f 100755
--- a/tools/proof
+++ b/tools/proof
@@ -2,6 +2,12 @@
set -e
+OUTPUT=$(tools/outdir)
+PRODUCTS=$(dirname "$OUTPUT")
+
+# We know which target pathnames are used here, because they are encoded in
+# tools/myacprep when specific build targets are requested (such as gcov).
+
function build_and_test() {
NAME=--$1
@@ -11,7 +17,7 @@ function build_and_test() {
exit 1
fi
- DIR=$HOME/Products/ledger-$1
+ DIR=$PRODUCTS/ledger-$1
echo %%% Cleaning $NAME %%%
if ! (cd $DIR && make clean); then
@@ -40,28 +46,24 @@ function build_and_test() {
fi
}
-echo %%% Copying src %%%
-rsync -a --delete ~/Projects/ledger/ ~/Products/ledger-src/
-cd ~/Products/ledger-src
-
echo %%% Removing old opt %%%
-rm -fr ~/Products/ledger-opt
+rm -fr $PRODUCTS/ledger-opt
build_and_test opt
echo %%% Removing old gcov %%%
-rm -fr ~/Products/ledger-gcov
+rm -fr $PRODUCTS/ledger-gcov
build_and_test gcov
echo %%% Removing old std %%%
-rm -fr ~/Products/ledger-std
+rm -fr $PRODUCTS/ledger-std
build_and_test std
echo %%% Removing old debug %%%
-rm -fr ~/Products/ledger-debug
+rm -fr $PRODUCTS/ledger-debug
build_and_test debug
echo %%% Building release-distcheck %%%
-if ! (cd ~/Products/ledger-std && make release-distcheck); then
+if ! (cd $PRODUCTS/ledger-std && make release-distcheck); then
echo %%% FAILED to build release-distcheck %%%
exit 1
fi