Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

/_build
/result
/etc
/theories/attic

/ec.*
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(dirs 3rdparty src theories examples scripts)
(dirs 3rdparty src etc theories examples scripts)

(install
(section (site (easycrypt commands)))
Expand Down
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(package
(name easycrypt)
(sites (lib theories) (libexec commands))
(sites (lib theories) (libexec commands) (lib config))
(depends
(ocaml (>= 4.08.0))
(batteries (>= 3))
Expand Down
2 changes: 2 additions & 0 deletions etc/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; All .conf files in this directory are automatically loaded by EasyCrypt at startup.
; They are processed in alphanumeric order, based on their filenames.
7 changes: 7 additions & 0 deletions etc/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(install
(section (site (easycrypt config)))
(files (glob_files_rec *.conf)))

(install
(section (site (easycrypt config)))
(files README))
47 changes: 34 additions & 13 deletions src/ec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let why3dflconf = Filename.concat XDG.home "why3.conf"
(* -------------------------------------------------------------------- *)
type pconfig = {
pc_why3 : string option;
pc_ini : string option;
pc_ini : string list;
pc_loadpath : (EcLoader.namespace option * string) list;
}

Expand Down Expand Up @@ -63,10 +63,17 @@ let print_config config =
| Some f -> Format.eprintf " %s@\n%!" f end;

(* Print EC configuration file location *)
Format.eprintf "EasyCrypt system configuration directory@\n%!";
Format.eprintf " %s@\n%!" Sites.config;

Format.eprintf "EasyCrypt configuration file@\n%!";
begin match config.pc_ini with
| None -> Format.eprintf " <none>@\n%!"
| Some f -> Format.eprintf " %s@\n%!" f end;
| [] -> Format.eprintf " <none>@\n%!"
| names ->
List.iter
(fun name -> Format.eprintf " %s@\n%!" name)
names
end;

(* Print list of known provers *)
begin
Expand Down Expand Up @@ -117,8 +124,8 @@ let main () =
let (module Sites) = EcRelocate.sites in

(* Parse command line arguments *)
let conffile, options =
let conffile =
let conffiles, options =
let sysfile =
let xdgini =
XDG.Config.file
~exists:true ~mode:`All ~appname:EcVersion.app
Expand All @@ -131,6 +138,19 @@ let main () =
if Sys.file_exists conffile then Some conffile else None) in
List.Exceptionless.hd (Option.to_list localini @ xdgini) in

let partfiles =
if Sys.file_exists Sites.config then
Sys.readdir Sites.config
|> Array.to_seq
|> Seq.filter (fun name -> String.lowercase_ascii (Filename.extension name) = ".conf")
|> Seq.map (Filename.concat Sites.config)
|> Seq.filter (fun p -> Sys.file_exists p && not (Sys.is_directory p))
|> List.of_seq
|> List.sort String.compare
else [] in

let conffiles = List.ocons sysfile partfiles in

let projfile (path : string option) =
let rec find (path : string) : string option =
let projfile = Filename.concat path projname in
Expand Down Expand Up @@ -168,11 +188,12 @@ let main () =

let getini (path : string option) =
let inisys =
Option.bind conffile (fun conffile ->
Option.map
(fun ini -> { inic_ini = ini; inic_root = None; })
(read_ini_file conffile)
)
List.filter_map
(fun conffile ->
Option.map
(fun ini -> { inic_ini = ini; inic_root = None; })
(read_ini_file conffile))
conffiles
in

let iniproj =
Expand All @@ -186,9 +207,9 @@ let main () =
)
in

List.filter_map identity [iniproj; inisys] in
List.ocons iniproj inisys in

(conffile, EcOptions.parse_cmdline ~ini:getini Sys.argv) in
(conffiles, EcOptions.parse_cmdline ~ini:getini Sys.argv) in

(* Execution of eager commands *)
begin
Expand Down Expand Up @@ -400,7 +421,7 @@ let main () =
| `Config ->
let config = {
pc_why3 = why3conf;
pc_ini = conffile;
pc_ini = conffiles;
pc_loadpath = EcCommands.loadpath ();
} in

Expand Down
6 changes: 6 additions & 0 deletions src/ecRelocate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ let local (name : string list) : string =
module type Sites = sig
val commands : string
val theories : string list
val config : string
end

(* -------------------------------------------------------------------- *)
module LocalSites() : Sites = struct
let commands = local ["scripts"; "testing"]
let theories = [local ["theories"]]
let config = local ["etc"]
end

(* -------------------------------------------------------------------- *)
Expand All @@ -39,6 +41,10 @@ module DuneSites() : Sites = struct

let theories =
EcDuneSites.Sites.theories

let config =
Option.value ~default:"etc"
(EcUtils.List.Exceptionless.hd EcDuneSites.Sites.config)
end

(* -------------------------------------------------------------------- *)
Expand Down
1 change: 1 addition & 0 deletions src/ecRelocate.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ val sourceroot : string option
module type Sites = sig
val commands : string
val theories : string list
val config : string
end

(* -------------------------------------------------------------------- *)
Expand Down