Clean up command line argument filtering.

master
Rohan Jacob-Rao 9 years ago
parent 9b3f291b99
commit 9643bdb1c6

@ -787,6 +787,12 @@ let filename_to_relative root fname =
remainder
(* Type of command-line arguments before processing *)
type arg_list = (string * Arg.spec * string option * string) list
let arg_desc_filter options_to_keep =
list_filter (function (option_name, _, _, _) -> list_mem string_equal option_name options_to_keep)
let base_arg_desc =
[
"-results_dir",

@ -388,11 +388,17 @@ val do_outf : outfile option ref -> (outfile -> unit) -> unit
(** close an outfile *)
val close_outf : outfile -> unit
(* Type of command-line arguments before processing *)
type arg_list = (string * Arg.spec * string option * string) list
(* Filter arguments by name, i.e. keep those whose name appears in the name list *)
val arg_desc_filter : string list -> arg_list -> arg_list
(** Basic command-line arguments *)
val base_arg_desc : (string * Arg.spec * string option * string) list
val base_arg_desc : arg_list
(** Reserved command-line arguments *)
val reserved_arg_desc : (string * Arg.spec * string option * string) list
val reserved_arg_desc : arg_list
(** Escape a string for use in a CSV or XML file: replace reserved characters with escape sequences *)
module Escape : sig

@ -16,66 +16,61 @@ module L = Logging
open CFrontend_utils
let arg_desc =
let base_arg =
let options_to_keep = ["-results_dir"] in
Config.dotty_cfg_libs := false; (* default behavior for this frontend *)
let filter arg_desc =
List.filter (fun desc -> let (option_name, _, _, _) = desc in List.mem option_name options_to_keep) arg_desc in
let desc =
(filter Utils.base_arg_desc) @
[
"-c",
Arg.String (fun cfile -> CFrontend_config.source_file := Some cfile),
Some "cfile",
"C File to translate";
"-x",
Arg.String (fun lang -> CFrontend_config.lang_from_string lang),
Some "cfile",
"Language (c, objective-c, c++, objc-++)";
"-ast",
Arg.String (fun file -> CFrontend_config.ast_file := Some file),
Some "file",
"AST file for the translation";
"-dotty_cfg_libs",
Arg.Unit (fun _ -> Config.dotty_cfg_libs := true),
None,
"Prints the cfg of the code coming from the libraries";
"-no_headers",
Arg.Unit (fun _ -> CFrontend_config.no_translate_libs := true),
None,
"Do not translate code in header files (default)";
"-headers",
Arg.Unit (fun _ -> CFrontend_config.no_translate_libs := false),
None,
"Translate code in header files";
"-testing_mode",
Arg.Unit (fun _ -> CFrontend_config.testing_mode := true),
None,
"Mode for testing, where no libraries are translated, including enums defined in the libraries";
"-debug",
Arg.Unit (fun _ -> CFrontend_config.debug_mode := true),
None,
"Enables debug mode";
"-stats",
Arg.Unit (fun _ -> CFrontend_config.stats_mode := true),
None,
"Enables stats mode";
"-project_root",
Arg.String (fun s ->
Config.project_root := Some (Utils.filename_to_absolute s)),
Some "dir",
"Toot directory of the project";
"-fobjc-arc",
Arg.Unit (fun s -> Config.arc_mode := true),
None,
"Translate with Objective-C Automatic Reference Counting (ARC)";
"-models_mode",
Arg.Unit (fun _ -> CFrontend_config.models_mode := true),
None,
"Mode for computing the models";
] in
Utils.Arg2.create_options_desc false "Parsing Options" desc in
base_arg
Config.dotty_cfg_libs := false; (* default behavior for this frontend *)
let desc =
(Utils.arg_desc_filter ["-results_dir"] Utils.base_arg_desc) @
[
"-c",
Arg.String (fun cfile -> CFrontend_config.source_file := Some cfile),
Some "cfile",
"C File to translate";
"-x",
Arg.String (fun lang -> CFrontend_config.lang_from_string lang),
Some "cfile",
"Language (c, objective-c, c++, objc-++)";
"-ast",
Arg.String (fun file -> CFrontend_config.ast_file := Some file),
Some "file",
"AST file for the translation";
"-dotty_cfg_libs",
Arg.Unit (fun _ -> Config.dotty_cfg_libs := true),
None,
"Prints the cfg of the code coming from the libraries";
"-no_headers",
Arg.Unit (fun _ -> CFrontend_config.no_translate_libs := true),
None,
"Do not translate code in header files (default)";
"-headers",
Arg.Unit (fun _ -> CFrontend_config.no_translate_libs := false),
None,
"Translate code in header files";
"-testing_mode",
Arg.Unit (fun _ -> CFrontend_config.testing_mode := true),
None,
"Mode for testing, where no libraries are translated, including enums defined in the libraries";
"-debug",
Arg.Unit (fun _ -> CFrontend_config.debug_mode := true),
None,
"Enables debug mode";
"-stats",
Arg.Unit (fun _ -> CFrontend_config.stats_mode := true),
None,
"Enables stats mode";
"-project_root",
Arg.String (fun s ->
Config.project_root := Some (Utils.filename_to_absolute s)),
Some "dir",
"Toot directory of the project";
"-fobjc-arc",
Arg.Unit (fun s -> Config.arc_mode := true),
None,
"Translate with Objective-C Automatic Reference Counting (ARC)";
"-models_mode",
Arg.Unit (fun _ -> CFrontend_config.models_mode := true),
None,
"Mode for computing the models";
] in
Utils.Arg2.create_options_desc false "Parsing Options" desc
let usage =
"\nUsage: InferClang -c C Files -ast AST Files -results_dir <output-dir> [options] \n"

@ -14,24 +14,20 @@ module L = Logging
open Utils
let arg_desc =
let base_arg =
let options_to_keep = ["-results_dir"; "-project_root"] in
let filter arg_desc =
list_filter (fun desc -> let (option_name, _, _, _) = desc in list_mem string_equal option_name options_to_keep) arg_desc in
let desc =
(filter base_arg_desc) @
[
"-models", Arg.String (fun filename -> JClasspath.add_models filename), Some "paths", "set the path to the jar containing the models";
"-debug", Arg.Unit (fun () -> JConfig.debug_mode := true), None, "write extra translation information";
"-dependencies", Arg.Unit (fun _ -> JConfig.dependency_mode := true), None, "translate all the dependencies during the capture";
"-no-static_final", Arg.Unit (fun () -> JTrans.no_static_final := true), None, "no special treatment for static final fields";
"-tracing", Arg.Unit (fun () -> JConfig.translate_checks := true), None,
"Translate JVM checks";
"-verbose_out", Arg.String (fun path -> JClasspath.set_verbose_out path), None,
"Set the path to the javac verbose output"
] in
Arg2.create_options_desc false "Parsing Options" desc in
base_arg
let options_to_keep = ["-results_dir"; "-project_root"] in
let desc =
(arg_desc_filter options_to_keep base_arg_desc) @
[
"-models", Arg.String (fun filename -> JClasspath.add_models filename), Some "paths", "set the path to the jar containing the models";
"-debug", Arg.Unit (fun () -> JConfig.debug_mode := true), None, "write extra translation information";
"-dependencies", Arg.Unit (fun _ -> JConfig.dependency_mode := true), None, "translate all the dependencies during the capture";
"-no-static_final", Arg.Unit (fun () -> JTrans.no_static_final := true), None, "no special treatment for static final fields";
"-tracing", Arg.Unit (fun () -> JConfig.translate_checks := true), None,
"Translate JVM checks";
"-verbose_out", Arg.String (fun path -> JClasspath.set_verbose_out path), None,
"Set the path to the javac verbose output"
] in
Arg2.create_options_desc false "Parsing Options" desc
let usage =
"Usage: InferJava -d compilation_dir -sources filename\n"

@ -10,11 +10,8 @@ open Utils
let arg_desc =
let options_to_keep = ["-results_dir"; "-project_root"] in
let filter arg_desc = list_filter
(fun desc -> let (option_name, _, _, _) = desc in list_mem string_equal option_name options_to_keep)
arg_desc in
let desc =
filter base_arg_desc @
arg_desc_filter options_to_keep base_arg_desc @
[
"-c",
Arg.String (fun cfile -> LConfig.source_filename := Some cfile),

Loading…
Cancel
Save