Skip to content

Commit

Permalink
refactor: limit Build_engine use where possible
Browse files Browse the repository at this point in the history
Use explicit imports to demonstrate that we depend on things from
[Dune_engine] that shouldn't be there.

Signed-off-by: Rudi Grinberg <[email protected]>

ps-id: 34210A9F-4EFF-46A8-A853-9E17C70CAF06
  • Loading branch information
rgrinberg committed May 7, 2022
1 parent 84f4ab8 commit 8511f2d
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 12 deletions.
5 changes: 4 additions & 1 deletion bin/dune_init.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
open! Dune_engine
open! Stdune
module Dune_file = Dune_rules.Dune_file
module Stanza = Dune_engine.Stanza
module Dune_project = Dune_engine.Dune_project
module Package = Dune_engine.Package
module Dialect = Dune_engine.Dialect

(** Because the dune_init utility deals with the addition of stanzas and fields
to dune projects and files, we need to inspect and manipulate the concrete
Expand Down
3 changes: 1 addition & 2 deletions bin/dune_init.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(** Initialize dune components *)
open! Dune_engine

open! Stdune

Expand All @@ -20,7 +19,7 @@ end
module Init_context : sig
type t =
{ dir : Path.t
; project : Dune_project.t
; project : Dune_engine.Dune_project.t
}

val make : string option -> t Memo.t
Expand Down
4 changes: 2 additions & 2 deletions bin/workspace_root.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
open Stdune
open Dune_engine
open Dune_rules

module Kind = struct
Expand All @@ -19,7 +18,8 @@ module Kind = struct

let of_dir_contents files =
if String.Set.mem files Workspace.filename then Some Dune_workspace
else if String.Set.mem files Dune_project.filename then Some Dune_project
else if String.Set.mem files Dune_engine.Dune_project.filename then
Some Dune_project
else None
end

Expand Down
1 change: 0 additions & 1 deletion configure.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ let () =
| Some _ -> ());
let oc = open_out out in
let pr fmt = fprintf oc (fmt ^^ "\n") in
pr "open! Dune_engine\n";
pr "let library_path = %s\n" ((list string) !library_path);
pr "let roots : string option Install.Section.Paths.Roots.t =";
pr " { lib_root = %s" (option string !library_destdir);
Expand Down
2 changes: 1 addition & 1 deletion src/dune_rpc_impl/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Id = Dune_rpc.Id
module Diagnostic = Dune_rpc.Diagnostic
module Conv = Dune_rpc.Conv
module Dep_conf = Dune_rules.Dep_conf
module Stanza = Dune_engine.Stanza
module Source_tree = Dune_engine.Source_tree
module Build_config = Dune_engine.Build_config
module Dune_project = Dune_engine.Dune_project
Expand All @@ -26,7 +27,6 @@ type pending_build_action =

(* TODO un-copy-paste from dune/bin/arg.ml *)
let dep_parser =
let open Dune_engine in
Dune_lang.Syntax.set Stanza.syntax (Active Stanza.latest_version)
Dep_conf.decode

Expand Down
1 change: 0 additions & 1 deletion src/dune_rules/bootstrap_info.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(** Generate bootstrap info *)
open! Dune_engine

(** Generate an OCaml file containing a description of the dune sources for the
bootstrap procedure *)
Expand Down
2 changes: 0 additions & 2 deletions src/dune_rules/setup.defaults.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
open! Dune_engine

let library_path = []

let roots : string option Install.Section.Paths.Roots.t =
Expand Down
7 changes: 6 additions & 1 deletion src/upgrader/dune_upgrader.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
open! Dune_engine
open! Stdune

(* XXX explicit export because we want to get rid of the dependency on the
engine *)
module Dune_project = Dune_engine.Dune_project
module Source_tree = Dune_engine.Source_tree
module Sub_dirs = Dune_engine.Sub_dirs

type rename_and_edit =
{ original_file : Path.Source.t
; extra_files_to_delete : Path.Source.t list
Expand Down
1 change: 0 additions & 1 deletion src/upgrader/dune_upgrader.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
(** Upgrade projects from jbuilder to Dune *)
open! Dune_engine

(** Upgrade all projects in this file tree *)
val upgrade : unit -> unit Fiber.t

0 comments on commit 8511f2d

Please sign in to comment.