summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS3
-rw-r--r--src/rebar_erlc_compiler.erl25
2 files changed, 22 insertions, 6 deletions
diff --git a/THANKS b/THANKS
index 8aa2a8a..daa5c69 100644
--- a/THANKS
+++ b/THANKS
@@ -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.
+
+