From fe96e2400194a58f236434ca61041e31af236ba6 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 2 Jul 2019 16:32:31 +0200 Subject: [PATCH] p2v: generate C about data authors from AUTHORS file Create a small Perl script to generate about-authors.c from the p2v AUTHORS file at build time, instead of generating in the generator at dist time. --- docs/C_SOURCE_FILES | 1 - generator/authors.ml | 37 ------------------------- generator/authors.mli | 1 - generator/main.ml | 2 -- p2v/Makefile.am | 10 ++++--- p2v/generate-p2v-authors.pl | 54 +++++++++++++++++++++++++++++++++++++ 6 files changed, 61 insertions(+), 44 deletions(-) create mode 100755 p2v/generate-p2v-authors.pl diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES index 20a38162c..c9a576c0c 100644 --- a/docs/C_SOURCE_FILES +++ b/docs/C_SOURCE_FILES @@ -355,7 +355,6 @@ ocaml/guestfs-c-actions.c ocaml/guestfs-c-errnos.c ocaml/guestfs-c.c ocaml/guestfs-c.h -p2v/about-authors.c p2v/conversion.c p2v/cpuid.c p2v/gui-gtk2-compat.h diff --git a/generator/authors.ml b/generator/authors.ml index 14403c624..3c8ee1de3 100644 --- a/generator/authors.ml +++ b/generator/authors.ml @@ -135,43 +135,6 @@ let authors = [ let generate_authors () = List.iter (fun (name, _, _) -> pr "%s\n" name) authors -let generate_p2v_about_authors_c () = - generate_header CStyle GPLv2plus; - - pr "#include \n"; - pr "\n"; - pr "#include \"p2v.h\"\n"; - pr "\n"; - - (* Split up the list according to how we want to add people to - * credit sections. However don't assign anyone to more than a - * single category. Be aware that with Gtk < 3.4, only the - * "authors" and "documenters" categories are actually displayed. - *) - let authors, qa, documenters, others = - let rec loop (authors, qa, documenters, others) = function - | [] -> authors, qa, documenters, others - | ((_, _, roles) as a) :: rest -> - if List.mem V2V_and_P2V roles then - loop (a :: authors, qa, documenters, others) rest - else if List.mem Quality_assurance roles then - loop (authors, a :: qa, documenters, others) rest - else if List.mem Documentation roles then - loop (authors, qa, a :: documenters, others) rest - else - loop (authors, qa, documenters, a :: others) rest - in - let authors, qa, documenters, others = loop ([],[],[],[]) authors in - List.rev authors, List.rev qa, List.rev documenters, List.rev others in - - let fn (name, _, _) = pr " \"%s\",\n" name in - - pr "/* Authors involved with virt-v2v and virt-p2v directly. */\n"; - pr "const char *authors[] = {\n"; - List.iter fn authors; - pr " NULL\n"; - pr "};\n" - let generate_p2v_authors () = let p2v_authors = List.filter_map ( diff --git a/generator/authors.mli b/generator/authors.mli index f63ff3264..834bcb811 100644 --- a/generator/authors.mli +++ b/generator/authors.mli @@ -23,5 +23,4 @@ val authors : (string * string list * role list) list (** List of authors, their aliases, and their roles. *) val generate_authors : unit -> unit -val generate_p2v_about_authors_c : unit -> unit val generate_p2v_authors : unit -> unit diff --git a/generator/main.ml b/generator/main.ml index 5e6f067bb..acacfb9e4 100644 --- a/generator/main.ml +++ b/generator/main.ml @@ -75,8 +75,6 @@ Run it from the top source directory using the command output_to "AUTHORS" Authors.generate_authors; - output_to "p2v/about-authors.c" - Authors.generate_p2v_about_authors_c; output_to "p2v/AUTHORS" Authors.generate_p2v_authors; diff --git a/p2v/Makefile.am b/p2v/Makefile.am index 689722ad8..20e00fcc0 100644 --- a/p2v/Makefile.am +++ b/p2v/Makefile.am @@ -18,7 +18,6 @@ include $(top_srcdir)/subdir-rules.mk generator_built = \ - about-authors.c \ AUTHORS BUILT_SOURCES = \ @@ -28,6 +27,7 @@ EXTRA_DIST = \ $(BUILT_SOURCES) \ $(TESTS) $(SLOW_TESTS) \ dependencies.m4 \ + generate-p2v-authors.pl \ generate-p2v-config.pl \ issue \ kiwi-config.sh \ @@ -52,6 +52,7 @@ EXTRA_DIST = \ CLEANFILES += \ $(dependencies_files) \ $(generated_sources) \ + about-authors.c \ stamp-test-virt-p2v-pxe-data-files \ stamp-test-virt-p2v-pxe-kernel \ test-virt-p2v-pxe.authorized_keys \ @@ -81,7 +82,6 @@ virt-p2v.xz: virt-p2v noinst_PROGRAMS = virt-p2v virt_p2v_SOURCES = \ - about-authors.c \ conversion.c \ cpuid.c \ gui.c \ @@ -105,7 +105,8 @@ generated_sources = \ kernel-config.c nodist_virt_p2v_SOURCES = \ - $(generated_sources) + $(generated_sources) \ + about-authors.c virt_p2v_CPPFLAGS = \ -DLOCALEBASEDIR=\""$(datadir)/locale"\" \ @@ -135,6 +136,9 @@ virt_p2v_LDADD = \ $(generated_sources) virt-p2v-kernel-config.pod: $(srcdir)/generate-p2v-config.pl $(AM_V_GEN)rm -f $@ $@-t && $(PERL) $(<) --file=$@ --output=$@-t && mv $@-t $@ +about-authors.c: $(srcdir)/generate-p2v-authors.pl $(srcdir)/AUTHORS + $(AM_V_GEN)rm -f $@ $@-t && $(PERL) $(<) $(srcdir)/AUTHORS > $@-t && mv $@-t $@ + # Scripts to build the disk image, USB key, or kickstart. bin_SCRIPTS = virt-p2v-make-disk virt-p2v-make-kickstart virt-p2v-make-kiwi diff --git a/p2v/generate-p2v-authors.pl b/p2v/generate-p2v-authors.pl new file mode 100755 index 000000000..18a825bd7 --- /dev/null +++ b/p2v/generate-p2v-authors.pl @@ -0,0 +1,54 @@ +#!/usr/bin/env perl +# Copyright (C) 2019 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use strict; +use warnings; + +# Clean up the program name. +my $progname = $0; +$progname =~ s{.*/}{}; + +my $filename = shift or die "$progname: missing filename"; + +open(my $fh, '<', $filename) or die "Unable to open file '$filename': $!"; + +print <<"EOF"; +/* libguestfs generated file + * WARNING: THIS FILE IS GENERATED FROM THE FOLLOWING FILES: + * $filename + * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST. + */ + +#include + +#include "p2v.h" + +/* Authors involved with virt-v2v and virt-p2v directly. */ +const char *authors[] = { +EOF + +while (<$fh>) { + chomp $_; + printf " \"%s\",\n", $_; +} + +print <<"EOF"; + NULL +}; +EOF + +close($fh);