Skip to content

Commit

Permalink
more build avoidance for rebar build
Browse files Browse the repository at this point in the history
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
vinoski committed May 8, 2011
1 parent 21d0299 commit 61a1116
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rebar.config
Expand Up @@ -7,7 +7,7 @@


{port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"}, {port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"},
{"(linux|freebsd|dragonfly|solaris|darwin)", {"(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"]}, {so_specs, [{"priv/lib/epam.so", ["c_src/epam.o"]},
{"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]}, {"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]},
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile
Expand Up @@ -10,7 +10,7 @@ all debug: ../bin/yaws yaws.conf




local_install: ../bin/yaws local_install: ../bin/yaws
VARDIR='$(VARDIR)' ./local-install VARDIR='$(VARDIR)' ./local-install true


yaws.conf: yaws.conf:
YAWSDIR='$(PREFIX)/lib/yaws' LOGDIR='$(PREFIX)/var/log/yaws' \ YAWSDIR='$(PREFIX)/lib/yaws' LOGDIR='$(PREFIX)/var/log/yaws' \
Expand Down
26 changes: 19 additions & 7 deletions scripts/local-install
Expand Up @@ -13,23 +13,35 @@ if [ -z "$HOME" ]; then
fi fi
fi fi


script=`basename $0`
tmpgen=`mktemp /tmp/${script}.XXXXXX`

logdir="${HOME}/yaws_logs" logdir="${HOME}/yaws_logs"
[ -d $logdir ] || mkdir $logdir [ -d $logdir ] || mkdir $logdir
overwrite=true
if [ -f "${HOME}/yaws.conf" ]; then if [ -f "${HOME}/yaws.conf" ]; then
echo "--- Will not overwrite ${HOME}/yaws.conf" overwrite=false
target="${HOME}/yaws.conf.template" target="${HOME}/yaws.conf.template"
else else
target="${HOME}/yaws.conf" target="${HOME}/yaws.conf"
fi fi
echo "--- Installing local config file at $target"


topdir=`cd .. && pwd` topdir=`cd .. && pwd`
YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \ YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \
DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \ DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \
./gen-yaws-conf > $target ./gen-yaws-conf > $tmpgen
[ -d "${HOME}/bin" ] || mkdir "${HOME}/bin" if [ -f "$target" ] && cmp -s "$target" "$tmpgen"; then
rm -f "${HOME}/bin/yaws" rm -f "$tmpgen"
cp -f ../bin/yaws "${HOME}/bin/yaws" else
echo "--- Installed $HOME/bin/yaws" 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 exit 0
28 changes: 24 additions & 4 deletions scripts/rebar-pre-script
Expand Up @@ -14,6 +14,8 @@ WERL_BIN=$YAWS_ERLBINDIR/werl
# For rebar, support only local install for the yaws script. # For rebar, support only local install for the yaws script.
YAWS_LOCALINSTALL=true YAWS_LOCALINSTALL=true


script=`basename $0`

# Use a function for error exit instead of set -e so we can conditionally # 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 # remove files before exiting. If this were bash we could trap ERR but
# Bourne shell doesn't support that portably. # Bourne shell doesn't support that portably.
Expand All @@ -22,6 +24,16 @@ fail() {
exit 1 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 cd src || fail


if [ "$1" = clean ]; then if [ "$1" = clean ]; then
Expand All @@ -45,19 +57,27 @@ if [ ! -f yaws_configure.hrl ]; then
echo '%% rebar sets HAVE_SENDFILE in erlc command line' > yaws_configure.hrl echo '%% rebar sets HAVE_SENDFILE in erlc command line' > yaws_configure.hrl
[ $? -eq 0 ] || fail [ $? -eq 0 ] || fail
fi fi
tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
YAWS_VSN=$YAWS_VSN VARDIR="$YAWS_VARDIR" ETCDIR="$YAWS_ETCDIR" \ 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_VARDIR" ] || mkdir "$YAWS_VARDIR" || fail
[ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail [ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail


cd ../scripts cd ../scripts


case $YAWS_LOCALINSTALL in case $YAWS_LOCALINSTALL in
true) true)
tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \ VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \
ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > ../bin/yaws || fail ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > $tmpgen || fail
test -x ../bin/yaws || chmod +x ../bin/yaws || fail keep_or_replace ../bin/yaws $tmpgen
VARDIR="${YAWS_VARDIR}" ./local-install || fail 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 \ echo "ERROR: Configurations other than 'localinstall' not yet \
Expand Down

0 comments on commit 61a1116

Please sign in to comment.