From eadf8443197e59f98dd0aa3de8058df0a8fa3711 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Fri, 20 Sep 2013 16:20:08 +0200 Subject: Change extensions for debug output: .spec/forms -> .D/F "spec" is an old term the internal representation of a dictionary. The new extensions are in the style or those that compile(3) can generate. --- lib/diameter/bin/diameterc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/diameter/bin/diameterc') diff --git a/lib/diameter/bin/diameterc b/lib/diameter/bin/diameterc index 2f5834d359..3bcfc59343 100755 --- a/lib/diameter/bin/diameterc +++ b/lib/diameter/bin/diameterc @@ -50,7 +50,7 @@ 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) -> -- cgit v1.2.3 From a3fa81eafff105086cf3f0c942c5247686edac28 Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Mon, 23 Sep 2013 09:08:14 +0200 Subject: Remove last remnants of "spec" --- lib/diameter/bin/diameterc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/diameter/bin/diameterc') diff --git a/lib/diameter/bin/diameterc b/lib/diameter/bin/diameterc index 3bcfc59343..cae2bcedbe 100755 --- a/lib/diameter/bin/diameterc +++ b/lib/diameter/bin/diameterc @@ -74,10 +74,10 @@ gen(Args) -> 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 + {ok, Dict} -> + maybe_output(A, Dict, Opts, dict), %% parsed dictionary + maybe_output(A, Dict, Opts, erl), %% the erl file + maybe_output(A, Dict, Opts, hrl), %% The hrl file 0; {error, Reason} -> error_msg(diameter_dict_util:format_error(Reason), []), @@ -139,7 +139,7 @@ arg(["-H" | Args], #argv{output = Output} = A) -> arg(["-d" | Args], #argv{options = Opts, output = Output} = A) -> arg(Args, A#argv{options = [debug | Opts], - output = [spec | Output]}); + output = [dict | Output]}); arg([[$- = M, C, H | T] | Args], A) %% clustered options when C /= $i, C /= $o, C /= $- -> -- cgit v1.2.3 From da973668bcfee7cba0aa6e0c498fee4aa1b24cce Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Mon, 23 Sep 2013 09:45:00 +0200 Subject: Make forms a separate output from diameter_codegen Instead of being output as a consequence of a debug option. --- lib/diameter/bin/diameterc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'lib/diameter/bin/diameterc') diff --git a/lib/diameter/bin/diameterc b/lib/diameter/bin/diameterc index cae2bcedbe..d4dd3153c5 100755 --- a/lib/diameter/bin/diameterc +++ b/lib/diameter/bin/diameterc @@ -137,9 +137,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 = [dict | Output]}); +arg(["-d" | Args], #argv{output = Output} = A) -> + arg(Args, A#argv{output = [dict, forms | Output]}); arg([[$- = M, C, H | T] | Args], A) %% clustered options when C /= $i, C /= $o, C /= $- -> -- cgit v1.2.3 From 8e819a7960a256b6c3b7bf5856c3f81b8df9ca7e Mon Sep 17 00:00:00 2001 From: Anders Svensson Date: Wed, 25 Sep 2013 11:28:19 +0200 Subject: Simplify and extend diameter_make interface In particular, make codec/2 flexible as to what's generated, the formats (erl, hrl, parse, forms and beam) being passed in the options list and defaulting to [erl, hrl]. The 'parse' format is the internal format to which dictionaries are parsed, which can be manipulated by flatten/1 before being passed back to codec/2 or format/1. Remove the (undocumented) dict/1,2 since codec/2 now subsumes it with the 'parse' option. --- lib/diameter/bin/diameterc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'lib/diameter/bin/diameterc') diff --git a/lib/diameter/bin/diameterc b/lib/diameter/bin/diameterc index d4dd3153c5..d31f341c36 100755 --- a/lib/diameter/bin/diameterc +++ b/lib/diameter/bin/diameterc @@ -54,9 +54,6 @@ usage() -> [?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, Dict} -> - maybe_output(A, Dict, Opts, dict), %% parsed dictionary - maybe_output(A, Dict, Opts, erl), %% the erl file - maybe_output(A, Dict, 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]}); @@ -138,7 +129,7 @@ arg(["-H" | Args], #argv{output = Output} = A) -> arg(Args, A#argv{output = lists:delete(hrl, Output)}); arg(["-d" | Args], #argv{output = Output} = A) -> - arg(Args, A#argv{output = [dict, forms | Output]}); + 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 /= $- -> -- cgit v1.2.3