Split more long lines in makefiles

This commit is contained in:
Jérémie Dimino 2017-05-19 02:12:51 +01:00
parent 42cb733c6a
commit 0a2157919c
3 changed files with 14 additions and 9 deletions

View File

@ -532,13 +532,13 @@ let rules =
Format.pp_open_vbox ppf 0;
if makefile_syntax then begin
List.iter rules ~f:(fun (rule : Build_system.Rule.t) ->
Format.fprintf ppf "%s:%s@\n@<0>\t@{<makefile-action>%a@}@,@,"
(Path.Set.elements rule.targets
|> List.map ~f:Path.to_string
|> String.concat ~sep:" ")
(Path.Set.elements rule.deps
|> List.map ~f:(fun p -> " " ^ Path.to_string p)
|> String.concat ~sep:"")
Format.fprintf ppf "@[<hov 2>@{<makefile-stuff>%a:%t@}@]@,@<0>\t@{<makefile-action>%a@}@,@,"
(Format.pp_print_list ~pp_sep:Format.pp_print_space (fun ppf p ->
Format.pp_print_string ppf (Path.to_string p)))
(Path.Set.elements rule.targets)
(fun ppf ->
Path.Set.iter rule.deps ~f:(fun dep ->
Format.fprintf ppf "@ %s" (Path.to_string dep)))
Sexp.pp_split_strings (Action.Mini_shexp.sexp_of_t (get_action rule)))
end else begin
List.iter rules ~f:(fun (rule : Build_system.Rule.t) ->

View File

@ -75,6 +75,7 @@ let rec pp_split_strings ppf = function
type formatter_state =
| In_atom
| In_makefile_action
| In_makefile_stuff
let prepare_formatter ppf =
let state = ref [] in
@ -86,9 +87,10 @@ let prepare_formatter ppf =
mark_open_tag = (function
| "atom" -> state := In_atom :: !state; ""
| "makefile-action" -> state := In_makefile_action :: !state; ""
| "makefile-stuff" -> state := In_makefile_stuff :: !state; ""
| s -> tfuncs.mark_open_tag s)
; mark_close_tag = (function
| "atom" | "makefile-action" -> state := List.tl !state; ""
| "atom" | "makefile-action" | "makefile-stuff" -> state := List.tl !state; ""
| s -> tfuncs.mark_close_tag s)
};
Format.pp_set_formatter_out_functions ppf
@ -101,6 +103,8 @@ let prepare_formatter ppf =
ofuncs.out_string "\\\n" 0 2
| [In_makefile_action] ->
ofuncs.out_string " \\\n\t" 0 4
| [In_makefile_stuff] ->
ofuncs.out_string " \\\n" 0 3
| [] ->
ofuncs.out_string "\n" 0 1
| _ -> assert false)

View File

@ -29,7 +29,8 @@ val pp : Format.formatter -> t -> unit
val pp_split_strings : Format.formatter -> t -> unit
(** Prepare a formatter for [pp_split_strings]. Additionaly the
formatter escape newlines when the tag "makefile-action" is active. *)
formatter escape newlines when the tags "makefile-action" or
"makefile-stuff" are active. *)
val prepare_formatter : Format.formatter -> unit
module type Combinators = sig