0.94
[imt.git] / driver.ml
blob83875924baf616b7505ea9b963627c8c012c63f4
1 let help () =
2 print_string "usage: ";
3 print_string (Filename.basename Sys.executable_name);
4 print_endline " command [ command-argument ] [ arguments ... ]";
5 print_endline "command is one of: ";
6 List.iter (fun s -> print_string " "; print_endline s)
7 ["cl";
8 " run `cl [arguments]' sanitizing output (converting pathes etc)";
9 "";
11 "dep target";
12 " run `cl /E [arguments]'";
13 " search output for headers";
14 " print `target: <list-of-headers>' to standard output";
15 "";
17 "dep7 target";
18 " run `cl /showIncludes /Zs [arguments]'";
19 " same as dep";
20 "";
22 "dep7-test";
23 " test if cl is new enough and has /showIncludes option";
24 "";
26 "cldep7 target depfile";
27 " run `cl /showIncludes [arguments]'";
28 " same as cl+dep7 but put the dependency information into file <depfile>";
29 " (sans /Zs)";
30 "";
32 "link";
33 " run `link [arguments]'";
34 "";
36 "help";
37 " show this help screen";
40 let exp_cmd, run_cmd =
41 if Wine.native
42 then
43 "C:\\> set ", "C:\\> "
44 else
45 "$ export ", "$ "
47 List.iter print_endline
48 ["If environment variable IMT_[CL|LINK] is set it will be used as the ";
49 "path to respective utility, otherwise [cl.exe|link.exe] will be used";
50 "";
51 "Headers produced by [cl]dep[7] commands will be tested against IMT_REJ";
52 "environment variable (: separated list of OCaml style regular expressions)";
53 "if the path to header matches it will be excluded from the printout";
54 "(pathes are tested after windows to unix translation (nop on Win platforms))";
55 "";
56 "Example:";
57 exp_cmd ^ "IMT_REJ=/mnt/windows/msc/include:/mnt/psdk/include";
58 exp_cmd ^ "IMT_CL=/mnt/windows/msc/bin/cl.exe";
59 run_cmd ^ "imt cldep7 moo.obj moo.dep -c moo.c";
62 print_endline "Have a nice day";
63 exit 0
65 let show_usage () =
66 print_endline "Incredible Mega Thing by extremely cool hacker, Version 0.94";
67 print_newline ();
68 print_string "usage: ";
69 print_string (Filename.basename Sys.executable_name);
70 print_endline " command [ command-argument ] [ arguments ... ]";
71 print_endline "command is one of: ";
72 List.iter (fun s -> print_string " "; print_endline s)
73 ["cl: invoke cl";
74 "dep target: invoke cl /E, parse output, print dependencies to stdout";
75 "dep7 target: invoke cl /showIncludes /Zs, same as dep";
76 "dep7-test: test if /showIncludes is available, exit with non-zero if not";
77 "cldep7 target depfile: cl+dep7 combined, put dependencies into depfile";
78 "link: invoke link";
79 "help: show extended help"
81 print_endline "Have a nice day";
82 exit 100
84 let main argv =
85 if Array.length argv < 2
86 then
87 show_usage ()
88 else
89 begin
90 Drive.init ();
91 let code =
92 match argv.(1) with
93 | "cl" ->
94 Cl.invoke argv 2
96 | "dep7" ->
97 if Array.length argv < 3
98 then
99 show_usage ()
100 else
101 let target = argv.(2) in
102 Dep7.invoke target argv 3
104 | "dep" ->
105 if Array.length argv < 3
106 then
107 show_usage ()
108 else
109 let target = argv.(2) in
110 Dep.invoke target argv 3
112 | "link" ->
113 Link.invoke argv 2
115 | "dep7-test" ->
116 Dep7.test ()
118 | "cldep7" ->
119 if Array.length argv < 4
120 then
121 show_usage ()
122 else
123 let target = argv.(2)
124 and depfile = argv.(3) in
125 Dep7.invoke2 target depfile argv 4
127 | "help" ->
128 help ()
130 | cmd ->
131 prerr_string "invalid command: ";
132 prerr_string (String.escaped cmd);
133 prerr_newline ();
134 show_usage ()
136 exit code
139 let _ =
140 main Sys.argv