From 88ebd2cc2f7a41b7cf3552b546ccf3b8e00a8e69 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Fri, 5 Aug 2022 14:18:11 -0500 Subject: [PATCH] refactor(stdune): move [Console] to own library [Console] isn't general purpose enough to live in [Stdune] Signed-off-by: Rudi Grinberg ps-id: ebd1cb41-98fd-4acc-b2a8-0a33ce911772 --- bin/common.ml | 1 + bin/dune | 1 + bin/import.ml | 1 + bin/internal_dump.ml | 1 - boot/libs.ml | 1 + otherlibs/stdune/stdune.ml | 1 - src/dune_config/dune | 1 + src/dune_config/dune_config.ml | 1 + src/dune_console/dune | 3 +++ .../console.ml => src/dune_console/dune_console.ml | 2 ++ .../console.mli => src/dune_console/dune_console.mli | 2 ++ src/dune_engine/dune | 1 + src/dune_engine/import.ml | 1 + src/dune_file_watcher/dune | 1 + src/dune_file_watcher/dune_file_watcher.ml | 1 + src/dune_rules/dune | 2 +- src/dune_rules/import.ml | 1 + src/dune_util/dune | 1 + src/dune_util/import.ml | 1 + src/dune_util/log.ml | 1 + src/dune_util/report_error.ml | 1 + src/memo/dune | 2 +- src/memo/memo.ml | 1 + src/upgrader/dune | 9 ++++++++- src/upgrader/dune_upgrader.ml | 1 + test/expect-tests/common/dune | 2 +- test/expect-tests/common/dune_tests_common.ml | 1 + 27 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 src/dune_console/dune rename otherlibs/stdune/console.ml => src/dune_console/dune_console.ml (99%) rename otherlibs/stdune/console.mli => src/dune_console/dune_console.mli (99%) create mode 100644 src/dune_util/import.ml diff --git a/bin/common.ml b/bin/common.ml index 15a8969f92d..4f96b29f461 100644 --- a/bin/common.ml +++ b/bin/common.ml @@ -1,5 +1,6 @@ open Stdune module Config = Dune_util.Config +module Console = Dune_console module Colors = Dune_rules.Colors module Clflags = Dune_engine.Clflags module Graph = Dune_graph.Graph diff --git a/bin/dune b/bin/dune index 17a7d3e0ef3..124fa15ed46 100644 --- a/bin/dune +++ b/bin/dune @@ -10,6 +10,7 @@ dune_lang fiber stdune + dune_console unix dune_metrics dune_digest diff --git a/bin/import.ml b/bin/import.ml index c59c6ba219b..914ec34d25b 100644 --- a/bin/import.ml +++ b/bin/import.ml @@ -2,6 +2,7 @@ open Stdune open Dune_engine module Digest = Dune_digest module Metrics = Dune_metrics +module Console = Dune_console module Term = Cmdliner.Term module Manpage = Cmdliner.Manpage module Stanza = Dune_lang.Stanza diff --git a/bin/internal_dump.ml b/bin/internal_dump.ml index 5940ec44e4e..11eea8a3c6d 100644 --- a/bin/internal_dump.ml +++ b/bin/internal_dump.ml @@ -1,4 +1,3 @@ -open Stdune open Import module Persistent = Dune_util.Persistent diff --git a/boot/libs.ml b/boot/libs.ml index 1ff20f955ed..806d9d4e278 100644 --- a/boot/libs.ml +++ b/boot/libs.ml @@ -14,6 +14,7 @@ let local_libraries = ; ("vendor/incremental-cycles/src", Some "Incremental_cycles", false, None) ; ("src/dag", Some "Dag", false, None) ; ("src/fiber", Some "Fiber", false, None) + ; ("src/dune_console", Some "Dune_console", false, None) ; ("src/memo", Some "Memo", false, None) ; ("src/dune_metrics", Some "Dune_metrics", false, None) ; ("src/dune_digest", Some "Dune_digest", false, None) diff --git a/otherlibs/stdune/stdune.ml b/otherlibs/stdune/stdune.ml index 21792aab06d..fca0166e490 100644 --- a/otherlibs/stdune/stdune.ml +++ b/otherlibs/stdune/stdune.ml @@ -10,7 +10,6 @@ module Array = Array module Bytes = Bytes module Char = Char module Comparator = Comparator -module Console = Console module Either = Either module Exn = Exn module Exn_with_backtrace = Exn_with_backtrace diff --git a/src/dune_config/dune b/src/dune_config/dune index ca422e041d4..7e607ad4609 100644 --- a/src/dune_config/dune +++ b/src/dune_config/dune @@ -3,6 +3,7 @@ (libraries stdune xdg + dune_console dune_lang dune_cache dune_cache_storage diff --git a/src/dune_config/dune_config.ml b/src/dune_config/dune_config.ml index 704dbe10213..59702ea8aad 100644 --- a/src/dune_config/dune_config.ml +++ b/src/dune_config/dune_config.ml @@ -2,6 +2,7 @@ open Stdune open Dune_lang.Decoder module Scheduler = Dune_engine.Scheduler module Sandbox_mode = Dune_engine.Sandbox_mode +module Console = Dune_console module Stanza = Dune_lang.Stanza module Config = Dune_util.Config module String_with_vars = Dune_lang.String_with_vars diff --git a/src/dune_console/dune b/src/dune_console/dune new file mode 100644 index 00000000000..94dd19e3cc5 --- /dev/null +++ b/src/dune_console/dune @@ -0,0 +1,3 @@ +(library + (name dune_console) + (libraries stdune)) diff --git a/otherlibs/stdune/console.ml b/src/dune_console/dune_console.ml similarity index 99% rename from otherlibs/stdune/console.ml rename to src/dune_console/dune_console.ml index ddae71a3a33..92869935ba9 100644 --- a/otherlibs/stdune/console.ml +++ b/src/dune_console/dune_console.ml @@ -1,3 +1,5 @@ +open Stdune + module Backend = struct module type S = sig val print_user_message : User_message.t -> unit diff --git a/otherlibs/stdune/console.mli b/src/dune_console/dune_console.mli similarity index 99% rename from otherlibs/stdune/console.mli rename to src/dune_console/dune_console.mli index 43d18568267..e97da15f3f0 100644 --- a/otherlibs/stdune/console.mli +++ b/src/dune_console/dune_console.mli @@ -1,3 +1,5 @@ +open Stdune + (** Manages the console *) (** The console is a system than can report messages and a status to the user. diff --git a/src/dune_engine/dune b/src/dune_engine/dune index b1662546a0e..992f4c680ce 100644 --- a/src/dune_engine/dune +++ b/src/dune_engine/dune @@ -5,6 +5,7 @@ (libraries unix stdune + dune_console dyn fiber incremental_cycles diff --git a/src/dune_engine/import.ml b/src/dune_engine/import.ml index a517213c536..95d73e5da5e 100644 --- a/src/dune_engine/import.ml +++ b/src/dune_engine/import.ml @@ -1,5 +1,6 @@ include Stdune module Digest = Dune_digest +module Console = Dune_console module Metrics = Dune_metrics module Log = Dune_util.Log module Re = Dune_re diff --git a/src/dune_file_watcher/dune b/src/dune_file_watcher/dune index 51c9eacfee2..c35764e11ef 100644 --- a/src/dune_file_watcher/dune +++ b/src/dune_file_watcher/dune @@ -3,6 +3,7 @@ (libraries spawn fsevents + dune_console unix stdune threads.posix diff --git a/src/dune_file_watcher/dune_file_watcher.ml b/src/dune_file_watcher/dune_file_watcher.ml index d6cf3351732..01ebe8b1a9d 100644 --- a/src/dune_file_watcher/dune_file_watcher.ml +++ b/src/dune_file_watcher/dune_file_watcher.ml @@ -1,5 +1,6 @@ open! Stdune module Inotify_lib = Async_inotify_for_dune.Async_inotify +module Console = Dune_console module Fs_memo_event = struct type kind = diff --git a/src/dune_rules/dune b/src/dune_rules/dune index 88636aaeb90..aa7022e557a 100644 --- a/src/dune_rules/dune +++ b/src/dune_rules/dune @@ -9,7 +9,7 @@ memo ocaml dune_re - console + dune_console dune_digest opam_file_format dune_lang diff --git a/src/dune_rules/import.ml b/src/dune_rules/import.ml index 163e5460b56..6a0dd6c9449 100644 --- a/src/dune_rules/import.ml +++ b/src/dune_rules/import.ml @@ -1,6 +1,7 @@ include Stdune open Dune_util module Digest = Dune_digest +module Console = Dune_console module Config = Config module Log = Log module Persistent = Persistent diff --git a/src/dune_util/dune b/src/dune_util/dune index 21b3872e413..c48f23100e0 100644 --- a/src/dune_util/dune +++ b/src/dune_util/dune @@ -3,6 +3,7 @@ (libraries stdune xdg + dune_console build_path_prefix_map dune_sexp memo diff --git a/src/dune_util/import.ml b/src/dune_util/import.ml new file mode 100644 index 00000000000..b002483ab81 --- /dev/null +++ b/src/dune_util/import.ml @@ -0,0 +1 @@ +module Console = Dune_console diff --git a/src/dune_util/log.ml b/src/dune_util/log.ml index 23cc48e4314..28ca6ddde01 100644 --- a/src/dune_util/log.ml +++ b/src/dune_util/log.ml @@ -1,4 +1,5 @@ open Stdune +module Console = Dune_console module File = struct type t = diff --git a/src/dune_util/report_error.ml b/src/dune_util/report_error.ml index 22ff2fcc23b..4ff8424ddeb 100644 --- a/src/dune_util/report_error.ml +++ b/src/dune_util/report_error.ml @@ -1,4 +1,5 @@ open Stdune +open Import exception Already_reported diff --git a/src/memo/dune b/src/memo/dune index b65cce57c2d..b5bb7c6533d 100644 --- a/src/memo/dune +++ b/src/memo/dune @@ -1,4 +1,4 @@ (library (name memo) - (libraries stdune dyn dune_graph dag fiber unix) + (libraries stdune dyn dune_graph dag fiber dune_console unix) (synopsis "Incremental computation library that powers Dune")) diff --git a/src/memo/memo.ml b/src/memo/memo.ml index 31fd36dd7c4..18b370cc301 100644 --- a/src/memo/memo.ml +++ b/src/memo/memo.ml @@ -1,6 +1,7 @@ open! Stdune open Fiber.O module Graph = Dune_graph.Graph +module Console = Dune_console module Debug = struct let track_locations_of_lazy_values = ref false diff --git a/src/upgrader/dune b/src/upgrader/dune index 8173abcb202..d3f4cfd81eb 100644 --- a/src/upgrader/dune +++ b/src/upgrader/dune @@ -1,4 +1,11 @@ (library (name dune_upgrader) - (libraries stdune memo opam_file_format dune_lang dune_engine fiber) + (libraries + stdune + dune_console + memo + opam_file_format + dune_lang + dune_engine + fiber) (synopsis "Internal Dune library, do not use!")) diff --git a/src/upgrader/dune_upgrader.ml b/src/upgrader/dune_upgrader.ml index 95e0fd0f190..33720abd743 100644 --- a/src/upgrader/dune_upgrader.ml +++ b/src/upgrader/dune_upgrader.ml @@ -4,6 +4,7 @@ open! Stdune engine *) module Dune_project = Dune_engine.Dune_project module Source_tree = Dune_engine.Source_tree +module Console = Dune_console module Sub_dirs = Dune_engine.Sub_dirs type rename_and_edit = diff --git a/test/expect-tests/common/dune b/test/expect-tests/common/dune index f5ef932edbf..d55c5971a4d 100644 --- a/test/expect-tests/common/dune +++ b/test/expect-tests/common/dune @@ -1,4 +1,4 @@ (library (name dune_tests_common) (modules dune_tests_common) - (libraries stdune dune_util)) + (libraries stdune dune_console dune_util)) diff --git a/test/expect-tests/common/dune_tests_common.ml b/test/expect-tests/common/dune_tests_common.ml index ca0f7aebfd0..8d5341514e2 100644 --- a/test/expect-tests/common/dune_tests_common.ml +++ b/test/expect-tests/common/dune_tests_common.ml @@ -1,4 +1,5 @@ open Stdune +module Console = Dune_console let print pp = Format.printf "%a@." Pp.to_fmt pp