diff --git a/Makefile b/Makefile index dc222e2..4172604 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,52 @@ CLI_ARTIFACT_PATH = _build/escriptize/bin/locus -export ERL_FLAGS = -enable-feature maybe_expr # needed for katana-code under OTP 25 +SHELL := bash +.ONESHELL: +.SHELLFLAGS := -euc +.DELETE_ON_ERROR: +MAKEFLAGS += --warn-undefined-variables +MAKEFLAGS += --no-builtin-rules -.PHONY: all build clean check -.PHONY: xref hank-dead-code-cleaner elvis-linter dialyzer -.PHONY: test cover -.PHONY: shell console doc-dry publish cli +export ERL_FLAGS = -enable-feature maybe_expr # needed for katana-code under OTP 25 -.NOTPARALLEL: check cover test +## General Rules -all: build +all: compile +.PHONY: all +.NOTPARALLEL: all -build: +compile: @rebar3 compile +.PHONY: compile clean: - @rebar3 clean + @rebar3 clean -a +.PHONY: clean check: xref hank-dead-code-cleaner elvis-linter dialyzer +.NOTPARALLEL: check +.PHONY: check + +test: eunit ct cli + ./locus check --log-level debug test/priv/GeoLite2-Country.tar.gz +.NOTPARALLEL: test +.PHONY: test + +## Tests + +ct: + @rebar3 do ct, cover +.PHONY: ct + +eunit: + @rebar3 eunit +.PHONY: eunit + +## Checks xref: @rebar3 xref +.PHONY: xref hank-dead-code-cleaner: @if rebar3 plugins list | grep '^rebar3_hank\>' >/dev/null; then \ @@ -28,35 +54,38 @@ hank-dead-code-cleaner: else \ echo >&2 "WARN: skipping rebar3_hank check"; \ fi +.PHONY: hank-dead-code-cleaner elvis-linter: - @rebar3 lint + @if rebar3 plugins list | grep '^rebar3_lint\>' >/dev/null; then \ + rebar3 lint; \ + else \ + echo >&2 "WARN: skipping rebar3_lint check"; \ + fi +.PHONY: elvis-linter dialyzer: @rebar3 dialyzer +.PHONY: dialyzer eqwalizer: @rebar3 as eqwalizer,test compile elp eqwalize-all -test: cli - @rebar3 do eunit, ct, cover - ./locus check --log-level debug test/priv/GeoLite2-Country.tar.gz - -cover: test +## Shell, docs and publication shell: export ERL_FLAGS = +pc unicode shell: @rebar3 as shell shell -console: shell +cli: + @rebar3 as escriptize escriptize + cp -p "$(CLI_ARTIFACT_PATH)" ./ doc-dry: @rebar3 hex build +.PHONY: doc-dry publish: +publish: doc @rebar3 hex publish - -cli: - @rebar3 as escriptize escriptize - cp -p "$(CLI_ARTIFACT_PATH)" ./ diff --git a/rebar.config b/rebar.config index 9a8cb3e..a3dffc0 100644 --- a/rebar.config +++ b/rebar.config @@ -28,7 +28,7 @@ {rebar3_ex_doc, "0.2.22"}, {rebar3_hank, "1.4.0"}, % excluded on OTP 22 (see rebar.config.script) {rebar3_hex, "7.0.7"}, - {rebar3_lint, "3.2.3"} + {rebar3_lint, "3.2.3"} % excluded on OTP 22 (see rebar.config.script) ]}. %% == Dialyzer == diff --git a/rebar.config.script b/rebar.config.script index 25ff0a7..b6933f7 100644 --- a/rebar.config.script +++ b/rebar.config.script @@ -1,16 +1,27 @@ % vim: set ft=erlang: begin - TakeOutHank - = fun (Config) -> + TakeOutProjPlugin + = fun (Name, Config) -> {project_plugins, ProjPlugins} = lists:keyfind(project_plugins, 1, Config), - {value, {rebar3_hank, HankVersion}, RemainingProjPlugins} - = lists:keytake(rebar3_hank, 1, ProjPlugins), + {value, {_, Version}, RemainingProjPlugins} + = lists:keytake(Name, 1, ProjPlugins), + logger:info("Dropping proj plugin '~ts' ~ts", [Name, Version]), _UpdatedConfig = lists:keystore(project_plugins, 1, Config, {project_plugins, RemainingProjPlugins}) end, + TakeOutElvis + = fun (Config) -> + TakeOutProjPlugin(rebar3_lint, Config) + end, + + TakeOutHank + = fun (Config) -> + TakeOutProjPlugin(rebar3_hank, Config) + end, + TakeOutHankIfMaybeExprNotEnabledOnEnv = fun (Config) -> Env = os:getenv(), @@ -32,9 +43,9 @@ begin OtpRelease = erlang:system_info(otp_release), try list_to_integer(OtpRelease) of - 22 -> - % Take rebar3_hank away as it's no longer compatible with OTP 22 - TakeOutHank(CONFIG) ; + TooOld when TooOld =< 22 -> + % Take dev helpers away as they're no longer compatible with OTP 22 + TakeOutHank(TakeOutElvis(CONFIG)); 25 -> TakeOutHankIfMaybeExprNotEnabledOnEnv(CONFIG); _ ->