5 let in_f = open_in f in
8 let line = input_line in_f in
9 if String.length line != 0 then lines := line :: !lines
13 End_of_file -> close_in in_f; List.rev !lines
18 let profile = ref false
19 let verbose = ref false
22 let dir = Sys.getcwd ()
23 let project_root = Filename.dirname Sys.argv.(0)
26 for i = 1 to Array.length Sys.argv - 1 do
27 match Sys.argv.(i) with
28 | "-d" -> debug := true
29 | "-p" -> profile := true
30 | "-v" -> verbose := true
31 | "-t" -> trace := true
32 | x -> target := x :: !target
34 let otrace = if !trace then " -tag htmltrace " else ""
35 let oprofile = if !profile then " -tag profile " else ""
36 let odebug = if !debug then " -tag debug " else ""
37 let clean_first = ref false
39 Sys.chdir project_root;
40 Printf.printf "Entering directory `%s'\n%!" project_root
42 let otarget = List.fold_left (fun acc t ->
43 if t = "clean" || t = "-clean" then (clean_first := true; acc)
46 if Filename.check_suffix t ".otarget" then
47 String.concat " " (read_lines ((Filename.chop_suffix t ".otarget") ^ ".itarget"))
50 t ^ " " ^ acc) "" (if (!target == []) then [ "main.otarget" ] else !target)
51 let overbose = if !verbose then " -classic-display " else ""
52 let clean_cmd = if !clean_first then "ocamlbuild -clean;" else ""
53 let build_cmd = if otarget = "" then "" else
54 Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s %s"
55 overbose otrace oprofile odebug otarget
56 let i = Sys.command (clean_cmd ^ build_cmd)
57 let () = Sys.chdir dir;
58 Printf.printf "Leaving directory `%s'\n%!" project_root