Fix expansion of %{ocaml-config:..}
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
629b3d07ee
commit
0ca157f840
15
src/pform.ml
15
src/pform.ml
|
@ -30,6 +30,7 @@ module Macro = struct
|
||||||
| Read_strings
|
| Read_strings
|
||||||
| Read_lines
|
| Read_lines
|
||||||
| Path_no_dep
|
| Path_no_dep
|
||||||
|
| Ocaml_config
|
||||||
end
|
end
|
||||||
|
|
||||||
type 'a t =
|
type 'a t =
|
||||||
|
@ -77,6 +78,7 @@ module Map = struct
|
||||||
; "findlib", renamed_in ~version:(1, 0) ~new_name:"lib"
|
; "findlib", renamed_in ~version:(1, 0) ~new_name:"lib"
|
||||||
|
|
||||||
; "path-no-dep", deleted_in ~version:(1, 0) Path_no_dep
|
; "path-no-dep", deleted_in ~version:(1, 0) Path_no_dep
|
||||||
|
; "ocaml-config", macro Ocaml_config
|
||||||
]
|
]
|
||||||
|> String.Map.of_list_exn
|
|> String.Map.of_list_exn
|
||||||
|
|
||||||
|
@ -126,18 +128,7 @@ module Map = struct
|
||||||
; "profile" , string context.profile
|
; "profile" , string context.profile
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
let ocaml_config =
|
[ static_vars
|
||||||
List.map (Ocaml_config.to_list context.ocaml_config) ~f:(fun (k, v) ->
|
|
||||||
("ocaml-config:" ^ k,
|
|
||||||
match (v : Ocaml_config.Value.t) with
|
|
||||||
| Bool x -> string (string_of_bool x)
|
|
||||||
| Int x -> string (string_of_int x)
|
|
||||||
| String x -> string x
|
|
||||||
| Words x -> strings x
|
|
||||||
| Prog_and_args x -> strings (x.prog :: x.args)))
|
|
||||||
in
|
|
||||||
[ ocaml_config
|
|
||||||
; static_vars
|
|
||||||
; lowercased
|
; lowercased
|
||||||
; uppercased
|
; uppercased
|
||||||
; vars
|
; vars
|
||||||
|
|
|
@ -22,6 +22,7 @@ module Macro : sig
|
||||||
| Read_strings
|
| Read_strings
|
||||||
| Read_lines
|
| Read_lines
|
||||||
| Path_no_dep
|
| Path_no_dep
|
||||||
|
| Ocaml_config
|
||||||
end
|
end
|
||||||
|
|
||||||
type 'a t =
|
type 'a t =
|
||||||
|
|
|
@ -47,6 +47,7 @@ type t =
|
||||||
; cxx_flags : string list
|
; cxx_flags : string list
|
||||||
; vars : Pform.Var.t Pform.Map.t
|
; vars : Pform.Var.t Pform.Map.t
|
||||||
; macros : Pform.Macro.t Pform.Map.t
|
; macros : Pform.Macro.t Pform.Map.t
|
||||||
|
; ocaml_config : Value.t list String.Map.t
|
||||||
; chdir : (Action.t, Action.t) Build.t
|
; chdir : (Action.t, Action.t) Build.t
|
||||||
; host : t option
|
; host : t option
|
||||||
; libs_by_package : (Package.t * Lib.Set.t) Package.Name.Map.t
|
; libs_by_package : (Package.t * Lib.Set.t) Package.Name.Map.t
|
||||||
|
@ -290,6 +291,19 @@ let create
|
||||||
~f:(fun s -> not (String.is_prefix s ~prefix:"-std="))
|
~f:(fun s -> not (String.is_prefix s ~prefix:"-std="))
|
||||||
in
|
in
|
||||||
let vars = Pform.Map.create_vars ~context ~cxx_flags in
|
let vars = Pform.Map.create_vars ~context ~cxx_flags in
|
||||||
|
let ocaml_config =
|
||||||
|
let string s = [Value.String s] in
|
||||||
|
Ocaml_config.to_list context.ocaml_config
|
||||||
|
|> List.map ~f:(fun (k, v) ->
|
||||||
|
( k
|
||||||
|
, match (v : Ocaml_config.Value.t) with
|
||||||
|
| Bool x -> string (string_of_bool x)
|
||||||
|
| Int x -> string (string_of_int x)
|
||||||
|
| String x -> string x
|
||||||
|
| Words x -> Value.L.strings x
|
||||||
|
| Prog_and_args x -> Value.L.strings (x.prog :: x.args)))
|
||||||
|
|> String.Map.of_list_exn
|
||||||
|
in
|
||||||
let t =
|
let t =
|
||||||
{ context
|
{ context
|
||||||
; host
|
; host
|
||||||
|
@ -305,6 +319,7 @@ let create
|
||||||
; cxx_flags
|
; cxx_flags
|
||||||
; vars
|
; vars
|
||||||
; macros = Pform.Map.macros
|
; macros = Pform.Map.macros
|
||||||
|
; ocaml_config
|
||||||
; chdir = Build.arr (fun (action : Action.t) ->
|
; chdir = Build.arr (fun (action : Action.t) ->
|
||||||
match action with
|
match action with
|
||||||
| Chdir _ -> action
|
| Chdir _ -> action
|
||||||
|
@ -597,6 +612,7 @@ module Action = struct
|
||||||
let key = String_with_vars.Var.full_name var in
|
let key = String_with_vars.Var.full_name var in
|
||||||
begin match expand_macro sctx ~syntax_version ~var with
|
begin match expand_macro sctx ~syntax_version ~var with
|
||||||
| Some Pform.Macro.Exe -> Some (path_exp (map_exe (Path.relative dir s)))
|
| Some Pform.Macro.Exe -> Some (path_exp (map_exe (Path.relative dir s)))
|
||||||
|
| Some Ocaml_config -> String.Map.find sctx.ocaml_config s
|
||||||
| Some Dep -> Some (path_exp (Path.relative dir s))
|
| Some Dep -> Some (path_exp (Path.relative dir s))
|
||||||
| Some Bin -> begin
|
| Some Bin -> begin
|
||||||
let sctx = host sctx in
|
let sctx = host sctx in
|
||||||
|
|
Loading…
Reference in New Issue