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:
parent
e706421893
commit
d6c35e01df
|
@ -147,10 +147,9 @@ let find_root () =
|
||||||
let cwd = Sys.getcwd () in
|
let cwd = Sys.getcwd () in
|
||||||
let rec loop counter ~candidates ~to_cwd dir =
|
let rec loop counter ~candidates ~to_cwd dir =
|
||||||
let files = Sys.readdir dir |> Array.to_list |> String.Set.of_list in
|
let files = Sys.readdir dir |> Array.to_list |> String.Set.of_list in
|
||||||
if String.Set.mem files "dune-workspace" ||
|
if String.Set.mem files Workspace.filename then
|
||||||
String.Set.mem files "jbuild-workspace" then
|
|
||||||
cont counter ~candidates:((0, dir, to_cwd) :: candidates) dir ~to_cwd
|
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
|
String.is_prefix fn ~prefix:"jbuild-workspace") then
|
||||||
cont counter ~candidates:((1, dir, to_cwd) :: candidates) dir ~to_cwd
|
cont counter ~candidates:((1, dir, to_cwd) :: candidates) dir ~to_cwd
|
||||||
else if String.Set.mem files Dune_project.filename then
|
else if String.Set.mem files Dune_project.filename then
|
||||||
|
|
11
src/main.ml
11
src/main.ml
|
@ -61,12 +61,11 @@ let setup ?(log=Log.no_log)
|
||||||
Workspace.load ?x ?profile p
|
Workspace.load ?x ?profile p
|
||||||
| _ ->
|
| _ ->
|
||||||
match
|
match
|
||||||
List.find_map ["dune-workspace"; "jbuild-workspace"] ~f:(fun fn ->
|
let p = Path.of_string Workspace.filename in
|
||||||
let p = Path.of_string fn in
|
if Path.exists p then
|
||||||
if Path.exists p then
|
Some p
|
||||||
Some p
|
else
|
||||||
else
|
None
|
||||||
None)
|
|
||||||
with
|
with
|
||||||
| Some p -> Workspace.load ?x ?profile p
|
| Some p -> Workspace.load ?x ?profile p
|
||||||
| None ->
|
| None ->
|
||||||
|
|
|
@ -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 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"
|
||||||
|
|
|
@ -37,3 +37,6 @@ type t =
|
||||||
}
|
}
|
||||||
|
|
||||||
val load : ?x:string -> ?profile:string -> Path.t -> t
|
val load : ?x:string -> ?profile:string -> Path.t -> t
|
||||||
|
|
||||||
|
(** Default name of workspace files *)
|
||||||
|
val filename : string
|
||||||
|
|
Loading…
Reference in New Issue