Skip to content

Commit

Permalink
Honour OCAMLPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
nojb committed Apr 28, 2024
1 parent bbd2ace commit 73b0db2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/indexOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ let filter_to_string l =
in
String.concat "," (List.map pp l)

let initial_cwd = Sys.getcwd ()

let path_sep = if Sys.win32 then ';' else ':'

let parse_path_var s =
let l = String.split_on_char path_sep s in
let l = List.filter (fun s -> s <> "") l in
List.map (fun path -> if Filename.is_relative path then Filename.concat initial_cwd path else path) l

let common_opts ?(default_filter = default_filter) () : t Term.t =
let ocamllib : string list Term.t =
let no_stdlib : bool Term.t =
Expand All @@ -92,6 +101,11 @@ let common_opts ?(default_filter = default_filter) () : t Term.t =
in
let set_default no_stdlib no_opamlib includes =
let paths = List.flatten includes in
let paths =
match Sys.getenv "OCAMLPATH" with
| exception Not_found -> paths
| s -> parse_path_var s @ paths
in
let paths =
if no_opamlib then paths else
try cmd_input_line "opam config var lib" :: paths
Expand Down

0 comments on commit 73b0db2

Please sign in to comment.