提交 9ab6fc59 编写于 作者: R Richard Levitte

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: NRich Salz <rsalz@openssl.org>
上级 52cdc997
...@@ -1752,7 +1752,7 @@ sub run_dofile() ...@@ -1752,7 +1752,7 @@ sub run_dofile()
my $out = shift; my $out = shift;
# should we remove $out ? # should we remove $out ?
system("$config{perl} -I. -Mconfigdata util/dofile.pl <$in >$out.new"); system("$config{perl} -I. -Mconfigdata util/dofile.pl -o\"Configure\" $in > $out.new");
exit 1 if $? != 0; exit 1 if $? != 0;
rename("$out.new", $out) || die "Can't rename $out.new, $!"; rename("$out.new", $out) || die "Can't rename $out.new, $!";
} }
......
## ##
## Makefile for OpenSSL ## Makefile for OpenSSL
## ##
## {- join("\n## ", @autowarntext) -}
VERSION={- $config{version} -} VERSION={- $config{version} -}
MAJOR={- $config{major} -} MAJOR={- $config{major} -}
......
#!{- $config{perl} -} #!{- $config{perl} -}
# #
# Wrapper around the ca to make it easier to use # Wrapper around the ca to make it easier to use
# Edit CA.pl.in not CA.pl! #
# {- join("\n# ", @autowarntext) -}
use strict; use strict;
use warnings; use warnings;
......
...@@ -140,7 +140,7 @@ progs.h: progs.pl Makefile ...@@ -140,7 +140,7 @@ progs.h: progs.pl Makefile
$(RM) openssl.o $(RM) openssl.o
CA.pl: CA.pl.in CA.pl: CA.pl.in
$(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl < CA.pl.in > CA.pl.new $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl -oapps/Makefile CA.pl.in > CA.pl.new
mv CA.pl.new CA.pl mv CA.pl.new CA.pl
......
{- join("\n",map { "/* $_ */" } @autowarntext) -}
/* ==================================================================== /* ====================================================================
* Copyright (c) 2016 The OpenSSL Project. All rights reserved. * Copyright (c) 2016 The OpenSSL Project. All rights reserved.
* *
......
{- join("\n",map { "/* $_ */" } @autowarntext) -}
/* ==================================================================== /* ====================================================================
* Copyright (c) 2016 The OpenSSL Project. All rights reserved. * Copyright (c) 2016 The OpenSSL Project. All rights reserved.
* *
......
{- join("\n",map { "/* $_ */" } @autowarntext) -}
/* ==================================================================== /* ====================================================================
* Copyright (c) 2016 The OpenSSL Project. All rights reserved. * Copyright (c) 2016 The OpenSSL Project. All rights reserved.
* *
......
{- join("\n",map { "/* $_ */" } @autowarntext) -}
/* ==================================================================== /* ====================================================================
* Copyright (c) 2016 The OpenSSL Project. All rights reserved. * Copyright (c) 2016 The OpenSSL Project. All rights reserved.
* *
......
/* opensslconf.h */ /* opensslconf.h */
/* WARNING: Generated automatically from opensslconf.h.in by Configure. */ {- join("\n",map { "/* $_ */" } @autowarntext) -}
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
......
...@@ -59,7 +59,7 @@ clean: ...@@ -59,7 +59,7 @@ clean:
errors: errors:
c_rehash: c_rehash.in c_rehash: c_rehash.in
$(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl < c_rehash.in > c_rehash.new $(PERL) -I$(TOP) -Mconfigdata $(TOP)/util/dofile.pl -otools/Makefile c_rehash.in > c_rehash.new
mv c_rehash.new c_rehash mv c_rehash.new c_rehash
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.
#!{- $config{perl} -} #!{- $config{perl} -}
# {- join("\n# ", @autowarntext) -}
# Perl c_rehash script, scan all files in a directory # Perl c_rehash script, scan all files in a directory
# and add symbolic links to their hash values. # and add symbolic links to their hash values.
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
use strict; use strict;
use warnings; use warnings;
use Getopt::Std;
# Because we know that Text::Template isn't a core Perl module, we use # 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 # a fallback in case it's not installed on the system
use File::Basename; use File::Basename;
...@@ -74,6 +76,19 @@ sub broken { ...@@ -74,6 +76,19 @@ sub broken {
undef; 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 ################################################### # Template reading ###################################################
# Read in all the templates into $text, while keeping track of each # Read in all the templates into $text, while keeping track of each
...@@ -100,6 +115,7 @@ $template->fill_in(OUTPUT => \*STDOUT, ...@@ -100,6 +115,7 @@ $template->fill_in(OUTPUT => \*STDOUT,
HASH => { config => \%config, HASH => { config => \%config,
target => \%target, target => \%target,
withargs => \%withargs, withargs => \%withargs,
autowarntext => \@autowarntext,
quotify1 => \&quotify1, quotify1 => \&quotify1,
quotify_l => \&quotify_l }, quotify_l => \&quotify_l },
DELIMITERS => [ "{-", "-}" ], DELIMITERS => [ "{-", "-}" ],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册