Add Configurator.V1.write_flags

See https://github.com/ocaml/dune/pull/696/files#r181721525
This commit is contained in:
Christophe Troestler 2018-04-17 13:55:21 +02:00
parent e68faa0494
commit 7e1b521d7b
3 changed files with 14 additions and 0 deletions

View File

@ -80,6 +80,11 @@ this flag file using ``:include``:
(c_names (foo))
(c_library_flags (:include (flags.sexp)))))
For this, generate the list of flags for your library — for example
using ``Configurator.V1.Pkg_config`` — and then write them to a file,
in the above example ``flags.sexp``, with
``Configurator.V1.write_flags "flags.sexp" flags``.
Upgrading from the old Configurator
===================================

View File

@ -419,6 +419,10 @@ module Pkg_config = struct
None
end
let write_flags fname s =
let sexp = Usexp.List(List.map ~f:Usexp.atom_or_quoted_string s) in
Io.write_file fname (Usexp.to_string sexp)
let main ?(args=[]) ~name f =
let ocamlc = ref (
match Sys.getenv "DUNE_CONFIGURATOR" with

View File

@ -88,6 +88,11 @@ module Pkg_config : sig
val query : t -> package:string -> package_conf option
end with type configurator := t
val write_flags : string -> string list -> unit
(** [write_flags fname s] write the list of strings [s] to the file
[fname] in an appropriate format so that it can used in jbuild
files with "(:include [fname])". *)
(** Typical entry point for configurator programs *)
val main
: ?args:(Arg.key * Arg.spec * Arg.doc) list