forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsub_system_intf.ml
116 lines (92 loc) · 2.93 KB
/
sub_system_intf.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
open! Stdune
open! Import
module type Info = Dune_file.Sub_system_info.S
module type S = sig
module Info : Info
(** Instantiated representation of the sub-system. I.e. with names
resolved using a library database. *)
type t
(** Create an instance of the sub-system *)
val instantiate
: resolve:(Loc.t * Lib_name.t -> Lib.t Or_exn.t)
-> get:(loc:Loc.t -> Lib.t -> t option)
-> Lib.t
-> Info.t
-> t
end
(** A backend, for implementors of the sub-system *)
module type Backend = sig
include S
(** Description of a backend, such as "inline tests framework" or
"ppx driver". *)
val desc : plural:bool -> string
(** "a" or "an" *)
val desc_article : string
(** Library the backend is attached to *)
val lib : t -> Lib.t
(** Dump the sub-system configuration. This is used to generate META
files. *)
val encode : t -> Syntax.Version.t * Dune_lang.t
end
module type Registered_backend = sig
type t
val get : Lib.t -> t option
(** Resolve a backend name *)
val resolve : Lib.DB.t -> Loc.t * Lib_name.t -> t Or_exn.t
module Selection_error : sig
type nonrec t =
| Too_many_backends of t list
| No_backend_found
| Other of exn
val to_exn : t -> loc:Loc.t -> exn
val or_exn : ('a, t) result -> loc:Loc.t -> 'a Or_exn.t
end
(** Choose a backend by either using the ones written by the user or
by scanning the dependencies.
The returned list is sorted by order of dependencies. It is not
allowed to have two different backend that are completely
independent, i.e. none of them is in the transitive closure of
the other one. *)
val select_extensible_backends
: ?written_by_user:t list
-> extends:(t -> t list Or_exn.t)
-> Lib.t list
-> (t list, Selection_error.t) result
(** Choose a backend by either using the ones written by the user or
by scanning the dependencies.
A backend can replace other backends *)
val select_replaceable_backend
: ?written_by_user:t list
-> replaces:(t -> t list Or_exn.t)
-> Lib.t list
-> (t, Selection_error.t) result
end
(* This is probably what we'll give to plugins *)
module Library_compilation_context = struct
type t =
{ super_context : Super_context.t
; dir : Path.t
; stanza : Dune_file.Library.t
; scope : Scope.t
; source_modules : Module.t Module.Name.Map.t
; compile_info : Lib.Compile.t
}
end
(** An end-point, for users of the systems *)
module type End_point = sig
module Backend : sig
include Registered_backend
(** Backends that this backends extends *)
val extends : t -> t list Or_exn.t
end
module Info : sig
include Info
(** Additional backends specified by the user at use-site *)
val backends : t -> (Loc.t * Lib_name.t) list option
end
val gen_rules
: Library_compilation_context.t
-> info:Info.t
-> backends:Backend.t list
-> unit
end