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

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

mercurial