Commit 395e8644 authored by Francois Bobot's avatar Francois Bobot

Whyconf centralize all the configuration (temporary solution)

parent b6641c8d
......@@ -42,11 +42,9 @@ let debug =
let config = Whyconf.read_config None
let timelimit = match config.timelimit with
| None -> 3
| Some t -> t
let timelimit = config.main.timelimit
let env = Env.create_env (Lexer.retrieve config.loadpath)
let env = Env.create_env (Lexer.retrieve config.main.loadpath)
let provers = Hashtbl.create 17
......
This diff is collapsed.
......@@ -21,26 +21,44 @@
open Util
val libdir : string
val datadir : string
val sharedir : string (* For image, ... *)
type config_prover = {
name : string; (* "Alt-Ergo v2.95 (special)" *)
command : string; (* "exec why-limit %t %m alt-ergo %f" *)
driver : string; (* "/usr/local/share/why/drivers/ergo-spec.drv" *)
version : string; (* "v2.95" *)
editor : string; (* Interative theorem prover *)
}
type main = {
loadpath : string list; (* "/usr/local/share/why/theories" *)
timelimit : int; (* default prover time limit in seconds
(0 unlimited) *)
memlimit : int;
(* default prover memory limit in megabytes (0 unlimited)*)
running_provers_max : int;
(* max number of running prover processes *)
}
type ide = {
window_width : int;
window_height : int;
tree_width : int;
task_height : int;
verbose : int;
default_editor : string;
}
type config = {
conf_file : string; (* "/home/innocent_user/.why.conf" *)
(*
loadpath : string list; (* "/usr/local/share/why/theories" *)
*)
timelimit : int option; (* default prover time limit in seconds *)
memlimit : int option; (* default prover memory limit in megabytes *)
running_provers_max : int option; (* max number of running prover processes *)
provers : config_prover Mstr.t; (* indexed by short identifiers *)
main : main;
ide : ide;
}
val default_config : config
(** if conf_file is not given, tries the following:
"$WHY_CONFIG"; "./why.conf"; "./.why.conf";
"$HOME/.why.conf"; "$USERPROFILE/.why.conf" *)
......@@ -48,4 +66,5 @@ val read_config : string option -> config
val save_config : config -> unit
(** Replace the provers by autodetected one *)
val run_auto_detection : config -> config
This diff is collapsed.
......@@ -17,13 +17,16 @@ type t =
mutable tree_width : int;
mutable task_height : int;
mutable time_limit : int;
mutable mem_limit : int;
mutable verbose : int;
mutable max_running_processes : int;
mutable provers : prover_data list;
mutable default_editor : string;
env : Why.Env.env;
mutable config : Whyconf.config;
}
val read_config : Env.env -> t
val read_config : unit -> t
val save_config : t -> unit
......@@ -55,7 +58,7 @@ val show_legend_window : unit -> unit
val show_about_window : unit -> unit
val preferences : t -> unit
val run_auto_detection : Env.env -> t -> unit
val run_auto_detection : t -> unit
(*
Local Variables:
......
......@@ -75,15 +75,13 @@ let source_text =
close_in ic;
buf
let env = Why.Env.create_env (Why.Lexer.retrieve [Filename.concat Whyconf.datadir "theories"])
(********************************)
(* loading WhyIDE configuration *)
(********************************)
let gconfig =
eprintf "reading IDE config file@.";
read_config env
read_config ()
......@@ -94,7 +92,7 @@ let gconfig =
let theories : Theory.theory Theory.Mnm.t =
try
let cin = open_in fname in
let m = Env.read_channel env fname cin in
let m = Env.read_channel gconfig.env fname cin in
close_in cin;
eprintf "Parsing/Typing Ok@.";
m
......@@ -488,7 +486,7 @@ let prover_on_unproved_goals p () =
(* method: split all unproved goals *)
(*****************************************************)
let split_transformation = Trans.lookup_transform_l "split_goal" env
let split_transformation = Trans.lookup_transform_l "split_goal" gconfig.env
let split_unproved_goals () =
List.iter
......@@ -569,7 +567,7 @@ let (_ : GMenu.image_menu_item) =
let (_ : GMenu.image_menu_item) =
file_factory#add_image_item ~label:"_Detect provers" ~callback:
(fun () -> Gconfig.run_auto_detection env gconfig)
(fun () -> Gconfig.run_auto_detection gconfig)
()
let (_ : GMenu.image_menu_item) =
......
......@@ -89,7 +89,7 @@ let add_opt_meta meta =
let opt_config = ref None
let opt_parser = ref None
let opt_prover = ref None
let opt_loadpath = ref [Filename.concat Whyconf.datadir "theories"]
let opt_loadpath = ref []
let opt_driver = ref None
let opt_output = ref None
let opt_timelimit = ref None
......@@ -288,21 +288,12 @@ let () =
option_iter
(eprintf "No config file found (required by '-P %s').@.") !opt_prover;
if !opt_config <> None || !opt_prover <> None then exit 1;
{ conf_file = "";
(*
loadpath = [];
*)
timelimit = None;
memlimit = None;
running_provers_max = None;
provers = Mstr.empty }
default_config
in
(*
opt_loadpath := List.rev_append !opt_loadpath config.loadpath;
*)
if !opt_timelimit = None then opt_timelimit := config.timelimit;
if !opt_memlimit = None then opt_memlimit := config.memlimit;
opt_loadpath := List.rev_append !opt_loadpath config.main.loadpath;
if !opt_timelimit = None then opt_timelimit := Some config.main.timelimit;
if !opt_memlimit = None then opt_memlimit := Some config.main.memlimit;
begin match !opt_prover with
| Some s ->
let prover = try Mstr.find s config.provers with
......
......@@ -18,7 +18,6 @@
(**************************************************************************)
(** Parse rc files *)
type rc_value =
| RCint of int
| RCbool of bool
......@@ -26,6 +25,8 @@ type rc_value =
| RCstring of string
| RCident of string
type t = (string list * (string * rc_value) list) list
val int : rc_value -> int
(** raise Failure "Rc.int" if not a int value *)
......@@ -35,13 +36,13 @@ val bool : rc_value -> bool
val string : rc_value -> string
(** raise Failure "Rc.string" if not a string or an ident value *)
val from_file : string -> (string list * (string * rc_value) list) list
val from_file : string -> t
(** returns the records of the file [f]
@raise Not_found is f does not exists
@raise Failure "lexing" in case of incorrect syntax *)
val to_file : string -> (string list * (string * rc_value) list) list -> unit
(** write the records into the file [f] *)
val to_file : string -> t -> unit
(** save the records in the filr [f] *)
val get_home_dir : unit -> string
(** returns the home dir of the user *)
......
......@@ -35,6 +35,8 @@ type rc_value =
| RCstring of string
| RCident of string
type t = (string list * (string * rc_value) list) list
let int = function
| RCint n -> n
| _ -> failwith "Rc.int"
......@@ -147,44 +149,40 @@ and string_val key = parse
{
let from_file f =
let c =
try open_in f
with Sys_error _ -> raise Not_found
(*
let c =
try open_in f
with Sys_error _ -> raise Not_found
(*
Format.eprintf "Cannot open file %s@." f;
exit 1
*)
in
current := [];
let lb = from_channel c in
record lb;
close_in c;
List.rev !current
open Format
open Pp
*)
in
current := [];
let lb = from_channel c in
record lb;
close_in c;
List.rev !current
open Format
let to_file s l =
let print_value fmt = function
| RCint n -> fprintf fmt "%d" n
| RCbool b -> fprintf fmt "%b" b
| RCfloat f -> fprintf fmt "%f" f
| RCstring s -> fprintf fmt "\"%s\"" s
| RCident i -> fprintf fmt "%s" i
let record fmt (keys,fl) =
fprintf fmt "[%a]@\n" (print_list space pp_print_string) keys;
List.iter
(fun (f,v) -> fprintf fmt "%s = %a@\n" f print_value v)
fl;
fprintf fmt "@."
let to_file f l =
let c =
try open_out f
with Sys_error _ -> raise Not_found
in
let fmt = formatter_of_out_channel c in
List.iter (record fmt) l;
close_out c
| RCint i -> pp_print_int fmt i
| RCbool b -> pp_print_bool fmt b
| RCfloat f -> pp_print_float fmt f
| RCstring s -> fprintf fmt "\"%S\"" s
| RCident s -> pp_print_string fmt s in
let print_kv fmt (k,v) = fprintf fmt "%s = %a" k print_value v in
let print_section fmt (h,l) =
fprintf fmt "[%a]@\n%a"
(Pp.print_list Pp.space pp_print_string) h
(Pp.print_list Pp.newline print_kv) l in
let out = open_out s in
let fmt = formatter_of_out_channel out in
Pp.print_list Pp.newline print_section fmt l;
pp_print_flush fmt ();
close_out out
}
......@@ -31,6 +31,8 @@ let cons f acc x = (f x)::acc
let of_option = function None -> assert false | Some x -> x
let default_option d = function None -> d | Some x -> x
let option_map f = function None -> None | Some x -> Some (f x)
let option_apply d f = function None -> d | Some x -> f x
......
......@@ -31,6 +31,8 @@ val cons : ('a -> 'b) -> 'b list -> 'a -> 'b list
val of_option : 'a option -> 'a
val default_option : 'a -> 'a option -> 'a
val option_map : ('a -> 'b) -> 'a option -> 'b option
val option_iter : ('a -> unit) -> 'a option -> unit
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment