summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2010-12-12 23:18:26 +0000
committerRichard W.M. Jones <rjones@redhat.com>2010-12-12 23:19:36 +0000
commitdec770f171329868081985ca0aa3d52eb3759935 (patch)
tree0beb81b58eda78d7bf288d0b9a2d659db903dca4 /generator
parent9aacbe712d1326cff05a7343cf4603df38e96ef7 (diff)
downloadlibguestfs-dec770f171329868081985ca0aa3d52eb3759935.tar.gz
libguestfs-dec770f171329868081985ca0aa3d52eb3759935.tar.xz
libguestfs-dec770f171329868081985ca0aa3d52eb3759935.zip
generator: List files generated in a separate file.
Diffstat (limited to 'generator')
-rw-r--r--generator/Makefile.am2
-rw-r--r--generator/generator_main.ml10
-rw-r--r--generator/generator_pr.ml16
-rw-r--r--generator/generator_pr.mli3
4 files changed, 26 insertions, 5 deletions
diff --git a/generator/Makefile.am b/generator/Makefile.am
index b9fcfb94..39688c1b 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 bf1e8e0b..4ef9ba51 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 eef565e0..221a8ebd 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 2b09e06e..f4d658e7 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. *)