Skip to content

Commit 365aa80

Browse files
panglesdjonludlam
authored andcommitted
Driver: better handling of incompatible options
Signed-off-by: Paul-Elliot <[email protected]>
1 parent 769917f commit 365aa80

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/driver/dune_style.ml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ let of_dune_build dir =
3434
let cmtidir =
3535
Fpath.(path / Printf.sprintf ".%s.objs" libname / "byte")
3636
in
37-
match Fpath.rem_prefix dir path with
38-
| Some pkg_dir ->
39-
( pkg_dir,
40-
Packages.Lib.v pkg_dir
41-
(Util.StringMap.singleton libname libname)
42-
libname path (Some cmtidir) )
43-
| None -> failwith "Error")
37+
let pkg_dir = Fpath.rem_prefix dir path |> Option.get in
38+
( pkg_dir,
39+
Packages.Lib.v pkg_dir
40+
(Util.StringMap.singleton libname libname)
41+
libname path (Some cmtidir) ))
4442
libs
4543
in
4644
let packages =

src/driver/odoc_driver.ml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,22 @@ let run libs verbose packages_dir odoc_dir odocl_dir html_dir stats nb_workers
508508
let () = Worker_pool.start_workers env sw nb_workers in
509509

510510
let all =
511-
if voodoo then
512-
match package_name with
513-
| Some p -> Voodoo.of_voodoo p blessed
514-
| None -> failwith "Need a package name for voodoo"
515-
else
516-
match dune_style with
517-
| Some dir -> Dune_style.of_dune_build dir
518-
| None ->
519-
let libs = if libs = [] then Ocamlfind.all () else libs in
520-
let libs =
521-
List.map Ocamlfind.sub_libraries libs
522-
|> List.fold_left Util.StringSet.union Util.StringSet.empty
523-
in
524-
Packages.of_libs packages_dir libs
511+
match (voodoo, package_name, dune_style, packages_dir) with
512+
| true, Some p, None, None -> Voodoo.of_voodoo p blessed
513+
| false, None, Some dir, None -> Dune_style.of_dune_build dir
514+
| false, None, None, packages_dir ->
515+
let libs = if libs = [] then Ocamlfind.all () else libs in
516+
let libs =
517+
List.map Ocamlfind.sub_libraries libs
518+
|> List.fold_left Util.StringSet.union Util.StringSet.empty
519+
in
520+
Packages.of_libs packages_dir libs
521+
| true, None, _, _ -> failwith "--voodoo requires --package-name"
522+
| false, Some _, _, _ -> failwith "--package-name requires --voodoo"
523+
| true, _, _, Some _ | false, _, Some _, Some _ ->
524+
failwith "--packages-dir is only useful in opam mode"
525+
| true, _, Some _, _ ->
526+
failwith "--voodoo and --dune-style are mutually independent"
525527
in
526528
let partial =
527529
if voodoo then

0 commit comments

Comments
 (0)