-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use dune-site to find resources (when installed)
- Loading branch information
Showing
7 changed files
with
74 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,48 @@ | ||
(* -------------------------------------------------------------------- *) | ||
let myname = Filename.basename Sys.executable_name | ||
let mydir = Filename.dirname Sys.executable_name | ||
|
||
let eclocal = | ||
(* -------------------------------------------------------------------- *) | ||
let eclocal : bool = | ||
let rex = EcRegexp.regexp "^ec\\.(?:native|byte|exe)$" in | ||
EcRegexp.match_ (`C rex) myname | ||
|
||
let sourceroot = | ||
(* -------------------------------------------------------------------- *) | ||
let sourceroot : string option = | ||
if eclocal then | ||
if Filename.basename mydir = "src" | ||
then Some (Filename.dirname mydir) | ||
else Some mydir | ||
else None | ||
|
||
let resource name = | ||
match eclocal with | ||
| true -> | ||
if Filename.basename mydir = "src" then | ||
List.fold_left Filename.concat mydir | ||
([Filename.parent_dir_name] @ name) | ||
else | ||
List.fold_left Filename.concat mydir name | ||
|
||
| false -> | ||
List.fold_left Filename.concat mydir | ||
([Filename.parent_dir_name; "lib"; "easycrypt"] @ name) | ||
|
||
module Sites = struct | ||
let theories = [resource ["theories"]] | ||
(* -------------------------------------------------------------------- *) | ||
let local (name : string list) : string = | ||
List.fold_left Filename.concat (Option.value ~default:"." sourceroot) name | ||
|
||
(* -------------------------------------------------------------------- *) | ||
module type Sites = sig | ||
val commands : string | ||
val theories : string list | ||
end | ||
|
||
(* -------------------------------------------------------------------- *) | ||
module LocalSites() : Sites = struct | ||
let commands = local ["scripts"; "testing"] | ||
let theories = [local ["theories"]] | ||
end | ||
|
||
(* -------------------------------------------------------------------- *) | ||
module DuneSites() : Sites = struct | ||
let commands = | ||
Option.value ~default:"." | ||
(EcUtils.List.Exceptionless.hd EcDuneSites.Sites.commands) | ||
|
||
let theories = | ||
EcDuneSites.Sites.theories | ||
end | ||
|
||
(* -------------------------------------------------------------------- *) | ||
let sites : (module Sites) = | ||
if eclocal | ||
then (module LocalSites ()) | ||
else (module DuneSites ()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
(* -------------------------------------------------------------------- *) | ||
val sourceroot : string option | ||
val resource : string list -> string | ||
|
||
module Sites : sig | ||
(* -------------------------------------------------------------------- *) | ||
module type Sites = sig | ||
val commands : string | ||
val theories : string list | ||
end | ||
|
||
(* -------------------------------------------------------------------- *) | ||
val sites : (module Sites) |