forked from ocaml/opam
/
types.mli
311 lines (217 loc) · 7.41 KB
/
types.mli
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
(***********************************************************************)
(* *)
(* Copyright 2012 OCamlPro *)
(* Copyright 2012 INRIA *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Public License version 3.0. *)
(* *)
(* TypeRex is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU General Public License for more details. *)
(* *)
(***********************************************************************)
(** The OPAM types and then main function which operates on them. *)
(** {2 Abstract types} *)
(** All abstract types should implement this signature *)
module type Abstract = sig
(** Abstract type *)
type t
(** Create an abstract value from a string *)
val of_string: string -> t
(** Convert an abstract value to a string *)
val to_string: t -> string
(** Collection of abstract values *)
module Set: Set.S with type elt = t
(** Dictionaries of abstract values *)
module Map: Map.S with type key = t
end
(** {2 Filenames} *)
(** Absolute directory names *)
module Dirname: sig
include Abstract
(** Remove a directory *)
val rmdir: t -> unit
(** Create a directory *)
val mkdir: t -> unit
(** Execute a list of commands in a given directory *)
val exec: t -> string list -> int
(** Change the current directory *)
val chdir: t -> unit
end
(** Shortcut to directory type *)
type dirname = Dirname.t
(** Concatenate a directory and a string *)
val (/): dirname -> string -> dirname
(** Basenames *)
module Basename: Abstract
(** Shortcut to basename type *)
type basename = Basename.t
(** Raw file contents *)
module Raw: Abstract
(** Shortcut to raw file content type *)
type raw = Raw.t
(** Stdlib [Filename] module *)
module Stdlib_filename: sig
val concat: string -> string -> string
end
(** non-directory filenames *)
module Filename: sig
include Abstract
(** Create a filename from a dirname and a basename *)
val create: dirname -> basename -> t
(** Return the directory name *)
val dirname: t -> dirname
(** Retrieves the contents from the hard disk. *)
val read: t -> Raw.t
(** Removes everything in [filename] if existed. *)
val remove: t -> unit
(** Removes everything in [filename] if existed, then write [contents] instead. *)
val write: t -> Raw.t -> unit
(** see [Sys.file_exists] *)
val exists: t -> bool
(** Check whether a file has a given suffix *)
val check_suffix: t -> string -> bool
(** Remove the file suffix *)
val add_extension: t -> string -> t
(** List all the filenames (ie. which are not directories) in a directory *)
val list: dirname -> t list
(** Apply a function on the contents of a file *)
val with_raw: (Raw.t -> 'a) -> t -> 'a
(** Copy a file in a directory *)
val copy_in: t -> dirname -> unit
(** Symlink a file in a directory *)
val link_in: t -> dirname -> unit
(** Copy a file *)
val copy: t -> t -> unit
(** Symlink a file. If symlink is not possible on the system, use copy instead. *)
val link: t -> t -> unit
(** Extract an archive in a given directory (it rewrites the root to
match [dirname] dir if needed) *)
val extract: t -> dirname -> unit
end
(** Shortcut to file names *)
type filename = Filename.t
(** Concatenate a directory and a string to create a filename *)
val (//): dirname -> string -> filename
(** {2 Package name and versions} *)
(** Versions *)
module V: Abstract
(** Shortcut to V.t *)
type version = V.t
(** Names *)
module N: Abstract
(** Shortcut to N.t *)
type name = N.t
(** Package (name x version) pairs *)
module NV: sig
include Abstract
(** Return the package name *)
val name: t -> name
(** Return the version name *)
val version: t -> version
(** Create a new pair (name x version) *)
val create: name -> version -> t
(** Create a new pair from a filename. This function extracts {i
$name} and {i $version} from {i /path/to/$name.$version.XXX}
with various heuristics.*)
val of_filename: filename -> t option
(** Create a new pair from a debian package *)
val of_dpkg: Debian.Packages.package -> t
(** Create a new pair from a cudf package *)
val of_cudf: Debian.Debcudf.tables -> Cudf.package -> t
(** Convert a set of pairs to a map [name -> versions] *)
val to_map: Set.t -> V.Set.t N.Map.t
(** Convert a set of pairs to a string *)
val string_of_set: Set.t -> string
end
(** Shortcut to NV.t *)
type nv = NV.t
(** OCaml version *)
module OCaml_V: Abstract
(** OPAM version *)
module OPAM_V: Abstract
(** {2 Repositories} *)
(** OPAM repositories *)
module Repository: sig
include Abstract
(** Create a repository *)
val create: name:string -> kind:string -> address:string -> t
(** Default repository *)
val default: t
(** Get the repository name *)
val name: t -> string
(** Get the repository kind *)
val kind: t -> string
(** Get the repository address *)
val address: t -> string
end
(** Shortcut to repository type *)
type repository = Repository.t
(** {2 Variable names} *)
(** Variable names are used in .config files *)
module Variable: Abstract
(** Shortcut to variable type *)
type variable = Variable.t
(** Section names *)
module Section: Abstract
(** Shortcut to section names *)
type section = Section.t
(** Fully qualified variables *)
module Full_variable: sig
include Abstract
(** Create a variable local for a given library/syntax extension *)
val create_local: name -> section -> variable -> t
(** Create a global variable for a package *)
val create_global: name -> variable -> t
(** Return the package the variable is defined in *)
val package: t -> name
(** Return the section (library or syntax extension) the package is
defined in *)
val section: t -> section option
(** Return the variable name *)
val variable: t -> variable
end
(** Shortcut to fully qualified variables *)
type full_variable = Full_variable.t
(** Content of user-defined variables *)
type variable_contents =
| B of bool
| S of string
(** Convert the content of a variable to a string *)
val string_of_variable_contents: variable_contents -> string
(** {2 Command line arguments} *)
(** Upload arguments *)
type upload = {
opam : filename;
descr : filename;
archive: filename;
}
(** Pretty-print *)
val string_of_upload: upload -> string
(** Remote arguments *)
type remote =
| List
| Add of string
| Rm of string
(** Pretty-print *)
val string_of_remote: remote -> string
(** Configuration requests *)
type config_option =
| Includes of name list
| Bytecomp of (name * string) list
| Asmcomp of (name * string) list
| Bytelink of (name * string) list
| Asmlink of (name * string) list
type rec_config_option = {
recursive: bool;
options : config_option;
}
type config =
| List_vars
| Variable of full_variable
| Compil of rec_config_option
| Subst of filename list
(** Pretty-print *)
val string_of_config: config -> string