aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/compile.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2018-10-05 10:06:35 +0200
committerJohn Högberg <[email protected]>2018-10-05 11:47:57 +0200
commit3a34f37fbc5af8eca7a70f5dab61dca7ee1706b0 (patch)
treee3cd748cd4a63039165d8479d9328639d75e91cf /lib/compiler/src/compile.erl
parent16b93b98516df3fcc79a52847fa89fdda5b187c0 (diff)
downloadotp-3a34f37fbc5af8eca7a70f5dab61dca7ee1706b0.tar.gz
otp-3a34f37fbc5af8eca7a70f5dab61dca7ee1706b0.tar.bz2
otp-3a34f37fbc5af8eca7a70f5dab61dca7ee1706b0.zip
compiler: Forward +source flag to epp and fix bug in +deterministic
The source file path as given to `erlc` was included in an implicit file attribute inserted by epp, even when the +source flag was set to something else which was a bit surprising. It was also included when +deterministic was specified, breaking the flag's promise. This commit forwards the +source flag to epp so it inserts the right information, and if +deterministic is given it will be shaved to just the base name of the file, guaranteeing the same result regardless of how the input is reached.
Diffstat (limited to 'lib/compiler/src/compile.erl')
-rw-r--r--lib/compiler/src/compile.erl14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index 562d57a6ef..6510571441 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -931,11 +931,17 @@ parse_module(_Code, St0) ->
end.
do_parse_module(DefEncoding, #compile{ifile=File,options=Opts,dir=Dir}=St) ->
+ SourceName0 = proplists:get_value(source, Opts, File),
+ SourceName = case member(deterministic, Opts) of
+ true -> filename:basename(SourceName0);
+ false -> SourceName0
+ end,
R = epp:parse_file(File,
- [{includes,[".",Dir|inc_paths(Opts)]},
- {macros,pre_defs(Opts)},
- {default_encoding,DefEncoding},
- extra]),
+ [{includes,[".",Dir|inc_paths(Opts)]},
+ {source_name, SourceName},
+ {macros,pre_defs(Opts)},
+ {default_encoding,DefEncoding},
+ extra]),
case R of
{ok,Forms,Extra} ->
Encoding = proplists:get_value(encoding, Extra),