Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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...
commit 61a1116c1b59aadde7612120d42576d1a5b28ff7 1 parent 21d0299
Steve Vinoski vinoski authored
2  rebar.config
@@ -7,7 +7,7 @@
7 7
8 8 {port_envs, [{"CFLAGS", "$CFLAGS -g -O3 -Wall -I/usr/include/security"},
9 9 {"(linux|freebsd|dragonfly|solaris|darwin)",
10   - "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}.
  10 + "DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}]}.
11 11
12 12 {so_specs, [{"priv/lib/epam.so", ["c_src/epam.o"]},
13 13 {"priv/lib/setuid_drv.so", ["c_src/setuid_drv.o"]},
2  scripts/Makefile
@@ -10,7 +10,7 @@ all debug: ../bin/yaws yaws.conf
10 10
11 11
12 12 local_install: ../bin/yaws
13   - VARDIR='$(VARDIR)' ./local-install
  13 + VARDIR='$(VARDIR)' ./local-install true
14 14
15 15 yaws.conf:
16 16 YAWSDIR='$(PREFIX)/lib/yaws' LOGDIR='$(PREFIX)/var/log/yaws' \
26 scripts/local-install
@@ -13,23 +13,35 @@ if [ -z "$HOME" ]; then
13 13 fi
14 14 fi
15 15
  16 +script=`basename $0`
  17 +tmpgen=`mktemp /tmp/${script}.XXXXXX`
  18 +
16 19 logdir="${HOME}/yaws_logs"
17 20 [ -d $logdir ] || mkdir $logdir
  21 +overwrite=true
18 22 if [ -f "${HOME}/yaws.conf" ]; then
19   - echo "--- Will not overwrite ${HOME}/yaws.conf"
  23 + overwrite=false
20 24 target="${HOME}/yaws.conf.template"
21 25 else
22 26 target="${HOME}/yaws.conf"
23 27 fi
24   -echo "--- Installing local config file at $target"
25 28
26 29 topdir=`cd .. && pwd`
27 30 YAWSDIR="$topdir" LOGDIR="$logdir" VARDIR="$VARDIR" PORT=8000 \
28 31 DOCROOT="${topdir}/www" CERTDIR="${topdir}/ssl" SSLPORT=4443 \
29   - ./gen-yaws-conf > $target
30   -[ -d "${HOME}/bin" ] || mkdir "${HOME}/bin"
31   -rm -f "${HOME}/bin/yaws"
32   -cp -f ../bin/yaws "${HOME}/bin/yaws"
33   -echo "--- Installed $HOME/bin/yaws"
  32 + ./gen-yaws-conf > $tmpgen
  33 +if [ -f "$target" ] && cmp -s "$target" "$tmpgen"; then
  34 + rm -f "$tmpgen"
  35 +else
  36 + mv -f "$tmpgen" "$target"
  37 + [ $overwrite = false ] && echo "--- Will not overwrite ${HOME}/yaws.conf"
  38 + echo "--- Installing local config file at $target"
  39 +fi
  40 +if [ "$1" = true ] || [ ! -f "${HOME}/bin/yaws" ]; then
  41 + [ -d "${HOME}/bin" ] || mkdir "${HOME}/bin"
  42 + rm -f "${HOME}/bin/yaws"
  43 + cp -f ../bin/yaws "${HOME}/bin/yaws"
  44 + echo "--- Installed $HOME/bin/yaws"
  45 +fi
34 46
35 47 exit 0
28 scripts/rebar-pre-script
@@ -14,6 +14,8 @@ WERL_BIN=$YAWS_ERLBINDIR/werl
14 14 # For rebar, support only local install for the yaws script.
15 15 YAWS_LOCALINSTALL=true
16 16
  17 +script=`basename $0`
  18 +
17 19 # Use a function for error exit instead of set -e so we can conditionally
18 20 # remove files before exiting. If this were bash we could trap ERR but
19 21 # Bourne shell doesn't support that portably.
@@ -22,6 +24,16 @@ fail() {
22 24 exit 1
23 25 }
24 26
  27 +keep_or_replace() {
  28 + if [ -f "$1" ] && cmp -s "$1" "$2"; then
  29 + rm -f "$2"
  30 + return 0
  31 + else
  32 + mv "$2" "$1" || fail "$2"
  33 + return 1
  34 + fi
  35 +}
  36 +
25 37 cd src || fail
26 38
27 39 if [ "$1" = clean ]; then
@@ -45,8 +57,10 @@ if [ ! -f yaws_configure.hrl ]; then
45 57 echo '%% rebar sets HAVE_SENDFILE in erlc command line' > yaws_configure.hrl
46 58 [ $? -eq 0 ] || fail
47 59 fi
  60 +tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
48 61 YAWS_VSN=$YAWS_VSN VARDIR="$YAWS_VARDIR" ETCDIR="$YAWS_ETCDIR" \
49   - ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >yaws_generated.erl || fail
  62 + ../scripts/gen-yaws-generated $YAWS_LOCALINSTALL >$tmpgen || fail
  63 +keep_or_replace yaws_generated.erl $tmpgen
50 64 [ -d "$YAWS_VARDIR" ] || mkdir "$YAWS_VARDIR" || fail
51 65 [ -d "$YAWS_ETCDIR" ] || mkdir "$YAWS_ETCDIR" || fail
52 66
@@ -54,10 +68,16 @@ cd ../scripts
54 68
55 69 case $YAWS_LOCALINSTALL in
56 70 true)
  71 + tmpgen=`mktemp /tmp/${script}.XXXXXX` || fail
57 72 VARDIR="${YAWS_VARDIR}" ERLBINDIR="${YAWS_ERLBINDIR}" \
58   - ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > ../bin/yaws || fail
59   - test -x ../bin/yaws || chmod +x ../bin/yaws || fail
60   - VARDIR="${YAWS_VARDIR}" ./local-install || fail
  73 + ERL="${ERL_BIN}" WERL="${WERL_BIN}" ./gen-yaws > $tmpgen || fail
  74 + keep_or_replace ../bin/yaws $tmpgen
  75 + if [ $? -eq 0 ]; then
  76 + VARDIR="${YAWS_VARDIR}" ./local-install false || fail
  77 + else
  78 + chmod +x ../bin/yaws || fail
  79 + VARDIR="${YAWS_VARDIR}" ./local-install true || fail
  80 + fi
61 81 ;;
62 82 *)
63 83 echo "ERROR: Configurations other than 'localinstall' not yet \

0 comments on commit 61a1116

Please sign in to comment.
Something went wrong with that request. Please try again.