Просмотр исходного кода

Update to modernize build a little bit

Jordan Wilberding 11 лет назад
Родитель
Сommit
70b7a5c4a1
3 измененных файлов с 72 добавлено и 10 удалено
  1. 65 10
      Makefile
  2. 3 0
      cover.spec
  3. 4 0
      rebar.config

+ 65 - 10
Makefile

@@ -1,25 +1,80 @@
+ERLFLAGS= -pa $(CURDIR)/.eunit -pa $(CURDIR)/ebin -pa $(CURDIR)/deps/*/ebin
+
+DEPS_PLT=$(CURDIR)/.deps_plt
+
+# =============================================================================
+# Verify that the programs we need to run are installed on this system
+# =============================================================================
+ERL = $(shell which erl)
+
+ifeq ($(ERL),)
+$(error "Erlang not available on this system")
+endif
+
+REBAR=$(shell which rebar)
+
+# If building on travis, use the rebar in the current directory
+ifeq ($(TRAVIS),true)
+REBAR=$(CURDIR)/rebar
+endif
+
+ifeq ($(REBAR),)
+REBAR=$(CURDIR)/rebar
+endif
+
 .PHONY: all compile test dialyzer clean distclean doc
 .PHONY: all compile test dialyzer clean distclean doc
 
 
 all: compile test dialyzer
 all: compile test dialyzer
-	@rebar compile
 
 
-compile:
+REBAR_URL=https://github.com/rebar/rebar/wiki/rebar
-	@rebar compile
+$(REBAR):
+	curl -Lo rebar $(REBAR_URL) || wget $(REBAR_URL)
+	chmod a+x rebar
 
 
-test:
+get-rebar: $(REBAR)
-	@rebar eunit skip_deps=true
 
 
-dialyzer:
+compile: $(REBAR)
+	$(REBAR) compile
+
+eunit: compile clean-common-test-data
+	$(REBAR) skip_deps=true eunit
+
+ct: compile clean-common-test-data
+	mkdir -p $(CURDIR) logs
+	ct_run -pa $(CURDIR)/ebin \
+	-pa $(CURDIR)/deps/*/ebin \
+	-logdir $(CURDIR)/logs \
+	-dir $(CURDIR)/test/ \
+	-cover cover.spec
+
+test: compile dialyzer eunit ct
+
+$(DEPS_PLT): compile
+	@echo Building local erts plt at $(DEPS_PLT)
+	@echo
+	$(DIALYZER) --output_plt $(DEPS_PLT) --build_plt \
+	   --apps erts kernel stdlib -r deps
+
+dialyzer: compile $(DEPS_PLT)
 	@dialyzer -Wunderspecs -r ebin
 	@dialyzer -Wunderspecs -r ebin
 
 
 doc:
 doc:
-	@rebar doc skip_deps=true
+	$(REBAR) doc skip_deps=true
+
+clean-common-test-data:
+# We have to do this because of the unique way we generate test
+# data. Without this rebar eunit gets very confused
+	- rm -rf $(CURDIR)/test/*_SUITE_data
 
 
-clean:
+clean: clean-common-test-data $(REBAR)
-	@rebar clean
+	- rm -rf $(CURDIR)/test/*.beam
+	- rm -rf $(CURDIR)/logs
+	- rm -rf $(CURDIR)/ebin
+	$(REBAR) skip_deps=true clean
 
 
 distclean: clean
 distclean: clean
-	@rebar delete-deps
+	- rm -rf $(DEPS_PLT)
+	$(REBAR) delete-deps
 
 
 demo_shell: compile test
 demo_shell: compile test
 	@erl -pa .eunit ebin -config pooler-example -s pooler manual_start
 	@erl -pa .eunit ebin -config pooler-example -s pooler manual_start

+ 3 - 0
cover.spec

@@ -0,0 +1,3 @@
+%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+{incl_app, pooler}.
+{level, details}.

+ 4 - 0
rebar.config

@@ -11,4 +11,8 @@
      warnings_as_errors,
      warnings_as_errors,
      inline]}.
      inline]}.
 
 
+%% EUnit =======================================================================
+{eunit_opts,
+ [{report, {eunit_surefire, [{dir, "."}]}}]}.
 {cover_enabled, true}.
 {cover_enabled, true}.
+{cover_print_enabled, true}.