Extend ocamlc_config for configurator

* Add make to create ocamlc_config.t
* Add function to get bindings
This commit is contained in:
Jérémie Dimino 2018-02-28 23:32:24 +07:00 committed by Rudi Grinberg
parent 9a6d9a3aa9
commit 55675598c4
2 changed files with 19 additions and 3 deletions

View File

@ -6,6 +6,8 @@ type t =
; ocamlc: Path.t
}
let bindings t = t.bindings
let ocamlc_config_cmd ocamlc =
sprintf "%s -config" (Path.to_string ocamlc)
@ -13,9 +15,7 @@ let sexp_of_t t =
let open Sexp.To_sexp in
string_map Sexp.atom_or_quoted_string t.bindings
let read ~ocamlc ~env =
Process.run_capture_lines ~env Strict (Path.to_string ocamlc) ["-config"]
>>| fun lines ->
let make ~ocamlc ~ocamlc_config_output:lines =
List.map lines ~f:(fun line ->
match String.index line ':' with
| Some i ->
@ -31,6 +31,11 @@ let read ~ocamlc ~env =
die "variable %S present twice in the output of `%s`"
key (ocamlc_config_cmd ocamlc)
let read ~ocamlc ~env =
Process.run_capture_lines ~env Strict (Path.to_string ocamlc) ["-config"]
>>| fun lines ->
make ~ocamlc ~ocamlc_config_output:lines
let ocaml_value t =
let t = String_map.to_list t.bindings in
let longest = String.longest_map t ~f:fst in

View File

@ -1,8 +1,16 @@
(** Output of [ocamlc -config] *)
open Import
type t
val sexp_of_t : t -> Sexp.t
val make
: ocamlc:Path.t
-> ocamlc_config_output:string list
-> t
val read : ocamlc:Path.t -> env:string array -> t Fiber.t
(** Used to pass these settings to jbuild files using the OCaml syntax *)
@ -17,3 +25,6 @@ val word_size : t -> string option
val flambda : t -> bool
val stdlib_dir : t -> Path.t
val c_compiler_settings : t -> (string * string * string)
(**/**)
val bindings : t -> string String_map.t