9 let ocamlfind = A"ocamlfind"
10 let ocamlc = A"ocamlc"
11 let ocamlopt = A"ocamlopt"
13 let cduce_mkstubs includes =
16 (fun fn -> S[A"-I"; P fn])
19 (* cduce < 0.3.9: cdo2ml -static *)
21 let cduce_compile_args env =
23 A"-c"; A"-package"; A"cduce";
24 A"-pp"; cduce_mkstubs [Filename.dirname (env "%.cmi")];
25 A"-I"; P(Filename.dirname (env "%.cmi"));
26 A"-impl"; P(env "%.cdo")
30 let cduce_prepare_compile env build =
34 (* Fail but it just means that the .cmi will be generated
40 (build [[env "%.cmi"]])
43 rule "cduce: %.cd -> %.cdo"
49 T(tags_of_pathname (env "%.cd")++"cduce"++"compile");
51 A"-I"; P(Filename.dirname (env "%.cd"));
56 rule "cduce: %.cdo -> %.cmo"
61 cduce_prepare_compile env build;
64 T(tags_of_pathname (env "%.cdo")
65 ++"cduce"++"ocamlc"++"compile"++"byte")]
66 @ (cduce_compile_args env)))
70 rule "cduce: %.cdo -> %.cmx"
75 cduce_prepare_compile env build;
78 T(tags_of_pathname (env "%.cdo")
79 ++"cduce"++"ocamlopt"++"compile"++"native")]
80 @ (cduce_compile_args env)))
84 (***********************)
85 (* WSDL rules (ocsoap) *)
86 (***********************)
88 let ocsoap_dev = ref true;;
90 let wsdltointf = ref "src/wsdltointf.byte";;
91 let pa_ocsoapclientstubs = ref "src/pa_ocsoapclientstubs.cma";;
92 let camlp5o = ref "camlp5o";;
94 rule "ocsoap: %.wsdl -> %.intf & %_types.ml & %_conv.ml"
95 ~prods:["%.intf"; "%_types.ml"; "%_conv.ml"]
96 ~deps:(if !ocsoap_dev then
97 ["%.wsdl"; !wsdltointf]
102 Cmd(S([Px !wsdltointf; P(env "%.wsdl")]))
106 rule "ocsoap: %.intf -> %.ml"
108 ~deps:(if !ocsoap_dev then
109 ["%.intf"; !pa_ocsoapclientstubs]
114 Cmd(S[Px !camlp5o; P !pa_ocsoapclientstubs; P "pr_o.cmo"; A"-impl";
115 P(env "%.intf"); A"-o"; P(env "%.ml")])
120 (* DO NOT EDIT (digest: ea6f87916d3d3095edf230468afa4ab1) *)
121 module OASISGettext = struct
122 # 21 "/home/gildor/programmation/oasis/src/oasis/OASISGettext.ml"
130 let f_ (str : ('a, 'b, 'c, 'd) format4) =
133 let fn_ fmt1 fmt2 n =
144 module OASISExpr = struct
145 # 21 "/home/gildor/programmation/oasis/src/oasis/OASISExpr.ml"
161 | ETest of test * string
164 type 'a choices = (t * 'a) list
176 (eval' e1) && (eval' e2)
179 (eval' e1) || (eval' e2)
185 assert(v = "true" || v = "false");
196 let choose ?printer ?name var_get lst =
199 | (cond, vl) :: tl ->
200 if eval var_get cond then
215 | None -> s_ "<no printer>")
222 (f_ "No result for the choice list '%s': %s")
227 (f_ "No result for a choice list: %s")
230 choose_aux (List.rev lst)
235 # 117 "myocamlbuild.ml"
236 module BaseEnvLight = struct
237 # 21 "/home/gildor/programmation/oasis/src/base/BaseEnvLight.ml"
239 module MapString = Map.Make(String)
241 type t = string MapString.t
243 let default_filename =
248 let load ?(allow_empty=false) ?(filename=default_filename) () =
249 if Sys.file_exists filename then
255 Stream.of_channel chn
264 match Stream.next st with
265 | '\n' -> incr line; Some '\n'
267 with Stream.Failure -> None)
270 Genlex.make_lexer ["="] st_line
272 let rec read_file mp =
273 match Stream.npeek 3 lexer with
274 | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] ->
278 read_file (MapString.add nm value mp)
284 "Malformed data file '%s' line %d"
288 read_file MapString.empty
293 else if allow_empty then
301 "Unable to load environment, the file '%s' doesn't exist."
305 let var_get name env =
306 let rec var_expand str =
308 Buffer.create ((String.length str) * 2)
310 Buffer.add_substitute
314 var_expand (MapString.find var env)
318 "No variable %s defined when trying to expand %S."
324 var_expand (MapString.find name env)
326 let var_choose lst env =
328 (fun nm -> var_get nm env)
333 # 215 "myocamlbuild.ml"
334 module MyOCamlbuildFindlib = struct
335 # 21 "/home/gildor/programmation/oasis/src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml"
337 (** OCamlbuild extension, copied from
338 * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild
339 * by N. Pouillard and others
341 * Updated on 2009/02/28
343 * Modified by Sylvain Le Gall
345 open Ocamlbuild_plugin
347 (* these functions are not really officially exported *)
349 Ocamlbuild_pack.My_unix.run_and_read
351 let blank_sep_strings =
352 Ocamlbuild_pack.Lexers.blank_sep_strings
362 x := (String.before s pos)::!x;
363 go (String.after s (pos + 1))
369 let split_nl s = split s '\n'
373 String.before s (String.index s ' ')
376 (* this lists all supported packages *)
377 let find_packages () =
378 List.map before_space (split_nl & run_and_read "ocamlfind list")
380 (* this is supposed to list available syntaxes, but I don't know how to do it. *)
381 let find_syntaxes () = ["camlp4o"; "camlp4r"]
383 (* ocamlfind command *)
384 let ocamlfind x = S[A"ocamlfind"; x]
389 (* by using Before_options one let command line options have an higher priority *)
390 (* on the contrary using After_options will guarantee to have the higher priority *)
391 (* override default commands by ocamlfind ones *)
392 Options.ocamlc := ocamlfind & A"ocamlc";
393 Options.ocamlopt := ocamlfind & A"ocamlopt";
394 Options.ocamldep := ocamlfind & A"ocamldep";
395 Options.ocamldoc := ocamlfind & A"ocamldoc";
396 Options.ocamlmktop := ocamlfind & A"ocamlmktop"
400 (* When one link an OCaml library/binary/package, one should use -linkpkg *)
401 flag ["ocaml"; "link"; "program"] & A"-linkpkg";
403 (* For each ocamlfind package one inject the -package option when
404 * compiling, computing dependencies, generating documentation and
408 flag ["ocaml"; "compile"; "pkg_"^pkg] & S[A"-package"; A pkg];
409 flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S[A"-package"; A pkg];
410 flag ["ocaml"; "doc"; "pkg_"^pkg] & S[A"-package"; A pkg];
411 flag ["ocaml"; "link"; "pkg_"^pkg] & S[A"-package"; A pkg];
412 flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S[A"-package"; A pkg];
416 (* Like -package but for extensions syntax. Morover -syntax is useless
418 List.iter begin fun syntax ->
419 flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
420 flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
421 flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
422 flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & S[A"-syntax"; A syntax];
423 end (find_syntaxes ());
425 (* The default "thread" tag is not compatible with ocamlfind.
426 * Indeed, the default rules add the "threads.cma" or "threads.cmxa"
427 * options when using this tag. When using the "-linkpkg" option with
428 * ocamlfind, this module will then be added twice on the command line.
430 * To solve this, one approach is to add the "-thread" option when using
431 * the "threads" package using the previous plugin.
433 flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]);
434 flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]);
435 flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]);
436 flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"])
443 module MyOCamlbuildBase = struct
444 # 21 "/home/gildor/programmation/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
446 (** Base functions for writing myocamlbuild.ml
447 @author Sylvain Le Gall
452 open Ocamlbuild_plugin
453 module OC = Ocamlbuild_pack.Ocaml_compiler
460 # 56 "/home/gildor/programmation/oasis/src/plugins/ocamlbuild/MyOCamlbuildBase.ml"
464 lib_ocaml: (name * dir list) list;
465 lib_c: (name * dir * file list) list;
466 flags: (tag list * (spec OASISExpr.choices)) list;
467 (* Replace the 'dir: include' from _tags by a precise interdepends in
470 includes: (dir * dir list) list;
475 BaseEnvLight.default_filename
477 let dispatch_combine lst =
480 (fun dispatch -> dispatch e)
483 let tag_libstubs nm =
484 "use_lib"^nm^"_stubs"
492 ~filename:env_filename
498 let no_trailing_dot s =
499 if String.length s >= 1 && s.[0] = '.' then
500 String.sub s 1 ((String.length s) - 1)
507 opt := no_trailing_dot (BaseEnvLight.var_get var env)
509 Printf.eprintf "W: Cannot get variable %s" var)
511 Options.ext_obj, "ext_obj";
512 Options.ext_lib, "ext_lib";
513 Options.ext_dll, "ext_dll";
517 (* Declare OCaml libraries *)
523 ocaml_lib ~dir:dir (dir^"/"^nm);
528 flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir]))
529 ["compile"; "infer_interface"; "doc"])
533 (* Declare directories dependencies, replace "include" in _tags. *)
535 (fun (dir, include_dirs) ->
536 Pathname.define_context dir include_dirs)
539 (* Declare C libraries *)
541 (fun (lib, dir, headers) ->
542 (* Handle C part of library *)
543 flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib]
544 (S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib";
545 A("-l"^(nm_libstubs lib))]);
547 flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib]
548 (S[A"-cclib"; A("-l"^(nm_libstubs lib))]);
550 flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib]
551 (S[A"-dllib"; A("dll"^(nm_libstubs lib))]);
553 (* When ocaml link something that use the C library, then one
554 need that file to be up to date.
556 dep ["link"; "ocaml"; "program"; tag_libstubs lib]
557 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
559 dep ["compile"; "ocaml"; "program"; tag_libstubs lib]
560 [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)];
562 (* TODO: be more specific about what depends on headers *)
563 (* Depends on .h files *)
567 (* Setup search path for lib *)
568 flag ["link"; "ocaml"; "use_"^lib]
575 (fun (tags, cond_specs) ->
577 BaseEnvLight.var_choose cond_specs env
584 let dispatch_default t =
588 MyOCamlbuildFindlib.dispatch;
594 # 476 "myocamlbuild.ml"
595 open Ocamlbuild_plugin;;
596 let package_default =
598 MyOCamlbuildBase.lib_ocaml =
599 [("ocsoap", ["src"]); ("pa_ocsoapclientstubs", ["src"])];
602 includes = [("examples/adwords", ["src"])];
606 let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;
608 # 491 "myocamlbuild.ml"
616 Quote(S[Px !camlp5o; P"pa_extend.cmo"; P"q_MLast.cmo";
617 A"-loc"; A"loc"; A"-impl"])])
619 flag ["file:src/pa_ocsoapclientstubs.ml"; "ocaml"; "compile"]
621 flag ["file:src/pa_ocsoapclientstubs.ml"; "ocamldep"]
624 flag ["ocaml"; "doc"] (S[A"-stars"; A"-sort"]);
630 Ocamlbuild_plugin.dispatch
631 (MyOCamlbuildBase.dispatch_combine [dispatch_default; dispatch_extra])