Rename Jbuild.Named to Jbuild.Bindings
Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
parent
bfc1b9fd25
commit
65e1aa0043
|
@ -929,7 +929,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let module S = Sexp.To_sexp in
|
let module S = Sexp.To_sexp in
|
||||||
Sexp.List
|
Sexp.List
|
||||||
[ Sexp.unsafe_atom_of_string "user-alias"
|
[ Sexp.unsafe_atom_of_string "user-alias"
|
||||||
; Jbuild.Named.sexp_of_t Jbuild.Dep_conf.sexp_of_t alias_conf.deps
|
; Jbuild.Bindings.sexp_of_t Jbuild.Dep_conf.sexp_of_t alias_conf.deps
|
||||||
; S.option Action.Unexpanded.sexp_of_t
|
; S.option Action.Unexpanded.sexp_of_t
|
||||||
(Option.map alias_conf.action ~f:snd)
|
(Option.map alias_conf.action ~f:snd)
|
||||||
]
|
]
|
||||||
|
@ -976,7 +976,7 @@ module Gen(P : Install_rules.Params) = struct
|
||||||
let rule =
|
let rule =
|
||||||
{ Rule.
|
{ Rule.
|
||||||
targets = Infer
|
targets = Infer
|
||||||
; deps = Named.empty
|
; deps = Bindings.empty
|
||||||
; action =
|
; action =
|
||||||
(loc, Action.Unexpanded.Redirect (Stdout, diff.file2, run_action))
|
(loc, Action.Unexpanded.Redirect (Stdout, diff.file2, run_action))
|
||||||
; mode = Standard
|
; mode = Standard
|
||||||
|
|
|
@ -214,7 +214,7 @@ include Sub_system.Register_end_point(
|
||||||
~init:extra_vars
|
~init:extra_vars
|
||||||
~f:(fun acc (k, v) -> String.Map.add acc k v)
|
~f:(fun acc (k, v) -> String.Map.add acc k v)
|
||||||
in
|
in
|
||||||
Build.return Named.empty
|
Build.return Bindings.empty
|
||||||
>>>
|
>>>
|
||||||
Build.all
|
Build.all
|
||||||
(List.filter_map backends ~f:(fun (backend : Backend.t) ->
|
(List.filter_map backends ~f:(fun (backend : Backend.t) ->
|
||||||
|
|
|
@ -232,7 +232,7 @@ module Pps_and_flags = struct
|
||||||
Dune_syntax.t
|
Dune_syntax.t
|
||||||
end
|
end
|
||||||
|
|
||||||
module Named = struct
|
module Bindings = struct
|
||||||
type 'a one =
|
type 'a one =
|
||||||
| Unnamed of 'a
|
| Unnamed of 'a
|
||||||
| Named of string * 'a list
|
| Named of string * 'a list
|
||||||
|
@ -1140,7 +1140,7 @@ module Rule = struct
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ targets : Targets.t
|
{ targets : Targets.t
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
; action : Loc.t * Action.Unexpanded.t
|
; action : Loc.t * Action.Unexpanded.t
|
||||||
; mode : Mode.t
|
; mode : Mode.t
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
|
@ -1182,7 +1182,7 @@ module Rule = struct
|
||||||
let short_form =
|
let short_form =
|
||||||
located Action.Unexpanded.t >>| fun (loc, action) ->
|
located Action.Unexpanded.t >>| fun (loc, action) ->
|
||||||
{ targets = Infer
|
{ targets = Infer
|
||||||
; deps = Named.empty
|
; deps = Bindings.empty
|
||||||
; action = (loc, action)
|
; action = (loc, action)
|
||||||
; mode = Standard
|
; mode = Standard
|
||||||
; locks = []
|
; locks = []
|
||||||
|
@ -1195,7 +1195,7 @@ module Rule = struct
|
||||||
>>= fun action ->
|
>>= fun action ->
|
||||||
field "targets" (list file_in_current_dir)
|
field "targets" (list file_in_current_dir)
|
||||||
>>= fun targets ->
|
>>= fun targets ->
|
||||||
field "deps" (Named.t Dep_conf.t) ~default:Named.empty
|
field "deps" (Bindings.t Dep_conf.t) ~default:Bindings.empty
|
||||||
>>= fun deps ->
|
>>= fun deps ->
|
||||||
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
||||||
map_validate
|
map_validate
|
||||||
|
@ -1301,7 +1301,7 @@ module Rule = struct
|
||||||
let src = name ^ ".mll" in
|
let src = name ^ ".mll" in
|
||||||
let dst = name ^ ".ml" in
|
let dst = name ^ ".ml" in
|
||||||
{ targets = Static [dst]
|
{ targets = Static [dst]
|
||||||
; deps = Named.singleton (Dep_conf.File (S.virt_text __POS__ src))
|
; deps = Bindings.singleton (Dep_conf.File (S.virt_text __POS__ src))
|
||||||
; action =
|
; action =
|
||||||
(loc,
|
(loc,
|
||||||
Chdir
|
Chdir
|
||||||
|
@ -1322,7 +1322,7 @@ module Rule = struct
|
||||||
List.map modules ~f:(fun name ->
|
List.map modules ~f:(fun name ->
|
||||||
let src = name ^ ".mly" in
|
let src = name ^ ".mly" in
|
||||||
{ targets = Static [name ^ ".ml"; name ^ ".mli"]
|
{ targets = Static [name ^ ".ml"; name ^ ".mli"]
|
||||||
; deps = Named.singleton (Dep_conf.File (S.virt_text __POS__ src))
|
; deps = Bindings.singleton (Dep_conf.File (S.virt_text __POS__ src))
|
||||||
; action =
|
; action =
|
||||||
(loc,
|
(loc,
|
||||||
Chdir
|
Chdir
|
||||||
|
@ -1390,7 +1390,7 @@ end
|
||||||
module Alias_conf = struct
|
module Alias_conf = struct
|
||||||
type t =
|
type t =
|
||||||
{ name : string
|
{ name : string
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
; action : (Loc.t * Action.Unexpanded.t) option
|
; action : (Loc.t * Action.Unexpanded.t) option
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
; package : Package.t option
|
; package : Package.t option
|
||||||
|
@ -1409,7 +1409,7 @@ module Alias_conf = struct
|
||||||
field_o "package" Pkg.t >>= fun package ->
|
field_o "package" Pkg.t >>= fun package ->
|
||||||
field_o "action" (located Action.Unexpanded.t) >>= fun action ->
|
field_o "action" (located Action.Unexpanded.t) >>= fun action ->
|
||||||
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
||||||
field "deps" (Named.t Dep_conf.t) ~default:Named.empty
|
field "deps" (Bindings.t Dep_conf.t) ~default:Bindings.empty
|
||||||
>>= fun deps ->
|
>>= fun deps ->
|
||||||
return
|
return
|
||||||
{ name
|
{ name
|
||||||
|
@ -1425,7 +1425,7 @@ module Tests = struct
|
||||||
{ exes : Executables.t
|
{ exes : Executables.t
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
; package : Package.t option
|
; package : Package.t option
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
}
|
}
|
||||||
|
|
||||||
let gen_parse names =
|
let gen_parse names =
|
||||||
|
@ -1433,11 +1433,12 @@ module Tests = struct
|
||||||
(Buildable.t >>= fun buildable ->
|
(Buildable.t >>= fun buildable ->
|
||||||
field_oslu "link_flags" >>= fun link_flags ->
|
field_oslu "link_flags" >>= fun link_flags ->
|
||||||
names >>= fun names ->
|
names >>= fun names ->
|
||||||
field "deps" (Named.t Dep_conf.t) ~default:Named.empty >>= fun deps ->
|
|
||||||
field_o "package" Pkg.t >>= fun package ->
|
field_o "package" Pkg.t >>= fun package ->
|
||||||
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
field "locks" (list String_with_vars.t) ~default:[] >>= fun locks ->
|
||||||
field "modes" Executables.Link_mode.Set.t
|
field "modes" Executables.Link_mode.Set.t
|
||||||
~default:Executables.Link_mode.Set.default >>= fun modes ->
|
~default:Executables.Link_mode.Set.default >>= fun modes ->
|
||||||
|
field "deps" (Bindings.t Dep_conf.t) ~default:Bindings.empty
|
||||||
|
>>= fun deps ->
|
||||||
return
|
return
|
||||||
{ exes =
|
{ exes =
|
||||||
{ Executables.
|
{ Executables.
|
||||||
|
|
|
@ -81,7 +81,7 @@ module Lib_deps : sig
|
||||||
val of_pps : Pp.t list -> t
|
val of_pps : Pp.t list -> t
|
||||||
end
|
end
|
||||||
|
|
||||||
module Named : sig
|
module Bindings : sig
|
||||||
type 'a one =
|
type 'a one =
|
||||||
| Unnamed of 'a
|
| Unnamed of 'a
|
||||||
| Named of string * 'a list
|
| Named of string * 'a list
|
||||||
|
@ -304,7 +304,7 @@ module Rule : sig
|
||||||
|
|
||||||
type t =
|
type t =
|
||||||
{ targets : Targets.t
|
{ targets : Targets.t
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
; action : Loc.t * Action.Unexpanded.t
|
; action : Loc.t * Action.Unexpanded.t
|
||||||
; mode : Mode.t
|
; mode : Mode.t
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
|
@ -327,7 +327,7 @@ end
|
||||||
module Alias_conf : sig
|
module Alias_conf : sig
|
||||||
type t =
|
type t =
|
||||||
{ name : string
|
{ name : string
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
; action : (Loc.t * Action.Unexpanded.t) option
|
; action : (Loc.t * Action.Unexpanded.t) option
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
; package : Package.t option
|
; package : Package.t option
|
||||||
|
@ -370,7 +370,7 @@ module Tests : sig
|
||||||
{ exes : Executables.t
|
{ exes : Executables.t
|
||||||
; locks : String_with_vars.t list
|
; locks : String_with_vars.t list
|
||||||
; package : Package.t option
|
; package : Package.t option
|
||||||
; deps : Dep_conf.t Named.t
|
; deps : Dep_conf.t Bindings.t
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ let lint_module sctx ~dir ~dep_kind ~lint ~lib_name ~scope ~dir_kind =
|
||||||
let src_path = Path.relative dir src.name in
|
let src_path = Path.relative dir src.name in
|
||||||
add_alias src.name
|
add_alias src.name
|
||||||
(Build.path src_path
|
(Build.path src_path
|
||||||
>>^ (fun _ -> Jbuild.Named.singleton src_path)
|
>>^ (fun _ -> Jbuild.Bindings.singleton src_path)
|
||||||
>>> SC.Action.run sctx
|
>>> SC.Action.run sctx
|
||||||
action
|
action
|
||||||
~loc
|
~loc
|
||||||
|
@ -531,7 +531,7 @@ let make sctx ~dir ~dep_kind ~lint ~preprocess
|
||||||
(preprocessor_deps
|
(preprocessor_deps
|
||||||
>>>
|
>>>
|
||||||
Build.path src
|
Build.path src
|
||||||
>>^ (fun _ -> Jbuild.Named.singleton src)
|
>>^ (fun _ -> Jbuild.Bindings.singleton src)
|
||||||
>>>
|
>>>
|
||||||
SC.Action.run sctx
|
SC.Action.run sctx
|
||||||
(Redirect
|
(Redirect
|
||||||
|
|
|
@ -528,28 +528,18 @@ module Deps = struct
|
||||||
>>^ List.concat
|
>>^ List.concat
|
||||||
|
|
||||||
let interpret_named t ~scope ~dir bindings =
|
let interpret_named t ~scope ~dir bindings =
|
||||||
let unnamed x = Jbuild.Named.Unnamed x in
|
let unnamed x = Jbuild.Bindings.Unnamed x in
|
||||||
List.map bindings ~f:(function
|
List.map bindings ~f:(function
|
||||||
| Jbuild.Named.Unnamed p ->
|
| Jbuild.Bindings.Unnamed p ->
|
||||||
dep t ~scope ~dir p >>^ unnamed
|
dep t ~scope ~dir p >>^ unnamed
|
||||||
| Named (s, ps) ->
|
| Named (s, ps) ->
|
||||||
List.map ~f:(dep t ~scope ~dir) ps
|
List.map ~f:(dep t ~scope ~dir) ps
|
||||||
|> Build.all
|
|> Build.all
|
||||||
>>^ (fun deps -> Jbuild.Named.Named (s, deps)))
|
>>^ (fun deps -> Jbuild.Bindings.Named (s, deps)))
|
||||||
|> Build.all
|
|> Build.all
|
||||||
>>^ List.concat_map ~f:(function
|
>>^ List.concat_map ~f:(function
|
||||||
| Jbuild.Named.Unnamed s -> List.map s ~f:unnamed
|
| Jbuild.Bindings.Unnamed s -> List.map s ~f:unnamed
|
||||||
| Named (s, ps) -> [Named (s, List.concat ps)])
|
| Named (s, ps) -> [Named (s, List.concat ps)])
|
||||||
|
|
||||||
(* let unnamed = deps (Jbuild.Named.unnamed bindings) in
|
|
||||||
* let named =
|
|
||||||
* String.Map.to_list named
|
|
||||||
* |> List.map ~f:(fun (k, d) -> deps d >>^ fun d -> (k, d))
|
|
||||||
* |> Build.all
|
|
||||||
* >>^ String.Map.of_list_exn
|
|
||||||
* in
|
|
||||||
* unnamed &&& named >>^ fun (unnamed, named) ->
|
|
||||||
* { Named.unnamed; named } *)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Pkg_version = struct
|
module Pkg_version = struct
|
||||||
|
@ -780,7 +770,7 @@ module Action = struct
|
||||||
(t, acc)
|
(t, acc)
|
||||||
|
|
||||||
let expand_step2 ~dir ~dynamic_expansions
|
let expand_step2 ~dir ~dynamic_expansions
|
||||||
~(deps_written_by_user : Path.t Jbuild.Named.t)
|
~(deps_written_by_user : Path.t Jbuild.Bindings.t)
|
||||||
~map_exe t =
|
~map_exe t =
|
||||||
U.Partial.expand t ~dir ~map_exe ~f:(fun var syntax_version ->
|
U.Partial.expand t ~dir ~map_exe ~f:(fun var syntax_version ->
|
||||||
let key = String_with_vars.Var.full_name var in
|
let key = String_with_vars.Var.full_name var in
|
||||||
|
@ -792,17 +782,17 @@ module Action = struct
|
||||||
Pform.Map.expand Pform.Map.static_vars ~syntax_version ~var
|
Pform.Map.expand Pform.Map.static_vars ~syntax_version ~var
|
||||||
with
|
with
|
||||||
| None ->
|
| None ->
|
||||||
Jbuild.Named.find deps_written_by_user key
|
Jbuild.Bindings.find deps_written_by_user key
|
||||||
|> Option.map ~f:Value.L.paths
|
|> Option.map ~f:Value.L.paths
|
||||||
| Some x ->
|
| Some x ->
|
||||||
begin match x with
|
begin match x with
|
||||||
Pform.Var.Deps ->
|
Pform.Var.Deps ->
|
||||||
deps_written_by_user
|
deps_written_by_user
|
||||||
|> Jbuild.Named.to_list
|
|> Jbuild.Bindings.to_list
|
||||||
|> Value.L.paths
|
|> Value.L.paths
|
||||||
|> Option.some
|
|> Option.some
|
||||||
| First_dep ->
|
| First_dep ->
|
||||||
begin match Jbuild.Named.first deps_written_by_user with
|
begin match Jbuild.Bindings.first deps_written_by_user with
|
||||||
| Error `Named_exists ->
|
| Error `Named_exists ->
|
||||||
Loc.fail loc "%%{first-dep} is not allowed with named dependencies"
|
Loc.fail loc "%%{first-dep} is not allowed with named dependencies"
|
||||||
| Error `Empty ->
|
| Error `Empty ->
|
||||||
|
@ -819,7 +809,7 @@ module Action = struct
|
||||||
|
|
||||||
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
let run sctx ~loc ?(extra_vars=String.Map.empty)
|
||||||
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
t ~dir ~dep_kind ~targets:targets_written_by_user ~scope
|
||||||
: (Path.t Named.t, Action.t) Build.t =
|
: (Path.t Bindings.t, Action.t) Build.t =
|
||||||
let map_exe = map_exe sctx in
|
let map_exe = map_exe sctx in
|
||||||
if targets_written_by_user = Alias then begin
|
if targets_written_by_user = Alias then begin
|
||||||
match Action.Infer.unexpanded_targets t with
|
match Action.Infer.unexpanded_targets t with
|
||||||
|
|
|
@ -224,8 +224,8 @@ module Deps : sig
|
||||||
: t
|
: t
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
-> dir:Path.t
|
-> dir:Path.t
|
||||||
-> Dep_conf.t Named.t
|
-> Dep_conf.t Bindings.t
|
||||||
-> (unit, Path.t Named.t) Build.t
|
-> (unit, Path.t Bindings.t) Build.t
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Interpret action written in jbuild files *)
|
(** Interpret action written in jbuild files *)
|
||||||
|
@ -245,7 +245,7 @@ module Action : sig
|
||||||
-> dep_kind:Build.lib_dep_kind
|
-> dep_kind:Build.lib_dep_kind
|
||||||
-> targets:targets
|
-> targets:targets
|
||||||
-> scope:Scope.t
|
-> scope:Scope.t
|
||||||
-> (Path.t Named.t, Action.t) Build.t
|
-> (Path.t Bindings.t, Action.t) Build.t
|
||||||
end
|
end
|
||||||
|
|
||||||
module Pkg_version : sig
|
module Pkg_version : sig
|
||||||
|
|
Loading…
Reference in New Issue