Skip to content

Commit

Permalink
fully qualified function calls for cleaner debug (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiw authored Oct 6, 2021
1 parent 10b970b commit 7af2dec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/provider_asn1.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
-export([init/1]).

init(State) ->
lists:foldl(fun provider_init/2, {ok, State}, [provider_asn1_compile
,provider_asn1_clean]).
lists:foldl(fun provider_init/2, {ok, State}, [provider_asn1_compile,
provider_asn1_clean]).

provider_init(Module, {ok, State}) ->
Module:init(State).
10 changes: 1 addition & 9 deletions src/provider_asn1_clean.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@

-export([init/1, do/1, format_error/1]).

-import(provider_asn1_util,
[verbose_out/3,
move_files/4,
move_file/4,
delete_files/3,
delete_file/3,
resolve_args/2]).

-define(PROVIDER, 'clean').
-define(DEPS, [{default, app_discovery}]).
-define(DEFAULTS, [{verbose, false}]).
Expand All @@ -36,7 +28,7 @@ init(State) ->

-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, string()}.
do(PreState) ->
State = resolve_args(PreState, ?DEFAULTS),
State = provider_asn1_util:resolve_args(PreState, ?DEFAULTS),
Apps = lists:map(fun (App) -> rebar_app_info:dir(App) end,
rebar_state:project_apps(State)),
AllApps =
Expand Down
19 changes: 4 additions & 15 deletions src/provider_asn1_compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@

-export([init/1, do/1, format_error/1]).

-import(provider_asn1_util,
[verbose_out/3,
move_files/4,
move_file/4,
delete_files/3,
delete_file/3,
resolve_args/2,
get_args/1,
get_arg/2,
set_arg/3]).

-define(PROVIDER, 'compile').
-define(DEPS, [{default, app_discovery}]).
-define(DEFAULTS, [{verbose, false}, {encoding, ber}, {compile_opts, []}]).
Expand All @@ -40,14 +29,14 @@ init(State) ->
{ok, rebar_state:add_provider(State, Provider)}.

resolve_special_args(PreState) ->
NewState = resolve_args(PreState, ?DEFAULTS),
CompileOpts = get_arg(NewState, compile_opts),
NewState = provider_asn1_util:resolve_args(PreState, ?DEFAULTS),
CompileOpts = provider_asn1_util:get_arg(NewState, compile_opts),
if
is_binary(CompileOpts) ->
NewCompileOpts = lists:map(fun(X) ->
binary_to_atom(X, utf8) end,
re:split(CompileOpts, ",")),
set_arg(NewState, compile_opts, NewCompileOpts);
provider_asn1_util:set_arg(NewState, compile_opts, NewCompileOpts);
true -> NewState
end.

Expand Down Expand Up @@ -103,7 +92,7 @@ generate_asn(State, Path, AsnFile) ->
Verbose = proplists:get_value(verbose, Args),
CompileArgs = [verbose || Verbose] ++ [noobj, Encoding, {outdir, Path}]
++ proplists:get_value(compile_opts, Args),
verbose_out(State, "Beginning compile with opts: ~p", [CompileArgs]),
provider_asn1_util:verbose_out(State, "Beginning compile with opts: ~p", [CompileArgs]),
case asn1ct:compile(AsnFile, CompileArgs) of
{error, E} ->
provider_asn1_util:verbose_out(State, "Error ~p compiling ASN1 ~p~n", [E, AsnFile]);
Expand Down

0 comments on commit 7af2dec

Please sign in to comment.