Permalink
Browse files

more build avoidance for rebar build

Modify scripts/rebar-pre-scripts and scripts/local-install to avoid
rebuilding generated files that haven't changed since the last
build. Modify scripts/Makefile to account for local-install changes.

Also apply minor fix to rebar.config indentation.
  • Loading branch information...
1 parent 21d0299 commit 61a1116c1b59aadde7612120d42576d1a5b28ff7 @vinoski vinoski committed May 8, 2011
Showing with 45 additions and 13 deletions.
  1. +1 −1 rebar.config
  2. +1 −1 scripts/Makefile
  3. +19 −7 scripts/local-install
  4. +24 −4 scripts/rebar-pre-script
View
@@ -7,7 +7,7 @@
{port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"},
{"(linux|freebsd|dragonfly|solaris|darwin)",
- "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}.
+ "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}.
{so_specs, [{"priv/lib/epam.so", ["c_src/epam.o"]},
{"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]},
View
@@ -10,7 +10,7 @@ all debug: ../bin/yaws yaws.conf
local_install: ../bin/yaws
- VARDIR='$(VARDIR)' ./local-install
+ VARDIR='$(VARDIR)' ./local-install true
yaws.conf:
YAWSDIR='$(PREFIX)/lib/yaws' LOGDIR='$(PREFIX)/var/log/yaws' \
View
@@ -13,23 +13,35 @@ if [ -z "$HOME" ]; then
fi
fi
+script=`basename $0`
+tmpgen=`mktemp /tmp/${script}.XXXXXX`
+
logdir="${HOME}/yaws_logs"
[ -d $logdir ] || mkdir $logdir
+overwrite=true
if [ -f "${HOME}/yaws.conf" ]; then
- echo "--- Will not overwrite ${HOME}/yaws.conf"
+ overwrite=false
target="${HOME}/yaws.conf.template"
else
target="${HOME}/yaws.conf"
fi
-echo "--- Installing local config file at $target"
topdir=`cd .. && pwd`
YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \
DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \
- ./gen-yaws-conf > $target
-[ -d "${HOME}/bin" ] || mkdir "${HOME}/bin"
-rm -f "${HOME}/bin/yaws"
-cp -f ../bin/yaws "${HOME}/bin/yaws"
-echo "--- Installed $HOME/bin/yaws"
+ ./gen-yaws-conf > $tmpgen
+if [ -f "$target" ] && cmp -s "$target" "$tmpgen"; then
+ rm -f "$tmpgen"
+else
+ mv -f "$tmpgen" "$target"
+ [ $overwrite = false ] && echo "--- Will not overwrite ${HOME}/yaws.conf"
+ echo "--- Installing local config file at $target"
+fi
+if [ "$1" = true ] || [ ! -f "${HOME}/bin/yaws" ]; then
+ [ -d "${HOME}/bin" ] || mkdir "${HOME}/bin"
+ rm -f "${HOME}/bin/yaws"
+ cp -f ../bin/yaws "${HOME}/bin/yaws"
+ echo "--- Installed $HOME/bin/yaws"
+fi
exit 0
@@ -14,6 +14,8 @@ WERL_BIN=$YAWS_ERLBINDIR/werl
# For rebar, support only local install for the yaws script.
YAWS_LOCALINSTALL=true
+script=`basename $0`
+
# Use a function for error exit instead of set -e so we can conditionally
# remove files before exiting. If this were bash we could trap ERR but
# Bourne shell doesn't support that portably.
@@ -22,6 +24,16 @@ fail() {
exit 1
}
+keep_or_replace() {
+ if [ -f "$1" ] && cmp -s "$1" "$2"; then
+ rm -f "$2"
+ return 0
+ else
+ mv "$2" "$1" || fail "$2"
+ return 1
+ fi
+}
+
cd src || fail
if [ "$1" = clean ]; then
@@ -45,19 +57,27 @@ if [ ! -f yaws_configure.hrl ]; then
echo '%% rebar sets HAVE_SENDFILE in erlc command line' > yaws_configure.hrl
[ $? -eq 0 ] || fail
fi
+tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
YAWS_VSN=$YAWS_VSN VARDIR="$YAWS_VARDIR" ETCDIR="$YAWS_ETCDIR" \
- ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >yaws_generated.erl || fail
+ ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >$tmpgen || fail
+keep_or_replace yaws_generated.erl $tmpgen
[ -d "$YAWS_VARDIR" ] || mkdir "$YAWS_VARDIR" || fail
[ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail
cd ../scripts
case $YAWS_LOCALINSTALL in
true)
+ tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \
- ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > ../bin/yaws || fail
- test -x ../bin/yaws || chmod +x ../bin/yaws || fail
- VARDIR="${YAWS_VARDIR}" ./local-install || fail
+ ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > $tmpgen || fail
+ keep_or_replace ../bin/yaws $tmpgen
+ if [ $? -eq 0 ]; then
+ VARDIR="${YAWS_VARDIR}" ./local-install false || fail
+ else
+ chmod +x ../bin/yaws || fail
+ VARDIR="${YAWS_VARDIR}" ./local-install true || fail
+ fi
;;
*)
echo "ERROR: Configurations other than 'localinstall' not yet \

0 comments on commit 61a1116

Please sign in to comment.