From: Richard W.M. Jones Date: Sun, 12 Dec 2010 23:18:26 +0000 (+0000) Subject: generator: List files generated in a separate file. X-Git-Tag: 1.7.24~4 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=dec770f171329868081985ca0aa3d52eb3759935;p=libguestfs.git generator: List files generated in a separate file. --- diff --git a/.gitignore b/.gitignore index 4083a91..4887c31 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ fuse/guestmount fuse/guestmount.1 fuse/stamp-guestmount.pod generator/.pod2text.data* +generator/files-generated.txt generator/generator generator/stamp-generator guestfish.1 diff --git a/generator/Makefile.am b/generator/Makefile.am index b9fcfb9..39688c1 100644 --- a/generator/Makefile.am +++ b/generator/Makefile.am @@ -52,7 +52,7 @@ SOURCES = \ SOURCES_ML = $(filter %.ml,$(SOURCES)) OBJECTS = $(SOURCES_ML:.ml=.cmo) -EXTRA_DIST = $(SOURCES) +EXTRA_DIST = $(SOURCES) files-generated.txt OCAMLCFLAGS = -warn-error CDEFLMPSUVYZX OCAMLCLIBS = unix.cma str.cma diff --git a/generator/generator_main.ml b/generator/generator_main.ml index bf1e8e0..4ef9ba5 100644 --- a/generator/generator_main.ml +++ b/generator/generator_main.ml @@ -132,11 +132,15 @@ Run it from the top source directory using the command output_to "php/extension/php_guestfs_php.h" generate_php_h; output_to "php/extension/guestfs_php.c" generate_php_c; + (* Generate the list of files generated -- last. *) + printf "generated %d lines of code\n" (get_lines_generated ()); + let files = List.sort compare (get_files_generated ()) in + output_to "generator/files-generated.txt" + (fun () -> List.iter (pr "%s\n") files); + (* Always generate this file last, and unconditionally. It's used * by the Makefile to know when we must re-run the generator. *) let chan = open_out "generator/stamp-generator" in fprintf chan "1\n"; - close_out chan; - - printf "generated %d lines of code\n" (get_lines_generated ()) + close_out chan diff --git a/generator/generator_pr.ml b/generator/generator_pr.ml index eef565e..221a8eb 100644 --- a/generator/generator_pr.ml +++ b/generator/generator_pr.ml @@ -23,9 +23,18 @@ open Printf open Generator_utils -(* 'pr' prints to the current output file. *) +(* Output channel, 'pr' prints to this. *) let chan = ref Pervasives.stdout + +(* Number of lines generated. *) let lines = ref 0 + +(* Name of each file generated. *) +let files = ref [] + +(* Print-to-current-output function, used everywhere. It has + * printf-like semantics. + *) let pr fs = ksprintf (fun str -> @@ -35,6 +44,8 @@ let pr fs = ) fs let output_to filename k = + files := filename :: !files; + let filename_new = filename ^ ".new" in chan := open_out filename_new; k (); @@ -54,3 +65,6 @@ let output_to filename k = let get_lines_generated () = !lines + +let get_files_generated () = + List.rev !files diff --git a/generator/generator_pr.mli b/generator/generator_pr.mli index 2b09e06..f4d658e 100644 --- a/generator/generator_pr.mli +++ b/generator/generator_pr.mli @@ -30,3 +30,6 @@ val output_to : string -> (unit -> unit) -> unit val get_lines_generated : unit -> int (** Return number of lines of code generated. *) + +val get_files_generated : unit -> string list +(** Return names of the files that were generated. *)