security/nss/coreconf/jniregen.pl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 #!/usr/local/bin/perl
     2 #
     3 # This Source Code Form is subject to the terms of the Mozilla Public
     4 # License, v. 2.0. If a copy of the MPL was not distributed with this
     5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     7 # Input: -d dir -j javahcmd foo1 foo2 . . .
     8 #        Compares generated "_jni/foo1.h" file with "foo1.class", and
     9 #        generated "_jni/foo2.h" file with "foo2.class", etc.
    10 #        (NOTE:  unlike its closely related cousin, outofdate.pl,
    11 #                the "-d dir" must always be specified)
    12 #        Runs the javahcmd on all files that are different.
    13 #
    14 # Returns: list of headers which are OLDER than corresponding class
    15 #          files (non-existent class files are considered to be real old :-)
    17 my $javah = "";
    18 my $classdir = "";
    20 while(1) {
    21     if ($ARGV[0] eq '-d') {
    22         $classdir = $ARGV[1];
    23         $classdir .= "/";
    24         shift;
    25         shift;
    26     } elsif($ARGV[0] eq '-j') {
    27         $javah = $ARGV[1];
    28         shift;
    29         shift;
    30     } else {
    31         last;
    32     }
    33 }
    35 if( $javah  eq "") {
    36     die "Must specify -j <javah command>";
    37 }
    38 if( $classdir eq "") {
    39     die "Must specify -d <classdir>";
    40 }
    42 foreach $filename (@ARGV)
    43 {
    44     $headerfilename = "_jni/";
    45     $headerfilename .= $filename;
    46     $headerfilename =~ s/\./_/g;
    47     $headerfilename .= ".h";
    49     $classfilename = $filename;
    50     $classfilename =~ s|\.|/|g;
    51     $classfilename .= ".class";
    53     $classfilename = $classdir . $classfilename;
    56     ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $headermtime,
    57       $ctime, $blksize, $blocks ) = stat( $headerfilename );
    59     ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $classmtime,
    60       $ctime, $blksize, $blocks ) = stat( $classfilename );
    62     if( $headermtime < $classmtime )
    63     {
    64 	# NOTE:  Since this is used by "javah", and "javah" refuses to overwrite
    65 	#        an existing file, we force an unlink from this script, since
    66 	#        we actually want to regenerate the header file at this time.
    67         unlink $headerfilename;
    68         push @filelist, $filename;
    69     }
    70 }
    72 if( @filelist ) {
    73     $cmd = "$javah " . join(" ",@filelist);
    74     $cmd =~ s/\'/\"/g;  # because windows doesn't understand single quote
    75     print "$cmd\n";
    76     exit (system($cmd) >> 8);
    77 } else {
    78     print "All JNI header files up to date.\n"
    79 }

mercurial