Skip to content

Commit

Permalink
Update ocamlformat to 0.17.0
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg committed Mar 8, 2021
1 parent 8dd908c commit 154272b
Show file tree
Hide file tree
Showing 214 changed files with 1,606 additions and 1,524 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.15.0
version=0.17.0
break-separators=before
dock-collection-brackets=false
break-sequences=true
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ mdx \
menhir \
"merlin>=3.4.0" \
ocamlfind \
ocamlformat.0.15.0 \
ocamlformat.0.17.0 \
"odoc>=1.5.0" \
"ppx_expect>=v0.14" \
ppx_inline_test \
"ppxlib.0.15.0" \
ppxlib \
result \
"utop>=2.6.0"

Expand Down
4 changes: 2 additions & 2 deletions bench/dune_bench/scheduler_bench.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let config =

let setup =
lazy
( Path.set_root (Path.External.cwd ());
Path.Build.set_build_dir (Path.Build.Kind.of_string "_build") )
(Path.set_root (Path.External.cwd ());
Path.Build.set_build_dir (Path.Build.Kind.of_string "_build"))

let prog = Option.value_exn (Bin.which ~path:(Env.path Env.initial) "true")

Expand Down
4 changes: 2 additions & 2 deletions bin/alias.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ type t =
let pp { name; recursive; dir; contexts = _ } =
let open Pp.O in
let s =
( if recursive then
(if recursive then
"@"
else
"@@" )
"@@")
^ Path.Source.to_string
(Path.Source.relative dir (Dune_engine.Alias.Name.to_string name))
in
Expand Down
6 changes: 3 additions & 3 deletions bin/arg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ module Dep = struct
in
let s = String_with_vars.make_text Loc.none (String.drop s pos) in
Some
( if recursive then
(if recursive then
Dep_conf.Alias_rec s
else
Dep_conf.Alias s )
Dep_conf.Alias s)

let dep_parser =
Dune_lang.Syntax.set Stanza.syntax (Active Stanza.latest_version)
Expand All @@ -71,7 +71,7 @@ module Dep = struct
~mode:Dune_lang.Parser.Mode.Single s)
with
| x -> `Ok x
| exception User_error.E msg -> `Error (User_message.to_string msg) )
| exception User_error.E msg -> `Error (User_message.to_string msg))

let string_of_alias ~recursive sv =
let prefix =
Expand Down
4 changes: 2 additions & 2 deletions bin/build_cmd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ let run_build_command_once ~(common : Common.t) ~targets ~setup =

let run_build_command ~(common : Common.t) ~targets =
let setup () = make_setup common in
( if Common.watch common then
(if Common.watch common then
run_build_command_poll
else
run_build_command_once )
run_build_command_once)
~setup ~common ~targets;
Build_system.cache_teardown ()

Expand Down
6 changes: 3 additions & 3 deletions bin/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ let set_common ?log_file c =
else
loop (Filename.concat acc "..") (Filename.dirname dir)
in
loop ".." (Filename.dirname s) ) )
loop ".." (Filename.dirname s)))
in
Console.print [ Pp.verbatim (sprintf "Entering directory '%s'" dir) ]

Expand Down Expand Up @@ -270,12 +270,12 @@ let build_info =
, ver_string (B.Statically_linked_library.version lib) ))
|> List.sort ~compare:Poly.compare
in
( match libs with
(match libs with
| [] -> ()
| _ ->
pr "statically linked libraries:";
let longest = String.longest_map libs ~f:fst in
List.iter libs ~f:(fun (name, v) -> pr "- %-*s %s" longest name v) );
List.iter libs ~f:(fun (name, v) -> pr "- %-*s %s" longest name v));
exit 0
)

Expand Down
6 changes: 3 additions & 3 deletions bin/compute.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ let term =
Fiber.return
(`Result
(Dyn.String
( Dune_lang.Syntax.greatest_supported_version
Dune_engine.Stanza.syntax
|> Dune_lang.Syntax.Version.to_string )))
(Dune_lang.Syntax.greatest_supported_version
Dune_engine.Stanza.syntax
|> Dune_lang.Syntax.Version.to_string)))
| "list", None -> Fiber.return `List
| "list", Some _ ->
Fiber.return (`Error "'list' doesn't take an argument")
Expand Down
2 changes: 1 addition & 1 deletion bin/describe.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ module Crawl = struct
| Dune_file.Executables exes -> (
match executables sctx ~project:dune_file.project ~dir exes with
| None -> accu
| Some exes -> exes :: accu )
| Some exes -> exes :: accu)
| _ -> accu)
in
Dyn.List exes_and_libs
Expand Down
13 changes: 7 additions & 6 deletions bin/dune_init.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,14 @@ module File = struct
; Pp.nop
; Pp.text "Pre-existing stanza:"
; pp b
] )
])
end

(* Stanza *)

let create_dir path =
try Path.mkdir_p path
with Unix.Unix_error (EACCES, _, _) ->
try Path.mkdir_p path with
| Unix.Unix_error (EACCES, _, _) ->
User_error.raise
[ Pp.textf
"A project directory cannot be created or accessed: Lacking \
Expand Down Expand Up @@ -305,13 +305,14 @@ module Component = struct

let common (options : Options.Common.t) =
name options.name
:: ( optional_field ~f:libraries options.libraries
@ optional_field ~f:pps options.pps )
::
(optional_field ~f:libraries options.libraries
@ optional_field ~f:pps options.pps)
end

let make kind common_options fields =
(* Form the AST *)
List ((atom kind :: fields) @ Field.common common_options)
List (atom kind :: fields @ Field.common common_options)
(* Convert to a CST *)
|> Dune_lang.Ast.add_loc ~loc:Loc.none
|> Cst.concrete (* Package as a list CSTs *) |> List.singleton
Expand Down
32 changes: 16 additions & 16 deletions bin/exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,33 +62,33 @@ let term =
in
let targets =
lazy
( ( match prog_where with
| `Search p ->
[ Path.Build.relative
(Local_install_path.bin_dir ~context:context.name)
p
|> Path.build
]
| `This_rel p when Sys.win32 ->
[ p; Path.extend_basename p ~suffix:Bin.exe ]
| `This_rel p -> [ p ]
| `This_abs p when Path.is_in_build_dir p -> [ p ]
| `This_abs _ -> [] )
((match prog_where with
| `Search p ->
[ Path.Build.relative
(Local_install_path.bin_dir ~context:context.name)
p
|> Path.build
]
| `This_rel p when Sys.win32 ->
[ p; Path.extend_basename p ~suffix:Bin.exe ]
| `This_rel p -> [ p ]
| `This_abs p when Path.is_in_build_dir p -> [ p ]
| `This_abs _ -> [])
|> List.map ~f:(fun p -> Target.Path p)
|> Target.resolve_targets_mixed common setup
|> List.concat_map ~f:(function
| Ok targets -> targets
| Error _ -> []) )
| Error _ -> []))
in
let real_prog =
( if not no_rebuild then
(if not no_rebuild then
match Lazy.force targets with
| [] -> ()
| targets ->
Build_cmd.run_build_command_once ~common
~targets:(fun () -> targets)
~setup:(fun () -> Memo.Build.return ());
Hooks.End_of_build.run () );
Hooks.End_of_build.run ());
match prog_where with
| `Search prog ->
let path =
Expand Down Expand Up @@ -129,7 +129,7 @@ let term =
"Program %S isn't built yet. You need to build it first or remove \
the --no-build option."
prog
] )
])
| None, false ->
let hints = hints () in
User_error.raise ~hints [ Pp.textf "Program %S not found!" prog ]
Expand Down
8 changes: 4 additions & 4 deletions bin/import.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ let make_cache (config : Dune_config.t) =
Cache.make_caching (module Cache.Client) cache
in
Fiber.return
( match config.cache_mode with
(match config.cache_mode with
| Dune_config.Caching.Mode.Enabled ->
Some
{ Build_system.cache = make_cache ()
; check_probability = config.cache_check_probability
}
| Dune_config.Caching.Mode.Disabled ->
Log.info [ Pp.text "disable binary cache" ];
None )
None)

module Main = struct
include Dune_rules.Main
Expand Down Expand Up @@ -109,8 +109,8 @@ module Main = struct
~hints:
(User_message.did_you_mean pkg_name
~candidates:
( Package.Name.Map.keys workspace.conf.packages
|> List.map ~f:Package.Name.to_string )));
(Package.Name.Map.keys workspace.conf.packages
|> List.map ~f:Package.Name.to_string)));
Package.Name.Map.filter workspace.conf.packages ~f:(fun pkg ->
let vendored =
let dir = Package.dir pkg in
Expand Down
4 changes: 2 additions & 2 deletions bin/init.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ let term =
let template = Option.value template ~default:Options.Project.Template.Exec in
(* for the [kind] of initialization *)
let check_unsupported_options = validate_component_options kind in
( match kind with
(match kind with
| Kind.Executable ->
check_unsupported_options
[ ("inline-tests", inline_tests)
Expand All @@ -242,7 +242,7 @@ let term =
; ("kind", given_template)
; ("pkg", given_pkg)
];
init @@ Test { context; common; options = () } );
init @@ Test { context; common; options = () });
print_completion kind name

let command = (term, info)
29 changes: 15 additions & 14 deletions bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ let resolve_package_install setup pkg =
~hints:
(User_message.did_you_mean pkg
~candidates:
( Package.Name.Map.keys setup.conf.packages
|> List.map ~f:Package.Name.to_string ))
(Package.Name.Map.keys setup.conf.packages
|> List.map ~f:Package.Name.to_string))

let print_unix_error f =
try f ()
with Unix.Unix_error (e, _, _) ->
try f () with
| Unix.Unix_error (e, _, _) ->
User_message.prerr (User_error.make [ Pp.text (Unix.error_message e) ])

module Special_file = struct
Expand Down Expand Up @@ -139,7 +139,7 @@ module File_ops_real (W : Workspace) : File_operations = struct
let+ version = Memo.Build.run (Dune_engine.Vcs.describe vcs) in
let ppf = Format.formatter_of_out_channel oc in
print ppf ~version;
Format.pp_print_flush ppf () )
Format.pp_print_flush ppf ())

let process_meta ic =
let lb = Lexing.from_channel ic in
Expand All @@ -153,7 +153,8 @@ module File_ops_real (W : Workspace) : File_operations = struct
raise_notrace Exit)
in
false
with Exit -> true
with
| Exit -> true
in
if not need_more_versions then
No_version_needed
Expand Down Expand Up @@ -309,9 +310,9 @@ let file_operations ~dry_run ~workspace : (module File_operations) =
if dry_run then
(module File_ops_dry_run)
else
( module File_ops_real (struct
(module File_ops_real (struct
let workspace = workspace
end) )
end))

let package_is_vendored (pkg : Dune_engine.Package.t) =
let dir = Package.dir pkg in
Expand Down Expand Up @@ -419,17 +420,17 @@ let install_uninstall ~what =
Pp.text (Path.to_string p))
]
~hints:[ Pp.text "try running: dune build @install" ];
( match
(contexts, prefix_from_command_line, libdir_from_command_line)
with
(match
(contexts, prefix_from_command_line, libdir_from_command_line)
with
| _ :: _ :: _, Some _, _
| _ :: _ :: _, _, Some _ ->
User_error.raise
[ Pp.text
"Cannot specify --prefix or --libdir when installing into \
multiple contexts!"
]
| _ -> () );
| _ -> ());
let module CMap = Map.Make (Context) in
let install_files_by_context =
CMap.of_list_multi install_files
Expand Down Expand Up @@ -466,9 +467,9 @@ let install_uninstall ~what =
let+ () =
let mandir =
Option.map ~f:Path.of_string
( match mandir with
(match mandir with
| Some _ -> mandir
| None -> Dune_rules.Setup.mandir )
| None -> Dune_rules.Setup.mandir)
in
Fiber.sequential_iter install_files_by_context
~f:(fun (context, entries_per_package) ->
Expand Down
7 changes: 4 additions & 3 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ let default =
( term
, Term.info "dune" ~doc
~version:
( match Build_info.V1.version () with
(match Build_info.V1.version () with
| None -> "n/a"
| Some v -> Build_info.V1.Version.to_string v )
| Some v -> Build_info.V1.Version.to_string v)
~man:
[ `Blocks common_commands_synopsis
; `S "DESCRIPTION"
Expand Down Expand Up @@ -89,7 +89,8 @@ let () =
match Term.Group.eval default all ~catch:false with
| `Error _ -> exit 1
| _ -> exit 0
with exn ->
with
| exn ->
let exn = Exn_with_backtrace.capture exn in
Dune_engine.Report_error.report exn;
exit 1
9 changes: 4 additions & 5 deletions bin/print_rules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ let print_rule_sexp ppf (rule : Build_system.Evaluated_rule.t) =
[ [ ("deps", Dep.Set.encode rule.deps)
; ( "targets"
, paths
( Path.Build.Set.to_list rule.targets
|> Path.set_of_build_paths_list ) )
(Path.Build.Set.to_list rule.targets
|> Path.set_of_build_paths_list) )
]
; ( match rule.context with
; (match rule.context with
| None -> []
| Some c -> [ ("context", Dune_engine.Context_name.encode c.name) ]
)
| Some c -> [ ("context", Dune_engine.Context_name.encode c.name) ])
; [ ("action", sexp_of_action rule.action) ]
])
in
Expand Down
Loading

0 comments on commit 154272b

Please sign in to comment.