Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 289 lines (243 sloc) 9.35 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
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 (**
120 [load filename content code]
121 check the validity of the 'Package' declarations from the code, and removes them
122 loads the dependency of the given code, and update the current package
123 It check the existence of .opx but doesn't load anything
124 *)
125 val load :
126 ?extrajs:string list ->
127 no_stdlib:bool ->
128 ('code_elt -> ([< `declaration | `import ] * package_name * FilePos.pos) option) ->
129 ('code_elt list -> float option StringMap.t) ->
130 'code_elt parsed_code ->
131 ('code_elt parsed_code -> unit) ->
132 unit
133
134 (**
135 Fold on all the dependencies of the current package in the order of dependencies
136 @param packages when [true], also fold on the packages that are linked
137 default is [false]
138 @param deep when [true], fold on the transitive dependencies
139 default is [false]
140 [filename] is the name of the directory containing all the information about the package
141 (stdlib.core.opx for instance)
142 *)
143 val fold_dir : ?packages:bool -> ?deep:bool -> ('a -> filename -> 'a) -> 'a -> 'a
144 val fold_dir_name : ?packages:bool -> ?deep:bool -> ('a -> filename -> package -> 'a) -> 'a -> 'a
145 val fold_name : ?packages:bool -> ?deep:bool -> ('a -> package -> 'a) -> 'a -> 'a
146 val iter_dir : ?packages:bool -> ?deep:bool -> (filename -> unit) -> unit
147 val iter_dir_name : ?packages:bool -> ?deep:bool -> (filename -> package -> unit) -> unit
148 val iter_name : ?packages:bool -> ?deep:bool -> (package -> unit) -> unit
149
150 (**
151 What the passes that need object files provide
152 [t] is the type t to be stored
153 [pass] is just the name of the pass
154 The type t is going to be marshalled, so you may need to be refresh
155 them when you load them
156 *)
157 module type S =
158 sig
159 type t
160 val pass : string (* don't use wierd chars in here, it will be a filename *)
161 val pp : Format.formatter -> t -> unit
162 end
163
164 (**
165 What the following functor provides:
166 [save] saves the given object in the current package
167 [fold] to get the content of the object files
168 *)
169 (* could avoid the functorization *)
170 (* actual loading happens lazily, not at functor application *)
171 module type R =
172 sig
173 type 'a wrapper
174 type t
175
176 (**
177 All the iteration functions take the parameter and iterate in the same order
178 as [fold_dir].
179
180 packages: packages linked in the command line only
181 deep: transitive dependencies
182 *)
183
184 val iter_with_name : (?packages:bool -> ?deep:bool -> (package -> t -> unit) -> unit) wrapper
185 val fold_with_name : (?packages:bool -> ?deep:bool -> (package -> 'acc -> t -> 'acc) -> 'acc -> 'acc) wrapper
186 val iter_with_dir : (?packages:bool -> ?deep:bool -> (filename -> t -> unit) -> unit) wrapper
187 val fold_with_dir : (?packages:bool -> ?deep:bool -> (filename -> 'a -> t -> 'a) -> 'a -> 'a) wrapper
188 val iter : (?packages:bool -> ?deep:bool -> (t -> unit) -> unit) wrapper
189 val fold : (?packages:bool -> ?deep:bool -> ('acc -> t -> 'acc) -> 'acc -> 'acc) wrapper
190
191 (**
192 Save the current information to the disk
193 Only the information about the current package should be saved, not the
194 whole environment that results from merging the environment of the dependencies with
195 the current environment
196 *)
197 val save : (t -> unit) wrapper
198 end
199
200 module Make : functor (S:S) -> R with type t = S.t and type 'a wrapper = 'a
201
202 (** same as Make but with Client/Server variant *)
203 module MakeClientServer : functor (S:S) -> R with type t = S.t and type 'a wrapper = side:[`client | `server] -> 'a
204
205 (**
206 Compilation mode.
207 Used as a global imperative state of the compiler.
208 Set by the arg parser, and then, read by any pass which need to select its process
209 according to the current mode.
210 *)
211 type compilation_mode = [
212 | `prelude
213 | `init
214 | `linking
215 | `compilation
216 ]
217
218 (** Returns the current compilation mode. *)
219 val compilation_mode : unit -> compilation_mode
220
221 module Arg :
222 sig
223 (**
224 Concatenation of all specs in interaction with this module.
225
226 + [-c] Compile the current package
227 + [--package] Add package for linking.
228 *)
229 val public_options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
230 val private_options : (Base.Arg.key * Base.Arg.spec * Base.Arg.doc) list
231
232 (**
233 Since the anonfun of the compiler may add directly packages to link with,
234 the function add_link_package is also exported.
235 This is possible to call opa with a few opx files, for relinking.
236 *)
237 val add_link_package : filename -> unit
238
239 (**
240 Used by the pass_CheckOptions to know if there is nothing to do.
241 *)
242 val no_packages : unit -> bool
243
244 (**
245 Used by some passes in the transitional period,
246 or for some tests, or qmljs in command line.
247 *)
248 val is_separated : unit -> bool
249
250 (** same as above *)
251 val is_fully_separated : unit -> bool
252
253 (**
254 Option used for producing some dependencies graphs.
255 *)
256 val is_opadep : unit -> bool
257 end
258
259 (**
260 {5 Warnings}
261 *)
262 val warning_set : WarningClass.Set.t
263
264
265 (**
266 The packages that contain values that the compiler can call
267 *)
268 val stdlib_packages : package -> bool
269 val stdlib_package_names : package_name -> bool
270
271 (**
272 Loads the js extra lib with the given basename
273 *)
274 val find_js_file_content_digest : basename -> filename * content * hash
275
276 (**
277 Used by the rest of the compiler to tells objectFiles
278 that the current package has been compiled successfully
279 and so must not be deleted
280 *)
281 val compilation_is_successfull : unit -> unit
282
283 (**
284 Turn off separated compilation.
285 This function should be used only by tools not using a separated compilation at all,
286 and not using the standard Arg of this module.
287 *)
288 val turn_separated_off : unit -> unit
Something went wrong with that request. Please try again.