Skip to content

Commit 5915af0

Browse files
committed
Update Makefile to rebar3
1 parent a07d1b2 commit 5915af0

File tree

1 file changed

+32
-34
lines changed

1 file changed

+32
-34
lines changed

Makefile

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ PKG_REVISION ?= $(shell git describe --tags 2>/dev/null)
44
PKG_BUILD = 1
55
BASE_DIR = $(shell pwd)
66
ERLANG_BIN = $(shell dirname $(shell which erl 2>/dev/null) 2>/dev/null)
7-
REBAR ?= $(BASE_DIR)/rebar
7+
REBAR ?= $(BASE_DIR)/rebar3
88
OVERLAY_VARS ?=
9-
SPECIAL_DEPS ?= meck hamcrest riak_ensemble webmachine
109
TEST_IGNORE ?=
10+
TEST_DEPS_DIR ?= _build/test/lib
11+
DEPS = $(patsubst $(TEST_DEPS_DIR)/%, %, $(wildcard $(TEST_DEPS_DIR)/*))
12+
TEST_DEPS = $(filter-out $(TEST_IGNORE), $(DEPS))
1113

1214
RIAK_CORE_STAT_PREFIX = riak
1315
export RIAK_CORE_STAT_PREFIX
@@ -22,34 +24,24 @@ $(if $(ERLANG_BIN),,$(warning "Warning: No Erlang found in your path, this will
2224
all: deps compile
2325

2426
compile:
25-
./rebar compile
27+
$(REBAR) compile
2628

2729
deps:
2830
$(if $(HEAD_REVISION),$(warning "Warning: you have checked out a tag ($(HEAD_REVISION)) and should use the locked-deps target"))
29-
./rebar get-deps
31+
$(REBAR) get-deps
3032

3133
clean: testclean
32-
./rebar clean
34+
$(REBAR) clean
3335

3436
distclean: clean devclean relclean ballclean
35-
./rebar delete-deps
37+
@rm -rf _build
3638

3739
generate:
38-
./rebar generate $(OVERLAY_VARS)
39-
40-
41-
##
42-
## Lock Targets
43-
##
44-
## see https://github.com/seth/rebar_lock_deps_plugin
45-
lock: deps compile
46-
./rebar lock-deps
47-
48-
locked-all: locked-deps compile
40+
@echo "Todo: migrate to relx"
41+
# ./rebar generate $(OVERLAY_VARS)
4942

5043
locked-deps:
51-
@echo "Using rebar.config.lock file to fetch dependencies"
52-
./rebar -C rebar.config.lock get-deps
44+
$(REBAR) upgrade
5345

5446
##
5547
## Test targets
@@ -58,22 +50,28 @@ TEST_LOG_FILE := eunit.log
5850
testclean:
5951
@rm -f $(TEST_LOG_FILE)
6052

53+
TMP_CONFIG=rebar.config.tmp
54+
55+
# Tricking rebar3 to use the dependencies from the top-level _build directory.
56+
testdep-% :
57+
@echo "--- Running EUnit tests for $* ---"
58+
@rm -rf _build/deptest+test _build/deptest
59+
@(cd $(TEST_DEPS_DIR)/$* && \
60+
cp rebar.config $(TMP_CONFIG) && \
61+
echo "" >> $(TMP_CONFIG) && \
62+
echo '{profiles, [{deptest, [{base_dir, "../../.."}]}]}.' >> $(TMP_CONFIG) && \
63+
REBAR_CONFIG=$(TMP_CONFIG) $(REBAR) as deptest eunit) || echo "Eunit: $* FAILED" >> $(TEST_LOG_FILE)
64+
@(cd $(TEST_DEPS_DIR)/$* && rm -f $(TMP_CONFIG))
65+
66+
test-deps : deps compile testclean $(patsubst %, testdep-%, $(TEST_DEPS))
67+
6168
# Test each dependency individually in its own VM
62-
test : deps compile testclean
63-
@$(foreach dep, \
64-
$(filter-out $(TEST_IGNORE), \
65-
$(filter-out $(SPECIAL_DEPS), $(patsubst deps/%, %, $(wildcard deps/*)))), \
66-
(cd deps/$(dep) && REBAR_DEPS_DIR=$(BASE_DIR)/deps/ ../../rebar eunit deps_dir=.. skip_deps=true) \
67-
|| echo "Eunit: $(dep) FAILED" >> $(TEST_LOG_FILE);)
68-
@$(foreach special, \
69-
$(filter-out $(TEST_IGNORE), $(SPECIAL_DEPS)), \
70-
(cd deps/$(special) && make test) \
71-
|| echo "Eunit: $(special) FAILED" >> $(TEST_LOG_FILE);)
72-
./rebar eunit skip_deps=true
69+
test : test-deps
70+
$(REBAR) eunit
7371
@if test -s $(TEST_LOG_FILE) ; then \
74-
cat $(TEST_LOG_FILE) && \
75-
exit `wc -l < $(TEST_LOG_FILE)`; \
76-
fi
72+
cat $(TEST_LOG_FILE) && \
73+
exit `wc -l < $(TEST_LOG_FILE)`; \
74+
fi
7775

7876
##
7977
## Release targets
@@ -136,7 +134,7 @@ stage : rel
136134
## Doc targets
137135
##
138136
docs:
139-
./rebar skip_deps=true doc
137+
$(REBAR) doc
140138
@cp -R apps/riak_core/doc doc/riak_core
141139
@cp -R apps/riak_kv/doc doc/riak_kv
142140

0 commit comments

Comments
 (0)