Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

Commit 241961df authored by Andrei Paskevich's avatar Andrei Paskevich

use Whyconf.Args in why3ide and why3doc

- make Whyconf.Args.initialize return the base config file, too.
  This is needed when we change configuration and want to save it.
- make Main pass "why3 <command>" as argv[0]
- remove "-version" options from everything but the main executable
parent 96cfbb62
...@@ -786,14 +786,14 @@ module Args = struct ...@@ -786,14 +786,14 @@ module Args = struct
Format.printf "@[%s%a@]" (Arg.usage_string options usage) extra_help (); Format.printf "@[%s%a@]" (Arg.usage_string options usage) extra_help ();
exit 0 exit 0
end; end;
let config = read_config !opt_config in let base_config = read_config !opt_config in
let config = List.fold_left merge_config config !opt_extra in let config = List.fold_left merge_config base_config !opt_extra in
let main = get_main config in let main = get_main config in
load_plugins main; load_plugins main;
Debug.Args.set_flags_selected (); Debug.Args.set_flags_selected ();
if Debug.Args.option_list () then exit 0; if Debug.Args.option_list () then exit 0;
let lp = List.rev_append !opt_loadpath (loadpath main) in let lp = List.rev_append !opt_loadpath (loadpath main) in
config, Env.create_env lp config, base_config, Env.create_env lp
let exit_with_usage options usage = let exit_with_usage options usage =
Arg.usage (align_options options) usage; Arg.usage (align_options options) usage;
......
...@@ -239,7 +239,7 @@ module Args : sig ...@@ -239,7 +239,7 @@ module Args : sig
?extra_help : (Format.formatter -> unit -> unit) -> ?extra_help : (Format.formatter -> unit -> unit) ->
(string * Arg.spec * string) list -> (string * Arg.spec * string) list ->
(string -> unit) -> string -> (string -> unit) -> string ->
config * Env.env config * config * Env.env
val exit_with_usage : (string * Arg.spec * string) list -> string -> 'a val exit_with_usage : (string * Arg.spec * string) list -> string -> 'a
end end
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
(* *) (* *)
(********************************************************************) (********************************************************************)
open Format
open Why3 open Why3
open Rc open Rc
open Whyconf open Whyconf
...@@ -202,7 +200,7 @@ let load_altern alterns (_,section) = ...@@ -202,7 +200,7 @@ let load_altern alterns (_,section) =
Mprover.add unknown known alterns Mprover.add unknown known alterns
*) *)
let load_config config original_config = let load_config config original_config env =
let main = get_main config in let main = get_main config in
let ide = match Whyconf.get_section config "ide" with let ide = match Whyconf.get_section config "ide" with
| None -> default_ide | None -> default_ide
...@@ -211,8 +209,6 @@ let load_config config original_config = ...@@ -211,8 +209,6 @@ let load_config config original_config =
(* let alterns = *) (* let alterns = *)
(* List.fold_left load_altern *) (* List.fold_left load_altern *)
(* Mprover.empty (get_family config "alternative_prover") in *) (* Mprover.empty (get_family config "alternative_prover") in *)
(* temporary sets env to empty *)
let env = Env.create_env [] in
set_labels_flag ide.ide_show_labels; set_labels_flag ide.ide_show_labels;
set_locs_flag ide.ide_show_locs; set_locs_flag ide.ide_show_locs;
{ window_height = ide.ide_window_height; { window_height = ide.ide_window_height;
...@@ -307,25 +303,14 @@ let save_config t = ...@@ -307,25 +303,14 @@ let save_config t =
let config = Whyconf.set_section config "ide" ide in let config = Whyconf.set_section config "ide" ide in
Whyconf.save_config config Whyconf.save_config config
let read_config conf_file extra_files = let config,load_config =
try
let config = Whyconf.read_config conf_file in
let merged_config = List.fold_left Whyconf.merge_config config extra_files in
load_config merged_config config
with e when not (Debug.test_flag Debug.stack_trace) ->
eprintf "@.%a@." Exn_printer.exn_printer e;
exit 1
let config,read_config =
let config = ref None in let config = ref None in
(fun () -> (fun () ->
match !config with match !config with
| None -> invalid_arg "configuration not yet loaded" | None -> invalid_arg "configuration not yet loaded"
| Some conf -> conf), | Some conf -> conf),
(fun conf_file extra_files -> (fun conf base_conf env ->
(*Debug.dprintf debug "[Info] reading config file...@?";*) let c = load_config conf base_conf env in
let c = read_config conf_file extra_files in
(*Debug.dprintf debug " done.@.";*)
config := Some c) config := Some c)
let save_config () = save_config (config ()) let save_config () = save_config (config ())
......
...@@ -40,8 +40,8 @@ type t = ...@@ -40,8 +40,8 @@ type t =
mutable session_nb_processes : int; mutable session_nb_processes : int;
} }
val read_config : string option -> string list -> unit val load_config : Whyconf.config -> Whyconf.config -> Why3.Env.env -> unit
(** None use the default config *) (** [load_config config original_config env] creates and saves IDE config *)
val init : unit -> unit val init : unit -> unit
......
...@@ -39,54 +39,35 @@ let debug = Debug.lookup_flag "ide_info" ...@@ -39,54 +39,35 @@ let debug = Debug.lookup_flag "ide_info"
(* parsing command line *) (* parsing command line *)
(************************) (************************)
let includes = ref []
let files = Queue.create () let files = Queue.create ()
let opt_parser = ref None let opt_parser = ref None
let opt_config = ref None
let opt_extra = ref []
let spec = Arg.align [ let spec = Arg.align [
("-L",
Arg.String (fun s -> includes := s :: !includes),
"<dir> Add <dir> to the library search path") ;
"--library",
Arg.String (fun s -> includes := s :: !includes),
" same as -L" ;
"-C", Arg.String (fun s -> opt_config := Some s),
"<file> Read configuration from <file>";
"--config", Arg.String (fun s -> opt_config := Some s),
" same as -C";
"--extra-config", Arg.String (fun s -> opt_extra := !opt_extra @ [s]),
"<file> Read additional configuration from <file>";
"-F", Arg.String (fun s -> opt_parser := Some s), "-F", Arg.String (fun s -> opt_parser := Some s),
"<format> Select input format (default: \"why\")"; "<format> select input format (default: \"why\")";
"--format", Arg.String (fun s -> opt_parser := Some s), "--format", Arg.String (fun s -> opt_parser := Some s),
" same as -F"; " same as -F";
(* (*
("-f", "-f",
Arg.String (fun s -> input_files := s :: !input_files), Arg.String (fun s -> input_files := s :: !input_files),
"<f> add file f to the project (ignored if it is already there)") ; "<file> add file to the project (ignored if it is already there)";
*) *)
Debug.Args.desc_debug_list;
Debug.Args.desc_debug_all;
Debug.Args.desc_debug
] ]
let usage_str = sprintf let usage_str = sprintf
"Usage: %s [options] [<file.why>|<project directory> [<file.why> ...]]" "Usage: %s [options] [<file.why>|<project directory>]..."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let () = Arg.parse spec (fun f -> Queue.add f files) usage_str let gconfig = try
let config, base_config, env =
Whyconf.Args.initialize spec (fun f -> Queue.add f files) usage_str in
if Queue.is_empty files then Whyconf.Args.exit_with_usage spec usage_str;
Gconfig.load_config config base_config env;
Gconfig.config ()
let () = Gconfig.read_config !opt_config !opt_extra with e when not (Debug.test_flag Debug.stack_trace) ->
eprintf "%a@." Exn_printer.exn_printer e;
let () = C.load_plugins (Gconfig.get_main ()) exit 1
let () =
Debug.Args.set_flags_selected ();
if Debug.Args.option_list () then exit 0
let () = if Queue.is_empty files then begin Arg.usage spec usage_str; exit 1 end
let () = let () =
Debug.dprintf debug "[Info] Init the GTK interface...@?"; Debug.dprintf debug "[Info] Init the GTK interface...@?";
...@@ -115,9 +96,7 @@ let (why_lang, any_lang) = ...@@ -115,9 +96,7 @@ let (why_lang, any_lang) =
| Some _ as l -> l in | Some _ as l -> l in
(why_lang, any_lang) (why_lang, any_lang)
(* Borrowed from Frama-C src/gui/source_manager.ml:
(* Borrowed from Frama-C src/gui/source_manager.ml:
Try to convert a source file either as UTF-8 or as locale. *) Try to convert a source file either as UTF-8 or as locale. *)
let try_convert s = let try_convert s =
try try
...@@ -142,22 +121,6 @@ let source_text fname = ...@@ -142,22 +121,6 @@ let source_text fname =
with e when not (Debug.test_flag Debug.stack_trace) -> with e when not (Debug.test_flag Debug.stack_trace) ->
"Error while opening or reading file '" ^ fname ^ "':\n" ^ (Printexc.to_string e) "Error while opening or reading file '" ^ fname ^ "':\n" ^ (Printexc.to_string e)
(********************************)
(* loading WhyIDE configuration *)
(********************************)
let loadpath = (C.loadpath (Gconfig.get_main ())) @ List.rev !includes
let gconfig =
let c = Gconfig.config () in
c.env <- Env.create_env loadpath;
(*
let provers = C.get_provers c.Gconfig.config in
c.provers <-
Util.Mstr.fold (Session.get_prover_data c.env) provers Util.Mstr.empty;
*)
c
(***************) (***************)
(* Main window *) (* Main window *)
(***************) (***************)
...@@ -637,7 +600,7 @@ module MA = struct ...@@ -637,7 +600,7 @@ module MA = struct
let notify_timer_state = let notify_timer_state =
let c = ref 0 in let c = ref 0 in
fun t s r -> fun t s r ->
reset_gc (); reset_gc ();
incr c; incr c;
monitor_waiting#set_text ("Waiting: " ^ (string_of_int t)); monitor_waiting#set_text ("Waiting: " ^ (string_of_int t));
monitor_scheduled#set_text ("Scheduled: " ^ (string_of_int s)); monitor_scheduled#set_text ("Scheduled: " ^ (string_of_int s));
...@@ -1636,7 +1599,7 @@ let evaluate_window () = ...@@ -1636,7 +1599,7 @@ let evaluate_window () =
files_map (0, []) files_map (0, [])
in in
let (_store, column) = let (_store, column) =
GTree.store_of_list Gobject.Data.string file_names GTree.store_of_list Gobject.Data.string file_names
in in
files_combo#set_text_column column; files_combo#set_text_column column;
let ( _ : GtkSignal.id) = files_combo#connect#changed let ( _ : GtkSignal.id) = files_combo#connect#changed
...@@ -1889,7 +1852,7 @@ let reload () = ...@@ -1889,7 +1852,7 @@ let reload () =
current_file := ""; current_file := "";
(** create a new environnement (** create a new environnement
(in order to reload the files which are "use") *) (in order to reload the files which are "use") *)
gconfig.env <- Env.create_env loadpath; gconfig.env <- Env.create_env (Env.get_loadpath gconfig.env);
(** reload the session *) (** reload the session *)
let old_session = (env_session()).S.session in let old_session = (env_session()).S.session in
let new_env_session,(_:bool),(_:bool) = let new_env_session,(_:bool),(_:bool) =
......
...@@ -89,11 +89,12 @@ let command sscmd = ...@@ -89,11 +89,12 @@ let command sscmd =
for i = 1 to Array.length Sys.argv - 1 do for i = 1 to Array.length Sys.argv - 1 do
if i <> !Arg.current then args := Sys.argv.(i) :: !args; if i <> !Arg.current then args := Sys.argv.(i) :: !args;
done; done;
Unix.execv cmd (Array.of_list (sscmd :: List.rev !args)) let scmd = "why3 " ^ sscmd in
Unix.execv cmd (Array.of_list (scmd :: List.rev !args))
let () = try let () = try
let extra_help fmt () = extra_help fmt (available_commands ()) in let extra_help fmt () = extra_help fmt (available_commands ()) in
let config,_ = Args.initialize ~extra_help option_list command usage_msg in let config,_,_ = Args.initialize ~extra_help option_list command usage_msg in
(** listings *) (** listings *)
......
...@@ -14,7 +14,7 @@ open Why3 ...@@ -14,7 +14,7 @@ open Why3
open Stdlib open Stdlib
let usage_msg = sprintf let usage_msg = sprintf
"Usage: why3 %s [options] file module.ident..." "Usage: %s [options] file module.ident..."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let opt_file = ref None let opt_file = ref None
...@@ -37,7 +37,7 @@ let option_list = [ ...@@ -37,7 +37,7 @@ let option_list = [
"--format", Arg.String (fun s -> opt_parser := Some s), "--format", Arg.String (fun s -> opt_parser := Some s),
" same as -F" ] " same as -F" ]
let config, env = let config, _, env =
Whyconf.Args.initialize option_list add_opt usage_msg Whyconf.Args.initialize option_list add_opt usage_msg
let () = let () =
......
...@@ -15,7 +15,7 @@ open Stdlib ...@@ -15,7 +15,7 @@ open Stdlib
open Theory open Theory
let usage_msg = sprintf let usage_msg = sprintf
"Usage: why3 %s [options] -D <driver> -o <dir> [[file|-] [-T <theory>]...]..." "Usage: %s [options] -D <driver> -o <dir> [[file|-] [-T <theory>]...]..."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let opt_queue = Queue.create () let opt_queue = Queue.create ()
...@@ -71,7 +71,7 @@ let option_list = [ ...@@ -71,7 +71,7 @@ let option_list = [
"--output", Arg.String (fun s -> opt_output := Some s), "--output", Arg.String (fun s -> opt_output := Some s),
" same as -o" ] " same as -o" ]
let config, env = let config, _, env =
Whyconf.Args.initialize option_list add_opt_file usage_msg Whyconf.Args.initialize option_list add_opt_file usage_msg
let () = let () =
......
...@@ -18,7 +18,7 @@ open Task ...@@ -18,7 +18,7 @@ open Task
open Driver open Driver
let usage_msg = sprintf let usage_msg = sprintf
"Usage: why3 %s [options] [[file|-] [-T <theory> [-G <goal>]...]...]..." "Usage: %s [options] [[file|-] [-T <theory> [-G <goal>]...]...]..."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let opt_queue = Queue.create () let opt_queue = Queue.create ()
...@@ -144,7 +144,7 @@ let option_list = [ ...@@ -144,7 +144,7 @@ let option_list = [
Debug.Args.desc_shortcut Debug.Args.desc_shortcut
"type_only" "--type-only" " stop after type checking" ] "type_only" "--type-only" " stop after type checking" ]
let config, env = let config, _, env =
Whyconf.Args.initialize option_list add_opt_file usage_msg Whyconf.Args.initialize option_list add_opt_file usage_msg
let () = try let () = try
......
...@@ -13,7 +13,7 @@ open Format ...@@ -13,7 +13,7 @@ open Format
open Why3 open Why3
let usage_msg = sprintf let usage_msg = sprintf
"Usage: why3 %s [options] -D <driver> -o <dir> -T <theory> ..." "Usage: %s [options] -D <driver> -o <dir> -T <theory> ..."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let opt_queue = Queue.create () let opt_queue = Queue.create ()
...@@ -60,7 +60,7 @@ let option_list = [ ...@@ -60,7 +60,7 @@ let option_list = [
"--output", Arg.String (fun s -> opt_output := Some s), "--output", Arg.String (fun s -> opt_output := Some s),
" same as -o" ] " same as -o" ]
let config, env = let config, _, env =
Whyconf.Args.initialize option_list add_opt_file usage_msg Whyconf.Args.initialize option_list add_opt_file usage_msg
let () = let () =
......
...@@ -62,7 +62,7 @@ let set_opt_smoke = function ...@@ -62,7 +62,7 @@ let set_opt_smoke = function
| _ -> assert false | _ -> assert false
let usage_msg = Format.sprintf let usage_msg = Format.sprintf
"Usage: why3 %s [options] [<file.why>|<project directory>]" "Usage: %s [options] [<file.why>|<project directory>]"
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let option_list = [ let option_list = [
...@@ -104,7 +104,7 @@ let add_opt_file f = match !opt_file with ...@@ -104,7 +104,7 @@ let add_opt_file f = match !opt_file with
| None -> | None ->
opt_file := Some f opt_file := Some f
let config, env = let config, _, env =
Whyconf.Args.initialize option_list add_opt_file usage_msg Whyconf.Args.initialize option_list add_opt_file usage_msg
(* let () = *) (* let () = *)
......
...@@ -323,11 +323,12 @@ and skip_until_nl = parse ...@@ -323,11 +323,12 @@ and skip_until_nl = parse
end; end;
Queue.add file files Queue.add file files
let usage = "why3 wc [options] files...\n\ let usage = Format.sprintf "Usage: %s [options] files...\n\
\n\ \n\
Counts tokens/lines in Why3 source files.\n\ Counts tokens/lines in Why3 source files.\n\
Assumes source files to be lexically well-formed.\n\ Assumes source files to be lexically well-formed.\n\
If no source file is given, standard input is analyzed.\n" If no source file is given, standard input is analyzed.\n"
(Filename.basename Sys.argv.(0))
let () = Arg.parse spec add_file usage let () = Arg.parse spec add_file usage
......
...@@ -98,7 +98,7 @@ module Args = struct ...@@ -98,7 +98,7 @@ module Args = struct
let opt_list_flags = ref false in let opt_list_flags = ref false in
let desc = let desc =
"--list-debug-flags", Arg.Set opt_list_flags, "--list-debug-flags", Arg.Set opt_list_flags,
" List known debug flags" in " list known debug flags" in
let list () = let list () =
if !opt_list_flags then begin if !opt_list_flags then begin
let list = let list =
...@@ -127,14 +127,14 @@ module Args = struct ...@@ -127,14 +127,14 @@ module Args = struct
(option, Arg.Unit set_flag, desc) (option, Arg.Unit set_flag, desc)
let desc_debug = let desc_debug =
("--debug", Arg.String add_flag, "<flag> Set a debug flag") ("--debug", Arg.String add_flag, "<flag> set a debug flag")
let opt_debug_all = ref false let opt_debug_all = ref false
let desc_debug_all = let desc_debug_all =
let desc_debug = let desc_debug =
Pp.sprintf Pp.sprintf
" Set all debug flags that do not change Why3 behaviour" in " set all debug flags that do not change Why3 behaviour" in
("--debug-all", Arg.Set opt_debug_all, desc_debug) ("--debug-all", Arg.Set opt_debug_all, desc_debug)
let set_flags_selected () = let set_flags_selected () =
......
...@@ -19,16 +19,11 @@ let usage_msg = ...@@ -19,16 +19,11 @@ let usage_msg =
can be set to change the default paths.@." can be set to change the default paths.@."
(Filename.basename Sys.argv.(0)) (Filename.basename Sys.argv.(0))
let version_msg = sprintf
"Why3 configuration utility, version %s (build date: %s)"
Config.version Config.builddate
(* let libdir = ref None *) (* let libdir = ref None *)
(* let datadir = ref None *) (* let datadir = ref None *)
let conf_file = ref None let conf_file = ref None
let autoprovers = ref false let autoprovers = ref false
let autoplugins = ref false let autoplugins = ref false
let opt_version = ref false
let opt_list_prover_ids = ref false let opt_list_prover_ids = ref false
...@@ -47,31 +42,29 @@ let option_list = Arg.align [ ...@@ -47,31 +42,29 @@ let option_list = Arg.align [
(* "--datadir", Arg.String (set_oref datadir), *) (* "--datadir", Arg.String (set_oref datadir), *)
(* "<dir> set the data directory ($WHY3DATA)"; *) (* "<dir> set the data directory ($WHY3DATA)"; *)
"-C", Arg.String (set_oref conf_file), "-C", Arg.String (set_oref conf_file),
"<file> Config file to create"; "<file> config file to create";
"--config", Arg.String (set_oref conf_file), "--config", Arg.String (set_oref conf_file),
" same as -C"; " same as -C";
"--detect-provers", Arg.Set autoprovers, "--detect-provers", Arg.Set autoprovers,
" Search for provers in $PATH"; " search for provers in $PATH";
"--detect-plugins", Arg.Set autoplugins, "--detect-plugins", Arg.Set autoplugins,
" Search for plugins in the default library directory"; " search for plugins in the default library directory";
"--detect", Arg.Unit (fun () -> autoprovers := true; autoplugins := true), "--detect", Arg.Unit (fun () -> autoprovers := true; autoplugins := true),
" Search for both provers and plugins"; " search for both provers and plugins";
"--add-prover", Arg.Tuple "--add-prover", Arg.Tuple
(let id = ref "" in (let id = ref "" in
[Arg.Set_string id; [Arg.Set_string id;
Arg.String (fun name -> Queue.add (!id, name) prover_bins)]), Arg.String (fun name -> Queue.add (!id, name) prover_bins)]),
"<id><file> Add a new prover executable"; "<id><file> add a new prover executable";
"--list-prover-ids", Arg.Set opt_list_prover_ids, "--list-prover-ids", Arg.Set opt_list_prover_ids,
" List known prover families"; " list known prover families";
"--install-plugin", Arg.String add_plugin, "--install-plugin", Arg.String add_plugin,
"<file> Install a plugin to the actual libdir"; "<file> install a plugin to the actual libdir";
"--dont-save", Arg.Clear save, "--dont-save", Arg.Clear save,
" Do not modify the config file"; " do not modify the config file";
Debug.Args.desc_debug_list; Debug.Args.desc_debug_list;
Debug.Args.desc_debug_all; Debug.Args.desc_debug_all;
Debug.Args.desc_debug; Debug.Args.desc_debug;
"--version", Arg.Set opt_version,
" Print version information"
] ]
let anon_file _ = Arg.usage option_list usage_msg; exit 1 let anon_file _ = Arg.usage option_list usage_msg; exit 1
...@@ -125,10 +118,6 @@ let main () = ...@@ -125,10 +118,6 @@ let main () =
Arg.parse option_list anon_file usage_msg; Arg.parse option_list anon_file usage_msg;