Skip to content

Commit

Permalink
Record outdir and i compile options in compile_info
Browse files Browse the repository at this point in the history
  • Loading branch information
choptastic committed Oct 19, 2018
1 parent b6d3094 commit c106d74
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/rebar_erlc_compiler.erl
Expand Up @@ -528,7 +528,8 @@ expand_file_names(Files, Dirs) ->
list()) -> ok | {ok, any()} | {error, any(), any()}.
internal_erl_compile(Config, Source, OutDir, ErlOpts) ->
ok = filelib:ensure_dir(OutDir),
Opts = [{outdir, OutDir}] ++ ErlOpts ++ [{i, "include"}, return],
Opts0 = [{outdir, OutDir}] ++ ErlOpts ++ [{i, "include"}, return],
Opts = maybe_add_compile_info(Opts0),
case compile:file(Source, Opts) of
{ok, _Mod} ->
ok;
Expand All @@ -538,6 +539,18 @@ internal_erl_compile(Config, Source, OutDir, ErlOpts) ->
rebar_base_compiler:error_tuple(Config, Source, Es, Ws, Opts)
end.

maybe_add_compile_info(Opts) ->
CompileInfo = case lists:member(deterministic, Opts) of
true ->
[];
false ->
%% Capture Outdir and Include directories as compile_opts
CompInfo = [{K, V} || {K, V} <- Opts, lists:member(K, [outdir, i])],
[{compile_info, CompInfo}]
end,
CompileInfo ++ Opts.


-spec compile_mib(file:filename(), file:filename(),
rebar_config:config()) -> 'ok'.
compile_mib(Source, Target, Config) ->
Expand Down

0 comments on commit c106d74

Please sign in to comment.