Add a (mkdir ...) action
This commit is contained in:
parent
65a54f405b
commit
1d3341ed28
|
@ -135,6 +135,7 @@ struct
|
||||||
| Update_file (x, y) -> List [Atom "update-file"; path x; string y]
|
| Update_file (x, y) -> List [Atom "update-file"; path x; string y]
|
||||||
| Rename (x, y) -> List [Atom "rename"; path x; path y]
|
| Rename (x, y) -> List [Atom "rename"; path x; path y]
|
||||||
| Remove_tree x -> List [Atom "remove-tree"; path x]
|
| Remove_tree x -> List [Atom "remove-tree"; path x]
|
||||||
|
| Mkdir x -> List [Atom "mkdir"; path x]
|
||||||
end
|
end
|
||||||
|
|
||||||
module type Ast = Action_intf.Ast
|
module type Ast = Action_intf.Ast
|
||||||
|
@ -186,7 +187,8 @@ module Unexpanded = struct
|
||||||
| Bash x -> f acc x
|
| Bash x -> f acc x
|
||||||
| Update_file (x, y) -> f (f acc x) y
|
| Update_file (x, y) -> f (f acc x) y
|
||||||
| Rename (x, y) -> f (f acc x) y
|
| Rename (x, y) -> f (f acc x) y
|
||||||
| Remove_tree x -> f acc x
|
| Remove_tree x
|
||||||
|
| Mkdir x -> f acc x
|
||||||
|
|
||||||
let fold_vars t ~init ~f =
|
let fold_vars t ~init ~f =
|
||||||
fold t ~init ~f:(fun acc pat ->
|
fold t ~init ~f:(fun acc pat ->
|
||||||
|
@ -224,6 +226,8 @@ module Unexpanded = struct
|
||||||
Rename (expand_path ~dir ~f x, expand_path ~dir ~f y)
|
Rename (expand_path ~dir ~f x, expand_path ~dir ~f y)
|
||||||
| Remove_tree x ->
|
| Remove_tree x ->
|
||||||
Remove_tree (expand_path ~dir ~f x)
|
Remove_tree (expand_path ~dir ~f x)
|
||||||
|
| Mkdir x ->
|
||||||
|
Mkdir (expand_path ~dir ~f x)
|
||||||
end
|
end
|
||||||
|
|
||||||
let fold_one_step t ~init:acc ~f =
|
let fold_one_step t ~init:acc ~f =
|
||||||
|
@ -244,7 +248,8 @@ let fold_one_step t ~init:acc ~f =
|
||||||
| Bash _
|
| Bash _
|
||||||
| Update_file _
|
| Update_file _
|
||||||
| Rename _
|
| Rename _
|
||||||
| Remove_tree _ -> acc
|
| Remove_tree _
|
||||||
|
| Mkdir _ -> acc
|
||||||
|
|
||||||
let rec map t ~fs ~fp =
|
let rec map t ~fs ~fp =
|
||||||
match t with
|
match t with
|
||||||
|
@ -272,6 +277,7 @@ let rec map t ~fs ~fp =
|
||||||
| Update_file (x, y) -> Update_file (fp x, fs y)
|
| Update_file (x, y) -> Update_file (fp x, fs y)
|
||||||
| Rename (x, y) -> Rename (fp x, fp y)
|
| Rename (x, y) -> Rename (fp x, fp y)
|
||||||
| Remove_tree x -> Remove_tree (fp x)
|
| Remove_tree x -> Remove_tree (fp x)
|
||||||
|
| Mkdir x -> Mkdir (fp x)
|
||||||
|
|
||||||
let updated_files =
|
let updated_files =
|
||||||
let rec loop acc t =
|
let rec loop acc t =
|
||||||
|
@ -395,6 +401,16 @@ let rec exec t ~purpose ~dir ~env ~env_extra ~stdout_to ~stderr_to =
|
||||||
| Remove_tree path ->
|
| Remove_tree path ->
|
||||||
Path.rm_rf path;
|
Path.rm_rf path;
|
||||||
return ()
|
return ()
|
||||||
|
| Mkdir path ->
|
||||||
|
(match Path.kind path with
|
||||||
|
| External _ ->
|
||||||
|
(* CR-someday jdimino: we need to keep locations here *)
|
||||||
|
die "(mkdir ...) is not supported for paths outside of the workspace:\n\
|
||||||
|
\ %a\n"
|
||||||
|
Sexp.pp (List [Atom "mkdir"; Path.sexp_of_t path])
|
||||||
|
| Local path ->
|
||||||
|
Path.Local.mkdir_p path);
|
||||||
|
return ()
|
||||||
|
|
||||||
and redirect outputs fn t ~purpose ~dir ~env ~env_extra ~stdout_to ~stderr_to =
|
and redirect outputs fn t ~purpose ~dir ~env ~env_extra ~stdout_to ~stderr_to =
|
||||||
let fn = Path.to_string fn in
|
let fn = Path.to_string fn in
|
||||||
|
@ -485,6 +501,7 @@ module Infer = struct
|
||||||
{ acc with targets = S.filter acc.targets ~f:(fun fn ->
|
{ acc with targets = S.filter acc.targets ~f:(fun fn ->
|
||||||
not (Path.is_descendant fn ~of_:dir))
|
not (Path.is_descendant fn ~of_:dir))
|
||||||
}
|
}
|
||||||
|
| Mkdir _ -> acc
|
||||||
|
|
||||||
let infer t =
|
let infer t =
|
||||||
infer { deps = S.empty; targets = S.empty } t
|
infer { deps = S.empty; targets = S.empty } t
|
||||||
|
|
|
@ -27,5 +27,6 @@ module type Ast = sig
|
||||||
| Update_file of path * string
|
| Update_file of path * string
|
||||||
| Rename of path * path
|
| Rename of path * path
|
||||||
| Remove_tree of path
|
| Remove_tree of path
|
||||||
|
| Mkdir of path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,9 @@ let create_file fn =
|
||||||
let remove_tree dir =
|
let remove_tree dir =
|
||||||
arr (fun _ -> Action.Remove_tree dir)
|
arr (fun _ -> Action.Remove_tree dir)
|
||||||
|
|
||||||
|
let mkdir dir =
|
||||||
|
arr (fun _ -> Action.Mkdir dir)
|
||||||
|
|
||||||
let progn ts =
|
let progn ts =
|
||||||
all ts >>^ fun actions ->
|
all ts >>^ fun actions ->
|
||||||
Action.Progn actions
|
Action.Progn actions
|
||||||
|
|
|
@ -110,6 +110,7 @@ val symlink : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
||||||
|
|
||||||
val create_file : Path.t -> (_, Action.t) t
|
val create_file : Path.t -> (_, Action.t) t
|
||||||
val remove_tree : Path.t -> (_, Action.t) t
|
val remove_tree : Path.t -> (_, Action.t) t
|
||||||
|
val mkdir : Path.t -> (_, Action.t) t
|
||||||
|
|
||||||
(** Merge a list of actions *)
|
(** Merge a list of actions *)
|
||||||
val progn : ('a, Action.t) t list -> ('a, Action.t) t
|
val progn : ('a, Action.t) t list -> ('a, Action.t) t
|
||||||
|
|
|
@ -48,8 +48,7 @@ let to_html sctx (m : Module.t) odoc_file ~doc_dir ~odoc ~dir ~includes
|
||||||
>>>
|
>>>
|
||||||
Build.progn
|
Build.progn
|
||||||
[ Build.remove_tree html_dir
|
[ Build.remove_tree html_dir
|
||||||
; Build.action (* CR-someday jdimino: this is a mkdir ... *)
|
; Build.mkdir html_dir
|
||||||
(Chdir (html_dir, Progn [])) ~targets:[]
|
|
||||||
; Build.run ~context ~dir odoc ~extra_targets:[html_file]
|
; Build.run ~context ~dir odoc ~extra_targets:[html_file]
|
||||||
[ A "html"
|
[ A "html"
|
||||||
; Dyn (fun x -> x)
|
; Dyn (fun x -> x)
|
||||||
|
|
Loading…
Reference in New Issue