Generate warning text

Now that we're using templates, we should warn people not to edit the
resulting file.  We do it through util/dofile.pl, which is enhanced
with an option to tell what file it was called from.  We also change
the calls so the template files are on the command line instead of
being redirected through standard input.  That way, we can display
something like this (example taken from include/openssl/opensslconf.h):

    /* WARNING: do not edit! */
    /* Generated by Configure from include/openssl/opensslconf.h.in */

Reviewed-by: Rich Salz <rsalz@openssl.org>
This commit is contained in:
Richard Levitte
2016-01-25 21:19:59 +01:00
parent 52cdc9970d
commit 9ab6fc5936
12 changed files with 29 additions and 6 deletions

View File

@@ -8,6 +8,8 @@
use strict;
use warnings;
use Getopt::Std;
# Because we know that Text::Template isn't a core Perl module, we use
# a fallback in case it's not installed on the system
use File::Basename;
@@ -74,6 +76,19 @@ sub broken {
undef;
}
# Check options ######################################################
my %opts = ();
# -o ORIGINATOR
# declares ORIGINATOR as the originating script.
getopt('o', \%opts);
my @autowarntext = ("WARNING: do not edit!",
"Generated"
. (defined($opts{o}) ? " by ".$opts{o} : "")
. (scalar(@ARGV) > 0 ? " from ".join(", ",@ARGV) : ""));
# Template reading ###################################################
# Read in all the templates into $text, while keeping track of each
@@ -100,6 +115,7 @@ $template->fill_in(OUTPUT => \*STDOUT,
HASH => { config => \%config,
target => \%target,
withargs => \%withargs,
autowarntext => \@autowarntext,
quotify1 => \&quotify1,
quotify_l => \&quotify_l },
DELIMITERS => [ "{-", "-}" ],