+++ /dev/null
-SOURCE_DIR=src,src/xpath,src/utils,src/tree,src/auto
-TARGET=main.otarget
-OCAMLFINDPKG=unix,ulex,expat,camlp4,camlp4.lib,camlp4.macro
-all:
- @echo [BUILD]
- ocamlbuild -pkgs $(OCAMLFINDPKG) -use-ocamlfind -Is $(SOURCE_DIR) $(TARGET)
-
-clean:
- @echo [Clean]
- @ocamlbuild -clean
+#camlp4 packages and syntax tags
+
+true: package(ulex), \
+ package(unix), \
+ package(expat), \
+ package(camlp4.macro), \
+ syntax(camlp4o), \
+ macro_include(include)
+
+#compilation options
+
+true: inline(100), unsafe(true)
+
+
+#project source tree
<src/xpath/*.cmx>: for-pack(Xpath)
+<src/xpath>: include
+
<src/utils/*.cmx>: for-pack(Utils)
+<src/utils>: include
+
<src/tree/*.cmx>: for-pack(Tree)
+<src/tree>: include
+
<src/auto/*.cmx>: for-pack(Auto)
-<**/*.ml>: syntax(camlp4o), macro_include(include)
\ No newline at end of file
+<src/auto>: include
+
+<src>: include
+
+
--- /dev/null
+#!/usr/bin/env ocaml
+
+let target = ref "main.otarget"
+let debug = ref false
+let profile = ref false
+let verbose = ref false
+
+let () =
+ for i = 1 to Array.length Sys.argv - 1 do
+ match Sys.argv.(i) with
+ | "-d" -> debug := true
+ | "-p" -> profile := true
+ | "-v" -> verbose := true
+ | x -> target := x
+ done
+
+let oprofile = if !profile then " -tag profile " else ""
+let odebug = if !profile then " -tag debug " else ""
+let otarget = if !target = "clean" then " -clean " else !target
+let overbose = if !verbose then " -classic-display " else ""
+
+let cmd = "ocamlbuild -use-ocamlfind " ^ overbose ^ oprofile ^ odebug ^ otarget
+let _ = Sys.command cmd
+
open Ocamlbuild_plugin
open Command
-let includes = Hashtbl.create 17
+let includes = ref StringSet.empty
+
let register_include dir =
- if not (Hashtbl.mem includes dir) then begin
- Hashtbl.add includes dir ();
+ if not (StringSet.mem dir !includes) then begin
+ includes := StringSet.add dir !includes;
dep [ "extension:ml" ]
(List.map (fun s -> dir ^ "/" ^ s )
(Array.to_list (Pathname.readdir dir)))
end
+let set_flags tag_list action_list =
+ List.iter (fun s ->
+ List.iter (fun (fl, fu) ->
+ pflag s fl fu)
+ action_list
+ ) tag_list
+
let macro_flags = [
"macro_include",
(fun s -> register_include s; S [A"-ppopt"; A "-I"; A"-ppopt"; A s]);
let () = dispatch begin
function
| Before_rules ->
- List.iter (fun s ->
- List.iter (fun (fl, fu) ->
- pflag s fl fu) macro_flags
- )
- [["ocaml";"compile"];
- ["ocaml";"ocamldep"] ]
-;
+ set_flags [["ocaml";"compile"]; ["ocaml";"ocamldep"] ] macro_flags;
+ flag [ "ocaml"; "compile"; "debug" ] (S[ A"-g"; A"-ppopt"; A"-DDEBUG"]);
+ flag [ "ocaml"; "link"; "debug" ] (A"-g");
+ flag [ "ocaml"; "compile"; "profile"] (S[A"-ppopt"; A"-DPROFILE"]);
+ flag [ "ocaml"; "compile"; "profile"; "native"] (A"-p");
+ flag [ "ocaml"; "link"; "profile"; "native"] (A"-p");
+ pflag [ "ocaml"; "compile"; "native" ] "inline" (fun i -> (S[ A"-inline"; A i ]));
+ pflag [ "ocaml"; "compile" ] "unsafe" (fun s -> (if s = "true" then S[A"-ppopt";A "-unsafe"] else N));
+
| _ -> ()
end