All IO must go through Build
This commit is contained in:
parent
6364f70245
commit
ca4b6fbf41
|
@ -29,6 +29,8 @@ module Repr = struct
|
|||
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
||||
| Paths : Pset.t -> ('a, 'a) t
|
||||
| Paths_glob : Path.t * Re.re -> ('a, 'a) t
|
||||
| Contents : Path.t -> ('a, string) t
|
||||
| Lines_of : Path.t -> ('a, string list) t
|
||||
| Vpath : 'a Vspec.t -> (unit, 'a) t
|
||||
| Dyn_paths : ('a, Path.t list) t -> ('a, 'a) t
|
||||
| Record_lib_deps : Path.t * lib_deps -> ('a, 'a) t
|
||||
|
@ -99,6 +101,9 @@ let paths_glob ~dir re = Paths_glob (dir, re)
|
|||
let vpath vp = Vpath vp
|
||||
let dyn_paths t = Dyn_paths t
|
||||
|
||||
let contents p = Contents p
|
||||
let lines_of p = Lines_of p
|
||||
|
||||
let fail x = Fail x
|
||||
|
||||
let files_recursively_in ~dir =
|
||||
|
|
|
@ -42,6 +42,9 @@ val vpath : 'a Vspec.t -> (unit, 'a) t
|
|||
|
||||
val dyn_paths : ('a, Path.t list) t -> ('a, 'a) t
|
||||
|
||||
val contents : Path.t -> ('a, string) t
|
||||
val lines_of : Path.t -> ('a, string list) t
|
||||
|
||||
(** Always fail when executed. We pass a function rather than an exception to get a proper
|
||||
backtrace *)
|
||||
val fail : fail -> ('a, 'a) t
|
||||
|
@ -107,6 +110,8 @@ module Repr : sig
|
|||
| Fanout : ('a, 'b) t * ('a, 'c) t -> ('a, 'b * 'c) t
|
||||
| Paths : Path.Set.t -> ('a, 'a) t
|
||||
| Paths_glob : Path.t * Re.re -> ('a, 'a) t
|
||||
| Contents : Path.t -> ('a, string) t
|
||||
| Lines_of : Path.t -> ('a, string list) t
|
||||
| Vpath : 'a Vspec.t -> (unit, 'a) t
|
||||
| Dyn_paths : ('a, Path.t list) t -> ('a, 'a) t
|
||||
| Record_lib_deps : Path.t * lib_deps -> ('a, 'a) t
|
||||
|
|
|
@ -40,6 +40,8 @@ let deps t ~all_targets_by_dir =
|
|||
Re.execp re (Path.basename path))
|
||||
end
|
||||
| Dyn_paths t -> loop t acc
|
||||
| Contents p -> Pset.add p acc
|
||||
| Lines_of p -> Pset.add p acc
|
||||
| Record_lib_deps _ -> acc
|
||||
| Fail _ -> acc
|
||||
in
|
||||
|
@ -61,6 +63,8 @@ let lib_deps =
|
|||
| Vpath _ -> acc
|
||||
| Paths_glob _ -> acc
|
||||
| Dyn_paths t -> loop t acc
|
||||
| Contents _ -> acc
|
||||
| Lines_of _ -> acc
|
||||
| Record_lib_deps (dir, deps) ->
|
||||
let data =
|
||||
match Pmap.find dir acc with
|
||||
|
@ -88,6 +92,8 @@ let targets =
|
|||
| Vpath _ -> acc
|
||||
| Paths_glob _ -> acc
|
||||
| Dyn_paths t -> loop t acc
|
||||
| Contents _ -> acc
|
||||
| Lines_of _ -> acc
|
||||
| Record_lib_deps _ -> acc
|
||||
| Fail _ -> acc
|
||||
in
|
||||
|
|
|
@ -209,6 +209,8 @@ module Build_exec = struct
|
|||
both (exec a x) (exec b x)
|
||||
| Paths _ -> return x
|
||||
| Paths_glob _ -> return x
|
||||
| Contents p -> return (read_file (Path.to_string p))
|
||||
| Lines_of p -> return (lines_of_file (Path.to_string p))
|
||||
| Vpath (Vspec.T (fn, kind)) ->
|
||||
let file : b File_spec.t = get_file bs fn (Sexp_file kind) in
|
||||
return (Option.value_exn file.data)
|
||||
|
|
|
@ -511,10 +511,8 @@ module Gen(P : Params) = struct
|
|||
add_rule
|
||||
(Build.run (Dep ctx.ocamldep) [A "-modules"; S files] ~stdout_to:ocamldep_output);
|
||||
add_rule
|
||||
(Build.path ocamldep_output
|
||||
>>^ (fun () ->
|
||||
parse_deps ~dir ~modules ~alias_module
|
||||
(lines_of_file (Path.to_string ocamldep_output)))
|
||||
(Build.lines_of ocamldep_output
|
||||
>>^ parse_deps ~dir ~modules ~alias_module
|
||||
>>> Build.store_vfile vdepends);
|
||||
Build.vpath vdepends
|
||||
|
||||
|
@ -1652,9 +1650,7 @@ end of your list of preprocessors. Consult the manual for more details."
|
|||
let template =
|
||||
if has_meta_tmpl then
|
||||
let meta_templ_path = Path.relative pkg.path meta_templ_fn in
|
||||
Build.path meta_templ_path
|
||||
>>^ fun () ->
|
||||
lines_of_file (Path.to_string meta_templ_path)
|
||||
Build.lines_of meta_templ_path
|
||||
else
|
||||
Build.return ["# JBUILDER_GEN"]
|
||||
in
|
||||
|
|
Loading…
Reference in New Issue