diff options
author | Frej Drejhammar <frej@sics.se> | 2020-07-20 10:38:45 +0200 |
---|---|---|
committer | Frej Drejhammar <frej@sics.se> | 2020-07-20 11:04:23 +0200 |
commit | 6c6af2bb4c22d73b396b1dbcdd0ad1ec1b36bf21 (patch) | |
tree | d27056b0195afd10ee137e9b0e17bdbae190625f /scripts/diffable | |
parent | a5ec1eeda69312b11505cb31f42345560ae1d8e5 (diff) | |
download | erlang-6c6af2bb4c22d73b396b1dbcdd0ad1ec1b36bf21.tar.gz |
diffable: Allow passing arbitrary compiler options to the compiler
This patch removes the hard-coding of supported compiler options from
diffable. Compiler options can now be given using the `--co <option>`
flag. The implementation of the `--deterministic` flag has been
implemented using the new framework.
Diffstat (limited to 'scripts/diffable')
-rwxr-xr-x | scripts/diffable | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/scripts/diffable b/scripts/diffable index 435c69006b..03faf471f7 100755 --- a/scripts/diffable +++ b/scripts/diffable @@ -7,7 +7,7 @@ -define(LONG_COMPILE_THRESHOLD, 10000). main(Args0) -> - DefOpts = #{format=>asm,no_compile=>false,legacy=>false,deterministic=>[]}, + DefOpts = #{format=>asm,no_compile=>false,legacy=>false,copts=>[]}, {Args,Opts} = opts(Args0, DefOpts), case Args of [OutDir] -> @@ -26,6 +26,8 @@ usage() -> " --deterministic Compile with +deterministic (useful when\n" " comparing output from different build trees using\n" " --asm)\n" + " --co <option> Add <option> to the list of options given to the\n" + " compiler. See compile:file/2 for valid options.\n" "\n" "DESCRIPTION\n" "\n" @@ -79,8 +81,10 @@ opts(["--legacy-asm"|Args], Opts) -> opts(Args, Opts#{format:=asm,legacy:=true}); opts(["--no-compile"|Args], Opts) -> opts(Args, Opts#{format:=dis,no_compile:=true}); -opts(["--deterministic"|Args], Opts) -> - opts(Args, Opts#{deterministic:=[deterministic]}); +opts(["--deterministic"|Args], #{copts:=Copts}=Opts) -> + opts(Args, Opts#{copts:=Copts++[deterministic]}); +opts(["--co",Opt|Args], #{copts:=Copts}=Opts) -> + opts(Args, Opts#{copts:=Copts++[list_to_atom(Opt)]}); opts(["--"++Opt|_], _Opts) -> io:format("Uknown option: --~ts\n\n", [Opt]), usage(); @@ -261,22 +265,22 @@ get_beams([]) -> []. compile_to_asm_fun(#{outdir:=OutDir}=Opts) -> fun(Spec) -> Legacy = map_get(legacy, Opts), - Deterministic = map_get(deterministic, Opts), - compile_to_asm(Spec, OutDir, Legacy, Deterministic) + COpts = map_get(copts, Opts), + compile_to_asm(Spec, OutDir, Legacy, COpts) end. -compile_to_asm({Beam,elixir}, OutDir, _Legacy, _Deterministic) -> +compile_to_asm({Beam,elixir}, OutDir, _Legacy, COpts) -> Abst = get_abstract_from_beam(Beam), Source = filename:rootname(Beam, ".beam"), - Opts = [diffable,{outdir,OutDir},report_errors,{source,Source}], + Opts = [diffable,{outdir,OutDir},report_errors,{source,Source}]++COpts, case compile:forms(Abst, Opts) of {ok,_Mod,_Asm} -> ok; error -> error end; -compile_to_asm({File,Opts0}, OutDir, Legacy, Deterministic) -> - Opts = Deterministic ++ [diffable,{outdir,OutDir},report_errors|Opts0], +compile_to_asm({File,Opts0}, OutDir, Legacy, COpts) -> + Opts = [diffable,{outdir,OutDir},report_errors|Opts0]++COpts, case compile:file(File, Opts) of {ok,_Mod} -> case Legacy of |