summaryrefslogtreecommitdiff
path: root/src/rebar_erlc_compiler.erl
diff options
context:
space:
mode:
authorDavid Kubecka <davidkubecka@seznam.cz>2015-03-22 23:03:36 +0100
committerDavid Kubecka <davidkubecka@seznam.cz>2015-04-05 00:16:56 +0200
commitccdfc1a27045ec5023e4f3c4d569a431f65234ea (patch)
treee1ccef7f0cc357b7091c3c768a95a9b2b7665b10 /src/rebar_erlc_compiler.erl
parentd61b51bcf8396b90513bfa3bbb36ba8857c4b6ce (diff)
downloadrebar-ccdfc1a27045ec5023e4f3c4d569a431f65234ea.tar.gz
Extract common pattern from rebar_erlc_compiler:process_attr
Diffstat (limited to 'src/rebar_erlc_compiler.erl')
-rw-r--r--src/rebar_erlc_compiler.erl21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index e82a1c3..91e873c 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -678,9 +678,9 @@ process_attr(Form, Includes) ->
process_attr(import, Form, Includes) ->
case erl_syntax_lib:analyze_import_attribute(Form) of
{Mod, _Funs} ->
- [atom_to_list(Mod) ++ ".erl"|Includes];
+ [module_to_erl(Mod)|Includes];
Mod ->
- [atom_to_list(Mod) ++ ".erl"|Includes]
+ [module_to_erl(Mod)|Includes]
end;
process_attr(file, Form, Includes) ->
{File, _} = erl_syntax_lib:analyze_file_attribute(Form),
@@ -696,21 +696,21 @@ process_attr(include_lib, Form, Includes) ->
[File|Includes];
process_attr(behaviour, Form, Includes) ->
[FileNode] = erl_syntax:attribute_arguments(Form),
- File = erl_syntax:atom_name(FileNode) ++ ".erl",
+ File = module_to_erl(erl_syntax:atom_value(FileNode)),
[File|Includes];
process_attr(compile, Form, Includes) ->
[Arg] = erl_syntax:attribute_arguments(Form),
case erl_syntax:concrete(Arg) of
{parse_transform, Mod} ->
- [atom_to_list(Mod) ++ ".erl"|Includes];
+ [module_to_erl(Mod)|Includes];
{core_transform, Mod} ->
- [atom_to_list(Mod) ++ ".erl"|Includes];
+ [module_to_erl(Mod)|Includes];
L when is_list(L) ->
lists:foldl(
- fun({parse_transform, M}, Acc) ->
- [atom_to_list(M) ++ ".erl"|Acc];
- ({core_transform, M}, Acc) ->
- [atom_to_list(M) ++ ".erl"|Acc];
+ fun({parse_transform, Mod}, Acc) ->
+ [module_to_erl(Mod)|Acc];
+ ({core_transform, Mod}, Acc) ->
+ [module_to_erl(Mod)|Acc];
(_, Acc) ->
Acc
end, Includes, L);
@@ -720,6 +720,9 @@ process_attr(compile, Form, Includes) ->
process_attr(_, _Form, Includes) ->
Includes.
+module_to_erl(Mod) ->
+ atom_to_list(Mod) ++ ".erl".
+
%% Given the filename from an include_lib attribute, if the path
%% exists, return unmodified, or else get the absolute ERL_LIBS
%% path.