mirror of
https://github.com/correl/rebar.git
synced 2024-11-23 11:09:55 +00:00
Extract common pattern from rebar_erlc_compiler:process_attr
This commit is contained in:
parent
d61b51bcf8
commit
ccdfc1a270
1 changed files with 12 additions and 9 deletions
|
@ -678,9 +678,9 @@ process_attr(Form, Includes) ->
|
||||||
process_attr(import, Form, Includes) ->
|
process_attr(import, Form, Includes) ->
|
||||||
case erl_syntax_lib:analyze_import_attribute(Form) of
|
case erl_syntax_lib:analyze_import_attribute(Form) of
|
||||||
{Mod, _Funs} ->
|
{Mod, _Funs} ->
|
||||||
[atom_to_list(Mod) ++ ".erl"|Includes];
|
[module_to_erl(Mod)|Includes];
|
||||||
Mod ->
|
Mod ->
|
||||||
[atom_to_list(Mod) ++ ".erl"|Includes]
|
[module_to_erl(Mod)|Includes]
|
||||||
end;
|
end;
|
||||||
process_attr(file, Form, Includes) ->
|
process_attr(file, Form, Includes) ->
|
||||||
{File, _} = erl_syntax_lib:analyze_file_attribute(Form),
|
{File, _} = erl_syntax_lib:analyze_file_attribute(Form),
|
||||||
|
@ -696,21 +696,21 @@ process_attr(include_lib, Form, Includes) ->
|
||||||
[File|Includes];
|
[File|Includes];
|
||||||
process_attr(behaviour, Form, Includes) ->
|
process_attr(behaviour, Form, Includes) ->
|
||||||
[FileNode] = erl_syntax:attribute_arguments(Form),
|
[FileNode] = erl_syntax:attribute_arguments(Form),
|
||||||
File = erl_syntax:atom_name(FileNode) ++ ".erl",
|
File = module_to_erl(erl_syntax:atom_value(FileNode)),
|
||||||
[File|Includes];
|
[File|Includes];
|
||||||
process_attr(compile, Form, Includes) ->
|
process_attr(compile, Form, Includes) ->
|
||||||
[Arg] = erl_syntax:attribute_arguments(Form),
|
[Arg] = erl_syntax:attribute_arguments(Form),
|
||||||
case erl_syntax:concrete(Arg) of
|
case erl_syntax:concrete(Arg) of
|
||||||
{parse_transform, Mod} ->
|
{parse_transform, Mod} ->
|
||||||
[atom_to_list(Mod) ++ ".erl"|Includes];
|
[module_to_erl(Mod)|Includes];
|
||||||
{core_transform, Mod} ->
|
{core_transform, Mod} ->
|
||||||
[atom_to_list(Mod) ++ ".erl"|Includes];
|
[module_to_erl(Mod)|Includes];
|
||||||
L when is_list(L) ->
|
L when is_list(L) ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({parse_transform, M}, Acc) ->
|
fun({parse_transform, Mod}, Acc) ->
|
||||||
[atom_to_list(M) ++ ".erl"|Acc];
|
[module_to_erl(Mod)|Acc];
|
||||||
({core_transform, M}, Acc) ->
|
({core_transform, Mod}, Acc) ->
|
||||||
[atom_to_list(M) ++ ".erl"|Acc];
|
[module_to_erl(Mod)|Acc];
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, Includes, L);
|
end, Includes, L);
|
||||||
|
@ -720,6 +720,9 @@ process_attr(compile, Form, Includes) ->
|
||||||
process_attr(_, _Form, Includes) ->
|
process_attr(_, _Form, Includes) ->
|
||||||
Includes.
|
Includes.
|
||||||
|
|
||||||
|
module_to_erl(Mod) ->
|
||||||
|
atom_to_list(Mod) ++ ".erl".
|
||||||
|
|
||||||
%% Given the filename from an include_lib attribute, if the path
|
%% Given the filename from an include_lib attribute, if the path
|
||||||
%% exists, return unmodified, or else get the absolute ERL_LIBS
|
%% exists, return unmodified, or else get the absolute ERL_LIBS
|
||||||
%% path.
|
%% path.
|
||||||
|
|
Loading…
Reference in a new issue