Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 644 lines (516 sloc) 18.012 kb
a4de7f4 @avsm OASIS up the library
avsm authored
1 (* OASIS_START *)
222b797 @djs55 Regenerate OASIS
authored
2 (* DO NOT EDIT (digest: 6109ad5cd6941012dff2b67f3fff2eea) *)
a4de7f4 @avsm OASIS up the library
avsm authored
3 module OASISGettext = struct
1352a62 @djs55 Incremental commit: what a mess!
authored
4 (* # 22 "src/oasis/OASISGettext.ml" *)
5
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
6
7 let ns_ str =
a4de7f4 @avsm OASIS up the library
avsm authored
8 str
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
9
1352a62 @djs55 Incremental commit: what a mess!
authored
10
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
11 let s_ str =
a4de7f4 @avsm OASIS up the library
avsm authored
12 str
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
13
1352a62 @djs55 Incremental commit: what a mess!
authored
14
15 let f_ (str: ('a, 'b, 'c, 'd) format4) =
a4de7f4 @avsm OASIS up the library
avsm authored
16 str
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
17
1352a62 @djs55 Incremental commit: what a mess!
authored
18
a4de7f4 @avsm OASIS up the library
avsm authored
19 let fn_ fmt1 fmt2 n =
20 if n = 1 then
21 fmt1^^""
22 else
23 fmt2^^""
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
24
1352a62 @djs55 Incremental commit: what a mess!
authored
25
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
26 let init =
a4de7f4 @avsm OASIS up the library
avsm authored
27 []
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
28
1352a62 @djs55 Incremental commit: what a mess!
authored
29
a4de7f4 @avsm OASIS up the library
avsm authored
30 end
31
32 module OASISExpr = struct
1352a62 @djs55 Incremental commit: what a mess!
authored
33 (* # 22 "src/oasis/OASISExpr.ml" *)
34
35
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
36
37
38
a4de7f4 @avsm OASIS up the library
avsm authored
39 open OASISGettext
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
40
1352a62 @djs55 Incremental commit: what a mess!
authored
41
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
42 type test = string
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
43
1352a62 @djs55 Incremental commit: what a mess!
authored
44
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
45 type flag = string
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
46
1352a62 @djs55 Incremental commit: what a mess!
authored
47
a4de7f4 @avsm OASIS up the library
avsm 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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
55
1352a62 @djs55 Incremental commit: what a mess!
authored
56
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
57
58 type 'a choices = (t * 'a) list
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
59
1352a62 @djs55 Incremental commit: what a mess!
authored
60
a4de7f4 @avsm OASIS up the library
avsm authored
61 let eval var_get t =
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
62 let rec eval' =
a4de7f4 @avsm OASIS up the library
avsm authored
63 function
64 | EBool b ->
65 b
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
66
67 | ENot e ->
a4de7f4 @avsm OASIS up the library
avsm authored
68 not (eval' e)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
69
a4de7f4 @avsm OASIS up the library
avsm authored
70 | EAnd (e1, e2) ->
71 (eval' e1) && (eval' e2)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
72
73 | EOr (e1, e2) ->
a4de7f4 @avsm OASIS up the library
avsm authored
74 (eval' e1) || (eval' e2)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
75
a4de7f4 @avsm OASIS up the library
avsm authored
76 | EFlag nm ->
77 let v =
78 var_get nm
79 in
80 assert(v = "true" || v = "false");
81 (v = "true")
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
82
a4de7f4 @avsm OASIS up the library
avsm authored
83 | ETest (nm, vl) ->
84 let v =
85 var_get nm
86 in
87 (v = vl)
88 in
89 eval' t
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
90
1352a62 @djs55 Incremental commit: what a mess!
authored
91
a4de7f4 @avsm OASIS up the library
avsm authored
92 let choose ?printer ?name var_get lst =
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
93 let rec choose_aux =
a4de7f4 @avsm OASIS up the library
avsm authored
94 function
95 | (cond, vl) :: tl ->
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
96 if eval var_get cond then
97 vl
a4de7f4 @avsm OASIS up the library
avsm authored
98 else
99 choose_aux tl
100 | [] ->
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
101 let str_lst =
a4de7f4 @avsm OASIS up the library
avsm authored
102 if lst = [] then
103 s_ "<empty>"
104 else
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
105 String.concat
a4de7f4 @avsm OASIS up the library
avsm 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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
114 match name with
a4de7f4 @avsm OASIS up the library
avsm authored
115 | Some nm ->
116 failwith
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
117 (Printf.sprintf
a4de7f4 @avsm OASIS up the library
avsm 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)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
127
1352a62 @djs55 Incremental commit: what a mess!
authored
128
a4de7f4 @avsm OASIS up the library
avsm authored
129 end
130
131
1352a62 @djs55 Incremental commit: what a mess!
authored
132 # 132 "myocamlbuild.ml"
a4de7f4 @avsm OASIS up the library
avsm authored
133 module BaseEnvLight = struct
1352a62 @djs55 Incremental commit: what a mess!
authored
134 (* # 22 "src/base/BaseEnvLight.ml" *)
135
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
136
a4de7f4 @avsm OASIS up the library
avsm authored
137 module MapString = Map.Make(String)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
138
1352a62 @djs55 Incremental commit: what a mess!
authored
139
a4de7f4 @avsm OASIS up the library
avsm authored
140 type t = string MapString.t
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
141
1352a62 @djs55 Incremental commit: what a mess!
authored
142
a4de7f4 @avsm OASIS up the library
avsm authored
143 let default_filename =
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
144 Filename.concat
a4de7f4 @avsm OASIS up the library
avsm authored
145 (Sys.getcwd ())
146 "setup.data"
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
147
1352a62 @djs55 Incremental commit: what a mess!
authored
148
a4de7f4 @avsm OASIS up the library
avsm 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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
161 let st_line =
a4de7f4 @avsm OASIS up the library
avsm authored
162 Stream.from
163 (fun _ ->
164 try
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
165 match Stream.next st with
a4de7f4 @avsm OASIS up the library
avsm authored
166 | '\n' -> incr line; Some '\n'
167 | c -> Some c
168 with Stream.Failure -> None)
169 in
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
170 let lexer =
a4de7f4 @avsm OASIS up the library
avsm authored
171 Genlex.make_lexer ["="] st_line
172 in
173 let rec read_file mp =
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
174 match Stream.npeek 3 lexer with
a4de7f4 @avsm OASIS up the library
avsm authored
175 | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
176 Stream.junk lexer;
177 Stream.junk lexer;
a4de7f4 @avsm OASIS up the library
avsm 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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
200 failwith
201 (Printf.sprintf
a4de7f4 @avsm OASIS up the library
avsm authored
202 "Unable to load environment, the file '%s' doesn't exist."
203 filename)
204 end
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
205
1352a62 @djs55 Incremental commit: what a mess!
authored
206
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
207 let rec var_expand str env =
208 let buff =
209 Buffer.create ((String.length str) * 2)
a4de7f4 @avsm OASIS up the library
avsm authored
210 in
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
228
1352a62 @djs55 Incremental commit: what a mess!
authored
229
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
230 let var_choose lst env =
a4de7f4 @avsm OASIS up the library
avsm authored
231 OASISExpr.choose
232 (fun nm -> var_get nm env)
233 lst
234 end
235
236
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
237 # 237 "myocamlbuild.ml"
a4de7f4 @avsm OASIS up the library
avsm authored
238 module MyOCamlbuildFindlib = struct
1352a62 @djs55 Incremental commit: what a mess!
authored
239 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *)
240
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
241
1352a62 @djs55 Incremental commit: what a mess!
authored
242 (** OCamlbuild extension, copied from
a4de7f4 @avsm OASIS up the library
avsm 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 *
1352a62 @djs55 Incremental commit: what a mess!
authored
248 * Modified by Sylvain Le Gall
a4de7f4 @avsm OASIS up the library
avsm authored
249 *)
250 open Ocamlbuild_plugin
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
251
021d0d1 @djs55 Regenerate OASIS
authored
252 type conf =
253 { no_automatic_syntax: bool;
254 }
1352a62 @djs55 Incremental commit: what a mess!
authored
255
a4de7f4 @avsm OASIS up the library
avsm authored
256 (* these functions are not really officially exported *)
1352a62 @djs55 Incremental commit: what a mess!
authored
257 let run_and_read =
a4de7f4 @avsm OASIS up the library
avsm authored
258 Ocamlbuild_pack.My_unix.run_and_read
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
259
1352a62 @djs55 Incremental commit: what a mess!
authored
260
261 let blank_sep_strings =
a4de7f4 @avsm OASIS up the library
avsm authored
262 Ocamlbuild_pack.Lexers.blank_sep_strings
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
263
1352a62 @djs55 Incremental commit: what a mess!
authored
264
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
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
287 in
288 fix_win32 exec
289
a4de7f4 @avsm OASIS up the library
avsm authored
290 let split s ch =
1352a62 @djs55 Incremental commit: what a mess!
authored
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
a4de7f4 @avsm OASIS up the library
avsm authored
296 in
1352a62 @djs55 Incremental commit: what a mess!
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
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
307
a4de7f4 @avsm OASIS up the library
avsm authored
308 let split_nl s = split s '\n'
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
309
1352a62 @djs55 Incremental commit: what a mess!
authored
310
a4de7f4 @avsm OASIS up the library
avsm authored
311 let before_space s =
312 try
313 String.before s (String.index s ' ')
314 with Not_found -> s
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
315
1352a62 @djs55 Incremental commit: what a mess!
authored
316 (* ocamlfind command *)
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
317 let ocamlfind x = S[Sh (exec_from_conf "ocamlfind"); x]
1352a62 @djs55 Incremental commit: what a mess!
authored
318
319 (* This lists all supported packages. *)
a4de7f4 @avsm OASIS up the library
avsm authored
320 let find_packages () =
021d0d1 @djs55 Regenerate OASIS
authored
321 List.map before_space (split_nl & run_and_read (exec_from_conf "ocamlfind" ^ " list"))
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
322
1352a62 @djs55 Incremental commit: what a mess!
authored
323
324 (* Mock to list available syntaxes. *)
a4de7f4 @avsm OASIS up the library
avsm authored
325 let find_syntaxes () = ["camlp4o"; "camlp4r"]
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
326
327
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
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
343
021d0d1 @djs55 Regenerate OASIS
authored
344 let dispatch conf =
a4de7f4 @avsm OASIS up the library
avsm authored
345 function
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
346 | After_options ->
1352a62 @djs55 Incremental commit: what a mess!
authored
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 *)
a4de7f4 @avsm OASIS up the library
avsm 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";
1352a62 @djs55 Incremental commit: what a mess!
authored
354 Options.ocamlmktop := ocamlfind & A"ocamlmktop";
355 Options.ocamlmklib := ocamlfind & A"ocamlmklib"
356
a4de7f4 @avsm OASIS up the library
avsm authored
357 | After_rules ->
1352a62 @djs55 Incremental commit: what a mess!
authored
358
359 (* When one link an OCaml library/binary/package, one should use
360 * -linkpkg *)
a4de7f4 @avsm OASIS up the library
avsm authored
361 flag ["ocaml"; "link"; "program"] & A"-linkpkg";
1352a62 @djs55 Incremental commit: what a mess!
authored
362
021d0d1 @djs55 Regenerate OASIS
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;
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
396
a4de7f4 @avsm OASIS up the library
avsm 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];
1352a62 @djs55 Incremental commit: what a mess!
authored
403 flag ["ocaml"; "infer_interface"; "syntax_"^syntax] &
404 S[A"-syntax"; A syntax];
a4de7f4 @avsm OASIS up the library
avsm authored
405 end (find_syntaxes ());
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
406
a4de7f4 @avsm OASIS up the library
avsm 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.
1352a62 @djs55 Incremental commit: what a mess!
authored
411 *
a4de7f4 @avsm OASIS up the library
avsm 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"]);
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
416 flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
a4de7f4 @avsm OASIS up the library
avsm authored
417 flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
1352a62 @djs55 Incremental commit: what a mess!
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"]);
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
423
1352a62 @djs55 Incremental commit: what a mess!
authored
424 | _ ->
a4de7f4 @avsm OASIS up the library
avsm authored
425 ()
426 end
427
428 module MyOCamlbuildBase = struct
1352a62 @djs55 Incremental commit: what a mess!
authored
429 (* # 22 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
430
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
431
a4de7f4 @avsm OASIS up the library
avsm authored
432 (** Base functions for writing myocamlbuild.ml
433 @author Sylvain Le Gall
434 *)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
435
436
437
1352a62 @djs55 Incremental commit: what a mess!
authored
438
439
a4de7f4 @avsm OASIS up the library
avsm authored
440 open Ocamlbuild_plugin
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
441 module OC = Ocamlbuild_pack.Ocaml_compiler
442
1352a62 @djs55 Incremental commit: what a mess!
authored
443
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
444 type dir = string
445 type file = string
446 type name = string
447 type tag = string
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
448
1352a62 @djs55 Incremental commit: what a mess!
authored
449
450 (* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *)
451
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
452
a4de7f4 @avsm OASIS up the library
avsm authored
453 type t =
454 {
1352a62 @djs55 Incremental commit: what a mess!
authored
455 lib_ocaml: (name * dir list * string list) list;
456 lib_c: (name * dir * file list) list;
a4de7f4 @avsm OASIS up the library
avsm authored
457 flags: (tag list * (spec OASISExpr.choices)) list;
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
458 (* Replace the 'dir: include' from _tags by a precise interdepends in
459 * directory.
460 *)
1352a62 @djs55 Incremental commit: what a mess!
authored
461 includes: (dir * dir list) list;
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
462 }
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
463
1352a62 @djs55 Incremental commit: what a mess!
authored
464
a4de7f4 @avsm OASIS up the library
avsm authored
465 let env_filename =
1352a62 @djs55 Incremental commit: what a mess!
authored
466 Pathname.basename
a4de7f4 @avsm OASIS up the library
avsm authored
467 BaseEnvLight.default_filename
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
468
1352a62 @djs55 Incremental commit: what a mess!
authored
469
a4de7f4 @avsm OASIS up the library
avsm authored
470 let dispatch_combine lst =
471 fun e ->
1352a62 @djs55 Incremental commit: what a mess!
authored
472 List.iter
a4de7f4 @avsm OASIS up the library
avsm authored
473 (fun dispatch -> dispatch e)
1352a62 @djs55 Incremental commit: what a mess!
authored
474 lst
475
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
476
477 let tag_libstubs nm =
478 "use_lib"^nm^"_stubs"
479
1352a62 @djs55 Incremental commit: what a mess!
authored
480
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
481 let nm_libstubs nm =
482 nm^"_stubs"
483
1352a62 @djs55 Incremental commit: what a mess!
authored
484
485 let dispatch t e =
486 let env =
487 BaseEnvLight.load
488 ~filename:env_filename
a4de7f4 @avsm OASIS up the library
avsm authored
489 ~allow_empty:true
490 ()
491 in
1352a62 @djs55 Incremental commit: what a mess!
authored
492 match e with
a4de7f4 @avsm OASIS up the library
avsm 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) ->
1352a62 @djs55 Incremental commit: what a mess!
authored
502 try
a4de7f4 @avsm OASIS up the library
avsm authored
503 opt := no_trailing_dot (BaseEnvLight.var_get var env)
504 with Not_found ->
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
505 Printf.eprintf "W: Cannot get variable %s\n" var)
a4de7f4 @avsm OASIS up the library
avsm authored
506 [
507 Options.ext_obj, "ext_obj";
508 Options.ext_lib, "ext_lib";
509 Options.ext_dll, "ext_dll";
510 ]
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
511
1352a62 @djs55 Incremental commit: what a mess!
authored
512 | After_rules ->
a4de7f4 @avsm OASIS up the library
avsm authored
513 (* Declare OCaml libraries *)
1352a62 @djs55 Incremental commit: what a mess!
authored
514 List.iter
a4de7f4 @avsm OASIS up the library
avsm authored
515 (function
1352a62 @djs55 Incremental commit: what a mess!
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 ->
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
523 ocaml_lib ~dir:dir (dir^"/"^nm);
1352a62 @djs55 Incremental commit: what a mess!
authored
524 List.iter
525 (fun dir ->
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
526 List.iter
527 (fun str ->
528 flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir]))
529 ["compile"; "infer_interface"; "doc"])
1352a62 @djs55 Incremental commit: what a mess!
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)
a4de7f4 @avsm OASIS up the library
avsm authored
536 t.lib_ocaml;
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
537
538 (* Declare directories dependencies, replace "include" in _tags. *)
1352a62 @djs55 Incremental commit: what a mess!
authored
539 List.iter
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
540 (fun (dir, include_dirs) ->
541 Pathname.define_context dir include_dirs)
542 t.includes;
543
a4de7f4 @avsm OASIS up the library
avsm authored
544 (* Declare C libraries *)
545 List.iter
546 (fun (lib, dir, headers) ->
547 (* Handle C part of library *)
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm 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))]);
1352a62 @djs55 Incremental commit: what a mess!
authored
554
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
555 flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
556 (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
557
a4de7f4 @avsm OASIS up the library
avsm authored
558 (* When ocaml link something that use the C library, then one
559 need that file to be up to date.
021d0d1 @djs55 Regenerate OASIS
authored
560 This holds both for programs and for libraries.
a4de7f4 @avsm OASIS up the library
avsm authored
561 *)
021d0d1 @djs55 Regenerate OASIS
authored
562 dep ["link"; "ocaml"; tag_libstubs lib]
563 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
564
021d0d1 @djs55 Regenerate OASIS
authored
565 dep ["compile"; "ocaml"; tag_libstubs lib]
566 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
567
a4de7f4 @avsm OASIS up the library
avsm authored
568 (* TODO: be more specific about what depends on headers *)
569 (* Depends on .h files *)
1352a62 @djs55 Incremental commit: what a mess!
authored
570 dep ["compile"; "c"]
a4de7f4 @avsm OASIS up the library
avsm authored
571 headers;
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
572
a4de7f4 @avsm OASIS up the library
avsm authored
573 (* Setup search path for lib *)
1352a62 @djs55 Incremental commit: what a mess!
authored
574 flag ["link"; "ocaml"; "use_"^lib]
a4de7f4 @avsm OASIS up the library
avsm authored
575 (S[A"-I"; P(dir)]);
576 )
577 t.lib_c;
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
578
a4de7f4 @avsm OASIS up the library
avsm authored
579 (* Add flags *)
580 List.iter
581 (fun (tags, cond_specs) ->
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
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
a4de7f4 @avsm OASIS up the library
avsm authored
588 in
26fee8c @djs55 Add new Cstruct-based xenstore packet parser and printer
authored
589 flag tags & (eval_specs spec))
a4de7f4 @avsm OASIS up the library
avsm authored
590 t.flags
1352a62 @djs55 Incremental commit: what a mess!
authored
591 | _ ->
a4de7f4 @avsm OASIS up the library
avsm authored
592 ()
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
593
1352a62 @djs55 Incremental commit: what a mess!
authored
594
021d0d1 @djs55 Regenerate OASIS
authored
595 let dispatch_default conf t =
1352a62 @djs55 Incremental commit: what a mess!
authored
596 dispatch_combine
a4de7f4 @avsm OASIS up the library
avsm authored
597 [
598 dispatch t;
021d0d1 @djs55 Regenerate OASIS
authored
599 MyOCamlbuildFindlib.dispatch conf;
a4de7f4 @avsm OASIS up the library
avsm authored
600 ]
2b550cc @avsm regenrate OASIS and add Xen support (with NOTES on how the magic works)
avsm authored
601
1352a62 @djs55 Incremental commit: what a mess!
authored
602
a4de7f4 @avsm OASIS up the library
avsm authored
603 end
604
605
021d0d1 @djs55 Regenerate OASIS
authored
606 # 606 "myocamlbuild.ml"
a4de7f4 @avsm OASIS up the library
avsm authored
607 open Ocamlbuild_plugin;;
608 let package_default =
609 {
9d2600a @djs55 Add Unix sockets interface and matching set of signatures
authored
610 MyOCamlbuildBase.lib_ocaml =
e9a2069 @djs55 Remove the server logic and add the interdomain transport
authored
611 [
612 ("xenstore", ["core"], []);
222b797 @djs55 Regenerate OASIS
authored
613 ("xenstore_unix", ["unix"], []);
614 ("xenstore_xenctrl", ["xenctrl"], []);
e9a2069 @djs55 Remove the server logic and add the interdomain transport
authored
615 ("xenstore_kernelspace", ["kernelspace"], [])
b3d7351 @djs55 Move all the userspace code into 'xenstore.userspace'
authored
616 ];
222b797 @djs55 Regenerate OASIS
authored
617 lib_c = [("xenstore_xenctrl", "xenctrl", [])];
021d0d1 @djs55 Regenerate OASIS
authored
618 flags =
619 [
222b797 @djs55 Regenerate OASIS
authored
620 (["oasis_library_xenstore_xenctrl_cclib"; "link"],
021d0d1 @djs55 Regenerate OASIS
authored
621 [(OASISExpr.EBool true, S [A "-cclib"; A "-lxenctrl"])]);
222b797 @djs55 Regenerate OASIS
authored
622 (["oasis_library_xenstore_xenctrl_cclib"; "ocamlmklib"; "c"],
021d0d1 @djs55 Regenerate OASIS
authored
623 [(OASISExpr.EBool true, S [A "-lxenctrl"])])
624 ];
7a93608 @djs55 Add 'xs', command-line tool (with man page)
authored
625 includes =
b3d7351 @djs55 Move all the userspace code into 'xenstore.userspace'
authored
626 [
222b797 @djs55 Regenerate OASIS
authored
627 ("xs", ["core"; "unix"]);
628 ("xenctrl", ["core"]);
629 ("unix", ["core"]);
e9a2069 @djs55 Remove the server logic and add the interdomain transport
authored
630 ("kernelspace", ["core"]);
222b797 @djs55 Regenerate OASIS
authored
631 ("examples", ["core"; "xenctrl"]);
632 ("core_test", ["core"; "unix"])
7a93608 @djs55 Add 'xs', command-line tool (with man page)
authored
633 ]
1352a62 @djs55 Incremental commit: what a mess!
authored
634 }
a4de7f4 @avsm OASIS up the library
avsm authored
635 ;;
636
021d0d1 @djs55 Regenerate OASIS
authored
637 let conf = {MyOCamlbuildFindlib.no_automatic_syntax = false}
638
639 let dispatch_default = MyOCamlbuildBase.dispatch_default conf package_default;;
a4de7f4 @avsm OASIS up the library
avsm authored
640
222b797 @djs55 Regenerate OASIS
authored
641 # 642 "myocamlbuild.ml"
a4de7f4 @avsm OASIS up the library
avsm authored
642 (* OASIS_STOP *)
09b04d4 @djs55 Incremental commit of an inter-domain transport for mirage
authored
643 Ocamlbuild_plugin.dispatch dispatch_default;;
Something went wrong with that request. Please try again.