Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to rebar3 #87

Merged
merged 3 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
.#*
/*.plt
/.deps_plt
/.eunit
/.rebar
/_build/
/bin
/deps
/doc/*.html
/doc/edoc-info
/doc/erlang.png
/doc/stylesheet.css
/ebin
/erl_crash.dump
/rebar3.crashdump
/logs
/rebar.lock
/test/*.beam
/test/dialyzer_warnings
/test/elvis
/test/elvis_warnings
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
sudo: false
language:
- erlang
language: erlang
os: linux

matrix:
jobs:
include:
- otp_release: 22.2
- otp_release: 22.1
- otp_release: 22.0
- otp_release: 21.3
Expand All @@ -26,7 +26,7 @@ matrix:
- otp_release: 18.1
- otp_release: 18.0
script:
- LATEST_OTP_RELEASE=22.1
- "[[ ${TRAVIS_OTP_RELEASE} != ${LATEST_OTP_RELEASE} ]] || make elvis"
- LATEST_OTP_RELEASE=22.2
- "[[ ${TRAVIS_OTP_RELEASE} != ${LATEST_OTP_RELEASE} ]] || make elvis docs"
- make
- make test
109 changes: 27 additions & 82 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,131 +1,76 @@
# See LICENSE for licensing information.

REBAR ?= $(shell command -v rebar >/dev/null 2>&1 && echo "rebar" || echo "$(CURDIR)/rebar")

ELVIS ?= $(shell command -v elvis >/dev/null 2>&1 && echo "elvis" || echo "$(CURDIR)/elvis")

DEPS_PLT := $(CURDIR)/.deps_plt

ERLANG_DIALYZER_APPS := erts \
kernel \
stdlib \
inets

DIALYZER := dialyzer

# Travis CI is slow at building dialyzer PLT
TRAVIS ?=
ifeq (true,$(TRAVIS))
OTP_VSN := $(shell erl -noshell -eval 'io:format("~p", [erlang:system_info(otp_release)]), erlang:halt(0).' | perl -lne 'print for /^(?:"R)?(\d+).*/g')
NO_DIALYZER := $(shell expr $(OTP_VSN) \<= 16 )

ifeq ($(NO_DIALYZER), 1)
DIALYZER := : not running dialyzer on TRAVIS with R16 and below
endif
endif
REBAR ?= $(shell command -v rebar3 >/dev/null 2>&1 && echo "rebar3" || echo "$(CURDIR)/rebar3")

SRCS := $(wildcard src/* include/* rebar.config)

SRC_BEAMS := $(patsubst src/%.erl, ebin/%.beam, $(wildcard src/*.erl))

.PHONY: all
all: maybe_dev deps ebin/jesse.app bin/jesse

.PHONY: maybe_dev
maybe_dev:
ifdef CI
$(MAKE) --no-print-directory .rebar/DEV_MODE
else
@:
endif
all: escript

# Clean

.PHONY: clean
clean:
$(REBAR) clean
$(RM) -r .rebar
$(RM) -r bin

.PHONY: distclean
distclean:
$(MAKE) clean
$(RM) -r _build
$(RM) doc/*.html
$(RM) doc/edoc-info
$(RM) doc/erlang.png
$(RM) doc/stylesheet.css
$(RM) -r ebin
$(RM) -r logs

.PHONY: distclean
distclean:
$(RM) $(DEPS_PLT)
$(RM) -r deps
$(MAKE) clean

# Deps

.PHONY: get-deps
get-deps:
$(REBAR) get-deps
[ -f .rebar/DEV_MODE ] && git submodule update --init --recursive || true

.PHONY: update-deps
update-deps:
$(REBAR) update-deps

.PHONY: delete-deps
delete-deps:
$(REBAR) delete-deps

.PHONY: deps
deps: get-deps

# Docs

.PHONY: docs
docs:
$(REBAR) doc skip_deps=true
$(REBAR) edoc

# Compile

ebin/jesse.app: compile

bin/jesse: ebin/jesse.app $(SRC_BEAMS)
.PHONY: escript
escript: ebin/jesse.app
$(REBAR) escriptize
bin/jesse --help
./_build/default/bin/jesse --help

.PHONY: compile
compile: $(SRCS)
$(REBAR) compile

# Tests.
test/JSON-Schema-Test-Suite/tests:
git submodule init
git submodule update

# Would be nice to include elvis to test, but it fails on OTP-18
.PHONY: test
test: .rebar/DEV_MODE deps eunit ct xref dialyzer

.rebar/DEV_MODE:
mkdir -p .rebar
touch .rebar/DEV_MODE
test: eunit ct xref dialyzer cover

.PHONY: eunit
eunit:
$(REBAR) eunit skip_deps=true
$(REBAR) eunit

.PHONY: ct
ct:
$(REBAR) ct skip_deps=true suites="jesse_tests_draft3,jesse_tests_draft4"
ct: test/JSON-Schema-Test-Suite/tests
$(REBAR) ct

.PHONY: xref
xref:
$(REBAR) xref skip_deps=true

$(DEPS_PLT):
$(DIALYZER) --build_plt --apps $(ERLANG_DIALYZER_APPS) -r deps --output_plt $(DEPS_PLT)
$(REBAR) xref

.PHONY: dialyzer
dialyzer: $(DEPS_PLT) ebin/jesse.app
$(DIALYZER) -q --plt $(DEPS_PLT) -Wno_return ebin > test/dialyzer_warnings || true
diff -U0 test/known_dialyzer_warnings test/dialyzer_warnings
dialyzer:
$(REBAR) dialyzer

.PHONY: elvis
elvis:
$(ELVIS) rock > test/elvis || true
grep "FAIL" test/elvis | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > test/elvis_warnings
diff -U0 test/known_elvis_warnings test/elvis_warnings || cat test/elvis
$(REBAR) as lint lint

.PHONY: cover
cover:
$(REBAR) cover -v
Binary file removed elvis
Binary file not shown.
80 changes: 0 additions & 80 deletions elvis.config

This file was deleted.

Binary file removed rebar
Binary file not shown.
Loading