Initial .gitignore
[imt.git] / dep.ml
blobb5cedd650374b365f7761e8d4270484ab703102a
1 let debug = false
3 let line_re = Str.regexp "^#line [0-9]+ \"\\(.*\\)\"$"
4 let over_re = Str.regexp
5 "^cl : Command line warning D4025 : overriding '/W[^']+' with '/w'"
7 let process_cl_cpp_output_line s set =
8 if Str.string_match line_re s 0
9 then
10 let win_path = Utils.safe_group 1 s in
11 if debug && (not (Utils.StringSet.mem win_path set))
12 then
13 prerr_endline s
15 Utils.StringSet.add win_path set
16 else
17 set
19 let invoke target argv arg_start =
20 let rejrel = Utils.build_reject_list () in
21 let args = Utils.make_arg_string Path.check_and_modify_absolute argv arg_start in
22 let tool = Utils.tool_name "cl" in
23 let command = Utils.construct_args tool args "-E -nologo -w" in
24 let env = Unix.environment () in
25 let (ic, _, ec) as channels = Unix.open_process_full command env in
26 let ifiles =
27 Utils.fold_crlf_chan ic process_cl_cpp_output_line Utils.StringSet.empty in
28 Utils.iter_crlf_chan ec
29 begin
30 fun s ->
31 if not (Str.string_match over_re s 0)
32 then
33 prerr_endline s
34 end;
35 let code = Utils.close_process_full channels in
36 if code = 0
37 then
38 begin
39 Utils.output_quoted_path stdout target;
40 print_string ": ";
41 Utils.StringSet.iter
42 begin
43 fun win_path ->
44 let unix_path = Path.find2 win_path in
45 match unix_path with
46 | None ->
47 prerr_string "Cannot convert windows path: '";
48 prerr_string (String.escaped win_path);
49 prerr_endline "' to unix"
50 | Some unix_path ->
51 if not (Utils.reject_path unix_path rejrel)
52 then
53 begin
54 Utils.output_quoted_path stdout unix_path;
55 print_char ' '
56 end
57 end ifiles;
58 print_newline ();
59 end;
60 code