Split xxx-workspace file between jbuilder and dune

- jbuilder only looks for jbuild-workspace files
- dune only looks for dune-workspace files

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-06-29 21:56:04 +01:00 committed by Rudi Grinberg
parent e706421893
commit d6c35e01df
4 changed files with 15 additions and 9 deletions

View File

@ -147,10 +147,9 @@ let find_root () =
let cwd = Sys.getcwd () in
let rec loop counter ~candidates ~to_cwd dir =
let files = Sys.readdir dir |> Array.to_list |> String.Set.of_list in
if String.Set.mem files "dune-workspace" ||
String.Set.mem files "jbuild-workspace" then
if String.Set.mem files Workspace.filename then
cont counter ~candidates:((0, dir, to_cwd) :: candidates) dir ~to_cwd
else if String.Set.exists files ~f:(fun fn ->
else if Which_program.t = Jbuilder && String.Set.exists files ~f:(fun fn ->
String.is_prefix fn ~prefix:"jbuild-workspace") then
cont counter ~candidates:((1, dir, to_cwd) :: candidates) dir ~to_cwd
else if String.Set.mem files Dune_project.filename then

View File

@ -61,12 +61,11 @@ let setup ?(log=Log.no_log)
Workspace.load ?x ?profile p
| _ ->
match
List.find_map ["dune-workspace"; "jbuild-workspace"] ~f:(fun fn ->
let p = Path.of_string fn in
if Path.exists p then
Some p
else
None)
let p = Path.of_string Workspace.filename in
if Path.exists p then
Some p
else
None
with
| Some p -> Workspace.load ?x ?profile p
| None ->

View File

@ -191,3 +191,8 @@ let t ?x ?profile:cmdline_profile sexps =
}
let load ?x ?profile p = t ?x ?profile (Io.Sexp.load p ~mode:Many)
let filename =
match Which_program.t with
| Dune -> "dune-workspace"
| Jbuilder -> "jbuild-workspace"

View File

@ -37,3 +37,6 @@ type t =
}
val load : ?x:string -> ?profile:string -> Path.t -> t
(** Default name of workspace files *)
val filename : string