提交 22defb43 编写于 作者: R Rich Salz

Make some perl scripts output to stdout

And only generate one output "file" at a time for objects.pl
Reviewed-by: NRichard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5432)
上级 4c861b38
...@@ -651,13 +651,18 @@ generate_crypto_bn: ...@@ -651,13 +651,18 @@ generate_crypto_bn:
( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h ) ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
generate_crypto_objects: generate_crypto_objects:
( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
crypto/objects/objects.txt \
crypto/objects/obj_mac.num \
> crypto/objects/obj_mac.new && \
mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \ ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
crypto/objects/objects.txt \ crypto/objects/objects.txt \
crypto/objects/obj_mac.num \ crypto/objects/obj_mac.num \
include/openssl/obj_mac.h ) > include/openssl/obj_mac.h )
( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \ ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
include/openssl/obj_mac.h \ include/openssl/obj_mac.h \
crypto/objects/obj_dat.h ) > crypto/objects/obj_dat.h )
( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \ ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
crypto/objects/obj_mac.num \ crypto/objects/obj_mac.num \
crypto/objects/obj_xref.txt \ crypto/objects/obj_xref.txt \
......
...@@ -152,8 +152,7 @@ for (my $i = 0; $i < $n; $i++) { ...@@ -152,8 +152,7 @@ for (my $i = 0; $i < $n; $i++) {
} }
# Finally ready to generate the output. # Finally ready to generate the output.
open(OUT, ">$ARGV[1]") || die "Can't open output file $ARGV[1], $!"; print <<"EOF";
print OUT <<"EOF";
/* /*
* WARNING: do not edit! * WARNING: do not edit!
* Generated by crypto/objects/obj_dat.pl * Generated by crypto/objects/obj_dat.pl
...@@ -167,44 +166,44 @@ print OUT <<"EOF"; ...@@ -167,44 +166,44 @@ print OUT <<"EOF";
EOF EOF
print OUT "/* Serialized OID's */\n"; print "/* Serialized OID's */\n";
printf OUT "static const unsigned char so[%d] = {\n", $lvalues + 1; printf "static const unsigned char so[%d] = {\n", $lvalues + 1;
print OUT @lvalues; print @lvalues;
print OUT "};\n\n"; print "};\n\n";
printf OUT "#define NUM_NID %d\n", $n; printf "#define NUM_NID %d\n", $n;
printf OUT "static const ASN1_OBJECT nid_objs[NUM_NID] = {\n"; printf "static const ASN1_OBJECT nid_objs[NUM_NID] = {\n";
print OUT @out; print @out;
print OUT "};\n\n"; print "};\n\n";
{ {
no warnings "uninitialized"; no warnings "uninitialized";
@a = grep(defined $sn{$nid{$_}}, 0 .. $n); @a = grep(defined $sn{$nid{$_}}, 0 .. $n);
} }
printf OUT "#define NUM_SN %d\n", $#a + 1; printf "#define NUM_SN %d\n", $#a + 1;
printf OUT "static const unsigned int sn_objs[NUM_SN] = {\n"; printf "static const unsigned int sn_objs[NUM_SN] = {\n";
foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) { foreach (sort { $sn{$nid{$a}} cmp $sn{$nid{$b}} } @a) {
printf OUT " %4d, /* \"$sn{$nid{$_}}\" */\n", $_; printf " %4d, /* \"$sn{$nid{$_}}\" */\n", $_;
} }
print OUT "};\n\n"; print "};\n\n";
{ {
no warnings "uninitialized"; no warnings "uninitialized";
@a = grep(defined $ln{$nid{$_}}, 0 .. $n); @a = grep(defined $ln{$nid{$_}}, 0 .. $n);
} }
printf OUT "#define NUM_LN %d\n", $#a + 1; printf "#define NUM_LN %d\n", $#a + 1;
printf OUT "static const unsigned int ln_objs[NUM_LN] = {\n"; printf "static const unsigned int ln_objs[NUM_LN] = {\n";
foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) { foreach (sort { $ln{$nid{$a}} cmp $ln{$nid{$b}} } @a) {
printf OUT " %4d, /* \"$ln{$nid{$_}}\" */\n", $_; printf " %4d, /* \"$ln{$nid{$_}}\" */\n", $_;
} }
print OUT "};\n\n"; print "};\n\n";
{ {
no warnings "uninitialized"; no warnings "uninitialized";
@a = grep(defined $obj{$nid{$_}}, 0 .. $n); @a = grep(defined $obj{$nid{$_}}, 0 .. $n);
} }
printf OUT "#define NUM_OBJ %d\n", $#a + 1; printf "#define NUM_OBJ %d\n", $#a + 1;
printf OUT "static const unsigned int obj_objs[NUM_OBJ] = {\n"; printf "static const unsigned int obj_objs[NUM_OBJ] = {\n";
# Compare DER; prefer shorter; if some length, use the "smaller" encoding. # Compare DER; prefer shorter; if some length, use the "smaller" encoding.
sub obj_cmp sub obj_cmp
...@@ -224,8 +223,6 @@ foreach (sort obj_cmp @a) { ...@@ -224,8 +223,6 @@ foreach (sort obj_cmp @a) {
my $v = $objd{$m}; my $v = $objd{$m};
$v =~ s/L//g; $v =~ s/L//g;
$v =~ s/,/ /g; $v =~ s/,/ /g;
printf OUT " %4d, /* %-32s %s */\n", $_, $m, $v; printf " %4d, /* %-32s %s */\n", $_, $m, $v;
} }
print OUT "};\n"; print "};\n";
close OUT;
...@@ -6,7 +6,12 @@ ...@@ -6,7 +6,12 @@
# in the file LICENSE in the source distribution or at # in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html # https://www.openssl.org/source/license.html
# Output year depends on the year of the script and the input files. use Getopt::Std;
our($opt_n);
getopts('n');
# Output year depends on the year of the script and the input file.
my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900; my $YEAR = [localtime([stat($0)]->[9])]->[5] + 1900;
my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900; my $iYEAR = [localtime([stat($ARGV[0])]->[9])]->[5] + 1900;
$YEAR = $iYEAR if $iYEAR > $YEAR; $YEAR = $iYEAR if $iYEAR > $YEAR;
...@@ -123,15 +128,15 @@ print STDERR "Added OID $Cname\n"; ...@@ -123,15 +128,15 @@ print STDERR "Added OID $Cname\n";
} }
close IN; close IN;
open (NUMOUT,">$ARGV[1]") || die "Can't open output file $ARGV[1]"; if ( $opt_n ) {
foreach (sort { $a <=> $b } keys %nidn) foreach (sort { $a <=> $b } keys %nidn)
{ {
print NUMOUT $nidn{$_},"\t\t",$_,"\n"; print $nidn{$_},"\t\t",$_,"\n";
} }
close NUMOUT; exit;
}
open (OUT,">$ARGV[2]") || die "Can't open output file $ARGV[2]"; print <<"EOF";
print OUT <<"EOF";
/* /*
* WARNING: do not edit! * WARNING: do not edit!
* Generated by crypto/objects/objects.pl * Generated by crypto/objects/objects.pl
...@@ -161,15 +166,13 @@ sub expand ...@@ -161,15 +166,13 @@ sub expand
foreach (sort { $a <=> $b } keys %ordern) foreach (sort { $a <=> $b } keys %ordern)
{ {
$Cname=$ordern{$_}; $Cname=$ordern{$_};
print OUT "\n"; print "\n";
print OUT expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne ""; print expand("#define SN_$Cname\t\t\"$sn{$Cname}\"\n") if $sn{$Cname} ne "";
print OUT expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne ""; print expand("#define LN_$Cname\t\t\"$ln{$Cname}\"\n") if $ln{$Cname} ne "";
print OUT expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne ""; print expand("#define NID_$Cname\t\t$nid{$Cname}\n") if $nid{$Cname} ne "";
print OUT expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne ""; print expand("#define OBJ_$Cname\t\t$obj{$Cname}\n") if $obj{$Cname} ne "";
} }
close OUT;
sub process_oid sub process_oid
{ {
local($oid)=@_; local($oid)=@_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册