X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=build;h=75781b010f50abbc502ae0e05e13ee122ece4a7a;hp=2b29bbad9a2f422ca675337e99cad40a66e7943d;hb=e381c2bd8da5a33c0fdb1e6cfa9c1800386eafed;hpb=38cbd62f27eb7e1f461bc764cc89366557ec0124 diff --git a/build b/build index 2b29bba..75781b0 100755 --- a/build +++ b/build @@ -1,25 +1,23 @@ #!/usr/bin/env ocaml -let file_content = - let buffer = Buffer.create 128 in - begin fun f -> - Buffer.clear buffer; - try - let in_f = open_in f in - while true do - let line = input_line in_f in - Buffer.add_string buffer line; - Buffer.add_char buffer ' '; - done; - failwith "finished" - with - e -> let s = Buffer.contents buffer in s - end +let read_lines f = + let lines = ref [] in + let in_f = open_in f in + try + while true do + let line = input_line in_f in + if String.length line != 0 then lines := line :: !lines + done; + [] + with + End_of_file -> close_in in_f; List.rev !lines +;; let target = ref [ ] let debug = ref false let profile = ref false let verbose = ref false +let trace = ref false let dir = Sys.getcwd () let project_root = Filename.dirname Sys.argv.(0) @@ -30,11 +28,12 @@ let () = | "-d" -> debug := true | "-p" -> profile := true | "-v" -> verbose := true + | "-t" -> trace := true | x -> target := x :: !target done - +let otrace = if !trace then " -tag htmltrace " else "" let oprofile = if !profile then " -tag profile " else "" -let odebug = if !profile then " -tag debug " else "" +let odebug = if !debug then " -tag debug " else "" let clean_first = ref false let () = Sys.chdir project_root; @@ -45,15 +44,15 @@ let otarget = List.fold_left (fun acc t -> else let t = if Filename.check_suffix t ".otarget" then - file_content ((Filename.chop_suffix t ".otarget") ^ ".itarget") + String.concat " " (read_lines ((Filename.chop_suffix t ".otarget") ^ ".itarget")) else t in t ^ " " ^ acc) "" (if (!target == []) then [ "main.otarget" ] else !target) let overbose = if !verbose then " -classic-display " else "" let clean_cmd = if !clean_first then "ocamlbuild -clean;" else "" let build_cmd = if otarget = "" then "" else - Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s" - overbose oprofile odebug otarget + Printf.sprintf "ocamlbuild -use-ocamlfind %s %s %s %s %s" + overbose otrace oprofile odebug otarget let i = Sys.command (clean_cmd ^ build_cmd) let () = Sys.chdir dir; Printf.printf "Leaving directory `%s'\n%!" project_root