From d455cf67203c29354ff792ea44aea09e7a2155f8 Mon Sep 17 00:00:00 2001 From: Tony Rogvall Date: Wed, 6 Dec 2017 02:28:29 +0100 Subject: Add -MMD option to erlc The compile option makedep_side_effect, erlc -MMD, instructs the compiler to emit dependencies and continue to compile as normal. --- lib/compiler/doc/src/compile.xml | 9 +++++++++ lib/compiler/src/compile.erl | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'lib/compiler') diff --git a/lib/compiler/doc/src/compile.xml b/lib/compiler/doc/src/compile.xml index b398871ddf..06afc55c07 100644 --- a/lib/compiler/doc/src/compile.xml +++ b/lib/compiler/doc/src/compile.xml @@ -233,6 +233,15 @@ module.beam: module.erl \ header.hrl + makedep_side_effect + +

The dependecies are created as a side effect to the + normal compilation process. This means that the object + file will also be produced. This option override the + makedep option. +

+
+ {makedep_output, Output}

Writes generated rules to Output instead of the diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 327fecf0e6..ad57eae855 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -203,7 +203,12 @@ expand_opts(Opts0) -> {_,_,undefined} -> [debug_info|Opts0]; {_,_,_} -> Opts0 end, - foldr(fun expand_opt/2, [], Opts). + %% iff,unless processing is to complex... + Opts1 = case proplists:is_defined(makedep_side_effect,Opts) of + true -> proplists:delete(makedep,Opts); + false -> Opts + end, + foldr(fun expand_opt/2, [], Opts1). expand_opt(basic_validation, Os) -> [no_code_generation,to_pp,binary|Os]; @@ -674,6 +679,7 @@ select_list_passes_1([], _, Acc) -> standard_passes() -> [?pass(transform_module), + {iff,makedep_side_effect,?pass(makedep_and_output)}, {iff,makedep,[ ?pass(makedep), {unless,binary,?pass(makedep_output)} @@ -1128,6 +1134,16 @@ core_lint_module(Code, St) -> errors=St#compile.errors ++ Es}} end. +%% makedep + output and continue +makedep_and_output(Code0, St) -> + {ok,DepCode,St1} = makedep(Code0,St), + case makedep_output(DepCode, St1) of + {ok,_IgnoreCode,St2} -> + {ok,Code0,St2}; + {error,St2} -> + {error,St2} + end. + makedep(Code0, #compile{ifile=Ifile,ofile=Ofile,options=Opts}=St) -> %% Get the target of the Makefile rule. -- cgit v1.2.3