make erlware_commons work on pre-R15 releases

Signed-off-by: Jordan Wilberding <diginux@gmail.com>
This commit is contained in:
Eric Merritt 2012-12-03 11:15:52 -05:00 committed by Jordan Wilberding
parent 8d300f5d02
commit 95f723e1e0
4 changed files with 44 additions and 4 deletions

View file

@ -1,9 +1,11 @@
language: erlang =nlanguage: erlang
otp_release: otp_release:
- R15B02 - R15B02
- R15B01 - R15B01
- R15B - R15B
- R14B04
- R14B03
- R14B02
before_script: "make get-deps" before_script: "make get-deps"
script: "make" script: "make"
branches: branches:

View file

@ -39,7 +39,7 @@ $(ERLWARE_COMMONS_PLT):
--apps erts kernel stdlib eunit -r deps --apps erts kernel stdlib eunit -r deps
dialyzer: $(ERLWARE_COMMONS_PLT) dialyzer: $(ERLWARE_COMMONS_PLT)
dialyzer --fullpath --plt $(ERLWARE_COMMONS_PLT) -Wrace_conditions --src src dialyzer --fullpath --plt $(ERLWARE_COMMONS_PLT) -Wrace_conditions -r ./ebin
typer: typer:
typer --plt $(ERLWARE_COMMONS_PLT) -r ./src typer --plt $(ERLWARE_COMMONS_PLT) -r ./src
@ -64,4 +64,4 @@ distclean: clean
rm -rf $(ERLWARE_COMMONS_PLT) rm -rf $(ERLWARE_COMMONS_PLT)
rm -rvf $(CURDIR)/deps/* rm -rvf $(CURDIR)/deps/*
rebuild: distclean all rebuild: distclean get-deps all

15
rebar.config.script Normal file
View file

@ -0,0 +1,15 @@
{match, [ErtsNumber]} = re:run("R15B02", "R(\\d+).+", [{capture, [1], list}]),
ErtsVsn = erlang:list_to_integer(ErtsNumber),
Opts1 = case lists:keysearch(erl_opts, 1, CONFIG) of
{value, {erl_opts, Opts0}} ->
Opts0;
false ->
[]
end,
Opts2 = if
ErtsVsn >= 15 ->
[{d, have_callback_support} | Opts1];
true ->
Opts1
end,
lists:keystore(erl_opts, 1, CONFIG, {erl_opts, Opts2}).

View file

@ -41,6 +41,8 @@
-type key(T) :: T. -type key(T) :: T.
-type value(T) :: T. -type value(T) :: T.
-ifdef(have_callback_support).
-callback new() -> any(). -callback new() -> any().
-callback has_key(key(any()), any()) -> boolean(). -callback has_key(key(any()), any()) -> boolean().
-callback get(key(any()), any()) -> any(). -callback get(key(any()), any()) -> any().
@ -52,6 +54,27 @@
-callback from_list([{key(any()), value(any())}]) -> any(). -callback from_list([{key(any()), value(any())}]) -> any().
-callback keys(any()) -> [key(any())]. -callback keys(any()) -> [key(any())].
-else.
%% In the case where R14 or lower is being used to compile the system
%% we need to export a behaviour info
-export([behaviour_info/1]).
-spec behaviour_info(atom()) -> [{atom(), arity()}] | undefined.
behaviour_info(callbacks) ->
[{new, 0},
{has_key, 2},
{get, 2},
{add, 3},
{remove, 2},
{has_value, 2},
{size, 1},
{to_list, 1},
{from_list, 1},
{keys, 1}];
behaviour_info(_Other) ->
undefined.
-endif.
%%%=================================================================== %%%===================================================================
%%% API %%% API
%%%=================================================================== %%%===================================================================