diff options
author | Anders Svensson <[email protected]> | 2013-12-02 09:42:34 +0100 |
---|---|---|
committer | Anders Svensson <[email protected]> | 2013-12-02 09:42:34 +0100 |
commit | 2b8c7d30e6c24ebc4c8d78c16d8033ff0d6c106e (patch) | |
tree | 8cb99cd58347852794fcc495fcc6548af4a80c01 /lib/diameter/bin | |
parent | 2bc1b1c962adf7849abb5a8399706aad708c5969 (diff) | |
parent | 2eb76ba556b8775cffc94eac26b448eac70af267 (diff) | |
download | otp-2b8c7d30e6c24ebc4c8d78c16d8033ff0d6c106e.tar.gz otp-2b8c7d30e6c24ebc4c8d78c16d8033ff0d6c106e.tar.bz2 otp-2b8c7d30e6c24ebc4c8d78c16d8033ff0d6c106e.zip |
Merge branch 'anders/diameter/dictionary_make/OTP-11348' into maint
* anders/diameter/dictionary_make/OTP-11348:
Return compilable forms instead of beam
Document diameter_make:format/1 and diameter_make:flatten/1
Fix diameter_make:flatten/1
Modify type that currently causes dialyzer woe
Simplify and extend diameter_make interface
Add diameter_make:flatten/1, remove reformat/1
Adapt compiler suite to diameter_make
Remove dead code from codec suite
Extend diameter_make:codec/2
Don't pollute process dictionary in diameter_codegen:from_dict/4
Make forms a separate output from diameter_codegen
Remove last remnants of "spec"
Write as last step in code generation
Change extensions for debug output: .spec/forms -> .D/F
Diffstat (limited to 'lib/diameter/bin')
-rwxr-xr-x | lib/diameter/bin/diameterc | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/lib/diameter/bin/diameterc b/lib/diameter/bin/diameterc index 2f5834d359..d31f341c36 100755 --- a/lib/diameter/bin/diameterc +++ b/lib/diameter/bin/diameterc @@ -50,13 +50,10 @@ usage() -> " -i dir = set an include directory for inherited beams~n" " -E = no .erl output~n" " -H = no .hrl output~n" - " -d = write intermediate files (.spec and .forms)~n", + " -d = write intermediate files (.D and .F)~n", [?MODULE]). main(Args) -> - %% Add the ebin directory relative to the script path. - BinDir = filename:dirname(escript:script_name()), - code:add_path(filename:join([BinDir, "..", "ebin"])), halt(gen(Args)). gen(Args) -> @@ -72,15 +69,12 @@ gen(Args) -> 1 end. -compile(#argv{file = File, options = Opts} = A) -> - try diameter_dict_util:parse({path, File}, Opts) of - {ok, Spec} -> - maybe_output(A, Spec, Opts, spec), %% the spec file - maybe_output(A, Spec, Opts, erl), %% the erl file - maybe_output(A, Spec, Opts, hrl), %% The hrl file +compile(#argv{file = File, options = Opts, output = Out}) -> + try diameter_make:codec({path, File}, Opts ++ Out) of + ok -> 0; {error, Reason} -> - error_msg(diameter_dict_util:format_error(Reason), []), + error_msg(Reason, []), 1 catch error: Reason -> @@ -88,10 +82,6 @@ compile(#argv{file = File, options = Opts} = A) -> 2 end. -maybe_output(#argv{file = File, output = Output}, Spec, Opts, Mode) -> - lists:member(Mode, Output) - andalso diameter_codegen:from_dict(File, Spec, Opts, Mode). - error_msg({Fmt, Args}) -> error_msg(Fmt, Args). @@ -119,8 +109,9 @@ arg(["-o", Dir | Args], #argv{options = Opts} = A) -> true = dir_exists(Dir), arg(Args, A#argv{options = [{outdir, Dir} | Opts]}); -arg(["-i", Dir | Args], #argv{options = Opts} = A) -> - arg(Args, A#argv{options = Opts ++ [{include, Dir}]}); +arg(["-i", Dir | Args], #argv{} = A) -> + code:add_patha(Dir), %% Set path here instead of passing an include + arg(Args, A); %% option so it's set before calling diameter_make. arg(["--name", Name | Args], #argv{options = Opts} = A) -> arg(Args, A#argv{options = [{name, Name} | Opts]}); @@ -137,9 +128,8 @@ arg(["-E" | Args], #argv{output = Output} = A) -> arg(["-H" | Args], #argv{output = Output} = A) -> arg(Args, A#argv{output = lists:delete(hrl, Output)}); -arg(["-d" | Args], #argv{options = Opts, output = Output} = A) -> - arg(Args, A#argv{options = [debug | Opts], - output = [spec | Output]}); +arg(["-d" | Args], #argv{output = Output} = A) -> + arg(Args, A#argv{output = [parse, forms | Output -- [parse, forms]]}); arg([[$- = M, C, H | T] | Args], A) %% clustered options when C /= $i, C /= $o, C /= $- -> |