per_file --> per_module
This commit is contained in:
parent
1a8fc057f4
commit
a7446ec7d3
|
@ -764,24 +764,29 @@ module-by-module basis by using the following syntax:
|
||||||
|
|
||||||
.. code:: scheme
|
.. code:: scheme
|
||||||
|
|
||||||
(preprocess (per_file
|
(preprocess (per_module
|
||||||
(<spec1> (<module-list1>))
|
(<spec1> (<module-list1>))
|
||||||
(<spec2> (<module-list2>))
|
(<spec2> (<module-list2>))
|
||||||
...))
|
...))
|
||||||
|
|
||||||
Where ``<spec1>``, ``<spec2>``, ... are preprocessing specifications and
|
Where ``<spec1>``, ``<spec2>``, ... are preprocessing specifications
|
||||||
``<module-list1>``, ``<module-list2>``, ... are list of module names. It is
|
and ``<module-list1>``, ``<module-list2>``, ... are list of module
|
||||||
currently not possible to distinguish between .ml/.mli files, however it
|
names.
|
||||||
wouldn't be hard to support if needed.
|
|
||||||
|
|
||||||
For instance:
|
For instance:
|
||||||
|
|
||||||
.. code:: scheme
|
.. code:: scheme
|
||||||
|
|
||||||
(preprocess (per_file
|
(preprocess (per_module
|
||||||
(((action (run ./pp.sh X=1 ${<})) (foo bar)))
|
(((action (run ./pp.sh X=1 ${<})) (foo bar)))
|
||||||
(((action (run ./pp.sh X=2 ${<})) (baz)))))
|
(((action (run ./pp.sh X=2 ${<})) (baz)))))
|
||||||
|
|
||||||
|
Note the beta versions of Jbuilder used ``per_file`` instead of
|
||||||
|
``per_module``, which was obviously the wrong name. ``per_file`` is
|
||||||
|
still accepted for backward compatibility but deprecated. It will be
|
||||||
|
re-purposed in the future to allow to distinguish between .ml and .mli
|
||||||
|
files.
|
||||||
|
|
||||||
Dependency specification
|
Dependency specification
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
|
|
@ -231,20 +231,25 @@ module Preprocess = struct
|
||||||
| _ -> []
|
| _ -> []
|
||||||
end
|
end
|
||||||
|
|
||||||
module Per_file = struct
|
module Per_module = struct
|
||||||
type 'a t =
|
type 'a t =
|
||||||
| For_all of 'a
|
| For_all of 'a
|
||||||
| Per_file of 'a String_map.t
|
| Per_module of 'a String_map.t
|
||||||
|
|
||||||
let t a sexp =
|
let t a sexp =
|
||||||
match sexp with
|
match sexp with
|
||||||
| List (_, Atom (_, "per_file") :: rest) -> begin
|
| List (_, Atom (loc, ("per_module" | "per_file" as kwd)) :: rest) -> begin
|
||||||
|
if kwd = "per_file" then
|
||||||
|
Loc.warn loc
|
||||||
|
"'per_file' was renamed 'per_module'. 'per_file' will be re-purposed \
|
||||||
|
in a future version and will take a list of file names rather \
|
||||||
|
than module names.";
|
||||||
List.concat_map rest ~f:(fun sexp ->
|
List.concat_map rest ~f:(fun sexp ->
|
||||||
let pp, names = pair a module_names sexp in
|
let pp, names = pair a module_names sexp in
|
||||||
List.map (String_set.elements names) ~f:(fun name -> (name, pp)))
|
List.map (String_set.elements names) ~f:(fun name -> (name, pp)))
|
||||||
|> String_map.of_alist
|
|> String_map.of_alist
|
||||||
|> function
|
|> function
|
||||||
| Ok map -> Per_file map
|
| Ok map -> Per_module map
|
||||||
| Error (name, _, _) ->
|
| Error (name, _, _) ->
|
||||||
of_sexp_error sexp (sprintf "module %s present in two different sets" name)
|
of_sexp_error sexp (sprintf "module %s present in two different sets" name)
|
||||||
end
|
end
|
||||||
|
@ -252,13 +257,13 @@ module Per_file = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
module Preprocess_map = struct
|
module Preprocess_map = struct
|
||||||
type t = Preprocess.t Per_file.t
|
type t = Preprocess.t Per_module.t
|
||||||
let t = Per_file.t Preprocess.t
|
let t = Per_module.t Preprocess.t
|
||||||
|
|
||||||
let find module_name (t : t) =
|
let find module_name (t : t) =
|
||||||
match t with
|
match t with
|
||||||
| For_all pp -> pp
|
| For_all pp -> pp
|
||||||
| Per_file map -> String_map.find_default module_name map ~default:No_preprocessing
|
| Per_module map -> String_map.find_default module_name map ~default:No_preprocessing
|
||||||
|
|
||||||
let default : t = For_all No_preprocessing
|
let default : t = For_all No_preprocessing
|
||||||
|
|
||||||
|
@ -266,7 +271,7 @@ module Preprocess_map = struct
|
||||||
|
|
||||||
let pps : t -> _ = function
|
let pps : t -> _ = function
|
||||||
| For_all pp -> Preprocess.pps pp
|
| For_all pp -> Preprocess.pps pp
|
||||||
| Per_file map ->
|
| Per_module map ->
|
||||||
String_map.fold map ~init:Pp_set.empty ~f:(fun ~key:_ ~data:pp acc ->
|
String_map.fold map ~init:Pp_set.empty ~f:(fun ~key:_ ~data:pp acc ->
|
||||||
Pp_set.union acc (Pp_set.of_list (Preprocess.pps pp)))
|
Pp_set.union acc (Pp_set.of_list (Preprocess.pps pp)))
|
||||||
|> Pp_set.elements
|
|> Pp_set.elements
|
||||||
|
@ -430,7 +435,7 @@ module Buildable = struct
|
||||||
>>= fun preprocessor_deps ->
|
>>= fun preprocessor_deps ->
|
||||||
(* CR-someday jdimino: remove this. There are still a few Jane Street packages using
|
(* CR-someday jdimino: remove this. There are still a few Jane Street packages using
|
||||||
this *)
|
this *)
|
||||||
field_o "lint" (Per_file.t Lint.t)
|
field_o "lint" (Per_module.t Lint.t)
|
||||||
>>= fun _lint ->
|
>>= fun _lint ->
|
||||||
field "modules" (fun s -> Ordered_set_lang.(map (t s)) ~f:String.capitalize_ascii)
|
field "modules" (fun s -> Ordered_set_lang.(map (t s)) ~f:String.capitalize_ascii)
|
||||||
~default:Ordered_set_lang.standard
|
~default:Ordered_set_lang.standard
|
||||||
|
@ -455,7 +460,7 @@ module Buildable = struct
|
||||||
let single_preprocess t =
|
let single_preprocess t =
|
||||||
match t.preprocess with
|
match t.preprocess with
|
||||||
| For_all pp -> pp
|
| For_all pp -> pp
|
||||||
| Per_file _ -> No_preprocessing
|
| Per_module _ -> No_preprocessing
|
||||||
end
|
end
|
||||||
|
|
||||||
module Public_lib = struct
|
module Public_lib = struct
|
||||||
|
|
Loading…
Reference in New Issue