diff options
author | Martin Karlsson <martin@kiwiowl.co.nz> | 2015-02-13 20:08:33 +1300 |
---|---|---|
committer | Martin Karlsson <martin@kiwiowl.co.nz> | 2015-02-13 20:50:44 +1300 |
commit | dca4edade0022851941a710686308c8b1d4c089f (patch) | |
tree | 1d3d9ab6432b6b37b6d88ccfd45233b8139c4a68 | |
parent | 3001618a4aadd9e3c8bae8019a298847780b9107 (diff) |
Fix #140 and preserve erl_first_files order
Match erl_first_files properly against all files needing
compilation and make sure the order of erl_first_files as specified in
rebar.config is preserved (rebar/rebar#445)
-rw-r--r-- | THANKS | 3 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 25 |
2 files changed, 22 insertions, 6 deletions
@@ -129,4 +129,5 @@ Andras Horvath Drew Varner Omar Yasin Tristan Sloughter -Kelly McLaughlin
\ No newline at end of file +Kelly McLaughlin +Martin Karlsson diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 9b11cc2..b096705 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -148,11 +148,13 @@ doterl_compile(Config, Dir, MoreSources, ErlOpts) -> %% (rebar_state:get instead of rebar_state:get_list), consider %% logging a warning message for any file listed in erl_first_files which %% wasn't found via gather_src. - {ErlFirstFiles, RestErls} = - lists:partition( - fun(Source) -> - lists:member(list_to_atom(filename:basename(Source, ".erl")), ErlFirstFilesConf) - end, AllErlFiles), + + %% Issue: rebar/rebar3#140 (fix matching based on same path + order of + %% erl_first_files) + ErlFirstFiles = get_erl_first_files(ErlFirstFilesConf, AllErlFiles), + RestErls = [ File || File <- AllErlFiles, + not lists:member(File, ErlFirstFiles) ], + %% Make sure that ebin/ exists and is on the path ok = filelib:ensure_dir(filename:join([Dir, "ebin", "dummy.beam"])), CurrPath = code:get_path(), @@ -207,6 +209,17 @@ erls(Files) -> [Erl || Erl <- Files, filename:extension(Erl) =:= ".erl"]. %% +%% Return a list of erl_first_files in order as specified in rebar.config +%% using the path from AllFiles. +%% +get_erl_first_files(FirstFiles, AllFiles) -> + BaseFirstFiles = [filename:basename(F) || F <- FirstFiles], + IndexedAllFiles = [{filename:basename(F), F} || F <- AllFiles ], + [ proplists:get_value(FileName, IndexedAllFiles) || + FileName <- BaseFirstFiles, + proplists:is_defined(FileName, IndexedAllFiles) ]. + +%% %% Return a list without duplicates while preserving order %% ulist(L) -> @@ -621,3 +634,5 @@ log_files(Prefix, Files) -> _ -> ?DEBUG("~s:~n~p", [Prefix, Files]) end. + + |