Diff of /PC_Mainboard/Apps/cards/myocamlbuild.ml [000000] .. [248975]  Maximize  Restore

Switch to side-by-side view

--- a
+++ b/PC_Mainboard/Apps/cards/myocamlbuild.ml
@@ -0,0 +1,112 @@
+(*
+ * myocamlbuild.ml
+ * ---------------
+ * Copyright : (c) 2009, Jeremie Dimino <jeremie@dimino.org>
+ * Licence   : BSD3
+ *
+ * This file is a part of [kro]bot.
+ *)
+
+open Printf
+open Ocamlbuild_plugin
+
+(* +-----------------------------------------------------------------+
+   | Ocamlfind                                                       |
+   +-----------------------------------------------------------------+ *)
+
+(* Put here packages you may use in this project: *)
+let packages = [
+  "type-conv";
+  "type-conv.syntax";
+  "camlp4";
+  "camlp4.extend";
+  "camlp4.lib";
+  "camlp4.macro";
+  "camlp4.quotations.o";
+  "camlp4.quotations.r";
+  "lwt";
+  "lwt.unix";
+  "lwt.syntax";
+  "str";
+  "xmlm";
+  "react";
+  "usb";
+  "obus";
+  "obus.syntax";
+]
+
+(* List of available syntaxes :*)
+let syntaxes = [
+  "camlp4o";
+  "camlp4r";
+]
+
+(* +-----------------------------------------------------------------+
+   | Utils                                                           |
+   +-----------------------------------------------------------------+ *)
+
+let flag_all_stages_except_link tag f =
+  flag ["ocaml"; "compile"; tag] f;
+  flag ["ocaml"; "ocamldep"; tag] f;
+  flag ["ocaml"; "doc"; tag] f
+
+let flag_all_stages tag f =
+  flag_all_stages_except_link tag f;
+  flag ["ocaml"; "link"; tag] f
+
+let _ =
+  dispatch begin function
+    | Before_options ->
+
+        (* override default commands by ocamlfind ones *)
+        let ocamlfind x = S[A"ocamlfind"; A x] in
+        Options.ocamlc   := ocamlfind "ocamlc";
+        Options.ocamlopt := ocamlfind "ocamlopt";
+        Options.ocamldep := ocamlfind "ocamldep";
+        (* FIXME: sometimes ocamldoc say that elements are not found
+           even if they are present: *)
+        Options.ocamldoc := S[A"ocamlfind"; A"ocamldoc"; A"-hide-warnings"]
+
+    | After_rules ->
+
+        (* D-Bus drivers can see the lowlevel interfaces *)
+        Pathname.define_context "dbus-drivers" [ "usb" ];
+
+        (* G��n��ration du fichier contenant les d��tails du protocol ��
+           partir du fichier .h *)
+        rule "protocol du krobot" ~dep:"PcInterface.h" ~prod:"protocol.ml"
+          (fun _ _ ->
+             Cmd(S[Sh"awk '$1 == \"#define\" && $3 != \"\" { print \"let \" tolower($2) \" = \" $3 }' PcInterface.h > protocol.ml"]));
+
+        (* +---------------------------------------------------------+
+           | Virtual targets                                         |
+           +---------------------------------------------------------+ *)
+
+        let virtual_rule name deps =
+          rule name ~stamp:name ~deps (fun _ _ -> Nop)
+        in
+
+        virtual_rule "all" ["dbus-drivers/card_interface.native"; "lib/krobot.cmxa"];
+
+        (* +---------------------------------------------------------+
+           | Ocamlfind stuff                                         |
+           +---------------------------------------------------------+ *)
+
+        (* When one link an OCaml binary, one should use -linkpkg *)
+        flag ["ocaml"; "link"; "program"] & A"-linkpkg";
+
+        (* For each ocamlfind package one inject the -package option
+           when compiling, computing dependencies, generating
+           documentation and linking. *)
+        List.iter
+          (fun package -> flag_all_stages ("pkg_" ^ package) (S[A"-package"; A package]))
+          packages;
+
+        (* Like -package but for extensions syntax. Morover -syntax is
+           useless when linking. *)
+        List.iter
+          (fun syntax -> flag_all_stages_except_link ("syntax_" ^ syntax) (S[A"-syntax"; A syntax]))
+          syntaxes;
+
+    | _ -> ()
+  end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks