Simplify hack for not deleting odoc files
This commit is contained in:
parent
35ba1bc0f1
commit
37d7131a11
|
@ -229,7 +229,7 @@ let action_context_independent ?dir ~targets action =
|
||||||
| Some dir -> Chdir (dir, action)
|
| Some dir -> Chdir (dir, action)
|
||||||
in
|
in
|
||||||
Targets targets
|
Targets targets
|
||||||
>>^ fun () ->
|
>>^ fun _ ->
|
||||||
{ Action. context = None; action }
|
{ Action. context = None; action }
|
||||||
|
|
||||||
let update_file fn s =
|
let update_file fn s =
|
||||||
|
|
|
@ -116,7 +116,7 @@ val copy : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
||||||
|
|
||||||
val symlink : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
val symlink : src:Path.t -> dst:Path.t -> (unit, Action.t) t
|
||||||
|
|
||||||
val create_file : Path.t -> (unit, Action.t) t
|
val create_file : 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
|
||||||
|
|
|
@ -617,23 +617,27 @@ let create ~contexts ~file_tree ~rules =
|
||||||
let remove_old_artifacts t =
|
let remove_old_artifacts t =
|
||||||
let rec walk dir =
|
let rec walk dir =
|
||||||
let keep =
|
let keep =
|
||||||
Path.readdir dir
|
if Hashtbl.mem t.files (Path.relative dir Config.jbuilder_keep_fname) then
|
||||||
|> List.filter ~f:(fun fn ->
|
true
|
||||||
let fn = Path.relative dir fn in
|
else begin
|
||||||
match Unix.lstat (Path.to_string fn) with
|
Path.readdir dir
|
||||||
| { st_kind = S_DIR; _ } ->
|
|> List.filter ~f:(fun fn ->
|
||||||
walk fn
|
let fn = Path.relative dir fn in
|
||||||
| exception _ ->
|
match Unix.lstat (Path.to_string fn) with
|
||||||
let keep = Hashtbl.mem t.files fn in
|
| { st_kind = S_DIR; _ } ->
|
||||||
if not keep then Path.unlink fn;
|
walk fn
|
||||||
keep
|
| exception _ ->
|
||||||
| _ ->
|
let keep = Hashtbl.mem t.files fn in
|
||||||
let keep = Hashtbl.mem t.files fn in
|
if not keep then Path.unlink fn;
|
||||||
if not keep then Path.unlink fn;
|
keep
|
||||||
keep)
|
| _ ->
|
||||||
|> function
|
let keep = Hashtbl.mem t.files fn in
|
||||||
| [] -> false
|
if not keep then Path.unlink fn;
|
||||||
| _ -> true
|
keep)
|
||||||
|
|> function
|
||||||
|
| [] -> false
|
||||||
|
| _ -> true
|
||||||
|
end
|
||||||
in
|
in
|
||||||
if not keep then Path.rmdir dir;
|
if not keep then Path.rmdir dir;
|
||||||
keep
|
keep
|
||||||
|
|
|
@ -16,3 +16,5 @@ let local_install_lib_dir ~context ~package =
|
||||||
package
|
package
|
||||||
|
|
||||||
let dev_null = Path.of_string (if Sys.win32 then "nul" else "/dev/null")
|
let dev_null = Path.of_string (if Sys.win32 then "nul" else "/dev/null")
|
||||||
|
|
||||||
|
let jbuilder_keep_fname = ".jbuilder-keep"
|
||||||
|
|
|
@ -11,3 +11,6 @@ val local_install_lib_dir : context:string -> package:string -> Path.t
|
||||||
|
|
||||||
val dev_null : Path.t
|
val dev_null : Path.t
|
||||||
|
|
||||||
|
(** When this file is present in a directory jbuilder will delete
|
||||||
|
nothing in it if it knows to generate this file. *)
|
||||||
|
val jbuilder_keep_fname : string
|
||||||
|
|
23
src/odoc.ml
23
src/odoc.ml
|
@ -39,21 +39,24 @@ let compile_module sctx (m : Module.t) ~odoc ~dir ~includes ~dep_graph ~modules
|
||||||
let to_html sctx (m : Module.t) odoc_file ~doc_dir ~odoc ~dir ~includes
|
let to_html sctx (m : Module.t) odoc_file ~doc_dir ~odoc ~dir ~includes
|
||||||
~lib_public_name ~(lib : Library.t) =
|
~lib_public_name ~(lib : Library.t) =
|
||||||
let context = SC.context sctx in
|
let context = SC.context sctx in
|
||||||
let html_file =
|
let html_dir = doc_dir ++ lib_public_name ++ String.capitalize m.obj_name in
|
||||||
doc_dir ++ lib_public_name ++ String.capitalize m.obj_name ++ "index.html"
|
let html_file = html_dir ++ "index.html" in
|
||||||
in
|
|
||||||
SC.add_rule sctx
|
SC.add_rule sctx
|
||||||
(SC.Libs.static_file_deps (dir, lib) ~ext:odoc_ext
|
(SC.Libs.static_file_deps (dir, lib) ~ext:odoc_ext
|
||||||
>>>
|
>>>
|
||||||
includes
|
includes
|
||||||
>>>
|
>>>
|
||||||
Build.run ~context ~dir odoc ~extra_targets:[html_file]
|
Build.progn
|
||||||
[ A "html"
|
[ Build.run ~context ~dir odoc ~extra_targets:[html_file]
|
||||||
; Dyn (fun x -> x)
|
[ A "html"
|
||||||
; A "-I"; Path dir
|
; Dyn (fun x -> x)
|
||||||
; A "-o"; Path doc_dir
|
; A "-I"; Path dir
|
||||||
; Dep odoc_file
|
; A "-o"; Path doc_dir
|
||||||
]);
|
; Dep odoc_file
|
||||||
|
]
|
||||||
|
; Build.create_file (html_dir ++ Config.jbuilder_keep_fname)
|
||||||
|
]
|
||||||
|
);
|
||||||
html_file
|
html_file
|
||||||
|
|
||||||
let lib_index sctx ~odoc ~dir ~(lib : Library.t) ~lib_public_name ~doc_dir ~modules
|
let lib_index sctx ~odoc ~dir ~(lib : Library.t) ~lib_public_name ~doc_dir ~modules
|
||||||
|
|
Loading…
Reference in New Issue