From 4067a0dd52cf6334ac984e1ff5783284d5c53525 Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Tue, 16 Jul 2019 17:44:00 +0000 Subject: Dedup dep list --- src/rebar_compiler_erl.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rebar_compiler_erl.erl b/src/rebar_compiler_erl.erl index a39e906..26ccd6e 100644 --- a/src/rebar_compiler_erl.erl +++ b/src/rebar_compiler_erl.erl @@ -78,7 +78,7 @@ needed_files(Graph, FoundFiles, _, AppInfo) -> dependencies(Source, SourceDir, Dirs) -> case file:open(Source, [read]) of {ok, Fd} -> - Incls = parse_attrs(Fd, [], SourceDir), + Incls = lists:usort(parse_attrs(Fd, [], SourceDir)), AbsIncls = expand_file_names(Incls, Dirs), ok = file:close(Fd), AbsIncls; -- cgit v1.1 From 18b39d7382ca1cd8ba5cb108142590f8ce824c33 Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Tue, 23 Jul 2019 09:26:23 +0000 Subject: De-dup inside parse_attr function itself --- src/rebar_compiler_erl.erl | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/rebar_compiler_erl.erl b/src/rebar_compiler_erl.erl index 26ccd6e..da4a1b0 100644 --- a/src/rebar_compiler_erl.erl +++ b/src/rebar_compiler_erl.erl @@ -78,7 +78,7 @@ needed_files(Graph, FoundFiles, _, AppInfo) -> dependencies(Source, SourceDir, Dirs) -> case file:open(Source, [read]) of {ok, Fd} -> - Incls = lists:usort(parse_attrs(Fd, [], SourceDir)), + Incls = parse_attrs(Fd, [], SourceDir), AbsIncls = expand_file_names(Incls, Dirs), ok = file:close(Fd), AbsIncls; @@ -245,20 +245,21 @@ module_to_erl(Mod) -> atom_to_list(Mod) ++ ".erl". parse_attrs(Fd, Includes, Dir) -> - case io:parse_erl_form(Fd, "") of - {ok, Form, _Line} -> - case erl_syntax:type(Form) of - attribute -> - NewIncludes = process_attr(Form, Includes, Dir), - parse_attrs(Fd, NewIncludes, Dir); - _ -> - parse_attrs(Fd, Includes, Dir) - end; - {eof, _} -> - Includes; - _Err -> - parse_attrs(Fd, Includes, Dir) - end. + DupIncludes = case io:parse_erl_form(Fd, "") of + {ok, Form, _Line} -> + case erl_syntax:type(Form) of + attribute -> + NewIncludes = process_attr(Form, Includes, Dir), + parse_attrs(Fd, NewIncludes, Dir); + _ -> + parse_attrs(Fd, Includes, Dir) + end; + {eof, _} -> + Includes; + _Err -> + parse_attrs(Fd, Includes, Dir) + end, + lists:usort(DupIncludes). process_attr(Form, Includes, Dir) -> AttrName = erl_syntax:atom_value(erl_syntax:attribute_name(Form)), -- cgit v1.1 From 6d8c544ecd0440ab959220f1cb121bb4ffa8678f Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Wed, 24 Jul 2019 10:24:34 +0000 Subject: Stick the usort in our termination clause --- src/rebar_compiler_erl.erl | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/rebar_compiler_erl.erl b/src/rebar_compiler_erl.erl index da4a1b0..95f3a17 100644 --- a/src/rebar_compiler_erl.erl +++ b/src/rebar_compiler_erl.erl @@ -245,21 +245,20 @@ module_to_erl(Mod) -> atom_to_list(Mod) ++ ".erl". parse_attrs(Fd, Includes, Dir) -> - DupIncludes = case io:parse_erl_form(Fd, "") of - {ok, Form, _Line} -> - case erl_syntax:type(Form) of - attribute -> - NewIncludes = process_attr(Form, Includes, Dir), - parse_attrs(Fd, NewIncludes, Dir); - _ -> - parse_attrs(Fd, Includes, Dir) - end; - {eof, _} -> - Includes; - _Err -> - parse_attrs(Fd, Includes, Dir) - end, - lists:usort(DupIncludes). + case io:parse_erl_form(Fd, "") of + {ok, Form, _Line} -> + case erl_syntax:type(Form) of + attribute -> + NewIncludes = process_attr(Form, Includes, Dir), + parse_attrs(Fd, NewIncludes, Dir); + _ -> + parse_attrs(Fd, Includes, Dir) + end; + {eof, _} -> + lists:usort(Includes); + _Err -> + parse_attrs(Fd, Includes, Dir) + end. process_attr(Form, Includes, Dir) -> AttrName = erl_syntax:atom_value(erl_syntax:attribute_name(Form)), -- cgit v1.1