[248975]: PC_Mainboard / Apps / cards / myocamlbuild.ml  Maximize  Restore  History

Download this file

113 lines (92 with data), 3.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
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