diff --git a/doc/configurator.rst b/doc/configurator.rst index 73d49f74..77d57277 100644 --- a/doc/configurator.rst +++ b/doc/configurator.rst @@ -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 =================================== diff --git a/src/configurator/v1.ml b/src/configurator/v1.ml index 80d46a0f..c1782f41 100644 --- a/src/configurator/v1.ml +++ b/src/configurator/v1.ml @@ -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 diff --git a/src/configurator/v1.mli b/src/configurator/v1.mli index e2d3c8b8..28c59383 100644 --- a/src/configurator/v1.mli +++ b/src/configurator/v1.mli @@ -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