Revision 04e26a3f
Added by Xavier Thirioux almost 9 years ago
myocamlbuild.ml | ||
---|---|---|
1 | 1 |
(* OASIS_START *) |
2 |
(* DO NOT EDIT (digest: 7eabc0106cad87d67c960d9a2ff80b28) *)
|
|
2 |
(* DO NOT EDIT (digest: 00359f2e15a7ed8f31f1d7ce086345f9) *)
|
|
3 | 3 |
module OASISGettext = struct |
4 |
# 21 "/build/buildd/oasis-0.2.0/src/oasis/OASISGettext.ml"
|
|
5 |
|
|
6 |
let ns_ str =
|
|
4 |
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISGettext.ml" *)
|
|
5 |
|
|
6 |
let ns_ str = |
|
7 | 7 |
str |
8 |
|
|
9 |
let s_ str =
|
|
8 |
|
|
9 |
let s_ str = |
|
10 | 10 |
str |
11 |
|
|
11 |
|
|
12 | 12 |
let f_ (str : ('a, 'b, 'c, 'd) format4) = |
13 | 13 |
str |
14 |
|
|
14 |
|
|
15 | 15 |
let fn_ fmt1 fmt2 n = |
16 | 16 |
if n = 1 then |
17 | 17 |
fmt1^^"" |
18 | 18 |
else |
19 | 19 |
fmt2^^"" |
20 |
|
|
21 |
let init =
|
|
20 |
|
|
21 |
let init = |
|
22 | 22 |
[] |
23 |
|
|
23 |
|
|
24 | 24 |
end |
25 | 25 |
|
26 | 26 |
module OASISExpr = struct |
27 |
# 21 "/build/buildd/oasis-0.2.0/src/oasis/OASISExpr.ml"
|
|
28 |
|
|
29 |
|
|
30 |
|
|
27 |
(* # 21 "/build/buildd/oasis-0.3.0/src/oasis/OASISExpr.ml" *)
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 | 31 |
open OASISGettext |
32 |
|
|
32 |
|
|
33 | 33 |
type test = string |
34 |
|
|
34 |
|
|
35 | 35 |
type flag = string |
36 |
|
|
36 |
|
|
37 | 37 |
type t = |
38 | 38 |
| EBool of bool |
39 | 39 |
| ENot of t |
... | ... | |
42 | 42 |
| EFlag of flag |
43 | 43 |
| ETest of test * string |
44 | 44 |
|
45 |
|
|
45 |
|
|
46 | 46 |
type 'a choices = (t * 'a) list |
47 |
|
|
47 |
|
|
48 | 48 |
let eval var_get t = |
49 |
let rec eval' =
|
|
49 |
let rec eval' = |
|
50 | 50 |
function |
51 | 51 |
| EBool b -> |
52 | 52 |
b |
53 |
|
|
54 |
| ENot e ->
|
|
53 |
|
|
54 |
| ENot e -> |
|
55 | 55 |
not (eval' e) |
56 |
|
|
56 |
|
|
57 | 57 |
| EAnd (e1, e2) -> |
58 | 58 |
(eval' e1) && (eval' e2) |
59 |
|
|
60 |
| EOr (e1, e2) ->
|
|
59 |
|
|
60 |
| EOr (e1, e2) -> |
|
61 | 61 |
(eval' e1) || (eval' e2) |
62 |
|
|
62 |
|
|
63 | 63 |
| EFlag nm -> |
64 | 64 |
let v = |
65 | 65 |
var_get nm |
66 | 66 |
in |
67 | 67 |
assert(v = "true" || v = "false"); |
68 | 68 |
(v = "true") |
69 |
|
|
69 |
|
|
70 | 70 |
| ETest (nm, vl) -> |
71 | 71 |
let v = |
72 | 72 |
var_get nm |
... | ... | |
74 | 74 |
(v = vl) |
75 | 75 |
in |
76 | 76 |
eval' t |
77 |
|
|
77 |
|
|
78 | 78 |
let choose ?printer ?name var_get lst = |
79 |
let rec choose_aux =
|
|
79 |
let rec choose_aux = |
|
80 | 80 |
function |
81 | 81 |
| (cond, vl) :: tl -> |
82 |
if eval var_get cond then
|
|
83 |
vl
|
|
82 |
if eval var_get cond then |
|
83 |
vl |
|
84 | 84 |
else |
85 | 85 |
choose_aux tl |
86 | 86 |
| [] -> |
87 |
let str_lst =
|
|
87 |
let str_lst = |
|
88 | 88 |
if lst = [] then |
89 | 89 |
s_ "<empty>" |
90 | 90 |
else |
91 |
String.concat
|
|
91 |
String.concat |
|
92 | 92 |
(s_ ", ") |
93 | 93 |
(List.map |
94 | 94 |
(fun (cond, vl) -> |
... | ... | |
97 | 97 |
| None -> s_ "<no printer>") |
98 | 98 |
lst) |
99 | 99 |
in |
100 |
match name with
|
|
100 |
match name with |
|
101 | 101 |
| Some nm -> |
102 | 102 |
failwith |
103 |
(Printf.sprintf
|
|
103 |
(Printf.sprintf |
|
104 | 104 |
(f_ "No result for the choice list '%s': %s") |
105 | 105 |
nm str_lst) |
106 | 106 |
| None -> |
... | ... | |
110 | 110 |
str_lst) |
111 | 111 |
in |
112 | 112 |
choose_aux (List.rev lst) |
113 |
|
|
113 |
|
|
114 | 114 |
end |
115 | 115 |
|
116 | 116 |
|
117 |
# 117 "myocamlbuild.ml" |
|
117 | 118 |
module BaseEnvLight = struct |
118 |
# 21 "/build/buildd/oasis-0.2.0/src/base/BaseEnvLight.ml"
|
|
119 |
|
|
119 |
(* # 21 "/build/buildd/oasis-0.3.0/src/base/BaseEnvLight.ml" *)
|
|
120 |
|
|
120 | 121 |
module MapString = Map.Make(String) |
121 |
|
|
122 |
|
|
122 | 123 |
type t = string MapString.t |
123 |
|
|
124 |
|
|
124 | 125 |
let default_filename = |
125 |
Filename.concat
|
|
126 |
Filename.concat |
|
126 | 127 |
(Sys.getcwd ()) |
127 | 128 |
"setup.data" |
128 |
|
|
129 |
|
|
129 | 130 |
let load ?(allow_empty=false) ?(filename=default_filename) () = |
130 | 131 |
if Sys.file_exists filename then |
131 | 132 |
begin |
... | ... | |
138 | 139 |
let line = |
139 | 140 |
ref 1 |
140 | 141 |
in |
141 |
let st_line =
|
|
142 |
let st_line = |
|
142 | 143 |
Stream.from |
143 | 144 |
(fun _ -> |
144 | 145 |
try |
145 |
match Stream.next st with
|
|
146 |
match Stream.next st with |
|
146 | 147 |
| '\n' -> incr line; Some '\n' |
147 | 148 |
| c -> Some c |
148 | 149 |
with Stream.Failure -> None) |
149 | 150 |
in |
150 |
let lexer =
|
|
151 |
let lexer = |
|
151 | 152 |
Genlex.make_lexer ["="] st_line |
152 | 153 |
in |
153 | 154 |
let rec read_file mp = |
154 |
match Stream.npeek 3 lexer with
|
|
155 |
match Stream.npeek 3 lexer with |
|
155 | 156 |
| [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] -> |
156 |
Stream.junk lexer;
|
|
157 |
Stream.junk lexer;
|
|
157 |
Stream.junk lexer; |
|
158 |
Stream.junk lexer; |
|
158 | 159 |
Stream.junk lexer; |
159 | 160 |
read_file (MapString.add nm value mp) |
160 | 161 |
| [] -> |
... | ... | |
177 | 178 |
end |
178 | 179 |
else |
179 | 180 |
begin |
180 |
failwith
|
|
181 |
(Printf.sprintf
|
|
181 |
failwith |
|
182 |
(Printf.sprintf |
|
182 | 183 |
"Unable to load environment, the file '%s' doesn't exist." |
183 | 184 |
filename) |
184 | 185 |
end |
185 |
|
|
186 |
|
|
186 | 187 |
let var_get name env = |
187 | 188 |
let rec var_expand str = |
188 | 189 |
let buff = |
189 | 190 |
Buffer.create ((String.length str) * 2) |
190 | 191 |
in |
191 |
Buffer.add_substitute
|
|
192 |
Buffer.add_substitute |
|
192 | 193 |
buff |
193 |
(fun var ->
|
|
194 |
try
|
|
194 |
(fun var -> |
|
195 |
try |
|
195 | 196 |
var_expand (MapString.find var env) |
196 | 197 |
with Not_found -> |
197 |
failwith
|
|
198 |
(Printf.sprintf
|
|
198 |
failwith |
|
199 |
(Printf.sprintf |
|
199 | 200 |
"No variable %s defined when trying to expand %S." |
200 |
var
|
|
201 |
var |
|
201 | 202 |
str)) |
202 | 203 |
str; |
203 | 204 |
Buffer.contents buff |
204 | 205 |
in |
205 | 206 |
var_expand (MapString.find name env) |
206 |
|
|
207 |
let var_choose lst env =
|
|
207 |
|
|
208 |
let var_choose lst env = |
|
208 | 209 |
OASISExpr.choose |
209 | 210 |
(fun nm -> var_get nm env) |
210 | 211 |
lst |
211 | 212 |
end |
212 | 213 |
|
213 | 214 |
|
215 |
# 215 "myocamlbuild.ml" |
|
214 | 216 |
module MyOCamlbuildFindlib = struct |
215 |
# 21 "/build/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
|
|
216 |
|
|
217 |
(* # 21 "/build/buildd/oasis-0.3.0/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
|
|
218 |
|
|
217 | 219 |
(** OCamlbuild extension, copied from |
218 | 220 |
* http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild |
219 | 221 |
* by N. Pouillard and others |
... | ... | |
223 | 225 |
* Modified by Sylvain Le Gall |
224 | 226 |
*) |
225 | 227 |
open Ocamlbuild_plugin |
226 |
|
|
228 |
|
|
227 | 229 |
(* these functions are not really officially exported *) |
228 | 230 |
let run_and_read = |
229 | 231 |
Ocamlbuild_pack.My_unix.run_and_read |
230 |
|
|
232 |
|
|
231 | 233 |
let blank_sep_strings = |
232 | 234 |
Ocamlbuild_pack.Lexers.blank_sep_strings |
233 |
|
|
235 |
|
|
234 | 236 |
let split s ch = |
235 | 237 |
let x = |
236 | 238 |
ref [] |
... | ... | |
245 | 247 |
try |
246 | 248 |
go s |
247 | 249 |
with Not_found -> !x |
248 |
|
|
250 |
|
|
249 | 251 |
let split_nl s = split s '\n' |
250 |
|
|
252 |
|
|
251 | 253 |
let before_space s = |
252 | 254 |
try |
253 | 255 |
String.before s (String.index s ' ') |
254 | 256 |
with Not_found -> s |
255 |
|
|
257 |
|
|
256 | 258 |
(* this lists all supported packages *) |
257 | 259 |
let find_packages () = |
258 | 260 |
List.map before_space (split_nl & run_and_read "ocamlfind list") |
259 |
|
|
261 |
|
|
260 | 262 |
(* this is supposed to list available syntaxes, but I don't know how to do it. *) |
261 | 263 |
let find_syntaxes () = ["camlp4o"; "camlp4r"] |
262 |
|
|
264 |
|
|
263 | 265 |
(* ocamlfind command *) |
264 | 266 |
let ocamlfind x = S[A"ocamlfind"; x] |
265 |
|
|
267 |
|
|
266 | 268 |
let dispatch = |
267 | 269 |
function |
268 | 270 |
| Before_options -> |
... | ... | |
292 | 294 |
flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg]; |
293 | 295 |
end |
294 | 296 |
(find_packages ()); |
295 |
|
|
297 |
|
|
296 | 298 |
(* Like -package but for extensions syntax. Morover -syntax is useless |
297 | 299 |
* when linking. *) |
298 | 300 |
List.iter begin fun syntax -> |
... | ... | |
301 | 303 |
flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; |
302 | 304 |
flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; |
303 | 305 |
end (find_syntaxes ()); |
304 |
|
|
306 |
|
|
305 | 307 |
(* The default "thread" tag is not compatible with ocamlfind. |
306 | 308 |
* Indeed, the default rules add the "threads.cma" or "threads.cmxa" |
307 | 309 |
* options when using this tag. When using the "-linkpkg" option with |
... | ... | |
311 | 313 |
* the "threads" package using the previous plugin. |
312 | 314 |
*) |
313 | 315 |
flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]); |
316 |
flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]); |
|
314 | 317 |
flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]); |
315 | 318 |
flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]) |
316 |
|
|
319 |
|
|
317 | 320 |
| _ -> |
318 | 321 |
() |
319 |
|
|
322 |
|
|
320 | 323 |
end |
321 | 324 |
|
322 | 325 |
module MyOCamlbuildBase = struct |
323 |
# 21 "/build/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
|
|
324 |
|
|
326 |
(* # 21 "/build/buildd/oasis-0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
|
|
327 |
|
|
325 | 328 |
(** Base functions for writing myocamlbuild.ml |
326 | 329 |
@author Sylvain Le Gall |
327 | 330 |
*) |
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
331 | 334 |
open Ocamlbuild_plugin |
332 |
|
|
335 |
module OC = Ocamlbuild_pack.Ocaml_compiler |
|
336 |
|
|
333 | 337 |
type dir = string |
334 | 338 |
type file = string |
335 | 339 |
type name = string |
336 | 340 |
type tag = string |
337 |
|
|
338 |
# 55 "/build/buildd/oasis-0.2.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
|
|
339 |
|
|
341 |
|
|
342 |
(* # 56 "/build/buildd/oasis-0.3.0/src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
|
|
343 |
|
|
340 | 344 |
type t = |
341 | 345 |
{ |
342 | 346 |
lib_ocaml: (name * dir list) list; |
343 | 347 |
lib_c: (name * dir * file list) list; |
344 | 348 |
flags: (tag list * (spec OASISExpr.choices)) list; |
349 |
(* Replace the 'dir: include' from _tags by a precise interdepends in |
|
350 |
* directory. |
|
351 |
*) |
|
352 |
includes: (dir * dir list) list; |
|
345 | 353 |
} |
346 |
|
|
354 |
|
|
347 | 355 |
let env_filename = |
348 | 356 |
Pathname.basename |
349 | 357 |
BaseEnvLight.default_filename |
350 |
|
|
358 |
|
|
351 | 359 |
let dispatch_combine lst = |
352 | 360 |
fun e -> |
353 | 361 |
List.iter |
354 | 362 |
(fun dispatch -> dispatch e) |
355 | 363 |
lst |
356 |
|
|
364 |
|
|
365 |
let tag_libstubs nm = |
|
366 |
"use_lib"^nm^"_stubs" |
|
367 |
|
|
368 |
let nm_libstubs nm = |
|
369 |
nm^"_stubs" |
|
370 |
|
|
357 | 371 |
let dispatch t e = |
358 | 372 |
let env = |
359 | 373 |
BaseEnvLight.load |
... | ... | |
380 | 394 |
Options.ext_lib, "ext_lib"; |
381 | 395 |
Options.ext_dll, "ext_dll"; |
382 | 396 |
] |
383 |
|
|
397 |
|
|
384 | 398 |
| After_rules -> |
385 | 399 |
(* Declare OCaml libraries *) |
386 | 400 |
List.iter |
387 | 401 |
(function |
388 |
| lib, [] ->
|
|
389 |
ocaml_lib lib;
|
|
390 |
| lib, dir :: tl ->
|
|
391 |
ocaml_lib ~dir:dir lib;
|
|
402 |
| nm, [] ->
|
|
403 |
ocaml_lib nm
|
|
404 |
| nm, dir :: tl ->
|
|
405 |
ocaml_lib ~dir:dir (dir^"/"^nm);
|
|
392 | 406 |
List.iter |
393 | 407 |
(fun dir -> |
394 |
flag |
|
395 |
["ocaml"; "use_"^lib; "compile"] |
|
396 |
(S[A"-I"; P dir])) |
|
408 |
List.iter |
|
409 |
(fun str -> |
|
410 |
flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir])) |
|
411 |
["compile"; "infer_interface"; "doc"]) |
|
397 | 412 |
tl) |
398 | 413 |
t.lib_ocaml; |
399 |
|
|
414 |
|
|
415 |
(* Declare directories dependencies, replace "include" in _tags. *) |
|
416 |
List.iter |
|
417 |
(fun (dir, include_dirs) -> |
|
418 |
Pathname.define_context dir include_dirs) |
|
419 |
t.includes; |
|
420 |
|
|
400 | 421 |
(* Declare C libraries *) |
401 | 422 |
List.iter |
402 | 423 |
(fun (lib, dir, headers) -> |
403 | 424 |
(* Handle C part of library *) |
404 |
flag ["link"; "library"; "ocaml"; "byte"; "use_lib"^lib] |
|
405 |
(S[A"-dllib"; A("-l"^lib); A"-cclib"; A("-l"^lib)]); |
|
406 |
|
|
407 |
flag ["link"; "library"; "ocaml"; "native"; "use_lib"^lib] |
|
408 |
(S[A"-cclib"; A("-l"^lib)]); |
|
425 |
flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib] |
|
426 |
(S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib"; |
|
427 |
A("-l"^(nm_libstubs lib))]); |
|
428 |
|
|
429 |
flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib] |
|
430 |
(S[A"-cclib"; A("-l"^(nm_libstubs lib))]); |
|
409 | 431 |
|
410 |
flag ["link"; "program"; "ocaml"; "byte"; "use_lib"^lib]
|
|
411 |
(S[A"-dllib"; A("dll"^lib)]);
|
|
412 |
|
|
432 |
flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
|
|
433 |
(S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
|
|
434 |
|
|
413 | 435 |
(* When ocaml link something that use the C library, then one |
414 | 436 |
need that file to be up to date. |
415 | 437 |
*) |
416 |
dep ["link"; "ocaml"; "use_lib"^lib] |
|
417 |
[dir/"lib"^lib^"."^(!Options.ext_lib)]; |
|
418 |
|
|
438 |
dep ["link"; "ocaml"; "program"; tag_libstubs lib] |
|
439 |
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; |
|
440 |
|
|
441 |
dep ["compile"; "ocaml"; "program"; tag_libstubs lib] |
|
442 |
[dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; |
|
443 |
|
|
419 | 444 |
(* TODO: be more specific about what depends on headers *) |
420 | 445 |
(* Depends on .h files *) |
421 | 446 |
dep ["compile"; "c"] |
422 | 447 |
headers; |
423 |
|
|
448 |
|
|
424 | 449 |
(* Setup search path for lib *) |
425 | 450 |
flag ["link"; "ocaml"; "use_"^lib] |
426 | 451 |
(S[A"-I"; P(dir)]); |
427 | 452 |
) |
428 | 453 |
t.lib_c; |
429 |
|
|
454 |
|
|
430 | 455 |
(* Add flags *) |
431 | 456 |
List.iter |
432 | 457 |
(fun (tags, cond_specs) -> |
... | ... | |
437 | 462 |
t.flags |
438 | 463 |
| _ -> |
439 | 464 |
() |
440 |
|
|
465 |
|
|
441 | 466 |
let dispatch_default t = |
442 | 467 |
dispatch_combine |
443 | 468 |
[ |
444 | 469 |
dispatch t; |
445 | 470 |
MyOCamlbuildFindlib.dispatch; |
446 | 471 |
] |
447 |
|
|
472 |
|
|
448 | 473 |
end |
449 | 474 |
|
450 | 475 |
|
476 |
# 476 "myocamlbuild.ml" |
|
451 | 477 |
open Ocamlbuild_plugin;; |
452 | 478 |
let package_default = |
453 |
{MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; } |
|
479 |
{MyOCamlbuildBase.lib_ocaml = []; lib_c = []; flags = []; includes = []; }
|
|
454 | 480 |
;; |
455 | 481 |
|
456 | 482 |
let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; |
457 | 483 |
|
484 |
# 485 "myocamlbuild.ml" |
|
458 | 485 |
(* OASIS_STOP *) |
459 | 486 |
Ocamlbuild_plugin.dispatch dispatch_default;; |
Also available in: Unified diff
answer to #feature 50:
- arrows are now factorized out and become part of include
as files arrow.h and arrow.c
- no more arrows in generated code
- compiling and linking arrow.c is only necessary
in case of dynamic allocation
- version now includes installation prefix (for the standard lib)
and svn number
git-svn-id: https://cavale.enseeiht.fr/svn/lustrec/lustre_compiler/trunk@180 041b043f-8d7c-46b2-b46e-ef0dd855326e