Replace Build.and_... by Build.progn
This commit is contained in:
parent
23f00abf18
commit
0a1f4f5658
65
src/build.ml
65
src/build.ml
|
@ -251,38 +251,33 @@ let symlink ~src ~dst =
|
|||
let create_file fn =
|
||||
action_context_independent ~targets:[fn] (Create_file fn)
|
||||
|
||||
let and_create_file fn =
|
||||
Targets [fn]
|
||||
>>^ fun (action : Action.t) ->
|
||||
{ action with
|
||||
action = Progn [action.action; Create_file fn]
|
||||
}
|
||||
|
||||
(*
|
||||
{[
|
||||
let progn ts =
|
||||
all ts >>^ fun (actions : Action.t list) ->
|
||||
match actions with
|
||||
| [] ->
|
||||
{ Action.
|
||||
context = None
|
||||
; dir = Path.root
|
||||
; action = Progn []
|
||||
}
|
||||
| first :: rest ->
|
||||
let rest =
|
||||
List.map rest ~f:(fun a ->
|
||||
(match first.context, a.context with
|
||||
| None, None -> ()
|
||||
| Some c1, Some c2 when c1.name = c2.name -> ()
|
||||
| _ ->
|
||||
Sexp.code_error "Build.progn"
|
||||
[ "actions", Sexp.To_sexp.list Action.sexp_of_t actions ]);
|
||||
if first.dir = a.dir then
|
||||
a.action
|
||||
else
|
||||
Chdir (a.dir, a.action))
|
||||
in
|
||||
{ first with action = Progn (first :: rest) }
|
||||
]}
|
||||
*)
|
||||
let progn ts =
|
||||
all ts >>^ fun (actions : Action.t list) ->
|
||||
let rec loop context acc actions =
|
||||
match actions with
|
||||
| [] ->
|
||||
{ Action.
|
||||
context
|
||||
; dir = Path.root
|
||||
; action = Progn (List.rev acc)
|
||||
}
|
||||
| { Action. context = context'; dir; action } :: rest ->
|
||||
let context =
|
||||
match context, context' with
|
||||
| None, c | c, None -> c
|
||||
| Some c1, Some c2 when c1.name = c2.name -> context
|
||||
| _ -> raise Exit
|
||||
in
|
||||
let action =
|
||||
if dir = Path.root then
|
||||
action
|
||||
else
|
||||
Chdir (dir, action)
|
||||
in
|
||||
loop context (action :: acc) rest
|
||||
in
|
||||
try
|
||||
loop None [] actions
|
||||
with Exit ->
|
||||
Sexp.code_error "Build.progn"
|
||||
[ "actions", Sexp.To_sexp.list Action.sexp_of_t actions ]
|
||||
|
|
|
@ -118,7 +118,8 @@ val symlink : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
|||
|
||||
val create_file : Path.t -> (unit, Action.t) t
|
||||
|
||||
val and_create_file : Path.t -> (Action.t, Action.t) t
|
||||
(** Merge a list of actions *)
|
||||
val progn : ('a, Action.t) t list -> ('a, Action.t) t
|
||||
|
||||
type lib_dep_kind =
|
||||
| Optional
|
||||
|
|
|
@ -512,7 +512,9 @@ module Gen(P : Params) = struct
|
|||
Build.create_file digest_path
|
||||
| Some action ->
|
||||
deps
|
||||
>>> SC.Action.run
|
||||
>>>
|
||||
Build.progn
|
||||
[ SC.Action.run
|
||||
sctx
|
||||
action
|
||||
~dir
|
||||
|
@ -520,8 +522,8 @@ module Gen(P : Params) = struct
|
|||
~targets:[]
|
||||
~deps:(SC.Deps.only_plain_files sctx ~dir alias_conf.deps)
|
||||
~package_context
|
||||
>>>
|
||||
Build.and_create_file digest_path)
|
||||
; Build.create_file digest_path
|
||||
])
|
||||
|
||||
(* +-----------------------------------------------------------------+
|
||||
| Modules listing |
|
||||
|
|
Loading…
Reference in New Issue