Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 307 lines (256 sloc) 9.719 kB
fccc685 Initial open-source release
MLstate authored
1 (*
0bc807e @OpaOnWindowsNow [feature] compiler,options: --conf-opa-files, use opa files from the …
OpaOnWindowsNow authored
2 Copyright © 2011, 2012 MLstate
fccc685 Initial open-source release
MLstate authored
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**)
19
20 (**
21 Type alias for lisibility.
22 *)
23 type package_name = string (* foo *)
24 type package = package_name * FilePos.pos
25 type filename = string (* path/foo.opx *)
26 type basename = string (* foo.opx *)
27 type hash = string
28 type content = string
29
30 type 'code_elt parsed_code = (filename * content * 'code_elt list) list
31
32 module Package :
33 sig
34 type t = package
35 val compare : t -> t -> int
36 val equal : t -> t -> bool
37
38 (**
39 Prints the name of the package
40 *)
41 val pp : Format.formatter -> package -> unit
42
43 (**
44 Prints the name of the package and its position
45 (the position where the package was imported)
46 *)
47 val pp_full : Format.formatter -> package -> unit
48 end
49 module PackageTbl : Hashtbl.S with type key = Package.t
50
51 (** {6 Current package} *)
52 (**
53 Get informations about the current packages being compiling.
54 If linking mode, or not separated mode, returns informations
55 of a dummy linking_packages, with an ["", nopos]
56 *)
57
58 val get_current_package : unit -> package
59 val get_current_package_name : unit -> package_name
60
61 (**
62 These two functions returns are injections from package to string
63 (ie there are no collisions) that 'remove' specials characters
64 that may appears in package names but that are not valid in js/caml
65 *)
66 val get_current_package_name_as_a_valid_ident : ?will_be_prefixed:bool -> unit -> string
67 val get_package_name_as_a_valid_ident : ?will_be_prefixed:bool -> package_name -> string
68 val get_package_as_a_valid_ident : ?will_be_prefixed:bool -> package -> string
69
70 (**
71 Not for casual user. Should be called only by the corresponding pass.
72 *)
73 val end_of_separate_compilation : unit -> unit
74 val global_compilation : unit -> bool (** true if we are not separated or if we are after the end of separate compilation *)
75 val last_pass : string
76 val no_init : bool ref (* used by qmlCompilers because it links but doesn't init *)
77
78 (**
79 Get the opx directory corresponding to the compilation of the current package.
80 If we are in linking mode, or if the separation mode is not activated, the
81 function returns [None]
82 *)
83 val get_compilation_directory : unit -> filename option
84 val get_compilation_directory_or_current_dir : unit -> filename
85
86 (**
87 Set extra paths, from the -I command line options
88 *)
89 val set_extrapaths : no_stdlib:bool -> filename list -> unit
90
91 (**
8371716 @BourgerieQuentin [fix] plugins: Install and searching
BourgerieQuentin authored
92 Get all paths where the compiler should search its objects
93 *)
94 val get_paths : unit -> filename list
95
96 (**
fccc685 Initial open-source release
MLstate authored
97 Set plugins version, from the loaded plugins
98 *)
99 val set_bsl_plugins : (basename * hash) list -> unit
100
101 (**
4692879 @OpaOnWindowsNow [feature] Internationalisation: add @i18n directive and start support…
OpaOnWindowsNow authored
102 test existence of a package given known or given extrapath
103 *)
104 val exists_package : ?extrapath:string list -> string -> bool
105
106 (**
fccc685 Initial open-source release
MLstate authored
107 expand syntax of import directives, for package or plugins
108 *)
109 val expand_glob :
110 ?mode:[`package|`plugin] -> Package.t list -> (package_name * FilePos.pos) -> Package.t list
111
112 (**
113 [load_conf filename] load the configuration of packaging architecture
114 for the current project. Used with --autobuild option, this may speed-up
115 refactoring and packaging of big projects.
116 *)
117 val load_conf : filename -> unit
118
119 (**
0bc807e @OpaOnWindowsNow [feature] compiler,options: --conf-opa-files, use opa files from the …
OpaOnWindowsNow authored
120 [conf_opa_files ()] returns all opa file present the loaded conf files
121 *)
122 val conf_opa_files : unit -> filename list
123
124 (**
fccc685 Initial open-source release
MLstate authored
125 [load filename content code]
126 check the validity of the 'Package' declarations from the code, and removes them
127 loads the dependency of the given code, and update the current package
128 It check the existence of .opx but doesn't load anything
129 *)
130 val load :
131 ?extrajs:string list ->
132 no_stdlib:bool ->
133 ('code_elt -> ([< `declaration | `import ] * package_name * FilePos.pos) option) ->
134 ('code_elt list -> float option StringMap.t) ->
135 'code_elt parsed_code ->
136 ('code_elt parsed_code -> unit) ->
137 unit
138
139 (**
140 Fold on all the dependencies of the current package in the order of dependencies
141 @param packages when [true], also fold on the packages that are linked
142 default is [false]
143 @param deep when [true], fold on the transitive dependencies
144 default is [false]
145 [filename] is the name of the directory containing all the information about the package
146 (stdlib.core.opx for instance)
147 *)
148 val fold_dir : ?packages:bool -> ?deep:bool -> ('a -> filename -> 'a) -> 'a -> 'a
149 val fold_dir_name : ?packages:bool -> ?deep:bool -> ('a -> filename -> package -> 'a) -> 'a -> 'a
150 val fold_name : ?packages:bool -> ?deep:bool -> ('a -> package -> 'a) -> 'a -> 'a
151 val iter_dir : ?packages:bool -> ?deep:bool -> (filename -> unit) -> unit
152 val iter_dir_name : ?packages:bool -> ?deep:bool -> (filename -> package -> unit) -> unit
153 val iter_name : ?packages:bool -> ?deep:bool -> (package -> unit) -> unit
154
155 (**
156 What the passes that need object files provide
157 [t] is the type t to be stored
158 [pass] is just the name of the pass
159 The type t is going to be marshalled, so you may need to be refresh
160 them when you load them
161 *)
162 module type S =
163 sig
164 type t
165 val pass : string (* don't use wierd chars in here, it will be a filename *)
166 val pp : Format.formatter -> t -> unit
167 end
168
169 (**
170 What the following functor provides:
171 [save] saves the given object in the current package
172 [fold] to get the content of the object files
173 *)
174 (* could avoid the functorization *)
175 (* actual loading happens lazily, not at functor application *)
176 module type R =
177 sig
178 type 'a wrapper
179 type t
180
181 (**
182 All the iteration functions take the parameter and iterate in the same order
183 as [fold_dir].
184
185 packages: packages linked in the command line only
186 deep: transitive dependencies
187 *)
188
189 val iter_with_name : (?packages:bool -> ?deep:bool -> (package -> t -> unit) -> unit) wrapper
190 val fold_with_name : (?packages:bool -> ?deep:bool -> (package -> 'acc -> t -> 'acc) -> 'acc -> 'acc) wrapper
191 val iter_with_dir : (?packages:bool -> ?deep:bool -> (filename -> t -> unit) -> unit) wrapper
192 val fold_with_dir : (?packages:bool -> ?deep:bool -> (filename -> 'a -> t -> 'a) -> 'a -> 'a) wrapper
193 val iter : (?packages:bool -> ?deep:bool -> (t -> unit) -> unit) wrapper
194 val fold : (?packages:bool -> ?deep:bool -> ('acc -> t -> 'acc) -> 'acc -> 'acc) wrapper
195
196 (**
197 Save the current information to the disk
198 Only the information about the current package should be saved, not the
199 whole environment that results from merging the environment of the dependencies with
200 the current environment
201 *)
202 val save : (t -> unit) wrapper
203 end
204
205 module Make : functor (S:S) -> R with type t = S.t and type 'a wrapper = 'a
206
207 (** same as Make but with Client/Server variant *)
208 module MakeClientServer : functor (S:S) -> R with type t = S.t and type 'a wrapper = side:[`client | `server] -> 'a
209
210 (**
211 Compilation mode.
212 Used as a global imperative state of the compiler.
213 Set by the arg parser, and then, read by any pass which need to select its process
214 according to the current mode.
215 *)
216 type compilation_mode = [
217 | `prelude
218 | `init
219 | `linking
220 | `compilation
221 ]
222
223 (** Returns the current compilation mode. *)
224 val compilation_mode : unit -> compilation_mode
225
226 module Arg :
227 sig
228 (**
229 Concatenation of all specs in interaction with this module.
230
231 + [-c] Compile the current package
232 + [--package] Add package for linking.
233 *)
234 val public_options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
235 val private_options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
236
237 (**
238 Since the anonfun of the compiler may add directly packages to link with,
239 the function add_link_package is also exported.
240 This is possible to call opa with a few opx files, for relinking.
241 *)
242 val add_link_package : filename -> unit
243
244 (**
245 Used by the pass_CheckOptions to know if there is nothing to do.
246 *)
247 val no_packages : unit -> bool
248
249 (**
250 Used by some passes in the transitional period,
251 or for some tests, or qmljs in command line.
252 *)
253 val is_separated : unit -> bool
254
255 (** same as above *)
256 val is_fully_separated : unit -> bool
257
258 (**
259 Option used for producing some dependencies graphs.
260 *)
261 val is_opadep : unit -> bool
262 end
263
264 (**
265 {5 Warnings}
266 *)
267 val warning_set : WarningClass.Set.t
268
269
270 (**
271 The packages that contain values that the compiler can call
272 *)
273 val stdlib_packages : package -> bool
274 val stdlib_package_names : package_name -> bool
275
5242af3 @BourgerieQuentin [enhance] compiler: Add compiler packages (Import packages that not p…
BourgerieQuentin authored
276
277 val compiler_package : package -> bool
278
fccc685 Initial open-source release
MLstate authored
279 (**
280 Loads the js extra lib with the given basename
281 *)
282 val find_js_file_content_digest : basename -> filename * content * hash
283
284 (**
285 Used by the rest of the compiler to tells objectFiles
286 that the current package has been compiled successfully
287 and so must not be deleted
288 *)
289 val compilation_is_successfull : unit -> unit
290
291 (**
292 Turn off separated compilation.
293 This function should be used only by tools not using a separated compilation at all,
294 and not using the standard Arg of this module.
295 *)
296 val turn_separated_off : unit -> unit
2ca2730 @BourgerieQuentin [feature] compilerlib: ObjectFiles.import_package (force a package im…
BourgerieQuentin authored
297
298 (**
299 Force a package importation.
300 *)
5242af3 @BourgerieQuentin [enhance] compiler: Add compiler packages (Import packages that not p…
BourgerieQuentin authored
301 val import_package : package_name -> FilePos.pos -> unit
302
303 (**
304 Use given package as a compiler package.
305 *)
306 val add_compiler_package : package_name -> unit
Something went wrong with that request. Please try again.