3
(* ocamldep.wrapper <filename> ... <filename> - <ocamldep command>
4
runs the <ocamldep command> in an environment where all of the
5
<filenames> listed appear to exist. The files are created, if
6
required, before the command is run, and destroyed afterwards. *)
10
(* Parse the command line. The arguments that precede "-" are understood
11
as file names and stored in the list [xs]. The arguments that follow
12
"-" are understood as a command and stored in [command]. *)
23
let rec loop accumulating i =
24
if i = Array.length Sys.argv then
26
else if accumulating then
27
match Sys.argv.(i) with
34
xs := Sys.argv.(i) :: !xs;
37
command := sprintf "%s %s" !command (Filename.quote Sys.argv.(i));
44
(* Create the required files if they don't exist, run the command,
45
then destroy any files that we have created. *)
47
let rec loop = function
50
fprintf stderr "ocamldep.wrapper: running %s\n" !command;
53
if Sys.file_exists x then
57
fprintf stderr "ocamldep.wrapper: creating fake %s\n" x;
60
let exitcode = loop xs in
61
if Sys.file_exists x then begin
64
fprintf stderr "ocamldep.wrapper: removing fake %s..." x;
67
fprintf stderr " ok\n"
70
fprintf stderr " failed\n"