mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Update erlang.mk and rebar.config
This commit is contained in:
parent
cc49659f93
commit
474cb359ce
2 changed files with 98 additions and 49 deletions
145
erlang.mk
vendored
145
erlang.mk
vendored
|
@ -17,7 +17,7 @@
|
||||||
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
|
ERLANG_MK_FILENAME := $(realpath $(lastword $(MAKEFILE_LIST)))
|
||||||
export ERLANG_MK_FILENAME
|
export ERLANG_MK_FILENAME
|
||||||
|
|
||||||
ERLANG_MK_VERSION = 2018.03.05-10-g4522af8
|
ERLANG_MK_VERSION = 2018.05.15
|
||||||
ERLANG_MK_WITHOUT =
|
ERLANG_MK_WITHOUT =
|
||||||
|
|
||||||
# Make 3.81 and 3.82 are deprecated.
|
# Make 3.81 and 3.82 are deprecated.
|
||||||
|
@ -154,9 +154,13 @@ define comma_list
|
||||||
$(subst $(space),$(comma),$(strip $(1)))
|
$(subst $(space),$(comma),$(strip $(1)))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
define escape_dquotes
|
||||||
|
$(subst ",\",$1)
|
||||||
|
endef
|
||||||
|
|
||||||
# Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy.
|
# Adding erlang.mk to make Erlang scripts who call init:get_plain_arguments() happy.
|
||||||
define erlang
|
define erlang
|
||||||
$(ERL) $(2) -pz $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(subst ",\",$(1)))" -- erlang.mk
|
$(ERL) $2 -pz $(ERLANG_MK_TMP)/rebar/ebin -eval "$(subst $(newline),,$(call escape_dquotes,$1))" -- erlang.mk
|
||||||
endef
|
endef
|
||||||
|
|
||||||
ifeq ($(PLATFORM),msys2)
|
ifeq ($(PLATFORM),msys2)
|
||||||
|
@ -252,7 +256,8 @@ distclean-kerl:
|
||||||
# Allow users to select which version of Erlang/OTP to use for a project.
|
# Allow users to select which version of Erlang/OTP to use for a project.
|
||||||
|
|
||||||
ifneq ($(strip $(LATEST_ERLANG_OTP)),)
|
ifneq ($(strip $(LATEST_ERLANG_OTP)),)
|
||||||
ERLANG_OTP := $(notdir $(lastword $(sort $(wildcard $(KERL_INSTALL_DIR)/*[^-native]))))
|
ERLANG_OTP := $(notdir $(lastword $(sort $(filter-out %-rc1 %-rc2 %-rc3,\
|
||||||
|
$(wildcard $(KERL_INSTALL_DIR)/*[^-native])))))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ERLANG_OTP ?=
|
ERLANG_OTP ?=
|
||||||
|
@ -4290,7 +4295,7 @@ export NO_AUTOPATCH
|
||||||
|
|
||||||
# Verbosity.
|
# Verbosity.
|
||||||
|
|
||||||
dep_verbose_0 = @echo " DEP " $(1);
|
dep_verbose_0 = @echo " DEP $1 ($(call dep_commit,$1))";
|
||||||
dep_verbose_2 = set -x;
|
dep_verbose_2 = set -x;
|
||||||
dep_verbose = $(dep_verbose_$(V))
|
dep_verbose = $(dep_verbose_$(V))
|
||||||
|
|
||||||
|
@ -5068,6 +5073,14 @@ define makedep.erl
|
||||||
E = ets:new(makedep, [bag]),
|
E = ets:new(makedep, [bag]),
|
||||||
G = digraph:new([acyclic]),
|
G = digraph:new([acyclic]),
|
||||||
ErlFiles = lists:usort(string:tokens("$(ERL_FILES)", " ")),
|
ErlFiles = lists:usort(string:tokens("$(ERL_FILES)", " ")),
|
||||||
|
DepsDir = "$(call core_native_path,$(DEPS_DIR))",
|
||||||
|
AppsDir = "$(call core_native_path,$(APPS_DIR))",
|
||||||
|
DepsDirsSrc = "$(if $(wildcard $(DEPS_DIR)/*/src), $(call core_native_path,$(wildcard $(DEPS_DIR)/*/src)))",
|
||||||
|
DepsDirsInc = "$(if $(wildcard $(DEPS_DIR)/*/include), $(call core_native_path,$(wildcard $(DEPS_DIR)/*/include)))",
|
||||||
|
AppsDirsSrc = "$(if $(wildcard $(APPS_DIR)/*/src), $(call core_native_path,$(wildcard $(APPS_DIR)/*/src)))",
|
||||||
|
AppsDirsInc = "$(if $(wildcard $(APPS_DIR)/*/include), $(call core_native_path,$(wildcard $(APPS_DIR)/*/include)))",
|
||||||
|
DepsDirs = lists:usort(string:tokens(DepsDirsSrc++DepsDirsInc, " ")),
|
||||||
|
AppsDirs = lists:usort(string:tokens(AppsDirsSrc++AppsDirsInc, " ")),
|
||||||
Modules = [{list_to_atom(filename:basename(F, ".erl")), F} || F <- ErlFiles],
|
Modules = [{list_to_atom(filename:basename(F, ".erl")), F} || F <- ErlFiles],
|
||||||
Add = fun (Mod, Dep) ->
|
Add = fun (Mod, Dep) ->
|
||||||
case lists:keyfind(Dep, 1, Modules) of
|
case lists:keyfind(Dep, 1, Modules) of
|
||||||
|
@ -5082,33 +5095,50 @@ define makedep.erl
|
||||||
end,
|
end,
|
||||||
AddHd = fun (F, Mod, DepFile) ->
|
AddHd = fun (F, Mod, DepFile) ->
|
||||||
case file:open(DepFile, [read]) of
|
case file:open(DepFile, [read]) of
|
||||||
{error, enoent} -> ok;
|
{error, enoent} ->
|
||||||
|
ok;
|
||||||
{ok, Fd} ->
|
{ok, Fd} ->
|
||||||
F(F, Fd, Mod),
|
|
||||||
{_, ModFile} = lists:keyfind(Mod, 1, Modules),
|
{_, ModFile} = lists:keyfind(Mod, 1, Modules),
|
||||||
ets:insert(E, {ModFile, DepFile})
|
case ets:match(E, {ModFile, DepFile}) of
|
||||||
|
[] ->
|
||||||
|
ets:insert(E, {ModFile, DepFile}),
|
||||||
|
F(F, Fd, Mod,0);
|
||||||
|
_ -> ok
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
SearchHrl = fun
|
||||||
|
F(_Hrl, []) -> {error,enoent};
|
||||||
|
F(Hrl, [Dir|Dirs]) ->
|
||||||
|
HrlF = filename:join([Dir,Hrl]),
|
||||||
|
case filelib:is_file(HrlF) of
|
||||||
|
true ->
|
||||||
|
{ok, HrlF};
|
||||||
|
false -> F(Hrl,Dirs)
|
||||||
|
end
|
||||||
|
end,
|
||||||
Attr = fun
|
Attr = fun
|
||||||
(F, Mod, behavior, Dep) -> Add(Mod, Dep);
|
(_F, Mod, behavior, Dep) ->
|
||||||
(F, Mod, behaviour, Dep) -> Add(Mod, Dep);
|
Add(Mod, Dep);
|
||||||
(F, Mod, compile, {parse_transform, Dep}) -> Add(Mod, Dep);
|
(_F, Mod, behaviour, Dep) ->
|
||||||
(F, Mod, compile, Opts) when is_list(Opts) ->
|
Add(Mod, Dep);
|
||||||
|
(_F, Mod, compile, {parse_transform, Dep}) ->
|
||||||
|
Add(Mod, Dep);
|
||||||
|
(_F, Mod, compile, Opts) when is_list(Opts) ->
|
||||||
case proplists:get_value(parse_transform, Opts) of
|
case proplists:get_value(parse_transform, Opts) of
|
||||||
undefined -> ok;
|
undefined -> ok;
|
||||||
Dep -> Add(Mod, Dep)
|
Dep -> Add(Mod, Dep)
|
||||||
end;
|
end;
|
||||||
(F, Mod, include, Hrl) ->
|
(F, Mod, include, Hrl) ->
|
||||||
case filelib:is_file("include/" ++ Hrl) of
|
case SearchHrl(Hrl, ["src", "include",AppsDir,DepsDir]++AppsDirs++DepsDirs) of
|
||||||
true -> AddHd(F, Mod, "include/" ++ Hrl);
|
{ok, FoundHrl} -> AddHd(F, Mod, FoundHrl);
|
||||||
false ->
|
{error, _} -> false
|
||||||
case filelib:is_file("src/" ++ Hrl) of
|
end;
|
||||||
true -> AddHd(F, Mod, "src/" ++ Hrl);
|
(F, Mod, include_lib, Hrl) ->
|
||||||
false -> false
|
case SearchHrl(Hrl, ["src", "include",AppsDir,DepsDir]++AppsDirs++DepsDirs) of
|
||||||
end
|
{ok, FoundHrl} -> AddHd(F, Mod, FoundHrl);
|
||||||
|
{error, _} -> false
|
||||||
end;
|
end;
|
||||||
(F, Mod, include_lib, "$1/include/" ++ Hrl) -> AddHd(F, Mod, "include/" ++ Hrl);
|
|
||||||
(F, Mod, include_lib, Hrl) -> AddHd(F, Mod, "include/" ++ Hrl);
|
|
||||||
(F, Mod, import, {Imp, _}) ->
|
(F, Mod, import, {Imp, _}) ->
|
||||||
IsFile =
|
IsFile =
|
||||||
case lists:keyfind(Imp, 1, Modules) of
|
case lists:keyfind(Imp, 1, Modules) of
|
||||||
|
@ -5121,21 +5151,29 @@ define makedep.erl
|
||||||
end;
|
end;
|
||||||
(_, _, _, _) -> ok
|
(_, _, _, _) -> ok
|
||||||
end,
|
end,
|
||||||
MakeDepend = fun(F, Fd, Mod) ->
|
MakeDepend = fun
|
||||||
case io:parse_erl_form(Fd, undefined) of
|
(F, Fd, Mod, StartLocation) ->
|
||||||
{ok, {attribute, _, Key, Value}, _} ->
|
{ok, Filename} = file:pid2name(Fd),
|
||||||
Attr(F, Mod, Key, Value),
|
case io:parse_erl_form(Fd, undefined, StartLocation) of
|
||||||
F(F, Fd, Mod);
|
{ok, AbsData, EndLocation} ->
|
||||||
{eof, _} ->
|
case AbsData of
|
||||||
file:close(Fd);
|
{attribute, _, Key, Value} ->
|
||||||
_ ->
|
Attr(F, Mod, Key, Value),
|
||||||
F(F, Fd, Mod)
|
F(F, Fd, Mod, EndLocation);
|
||||||
end
|
_ -> F(F, Fd, Mod, EndLocation)
|
||||||
|
end;
|
||||||
|
{eof, _ } -> file:close(Fd);
|
||||||
|
{error, ErrorDescription } ->
|
||||||
|
file:close(Fd);
|
||||||
|
{error, ErrorInfo, ErrorLocation} ->
|
||||||
|
F(F, Fd, Mod, ErrorLocation)
|
||||||
|
end,
|
||||||
|
ok
|
||||||
end,
|
end,
|
||||||
[begin
|
[begin
|
||||||
Mod = list_to_atom(filename:basename(F, ".erl")),
|
Mod = list_to_atom(filename:basename(F, ".erl")),
|
||||||
{ok, Fd} = file:open(F, [read]),
|
{ok, Fd} = file:open(F, [read]),
|
||||||
MakeDepend(MakeDepend, Fd, Mod)
|
MakeDepend(MakeDepend, Fd, Mod,0)
|
||||||
end || F <- ErlFiles],
|
end || F <- ErlFiles],
|
||||||
Depend = sofs:to_external(sofs:relation_to_family(sofs:relation(ets:tab2list(E)))),
|
Depend = sofs:to_external(sofs:relation_to_family(sofs:relation(ets:tab2list(E)))),
|
||||||
CompileFirst = [X || X <- lists:reverse(digraph_utils:topsort(G)), [] =/= digraph:in_neighbours(G, X)],
|
CompileFirst = [X || X <- lists:reverse(digraph_utils:topsort(G)), [] =/= digraph:in_neighbours(G, X)],
|
||||||
|
@ -5291,17 +5329,17 @@ endif
|
||||||
ifeq ($(wildcard src),)
|
ifeq ($(wildcard src),)
|
||||||
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
||||||
test-build:: clean deps test-deps
|
test-build:: clean deps test-deps
|
||||||
$(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(TEST_ERLC_OPTS)"
|
$(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
|
||||||
else
|
else
|
||||||
ifeq ($(wildcard ebin/test),)
|
ifeq ($(wildcard ebin/test),)
|
||||||
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
||||||
test-build:: clean deps test-deps $(PROJECT).d
|
test-build:: clean deps test-deps $(PROJECT).d
|
||||||
$(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(TEST_ERLC_OPTS)"
|
$(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
|
||||||
$(gen_verbose) touch ebin/test
|
$(gen_verbose) touch ebin/test
|
||||||
else
|
else
|
||||||
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
|
||||||
test-build:: deps test-deps $(PROJECT).d
|
test-build:: deps test-deps $(PROJECT).d
|
||||||
$(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(TEST_ERLC_OPTS)"
|
$(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
clean:: clean-test-dir
|
clean:: clean-test-dir
|
||||||
|
@ -5926,13 +5964,14 @@ ifndef n
|
||||||
$(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
|
$(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
|
||||||
endif
|
endif
|
||||||
ifdef in
|
ifdef in
|
||||||
$(verbose) $(MAKE) -C $(APPS_DIR)/$(in)/ new t=$t n=$n in=
|
$(call render_template,tpl_$(t),$(APPS_DIR)/$(in)/src/$(n).erl)
|
||||||
else
|
else
|
||||||
$(call render_template,tpl_$(t),src/$(n).erl)
|
$(call render_template,tpl_$(t),src/$(n).erl)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
list-templates:
|
list-templates:
|
||||||
$(verbose) echo Available templates: $(sort $(patsubst tpl_%,%,$(filter tpl_%,$(.VARIABLES))))
|
$(verbose) @echo Available templates:
|
||||||
|
$(verbose) printf " %s\n" $(sort $(patsubst tpl_%,%,$(filter tpl_%,$(.VARIABLES))))
|
||||||
|
|
||||||
# Copyright (c) 2014-2016, Loïc Hoguin <essen@ninenines.eu>
|
# Copyright (c) 2014-2016, Loïc Hoguin <essen@ninenines.eu>
|
||||||
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
||||||
|
@ -6327,6 +6366,7 @@ export DIALYZER_PLT
|
||||||
PLT_APPS ?=
|
PLT_APPS ?=
|
||||||
DIALYZER_DIRS ?= --src -r $(wildcard src) $(ALL_APPS_DIRS)
|
DIALYZER_DIRS ?= --src -r $(wildcard src) $(ALL_APPS_DIRS)
|
||||||
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs
|
DIALYZER_OPTS ?= -Werror_handling -Wrace_conditions -Wunmatched_returns # -Wunderspecs
|
||||||
|
DIALYZER_PLT_OPTS ?=
|
||||||
|
|
||||||
# Core targets.
|
# Core targets.
|
||||||
|
|
||||||
|
@ -6360,8 +6400,8 @@ endef
|
||||||
$(DIALYZER_PLT): deps app
|
$(DIALYZER_PLT): deps app
|
||||||
$(eval DEPS_LOG := $(shell test -f $(ERLANG_MK_TMP)/deps.log && \
|
$(eval DEPS_LOG := $(shell test -f $(ERLANG_MK_TMP)/deps.log && \
|
||||||
while read p; do test -d $$p/ebin && echo $$p/ebin; done <$(ERLANG_MK_TMP)/deps.log))
|
while read p; do test -d $$p/ebin && echo $$p/ebin; done <$(ERLANG_MK_TMP)/deps.log))
|
||||||
$(verbose) dialyzer --build_plt --apps erts kernel stdlib \
|
$(verbose) dialyzer --build_plt $(DIALYZER_PLT_OPTS) --apps \
|
||||||
$(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS_LOG)
|
erts kernel stdlib $(PLT_APPS) $(OTP_DEPS) $(LOCAL_DEPS) $(DEPS_LOG)
|
||||||
|
|
||||||
plt: $(DIALYZER_PLT)
|
plt: $(DIALYZER_PLT)
|
||||||
|
|
||||||
|
@ -6373,7 +6413,7 @@ dialyze:
|
||||||
else
|
else
|
||||||
dialyze: $(DIALYZER_PLT)
|
dialyze: $(DIALYZER_PLT)
|
||||||
endif
|
endif
|
||||||
$(verbose) dialyzer --no_native `$(ERL) -eval "$(subst $(newline),,$(subst ",\",$(call filter_opts.erl)))" -extra $(ERLC_OPTS)` $(DIALYZER_DIRS) $(DIALYZER_OPTS)
|
$(verbose) dialyzer --no_native `$(ERL) -eval "$(subst $(newline),,$(call escape_dquotes,$(call filter_opts.erl)))" -extra $(ERLC_OPTS)` $(DIALYZER_DIRS) $(DIALYZER_OPTS)
|
||||||
|
|
||||||
# Copyright (c) 2013-2016, Loïc Hoguin <essen@ninenines.eu>
|
# Copyright (c) 2013-2016, Loïc Hoguin <essen@ninenines.eu>
|
||||||
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
# This file is part of erlang.mk and subject to the terms of the ISC License.
|
||||||
|
@ -6546,20 +6586,25 @@ help::
|
||||||
# Plugin-specific targets.
|
# Plugin-specific targets.
|
||||||
|
|
||||||
define eunit.erl
|
define eunit.erl
|
||||||
case "$(COVER)" of
|
Enabled = case "$(COVER)" of
|
||||||
"" -> ok;
|
"" -> false;
|
||||||
_ ->
|
_ ->
|
||||||
case cover:compile_beam_directory("ebin") of
|
case filelib:is_dir("ebin") of
|
||||||
{error, _} -> halt(1);
|
false -> false;
|
||||||
_ -> ok
|
true ->
|
||||||
|
case cover:compile_beam_directory("ebin") of
|
||||||
|
{error, _} -> halt(1);
|
||||||
|
_ -> true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case eunit:test($1, [$(EUNIT_OPTS)]) of
|
case eunit:test($1, [$(EUNIT_OPTS)]) of
|
||||||
ok -> ok;
|
ok -> ok;
|
||||||
error -> halt(2)
|
error -> halt(2)
|
||||||
end,
|
end,
|
||||||
case "$(COVER)" of
|
case {Enabled, "$(COVER)"} of
|
||||||
"" -> ok;
|
{false, _} -> ok;
|
||||||
|
{_, ""} -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
cover:export("$(COVER_DATA_DIR)/eunit.coverdata")
|
cover:export("$(COVER_DATA_DIR)/eunit.coverdata")
|
||||||
end,
|
end,
|
||||||
|
@ -6605,7 +6650,10 @@ ifeq ($(filter proper,$(DEPS) $(TEST_DEPS)),proper)
|
||||||
tests:: proper
|
tests:: proper
|
||||||
|
|
||||||
define proper_check.erl
|
define proper_check.erl
|
||||||
code:add_pathsa(["$(call core_native_path,$(CURDIR)/ebin)", "$(call core_native_path,$(DEPS_DIR)/*/ebin)"]),
|
code:add_pathsa([
|
||||||
|
"$(call core_native_path,$(CURDIR)/ebin)",
|
||||||
|
"$(call core_native_path,$(DEPS_DIR)/*/ebin)",
|
||||||
|
"$(call core_native_path,$(TEST_DIR))"]),
|
||||||
Module = fun(M) ->
|
Module = fun(M) ->
|
||||||
[true] =:= lists:usort([
|
[true] =:= lists:usort([
|
||||||
case atom_to_list(F) of
|
case atom_to_list(F) of
|
||||||
|
@ -6643,7 +6691,8 @@ proper: test-build
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
proper: test-build
|
proper: test-build
|
||||||
$(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(wildcard ebin/*.beam))))))
|
$(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename \
|
||||||
|
$(wildcard ebin/*.beam) $(call core_find,$(TEST_DIR)/,*.beam))))))
|
||||||
$(gen_verbose) $(call erlang,$(call proper_check.erl,all,undefined,$(MODULES)))
|
$(gen_verbose) $(call erlang,$(call proper_check.erl,all,undefined,$(MODULES)))
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{deps, [
|
{deps, [
|
||||||
{cowlib,".*",{git,"https://github.com/ninenines/cowlib","2.3.0"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.5.0"}}
|
{cowlib,".*",{git,"https://github.com/ninenines/cowlib","master"}},{ranch,".*",{git,"https://github.com/ninenines/ranch","1.5.0"}}
|
||||||
]}.
|
]}.
|
||||||
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_missing_spec,warn_untyped_record]}.
|
{erl_opts, [debug_info,warn_export_vars,warn_shadow_vars,warn_obsolete_guard,warn_missing_spec,warn_untyped_record]}.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue