Browse files

Don't bundle rebar, download it if needed

  • Loading branch information...
1 parent 6a4f539 commit 2e0ada703c47137c3abed71d9a5f09599a550900 @andrewtj andrewtj committed Jan 3, 2012
Showing with 34 additions and 15 deletions.
  1. +34 −15 Makefile
  2. BIN rebar
View
49 Makefile
@@ -1,3 +1,6 @@
+REBAR:=$(shell which rebar || echo ./rebar)
+REBAR_URL:="https://github.com/downloads/basho/rebar/rebar"
+
gh-pages : TMPDIR := $(shell mktemp -d -t dns_erlang.gh-pages.XXXX)
gh-pages : BRANCH := $(shell git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1 /')
gh-pages : STASH := $(shell (test -z "`git status --porcelain`" && echo false) || echo true)
@@ -7,25 +10,41 @@ gh-pages : VERSION := $(shell sed -n 's/.*{vsn,.*"\(.*\)"}.*/\1/p' src/dns.app.s
all: deps compile
-compile:
- @./rebar compile
-
-deps:
- @./rebar get-deps
-
-doc:
- @./rebar doc skip_deps=true
-
-clean:
- @./rebar clean
+$(REBAR):
+ @echo "No rebar was found so a copy will be downloaded in 5 seconds."
+ @echo "Source: ${REBAR_URL} Destination: ${REBAR}"
+ @sleep 5
+ @echo "Commencing download... "
+ @erl -noshell -eval "\
+[ application:start(X) || X <- [crypto,public_key,ssl,inets]],\
+Request = {\"${REBAR_URL}\", []},\
+HttpOpts = [],\
+Opts = [{stream, \"$(REBAR)\"}],\
+Result = httpc:request(get, Request, HttpOpts, Opts),\
+Status = case Result of {ok, _} -> 0; _ -> 1 end,\
+init:stop(Status)."
+ @chmod u+x ./rebar
+ @echo "ok"
+
+compile: $(REBAR)
+ @$(REBAR) compile
+
+deps: $(REBAR)
+ @$(REBAR) get-deps
+
+doc: $(REBAR)
+ @$(REBAR) doc skip_deps=true
+
+clean: $(REBAR)
+ @$(REBAR) clean
@rm -fr doc/*
-gh-pages: test doc
+gh-pages: $(REBAR) test doc
@echo "Building gh-pages for ${VERSION} in ${TMPDIR} from branch ${BRANCH}. Branch dirty: ${STASH}."
sed 's/{{VERSION}}/${VERSION}/g' priv/index.html > ${TMPDIR}/index.html
rsync -a --remove-source-files doc/ ${TMPDIR}/doc
rsync -a --remove-source-files .eunit/ ${TMPDIR}/coverage
- @./rebar clean
+ @$(REBAR) clean
(${STASH} && git stash save) || true
git checkout gh-pages
rsync -a --delete ${TMPDIR}/* .
@@ -35,5 +54,5 @@ gh-pages: test doc
(${STASH} && git stash pop) || true
rm -fr ${TMPDIR}
-test: all
- @./rebar eunit skip_deps=true
+test: $(REBAR) all
+ @$(REBAR) eunit skip_deps=true
View
BIN rebar
Binary file not shown.

0 comments on commit 2e0ada7

Please sign in to comment.