Extend (:include ) form to library_flags

library_flags already included variable expansion.
This commit is contained in:
David Allsopp 2017-07-05 22:11:33 +02:00 committed by Jérémie Dimino
parent 3a64432d04
commit be4b5fa454
5 changed files with 15 additions and 8 deletions

View File

@ -122,6 +122,11 @@ let fanout3 a b c =
(a &&& (b &&& c))
>>>
arr (fun (a, (b, c)) -> (a, b, c))
let fanout4 a b c d =
let open O in
(a &&& (b &&& (c &&& d)))
>>>
arr (fun (a, (b, (c, d))) -> (a, b, c, d))
let rec all = function
| [] -> arr (fun _ -> [])

View File

@ -30,6 +30,7 @@ val second : ('a, 'b) t -> ('c * 'a, 'c * 'b) t
The default definition may be overridden with a more efficient version if desired. *)
val fanout : ('a, 'b) t -> ('a, 'c) t -> ('a, 'b * 'c) t
val fanout3 : ('a, 'b) t -> ('a, 'c) t -> ('a, 'd) t -> ('a, 'b * 'c * 'd) t
val fanout4 : ('a, 'b) t -> ('a, 'c) t -> ('a, 'd) t -> ('a, 'e) t -> ('a, 'b * 'c * 'd * 'e) t
val all : ('a, 'b) t list -> ('a, 'b list) t

View File

@ -87,7 +87,7 @@ module Gen(P : Params) = struct
fun x -> x
in
SC.add_rule sctx
(Build.fanout3
(Build.fanout4
(dep_graph >>>
Build.arr (fun dep_graph ->
Ocamldep.names_to_top_closed_cm_files
@ -98,21 +98,22 @@ module Gen(P : Params) = struct
(String_map.keys modules)))
(SC.expand_and_eval_set sctx ~scope ~dir lib.c_library_flags ~standard:[])
(Ocaml_flags.get flags mode)
(SC.expand_and_eval_set sctx ~scope ~dir lib.library_flags ~standard:[])
>>>
Build.run ~context:ctx (Dep compiler)
~extra_targets:(
match mode with
| Byte -> []
| Native -> [lib_archive lib ~dir ~ext:ctx.ext_lib])
[ Dyn (fun (_, _, flags) -> As flags)
[ Dyn (fun (_, _, flags, _) -> As flags)
; A "-a"; A "-o"; Target target
; As stubs_flags
; Dyn (fun (_, cclibs, _) -> Arg_spec.quote_args "-cclib" (map_cclibs cclibs))
; As (List.map lib.library_flags ~f:(SC.expand_vars sctx ~scope ~dir))
; Dyn (fun (_, cclibs, _, _) -> Arg_spec.quote_args "-cclib" (map_cclibs cclibs))
; Dyn (fun (_, _, _, library_flags) -> As library_flags)
; As (match lib.kind with
| Normal -> []
| Ppx_deriver | Ppx_rewriter -> ["-linkall"])
; Dyn (fun (cm_files, _, _) -> Deps cm_files)
; Dyn (fun (cm_files, _, _, _) -> Deps cm_files)
]))
let build_c_file (lib : Library.t) ~scope ~dir ~requires ~h_files c_name =

View File

@ -533,7 +533,7 @@ module Library = struct
; c_names : string list
; cxx_flags : Ordered_set_lang.Unexpanded.t
; cxx_names : string list
; library_flags : String_with_vars.t list
; library_flags : Ordered_set_lang.Unexpanded.t
; c_library_flags : Ordered_set_lang.Unexpanded.t
; self_build_stubs_archive : string option
; virtual_deps : string list
@ -555,7 +555,7 @@ module Library = struct
field_oslu "cxx_flags" >>= fun cxx_flags ->
field "c_names" (list string) ~default:[] >>= fun c_names ->
field "cxx_names" (list string) ~default:[] >>= fun cxx_names ->
field "library_flags" (list String_with_vars.t) ~default:[] >>= fun library_flags ->
field_oslu "library_flags" >>= fun library_flags ->
field_oslu "c_library_flags" >>= fun c_library_flags ->
field "virtual_deps" (list string) ~default:[] >>= fun virtual_deps ->
field "modes" Mode.Dict.Set.t ~default:Mode.Dict.Set.all >>= fun modes ->

View File

@ -138,7 +138,7 @@ module Library : sig
; c_names : string list
; cxx_flags : Ordered_set_lang.Unexpanded.t
; cxx_names : string list
; library_flags : String_with_vars.t list
; library_flags : Ordered_set_lang.Unexpanded.t
; c_library_flags : Ordered_set_lang.Unexpanded.t
; self_build_stubs_archive : string option
; virtual_deps : string list