0.90
[imt.git] / cl.ml
blob880dfb2026c78f831e2560411c16684261a70865
1 let debug = false
2 let src_file_re = Str.regexp "^\\(.*\\)([0-9]+) :"
3 let inc_file_re = Str.regexp "Cannot open include file: '\\(.*\\)'"
5 let process_include_err s =
6 let rec loop pos =
7 let opt_pos2 =
8 try
9 Some (Str.search_forward inc_file_re s pos)
10 with Not_found ->
11 None
13 match opt_pos2 with
14 | Some pos2 ->
15 let b, e = Utils.safe_group_extents 1 in
16 let win_path = String.sub s b (e - b) in
17 prerr_string (String.sub s pos b);
18 Path.prerr true win_path;
19 prerr_string (String.sub s e (String.length s - e));
20 loop e
21 | None ->
22 prerr_string (String.sub s pos (String.length s - pos))
24 loop 0
26 let process_cl_output_line s =
27 (* prerr_endline s; *)
28 if Str.string_match src_file_re s 0
29 then
30 let win_path = Utils.safe_group 1 s in
31 Path.prerr false win_path;
32 let gend = Utils.safe_group_end 1 in
33 process_include_err (String.sub s gend (String.length s - gend));
34 prerr_newline ()
35 else
36 begin
37 process_include_err s;
38 prerr_newline ()
39 end
41 let invoke argv arg_start =
42 let tool = Utils.tool_name "cl" in
43 let args = Utils.make_arg_string Path.check_and_modify_absolute argv arg_start in
44 let command = Wine.command tool ^ " /nologo " ^ args in
45 let ic = Unix.open_process_in command in
46 Utils.iter_crlf_chan ic process_cl_output_line;
47 let code = Utils.close_process_in ic in
48 code