Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 639 lines (511 sloc) 17.842 kb
47d44c3 @andrenth Initial commit
authored
1 (* OASIS_START *)
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
2 (* DO NOT EDIT (digest: 86e024a67a1fb2bc4a26b080ccc6740e) *)
1ada56b @andrenth Add autogenerated oasis stuff
authored
3 module OASISGettext = struct
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
4 (* # 22 "src/oasis/OASISGettext.ml" *)
959aa5f @andrenth Regen oasis stuff
authored
5
e695b6b @andrenth Upgrade to Oasis 0.3
authored
6
7 let ns_ str =
1ada56b @andrenth Add autogenerated oasis stuff
authored
8 str
e695b6b @andrenth Upgrade to Oasis 0.3
authored
9
959aa5f @andrenth Regen oasis stuff
authored
10
e695b6b @andrenth Upgrade to Oasis 0.3
authored
11 let s_ str =
1ada56b @andrenth Add autogenerated oasis stuff
authored
12 str
e695b6b @andrenth Upgrade to Oasis 0.3
authored
13
959aa5f @andrenth Regen oasis stuff
authored
14
15 let f_ (str: ('a, 'b, 'c, 'd) format4) =
1ada56b @andrenth Add autogenerated oasis stuff
authored
16 str
e695b6b @andrenth Upgrade to Oasis 0.3
authored
17
959aa5f @andrenth Regen oasis stuff
authored
18
1ada56b @andrenth Add autogenerated oasis stuff
authored
19 let fn_ fmt1 fmt2 n =
20 if n = 1 then
21 fmt1^^""
22 else
23 fmt2^^""
e695b6b @andrenth Upgrade to Oasis 0.3
authored
24
959aa5f @andrenth Regen oasis stuff
authored
25
e695b6b @andrenth Upgrade to Oasis 0.3
authored
26 let init =
1ada56b @andrenth Add autogenerated oasis stuff
authored
27 []
e695b6b @andrenth Upgrade to Oasis 0.3
authored
28
959aa5f @andrenth Regen oasis stuff
authored
29
1ada56b @andrenth Add autogenerated oasis stuff
authored
30 end
31
32 module OASISExpr = struct
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
33 (* # 22 "src/oasis/OASISExpr.ml" *)
959aa5f @andrenth Regen oasis stuff
authored
34
35
e695b6b @andrenth Upgrade to Oasis 0.3
authored
36
37
38
1ada56b @andrenth Add autogenerated oasis stuff
authored
39 open OASISGettext
e695b6b @andrenth Upgrade to Oasis 0.3
authored
40
959aa5f @andrenth Regen oasis stuff
authored
41
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
42 type test = string
e695b6b @andrenth Upgrade to Oasis 0.3
authored
43
959aa5f @andrenth Regen oasis stuff
authored
44
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
45 type flag = string
e695b6b @andrenth Upgrade to Oasis 0.3
authored
46
959aa5f @andrenth Regen oasis stuff
authored
47
1ada56b @andrenth Add autogenerated oasis stuff
authored
48 type t =
49 | EBool of bool
50 | ENot of t
51 | EAnd of t * t
52 | EOr of t * t
53 | EFlag of flag
54 | ETest of test * string
e695b6b @andrenth Upgrade to Oasis 0.3
authored
55
959aa5f @andrenth Regen oasis stuff
authored
56
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
57
58 type 'a choices = (t * 'a) list
e695b6b @andrenth Upgrade to Oasis 0.3
authored
59
959aa5f @andrenth Regen oasis stuff
authored
60
1ada56b @andrenth Add autogenerated oasis stuff
authored
61 let eval var_get t =
e695b6b @andrenth Upgrade to Oasis 0.3
authored
62 let rec eval' =
1ada56b @andrenth Add autogenerated oasis stuff
authored
63 function
64 | EBool b ->
65 b
e695b6b @andrenth Upgrade to Oasis 0.3
authored
66
67 | ENot e ->
1ada56b @andrenth Add autogenerated oasis stuff
authored
68 not (eval' e)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
69
1ada56b @andrenth Add autogenerated oasis stuff
authored
70 | EAnd (e1, e2) ->
71 (eval' e1) && (eval' e2)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
72
73 | EOr (e1, e2) ->
1ada56b @andrenth Add autogenerated oasis stuff
authored
74 (eval' e1) || (eval' e2)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
75
1ada56b @andrenth Add autogenerated oasis stuff
authored
76 | EFlag nm ->
77 let v =
78 var_get nm
79 in
80 assert(v = "true" || v = "false");
81 (v = "true")
e695b6b @andrenth Upgrade to Oasis 0.3
authored
82
1ada56b @andrenth Add autogenerated oasis stuff
authored
83 | ETest (nm, vl) ->
84 let v =
85 var_get nm
86 in
87 (v = vl)
88 in
89 eval' t
e695b6b @andrenth Upgrade to Oasis 0.3
authored
90
959aa5f @andrenth Regen oasis stuff
authored
91
1ada56b @andrenth Add autogenerated oasis stuff
authored
92 let choose ?printer ?name var_get lst =
e695b6b @andrenth Upgrade to Oasis 0.3
authored
93 let rec choose_aux =
1ada56b @andrenth Add autogenerated oasis stuff
authored
94 function
95 | (cond, vl) :: tl ->
e695b6b @andrenth Upgrade to Oasis 0.3
authored
96 if eval var_get cond then
97 vl
1ada56b @andrenth Add autogenerated oasis stuff
authored
98 else
99 choose_aux tl
100 | [] ->
e695b6b @andrenth Upgrade to Oasis 0.3
authored
101 let str_lst =
1ada56b @andrenth Add autogenerated oasis stuff
authored
102 if lst = [] then
103 s_ "<empty>"
104 else
e695b6b @andrenth Upgrade to Oasis 0.3
authored
105 String.concat
1ada56b @andrenth Add autogenerated oasis stuff
authored
106 (s_ ", ")
107 (List.map
108 (fun (cond, vl) ->
109 match printer with
110 | Some p -> p vl
111 | None -> s_ "<no printer>")
112 lst)
113 in
e695b6b @andrenth Upgrade to Oasis 0.3
authored
114 match name with
1ada56b @andrenth Add autogenerated oasis stuff
authored
115 | Some nm ->
116 failwith
e695b6b @andrenth Upgrade to Oasis 0.3
authored
117 (Printf.sprintf
1ada56b @andrenth Add autogenerated oasis stuff
authored
118 (f_ "No result for the choice list '%s': %s")
119 nm str_lst)
120 | None ->
121 failwith
122 (Printf.sprintf
123 (f_ "No result for a choice list: %s")
124 str_lst)
125 in
126 choose_aux (List.rev lst)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
127
959aa5f @andrenth Regen oasis stuff
authored
128
1ada56b @andrenth Add autogenerated oasis stuff
authored
129 end
130
131
959aa5f @andrenth Regen oasis stuff
authored
132 # 132 "myocamlbuild.ml"
1ada56b @andrenth Add autogenerated oasis stuff
authored
133 module BaseEnvLight = struct
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
134 (* # 22 "src/base/BaseEnvLight.ml" *)
959aa5f @andrenth Regen oasis stuff
authored
135
e695b6b @andrenth Upgrade to Oasis 0.3
authored
136
1ada56b @andrenth Add autogenerated oasis stuff
authored
137 module MapString = Map.Make(String)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
138
959aa5f @andrenth Regen oasis stuff
authored
139
1ada56b @andrenth Add autogenerated oasis stuff
authored
140 type t = string MapString.t
e695b6b @andrenth Upgrade to Oasis 0.3
authored
141
959aa5f @andrenth Regen oasis stuff
authored
142
1ada56b @andrenth Add autogenerated oasis stuff
authored
143 let default_filename =
e695b6b @andrenth Upgrade to Oasis 0.3
authored
144 Filename.concat
1ada56b @andrenth Add autogenerated oasis stuff
authored
145 (Sys.getcwd ())
146 "setup.data"
e695b6b @andrenth Upgrade to Oasis 0.3
authored
147
959aa5f @andrenth Regen oasis stuff
authored
148
1ada56b @andrenth Add autogenerated oasis stuff
authored
149 let load ?(allow_empty=false) ?(filename=default_filename) () =
150 if Sys.file_exists filename then
151 begin
152 let chn =
153 open_in_bin filename
154 in
155 let st =
156 Stream.of_channel chn
157 in
158 let line =
159 ref 1
160 in
e695b6b @andrenth Upgrade to Oasis 0.3
authored
161 let st_line =
1ada56b @andrenth Add autogenerated oasis stuff
authored
162 Stream.from
163 (fun _ ->
164 try
e695b6b @andrenth Upgrade to Oasis 0.3
authored
165 match Stream.next st with
1ada56b @andrenth Add autogenerated oasis stuff
authored
166 | '\n' -> incr line; Some '\n'
167 | c -> Some c
168 with Stream.Failure -> None)
169 in
e695b6b @andrenth Upgrade to Oasis 0.3
authored
170 let lexer =
1ada56b @andrenth Add autogenerated oasis stuff
authored
171 Genlex.make_lexer ["="] st_line
172 in
173 let rec read_file mp =
e695b6b @andrenth Upgrade to Oasis 0.3
authored
174 match Stream.npeek 3 lexer with
1ada56b @andrenth Add autogenerated oasis stuff
authored
175 | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
e695b6b @andrenth Upgrade to Oasis 0.3
authored
176 Stream.junk lexer;
177 Stream.junk lexer;
1ada56b @andrenth Add autogenerated oasis stuff
authored
178 Stream.junk lexer;
179 read_file (MapString.add nm value mp)
180 | [] ->
181 mp
182 | _ ->
183 failwith
184 (Printf.sprintf
185 "Malformed data file '%s' line %d"
186 filename !line)
187 in
188 let mp =
189 read_file MapString.empty
190 in
191 close_in chn;
192 mp
193 end
194 else if allow_empty then
195 begin
196 MapString.empty
197 end
198 else
199 begin
e695b6b @andrenth Upgrade to Oasis 0.3
authored
200 failwith
201 (Printf.sprintf
1ada56b @andrenth Add autogenerated oasis stuff
authored
202 "Unable to load environment, the file '%s' doesn't exist."
203 filename)
204 end
e695b6b @andrenth Upgrade to Oasis 0.3
authored
205
959aa5f @andrenth Regen oasis stuff
authored
206
207 let rec var_expand str env =
208 let buff =
209 Buffer.create ((String.length str) * 2)
1ada56b @andrenth Add autogenerated oasis stuff
authored
210 in
959aa5f @andrenth Regen oasis stuff
authored
211 Buffer.add_substitute
212 buff
213 (fun var ->
214 try
215 var_expand (MapString.find var env) env
216 with Not_found ->
217 failwith
218 (Printf.sprintf
219 "No variable %s defined when trying to expand %S."
220 var
221 str))
222 str;
223 Buffer.contents buff
224
225
226 let var_get name env =
227 var_expand (MapString.find name env) env
228
e695b6b @andrenth Upgrade to Oasis 0.3
authored
229
230 let var_choose lst env =
1ada56b @andrenth Add autogenerated oasis stuff
authored
231 OASISExpr.choose
232 (fun nm -> var_get nm env)
233 lst
234 end
235
236
959aa5f @andrenth Regen oasis stuff
authored
237 # 237 "myocamlbuild.ml"
1ada56b @andrenth Add autogenerated oasis stuff
authored
238 module MyOCamlbuildFindlib = struct
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
239 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
240
959aa5f @andrenth Regen oasis stuff
authored
241
242 (** OCamlbuild extension, copied from
1ada56b @andrenth Add autogenerated oasis stuff
authored
243 * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
244 * by N. Pouillard and others
245 *
246 * Updated on 2009/02/28
247 *
959aa5f @andrenth Regen oasis stuff
authored
248 * Modified by Sylvain Le Gall
1ada56b @andrenth Add autogenerated oasis stuff
authored
249 *)
250 open Ocamlbuild_plugin
e695b6b @andrenth Upgrade to Oasis 0.3
authored
251
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
252 type conf =
253 { no_automatic_syntax: bool;
254 }
959aa5f @andrenth Regen oasis stuff
authored
255
1ada56b @andrenth Add autogenerated oasis stuff
authored
256 (* these functions are not really officially exported *)
959aa5f @andrenth Regen oasis stuff
authored
257 let run_and_read =
1ada56b @andrenth Add autogenerated oasis stuff
authored
258 Ocamlbuild_pack.My_unix.run_and_read
e695b6b @andrenth Upgrade to Oasis 0.3
authored
259
959aa5f @andrenth Regen oasis stuff
authored
260
261 let blank_sep_strings =
1ada56b @andrenth Add autogenerated oasis stuff
authored
262 Ocamlbuild_pack.Lexers.blank_sep_strings
e695b6b @andrenth Upgrade to Oasis 0.3
authored
263
959aa5f @andrenth Regen oasis stuff
authored
264
265 let exec_from_conf exec =
266 let exec =
267 let env_filename = Pathname.basename BaseEnvLight.default_filename in
268 let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in
269 try
270 BaseEnvLight.var_get exec env
271 with Not_found ->
272 Printf.eprintf "W: Cannot get variable %s\n" exec;
273 exec
274 in
275 let fix_win32 str =
276 if Sys.os_type = "Win32" then begin
277 let buff = Buffer.create (String.length str) in
278 (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'.
279 *)
280 String.iter
281 (fun c -> Buffer.add_char buff (if c = '\\' then '/' else c))
282 str;
283 Buffer.contents buff
284 end else begin
285 str
286 end
1ada56b @andrenth Add autogenerated oasis stuff
authored
287 in
959aa5f @andrenth Regen oasis stuff
authored
288 fix_win32 exec
289
290 let split s ch =
291 let buf = Buffer.create 13 in
292 let x = ref [] in
293 let flush () =
294 x := (Buffer.contents buf) :: !x;
295 Buffer.clear buf
1ada56b @andrenth Add autogenerated oasis stuff
authored
296 in
959aa5f @andrenth Regen oasis stuff
authored
297 String.iter
298 (fun c ->
299 if c = ch then
300 flush ()
301 else
302 Buffer.add_char buf c)
303 s;
304 flush ();
305 List.rev !x
306
e695b6b @andrenth Upgrade to Oasis 0.3
authored
307
1ada56b @andrenth Add autogenerated oasis stuff
authored
308 let split_nl s = split s '\n'
e695b6b @andrenth Upgrade to Oasis 0.3
authored
309
959aa5f @andrenth Regen oasis stuff
authored
310
1ada56b @andrenth Add autogenerated oasis stuff
authored
311 let before_space s =
312 try
313 String.before s (String.index s ' ')
314 with Not_found -> s
e695b6b @andrenth Upgrade to Oasis 0.3
authored
315
959aa5f @andrenth Regen oasis stuff
authored
316 (* ocamlfind command *)
317 let ocamlfind x = S[Sh (exec_from_conf "ocamlfind"); x]
318
319 (* This lists all supported packages. *)
1ada56b @andrenth Add autogenerated oasis stuff
authored
320 let find_packages () =
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
321 List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))
e695b6b @andrenth Upgrade to Oasis 0.3
authored
322
959aa5f @andrenth Regen oasis stuff
authored
323
324 (* Mock to list available syntaxes. *)
1ada56b @andrenth Add autogenerated oasis stuff
authored
325 let find_syntaxes () = ["camlp4o"; "camlp4r"]
e695b6b @andrenth Upgrade to Oasis 0.3
authored
326
959aa5f @andrenth Regen oasis stuff
authored
327
328 let well_known_syntax = [
329 "camlp4.quotations.o";
330 "camlp4.quotations.r";
331 "camlp4.exceptiontracer";
332 "camlp4.extend";
333 "camlp4.foldgenerator";
334 "camlp4.listcomprehension";
335 "camlp4.locationstripper";
336 "camlp4.macro";
337 "camlp4.mapgenerator";
338 "camlp4.metagenerator";
339 "camlp4.profiler";
340 "camlp4.tracer"
341 ]
342
e695b6b @andrenth Upgrade to Oasis 0.3
authored
343
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
344 let dispatch conf =
1ada56b @andrenth Add autogenerated oasis stuff
authored
345 function
959aa5f @andrenth Regen oasis stuff
authored
346 | After_options ->
347 (* By using Before_options one let command line options have an higher
348 * priority on the contrary using After_options will guarantee to have
349 * the higher priority override default commands by ocamlfind ones *)
1ada56b @andrenth Add autogenerated oasis stuff
authored
350 Options.ocamlc := ocamlfind & A"ocamlc";
351 Options.ocamlopt := ocamlfind & A"ocamlopt";
352 Options.ocamldep := ocamlfind & A"ocamldep";
353 Options.ocamldoc := ocamlfind & A"ocamldoc";
959aa5f @andrenth Regen oasis stuff
authored
354 Options.ocamlmktop := ocamlfind & A"ocamlmktop";
355 Options.ocamlmklib := ocamlfind & A"ocamlmklib"
356
1ada56b @andrenth Add autogenerated oasis stuff
authored
357 | After_rules ->
959aa5f @andrenth Regen oasis stuff
authored
358
359 (* When one link an OCaml library/binary/package, one should use
360 * -linkpkg *)
1ada56b @andrenth Add autogenerated oasis stuff
authored
361 flag ["ocaml"; "link"; "program"] & A"-linkpkg";
959aa5f @andrenth Regen oasis stuff
authored
362
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
363 if not (conf.no_automatic_syntax) then begin
364 (* For each ocamlfind package one inject the -package option when
365 * compiling, computing dependencies, generating documentation and
366 * linking. *)
367 List.iter
368 begin fun pkg ->
369 let base_args = [A"-package"; A pkg] in
370 (* TODO: consider how to really choose camlp4o or camlp4r. *)
371 let syn_args = [A"-syntax"; A "camlp4o"] in
372 let (args, pargs) =
373 (* Heuristic to identify syntax extensions: whether they end in
374 ".syntax"; some might not.
375 *)
376 if Filename.check_suffix pkg "syntax" ||
377 List.mem pkg well_known_syntax then
378 (syn_args @ base_args, syn_args)
379 else
380 (base_args, [])
381 in
382 flag ["ocaml"; "compile"; "pkg_"^pkg] & S args;
383 flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args;
384 flag ["ocaml"; "doc"; "pkg_"^pkg] & S args;
385 flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args;
386 flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args;
387
388 (* TODO: Check if this is allowed for OCaml < 3.12.1 *)
389 flag ["ocaml"; "compile"; "package("^pkg^")"] & S pargs;
390 flag ["ocaml"; "ocamldep"; "package("^pkg^")"] & S pargs;
391 flag ["ocaml"; "doc"; "package("^pkg^")"] & S pargs;
392 flag ["ocaml"; "infer_interface"; "package("^pkg^")"] & S pargs;
393 end
394 (find_packages ());
395 end;
e695b6b @andrenth Upgrade to Oasis 0.3
authored
396
1ada56b @andrenth Add autogenerated oasis stuff
authored
397 (* Like -package but for extensions syntax. Morover -syntax is useless
398 * when linking. *)
399 List.iter begin fun syntax ->
400 flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
401 flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
402 flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
959aa5f @andrenth Regen oasis stuff
authored
403 flag ["ocaml"; "infer_interface"; "syntax_"^syntax] &
404 S[A"-syntax"; A syntax];
1ada56b @andrenth Add autogenerated oasis stuff
authored
405 end (find_syntaxes ());
e695b6b @andrenth Upgrade to Oasis 0.3
authored
406
1ada56b @andrenth Add autogenerated oasis stuff
authored
407 (* The default "thread" tag is not compatible with ocamlfind.
408 * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
409 * options when using this tag. When using the "-linkpkg" option with
410 * ocamlfind, this module will then be added twice on the command line.
959aa5f @andrenth Regen oasis stuff
authored
411 *
1ada56b @andrenth Add autogenerated oasis stuff
authored
412 * To solve this, one approach is to add the "-thread" option when using
413 * the "threads" package using the previous plugin.
414 *)
415 flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
e695b6b @andrenth Upgrade to Oasis 0.3
authored
416 flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
1ada56b @andrenth Add autogenerated oasis stuff
authored
417 flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
959aa5f @andrenth Regen oasis stuff
authored
418 flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]);
419 flag ["ocaml"; "package(threads)"; "compile"] (S[A "-thread"]);
420 flag ["ocaml"; "package(threads)"; "doc"] (S[A "-I"; A "+threads"]);
421 flag ["ocaml"; "package(threads)"; "link"] (S[A "-thread"]);
422 flag ["ocaml"; "package(threads)"; "infer_interface"] (S[A "-thread"]);
e695b6b @andrenth Upgrade to Oasis 0.3
authored
423
959aa5f @andrenth Regen oasis stuff
authored
424 | _ ->
1ada56b @andrenth Add autogenerated oasis stuff
authored
425 ()
426 end
427
428 module MyOCamlbuildBase = struct
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
429 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
959aa5f @andrenth Regen oasis stuff
authored
430
e695b6b @andrenth Upgrade to Oasis 0.3
authored
431
1ada56b @andrenth Add autogenerated oasis stuff
authored
432 (** Base functions for writing myocamlbuild.ml
433 @author Sylvain Le Gall
434 *)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
435
436
437
959aa5f @andrenth Regen oasis stuff
authored
438
439
1ada56b @andrenth Add autogenerated oasis stuff
authored
440 open Ocamlbuild_plugin
e695b6b @andrenth Upgrade to Oasis 0.3
authored
441 module OC = Ocamlbuild_pack.Ocaml_compiler
442
959aa5f @andrenth Regen oasis stuff
authored
443
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
444 type dir = string
445 type file = string
446 type name = string
447 type tag = string
e695b6b @andrenth Upgrade to Oasis 0.3
authored
448
959aa5f @andrenth Regen oasis stuff
authored
449
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
450 (* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
959aa5f @andrenth Regen oasis stuff
authored
451
e695b6b @andrenth Upgrade to Oasis 0.3
authored
452
1ada56b @andrenth Add autogenerated oasis stuff
authored
453 type t =
454 {
959aa5f @andrenth Regen oasis stuff
authored
455 lib_ocaml: (name * dir list * string list) list;
456 lib_c: (name * dir * file list) list;
1ada56b @andrenth Add autogenerated oasis stuff
authored
457 flags: (tag list * (spec OASISExpr.choices)) list;
e695b6b @andrenth Upgrade to Oasis 0.3
authored
458 (* Replace the 'dir: include' from _tags by a precise interdepends in
459 * directory.
460 *)
959aa5f @andrenth Regen oasis stuff
authored
461 includes: (dir * dir list) list;
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
462 }
e695b6b @andrenth Upgrade to Oasis 0.3
authored
463
959aa5f @andrenth Regen oasis stuff
authored
464
1ada56b @andrenth Add autogenerated oasis stuff
authored
465 let env_filename =
959aa5f @andrenth Regen oasis stuff
authored
466 Pathname.basename
1ada56b @andrenth Add autogenerated oasis stuff
authored
467 BaseEnvLight.default_filename
e695b6b @andrenth Upgrade to Oasis 0.3
authored
468
959aa5f @andrenth Regen oasis stuff
authored
469
1ada56b @andrenth Add autogenerated oasis stuff
authored
470 let dispatch_combine lst =
471 fun e ->
959aa5f @andrenth Regen oasis stuff
authored
472 List.iter
1ada56b @andrenth Add autogenerated oasis stuff
authored
473 (fun dispatch -> dispatch e)
959aa5f @andrenth Regen oasis stuff
authored
474 lst
475
e695b6b @andrenth Upgrade to Oasis 0.3
authored
476
477 let tag_libstubs nm =
478 "use_lib"^nm^"_stubs"
479
959aa5f @andrenth Regen oasis stuff
authored
480
e695b6b @andrenth Upgrade to Oasis 0.3
authored
481 let nm_libstubs nm =
482 nm^"_stubs"
483
959aa5f @andrenth Regen oasis stuff
authored
484
485 let dispatch t e =
486 let env =
487 BaseEnvLight.load
488 ~filename:env_filename
1ada56b @andrenth Add autogenerated oasis stuff
authored
489 ~allow_empty:true
490 ()
491 in
959aa5f @andrenth Regen oasis stuff
authored
492 match e with
1ada56b @andrenth Add autogenerated oasis stuff
authored
493 | Before_options ->
494 let no_trailing_dot s =
495 if String.length s >= 1 && s.[0] = '.' then
496 String.sub s 1 ((String.length s) - 1)
497 else
498 s
499 in
500 List.iter
501 (fun (opt, var) ->
959aa5f @andrenth Regen oasis stuff
authored
502 try
1ada56b @andrenth Add autogenerated oasis stuff
authored
503 opt := no_trailing_dot (BaseEnvLight.var_get var env)
504 with Not_found ->
959aa5f @andrenth Regen oasis stuff
authored
505 Printf.eprintf "W: Cannot get variable %s\n" var)
1ada56b @andrenth Add autogenerated oasis stuff
authored
506 [
507 Options.ext_obj, "ext_obj";
508 Options.ext_lib, "ext_lib";
509 Options.ext_dll, "ext_dll";
510 ]
e695b6b @andrenth Upgrade to Oasis 0.3
authored
511
959aa5f @andrenth Regen oasis stuff
authored
512 | After_rules ->
1ada56b @andrenth Add autogenerated oasis stuff
authored
513 (* Declare OCaml libraries *)
959aa5f @andrenth Regen oasis stuff
authored
514 List.iter
1ada56b @andrenth Add autogenerated oasis stuff
authored
515 (function
959aa5f @andrenth Regen oasis stuff
authored
516 | nm, [], intf_modules ->
517 ocaml_lib nm;
518 let cmis =
519 List.map (fun m -> (String.uncapitalize m) ^ ".cmi")
520 intf_modules in
521 dep ["ocaml"; "link"; "library"; "file:"^nm^".cma"] cmis
522 | nm, dir :: tl, intf_modules ->
e695b6b @andrenth Upgrade to Oasis 0.3
authored
523 ocaml_lib ~dir:dir (dir^"/"^nm);
959aa5f @andrenth Regen oasis stuff
authored
524 List.iter
525 (fun dir ->
e695b6b @andrenth Upgrade to Oasis 0.3
authored
526 List.iter
527 (fun str ->
528 flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir]))
529 ["compile"; "infer_interface"; "doc"])
959aa5f @andrenth Regen oasis stuff
authored
530 tl;
531 let cmis =
532 List.map (fun m -> dir^"/"^(String.uncapitalize m)^".cmi")
533 intf_modules in
534 dep ["ocaml"; "link"; "library"; "file:"^dir^"/"^nm^".cma"]
535 cmis)
1ada56b @andrenth Add autogenerated oasis stuff
authored
536 t.lib_ocaml;
e695b6b @andrenth Upgrade to Oasis 0.3
authored
537
538 (* Declare directories dependencies, replace "include" in _tags. *)
959aa5f @andrenth Regen oasis stuff
authored
539 List.iter
e695b6b @andrenth Upgrade to Oasis 0.3
authored
540 (fun (dir, include_dirs) ->
541 Pathname.define_context dir include_dirs)
542 t.includes;
543
1ada56b @andrenth Add autogenerated oasis stuff
authored
544 (* Declare C libraries *)
545 List.iter
546 (fun (lib, dir, headers) ->
547 (* Handle C part of library *)
e695b6b @andrenth Upgrade to Oasis 0.3
authored
548 flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib]
549 (S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib";
550 A("-l"^(nm_libstubs lib))]);
551
552 flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib]
553 (S[A"-cclib"; A("-l"^(nm_libstubs lib))]);
959aa5f @andrenth Regen oasis stuff
authored
554
e695b6b @andrenth Upgrade to Oasis 0.3
authored
555 flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
556 (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
557
1ada56b @andrenth Add autogenerated oasis stuff
authored
558 (* When ocaml link something that use the C library, then one
559 need that file to be up to date.
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
560 This holds both for programs and for libraries.
1ada56b @andrenth Add autogenerated oasis stuff
authored
561 *)
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
562 dep ["link"; "ocaml"; tag_libstubs lib]
563 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
e695b6b @andrenth Upgrade to Oasis 0.3
authored
564
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
565 dep ["compile"; "ocaml"; tag_libstubs lib]
566 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
e695b6b @andrenth Upgrade to Oasis 0.3
authored
567
1ada56b @andrenth Add autogenerated oasis stuff
authored
568 (* TODO: be more specific about what depends on headers *)
569 (* Depends on .h files *)
959aa5f @andrenth Regen oasis stuff
authored
570 dep ["compile"; "c"]
1ada56b @andrenth Add autogenerated oasis stuff
authored
571 headers;
e695b6b @andrenth Upgrade to Oasis 0.3
authored
572
1ada56b @andrenth Add autogenerated oasis stuff
authored
573 (* Setup search path for lib *)
959aa5f @andrenth Regen oasis stuff
authored
574 flag ["link"; "ocaml"; "use_"^lib]
1ada56b @andrenth Add autogenerated oasis stuff
authored
575 (S[A"-I"; P(dir)]);
576 )
577 t.lib_c;
e695b6b @andrenth Upgrade to Oasis 0.3
authored
578
1ada56b @andrenth Add autogenerated oasis stuff
authored
579 (* Add flags *)
580 List.iter
581 (fun (tags, cond_specs) ->
959aa5f @andrenth Regen oasis stuff
authored
582 let spec = BaseEnvLight.var_choose cond_specs env in
583 let rec eval_specs =
584 function
585 | S lst -> S (List.map eval_specs lst)
586 | A str -> A (BaseEnvLight.var_expand str env)
587 | spec -> spec
1ada56b @andrenth Add autogenerated oasis stuff
authored
588 in
959aa5f @andrenth Regen oasis stuff
authored
589 flag tags & (eval_specs spec))
1ada56b @andrenth Add autogenerated oasis stuff
authored
590 t.flags
959aa5f @andrenth Regen oasis stuff
authored
591 | _ ->
1ada56b @andrenth Add autogenerated oasis stuff
authored
592 ()
e695b6b @andrenth Upgrade to Oasis 0.3
authored
593
959aa5f @andrenth Regen oasis stuff
authored
594
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
595 let dispatch_default conf t =
959aa5f @andrenth Regen oasis stuff
authored
596 dispatch_combine
1ada56b @andrenth Add autogenerated oasis stuff
authored
597 [
598 dispatch t;
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
599 MyOCamlbuildFindlib.dispatch conf;
1ada56b @andrenth Add autogenerated oasis stuff
authored
600 ]
e695b6b @andrenth Upgrade to Oasis 0.3
authored
601
959aa5f @andrenth Regen oasis stuff
authored
602
1ada56b @andrenth Add autogenerated oasis stuff
authored
603 end
604
605
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
606 # 606 "myocamlbuild.ml"
1ada56b @andrenth Add autogenerated oasis stuff
authored
607 open Ocamlbuild_plugin;;
608 let package_default =
609 {
f510f1c @andrenth Add configuration file support via Release_config
authored
610 MyOCamlbuildBase.lib_ocaml =
486125a @andrenth Add async library
authored
611 [
3e412d2 @andrenth Rename lib/core to lib/release
authored
612 ("release", ["lib/release"], []);
486125a @andrenth Add async library
authored
613 ("release-async", ["lib/async"], []);
614 ("release-lwt", ["lib/lwt"], [])
615 ];
01480c3 @andrenth Switch to extunix now that it has setres[ug]id
authored
616 lib_c = [];
1ada56b @andrenth Add autogenerated oasis stuff
authored
617 flags = [];
486125a @andrenth Add async library
authored
618 includes =
619 [
b1fbd01 @andrenth Reorganize tests
authored
620 ("lib_test/lwt/config", ["lib/lwt"]);
621 ("lib_test/lwt", ["lib/lwt"]);
622 ("lib_test/async/config", ["lib/async"]);
623 ("lib_test/async", ["lib/async"]);
3e412d2 @andrenth Rename lib/core to lib/release
authored
624 ("lib/lwt", ["lib/release"]);
625 ("lib/async", ["lib/release"])
486125a @andrenth Add async library
authored
626 ]
959aa5f @andrenth Regen oasis stuff
authored
627 }
1ada56b @andrenth Add autogenerated oasis stuff
authored
628 ;;
629
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
630 let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
631
632 let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
1ada56b @andrenth Add autogenerated oasis stuff
authored
633
636cbff @andrenth Require Lwt 2.4.6 as 2.4.7 breaks socketpair
authored
634 # 635 "myocamlbuild.ml"
47d44c3 @andrenth Initial commit
authored
635 (* OASIS_STOP *)
636 (*flag ["ocaml"; "compile"; "ppopt_lwt_debug"] & S[A"-ppopt"; A"-lwt-debug"];*)
637 flag ["ocaml"; "compile"; "warn_error"] & S[A"-warn-error"; A"A"];
638 Ocamlbuild_plugin.dispatch dispatch_default;;
Something went wrong with that request. Please try again.