Skip to content

Commit

Permalink
Merge pull request ocaml#3742 from cwong-ocaml/api-split
Browse files Browse the repository at this point in the history
preliminary rules/engine split
  • Loading branch information
cwong-ocaml authored Aug 26, 2020
2 parents ee9bf53 + 328ed1f commit 6d83f12
Show file tree
Hide file tree
Showing 409 changed files with 517 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .ocamlformat-ignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
boot/libs.ml
src/dune/assets.ml
src/dune_rules/assets.ml
2 changes: 1 addition & 1 deletion bench/dune_bench/dune
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(library
(name dune_bench)
(libraries stdune fiber dune)
(libraries stdune fiber dune_engine dune_rules)
(library_flags -linkall)
(preprocess
(pps ppx_bench)))
3 changes: 2 additions & 1 deletion bench/dune_bench/file_tree_cache.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(* Benchmark File_tree.t's internal cache *)

open Stdune
open Dune
open Dune_rules
open Dune_engine

let deep_path = "a1/a2/a3/a4/a5/a6/a7/a8/a9/10"

Expand Down
2 changes: 1 addition & 1 deletion bench/dune_bench/scheduler_bench.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* Benchmark the scheduler *)

open Stdune
open Dune
open Dune_engine

let setup =
lazy
Expand Down
14 changes: 8 additions & 6 deletions bin/alias.ml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
open Stdune

type t =
{ name : Dune.Alias.Name.t
{ name : Dune_engine.Alias.Name.t
; recursive : bool
; dir : Path.Source.t
; contexts : Dune.Context.t list
; contexts : Dune_rules.Context.t list
}

let pp { name; recursive; dir; contexts = _ } =
Expand All @@ -15,7 +15,7 @@ let pp { name; recursive; dir; contexts = _ } =
else
"@@" )
^ Path.Source.to_string
(Path.Source.relative dir (Dune.Alias.Name.to_string name))
(Path.Source.relative dir (Dune_engine.Alias.Name.to_string name))
in
let pp = Pp.verbatim "alias" ++ Pp.space ++ Pp.verbatim s in
if recursive then
Expand All @@ -34,7 +34,7 @@ let in_dir ~name ~recursive ~contexts dir =
User_error.raise
[ Pp.textf "Invalid alias: %s."
(Path.to_string_maybe_quoted
(Path.build Dune.Dpath.Build.install_dir))
(Path.build Dune_engine.Dpath.Build.install_dir))
; Pp.textf "There are no aliases in %s." (Path.to_string_maybe_quoted dir)
]
| In_build_dir (ctx, dir) ->
Expand All @@ -43,7 +43,9 @@ let in_dir ~name ~recursive ~contexts dir =
; name
; contexts =
[ List.find_exn contexts ~f:(fun c ->
Dune.Context_name.equal (Dune.Context.name c) ctx.name)
Dune_engine.Context_name.equal
(Dune_rules.Context.name c)
ctx.name)
]
}

Expand All @@ -55,5 +57,5 @@ let of_string common ~recursive s ~contexts =
]
else
let dir = Path.parent_exn path in
let name = Dune.Alias.Name.of_string (Path.basename path) in
let name = Dune_engine.Alias.Name.of_string (Path.basename path) in
in_dir ~name ~recursive ~contexts dir
14 changes: 9 additions & 5 deletions bin/alias.mli
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
open Stdune

type t = private
{ name : Dune.Alias.Name.t
{ name : Dune_engine.Alias.Name.t
; recursive : bool
; dir : Path.Source.t
; contexts : Dune.Context.t list
; contexts : Dune_rules.Context.t list
}

val in_dir :
name:Dune.Alias.Name.t
name:Dune_engine.Alias.Name.t
-> recursive:bool
-> contexts:Dune.Context.t list
-> contexts:Dune_rules.Context.t list
-> Path.t
-> t

val of_string :
Common.t -> recursive:bool -> string -> contexts:Dune.Context.t list -> t
Common.t
-> recursive:bool
-> string
-> contexts:Dune_rules.Context.t list
-> t

val pp : t -> _ Pp.t
11 changes: 6 additions & 5 deletions bin/arg.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Stdune
open Dune
open Dune_engine
open Dune_rules
include Cmdliner.Arg

let package_name = conv Package.Name.conv
Expand All @@ -16,7 +17,7 @@ end

let path = Path.conv

let profile = conv Dune.Profile.conv
let profile = conv Dune_rules.Profile.conv

module Dep = struct
module Dep_conf = Dep_conf
Expand All @@ -27,7 +28,7 @@ module Dep = struct

let make_alias_sw ~dir s =
let path =
Dune.Alias.Name.to_string s
Dune_engine.Alias.Name.to_string s
|> Stdune.Path.Local.relative dir
|> Stdune.Path.Local.to_string
in
Expand All @@ -50,7 +51,7 @@ module Dep = struct
let s = String.drop s pos in
let dir, alias =
let path = Stdune.Path.Local.of_string s in
Dune.Alias.Name.parse_local_path (Loc.none, path)
Dune_engine.Alias.Name.parse_local_path (Loc.none, path)
in
Some (recursive, dir, alias)

Expand Down Expand Up @@ -123,4 +124,4 @@ let bytes =

let context_name : Context_name.t conv = conv Context_name.conv

let lib_name = conv Dune.Lib_name.conv
let lib_name = conv Dune_engine.Lib_name.conv
7 changes: 4 additions & 3 deletions bin/arg.mli
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
open Stdune
open Dune
open Dune_engine
open Dune_rules

include module type of struct
include Cmdliner.Arg
Expand All @@ -18,9 +19,9 @@ module Dep : sig

val file : string -> t

val alias : dir:Stdune.Path.Local.t -> Dune.Alias.Name.t -> t
val alias : dir:Stdune.Path.Local.t -> Dune_engine.Alias.Name.t -> t

val alias_rec : dir:Stdune.Path.Local.t -> Dune.Alias.Name.t -> t
val alias_rec : dir:Stdune.Path.Local.t -> Dune_engine.Alias.Name.t -> t

val to_string_maybe_quoted : t -> string
end
Expand Down
46 changes: 24 additions & 22 deletions bin/common.ml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
open Stdune
module Config = Dune.Config
module Colors = Dune.Colors
module Clflags = Dune.Clflags
module Package = Dune.Package
module Profile = Dune.Profile
module Config = Dune_engine.Config
module Colors = Dune_rules.Colors
module Clflags = Dune_engine.Clflags
module Package = Dune_engine.Package
module Profile = Dune_rules.Profile
module Term = Cmdliner.Term
module Manpage = Cmdliner.Manpage

Expand All @@ -17,7 +17,7 @@ open Let_syntax

module Only_packages = struct
type t =
{ names : Dune.Package.Name.Set.t
{ names : Dune_engine.Package.Name.Set.t
; command_line_option : string
}
end
Expand All @@ -33,7 +33,7 @@ type t =
; target_prefix : string
; only_packages : Only_packages.t option
; capture_outputs : bool
; x : Dune.Context_name.t option
; x : Dune_engine.Context_name.t option
; diff_command : string option
; promote : Clflags.Promote.t option
; force : bool
Expand All @@ -43,13 +43,13 @@ type t =
; store_orig_src_dir : bool
; (* Original arguments for the external-lib-deps hint *)
orig_args : string list
; config : Dune.Config.t
; config : Dune_engine.Config.t
; default_target : Arg.Dep.t (* For build & runtest only *)
; watch : bool
; stats_trace_file : string option
; always_show_command_line : bool
; promote_install_files : bool
; instrument_with : Dune.Lib_name.t list option
; instrument_with : Dune_engine.Lib_name.t list option
}

let workspace_file t = t.workspace_file
Expand Down Expand Up @@ -102,7 +102,7 @@ let set_common_other ?log_file c ~targets =
];
Clflags.always_show_command_line := c.always_show_command_line;
Clflags.ignore_promoted_rules := c.ignore_promoted_rules;
Option.iter ~f:Dune.Stats.enable c.stats_trace_file
Option.iter ~f:Dune_engine.Stats.enable c.stats_trace_file

let set_common ?log_file ?external_lib_deps_mode c ~targets =
Option.iter external_lib_deps_mode ~f:(fun x ->
Expand Down Expand Up @@ -272,7 +272,8 @@ module Options_implied_by_dash_p = struct
Arg.(
value
& opt dep
(Dep.alias ~dir:Stdune.Path.Local.root Dune.Alias.Name.default)
(Dep.alias ~dir:Stdune.Path.Local.root
Dune_engine.Alias.Name.default)
& info [ "default-target" ] ~docs ~docv:"TARGET"
~doc:
{|Set the default target that when none is specified to
Expand Down Expand Up @@ -305,7 +306,7 @@ module Options_implied_by_dash_p = struct
; config_file = No_config
; profile = Some Profile.Release
; default_target =
Arg.Dep.alias_rec ~dir:Path.Local.root Dune.Alias.Name.install
Arg.Dep.alias_rec ~dir:Path.Local.root Dune_engine.Alias.Name.install
; always_show_command_line = true
; promote_install_files = true
}
Expand Down Expand Up @@ -385,7 +386,7 @@ module Options_implied_by_dash_p = struct
(Printf.sprintf
"Select the build profile, for instance $(b,dev) or \
$(b,release). The default is $(b,%s)."
(Profile.to_string Dune.Profile.default)))
(Profile.to_string Dune_rules.Profile.default)))
in
match profile with
| None -> t
Expand Down Expand Up @@ -424,10 +425,11 @@ let term =
let arg =
Arg.conv
( (fun s ->
Result.map_error (Dune.Config.Concurrency.of_string s) ~f:(fun s ->
`Msg s))
Result.map_error (Dune_engine.Config.Concurrency.of_string s)
~f:(fun s -> `Msg s))
, fun pp x ->
Format.pp_print_string pp (Dune.Config.Concurrency.to_string x) )
Format.pp_print_string pp
(Dune_engine.Config.Concurrency.to_string x) )
in
Arg.(
value
Expand All @@ -438,10 +440,10 @@ let term =
let arg =
Arg.conv
( (fun s ->
Result.map_error (Dune.Sandbox_mode.of_string s) ~f:(fun s ->
Result.map_error (Dune_engine.Sandbox_mode.of_string s) ~f:(fun s ->
`Msg s))
, fun pp x -> Format.pp_print_string pp (Dune.Sandbox_mode.to_string x)
)
, fun pp x ->
Format.pp_print_string pp (Dune_engine.Sandbox_mode.to_string x) )
in
Arg.(
value
Expand All @@ -457,8 +459,8 @@ let term =
certain sandboxing mode, so they will ignore this setting. The \
allowed values are: %s."
(String.concat ~sep:", "
(List.map Dune.Sandbox_mode.all
~f:Dune.Sandbox_mode.to_string))))
(List.map Dune_engine.Sandbox_mode.all
~f:Dune_engine.Sandbox_mode.to_string))))
and+ debug_dep_path =
Arg.(
value & flag
Expand Down Expand Up @@ -713,5 +715,5 @@ let config_term =
let context_arg ~doc =
Arg.(
value
& opt Arg.context_name Dune.Context_name.default
& opt Arg.context_name Dune_engine.Context_name.default
& info [ "context" ] ~docv:"CONTEXT" ~doc)
16 changes: 8 additions & 8 deletions bin/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ type t

val workspace_file : t -> Arg.Path.t option

val x : t -> Dune.Context_name.t option
val x : t -> Dune_engine.Context_name.t option

val profile : t -> Dune.Profile.t option
val profile : t -> Dune_rules.Profile.t option

val capture_outputs : t -> bool

val root : t -> Workspace_root.t

val config : t -> Dune.Config.t
val config : t -> Dune_engine.Config.t

module Only_packages : sig
type t =
{ names : Dune.Package.Name.Set.t
{ names : Dune_engine.Package.Name.Set.t
; command_line_option : string
(** Which of [-p], [--only-packages], ... was passed *)
}
Expand All @@ -28,7 +28,7 @@ val default_target : t -> Arg.Dep.t

val prefix_target : t -> string -> string

val instrument_with : t -> Dune.Lib_name.t list option
val instrument_with : t -> Dune_engine.Lib_name.t list option

(** [set_common ?log common ~targets ~external_lib_deps_mode] is
[set_dirs common] followed by [set_common_other common ~targets]. In
Expand Down Expand Up @@ -60,11 +60,11 @@ val footer : Cmdliner.Manpage.block

val term : t Cmdliner.Term.t

val config_term : Dune.Config.t Cmdliner.Term.t
val config_term : Dune_engine.Config.t Cmdliner.Term.t

val display_term : Dune.Config.Display.t option Cmdliner.Term.t
val display_term : Dune_engine.Config.Display.t option Cmdliner.Term.t

val context_arg : doc:string -> Dune.Context_name.t Cmdliner.Term.t
val context_arg : doc:string -> Dune_engine.Context_name.t Cmdliner.Term.t

(** A [--build-info] command line argument that print build information
(included in [term]) *)
Expand Down
Loading

0 comments on commit 6d83f12

Please sign in to comment.