security/nss/coreconf/jniregen.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/coreconf/jniregen.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,79 @@
     1.4 +#!/usr/local/bin/perl
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +# Input: -d dir -j javahcmd foo1 foo2 . . .
    1.11 +#        Compares generated "_jni/foo1.h" file with "foo1.class", and
    1.12 +#        generated "_jni/foo2.h" file with "foo2.class", etc.
    1.13 +#        (NOTE:  unlike its closely related cousin, outofdate.pl,
    1.14 +#                the "-d dir" must always be specified)
    1.15 +#        Runs the javahcmd on all files that are different.
    1.16 +#
    1.17 +# Returns: list of headers which are OLDER than corresponding class
    1.18 +#          files (non-existent class files are considered to be real old :-)
    1.19 +
    1.20 +my $javah = "";
    1.21 +my $classdir = "";
    1.22 +
    1.23 +while(1) {
    1.24 +    if ($ARGV[0] eq '-d') {
    1.25 +        $classdir = $ARGV[1];
    1.26 +        $classdir .= "/";
    1.27 +        shift;
    1.28 +        shift;
    1.29 +    } elsif($ARGV[0] eq '-j') {
    1.30 +        $javah = $ARGV[1];
    1.31 +        shift;
    1.32 +        shift;
    1.33 +    } else {
    1.34 +        last;
    1.35 +    }
    1.36 +}
    1.37 +
    1.38 +if( $javah  eq "") {
    1.39 +    die "Must specify -j <javah command>";
    1.40 +}
    1.41 +if( $classdir eq "") {
    1.42 +    die "Must specify -d <classdir>";
    1.43 +}
    1.44 +
    1.45 +foreach $filename (@ARGV)
    1.46 +{
    1.47 +    $headerfilename = "_jni/";
    1.48 +    $headerfilename .= $filename;
    1.49 +    $headerfilename =~ s/\./_/g;
    1.50 +    $headerfilename .= ".h";
    1.51 +
    1.52 +    $classfilename = $filename;
    1.53 +    $classfilename =~ s|\.|/|g;
    1.54 +    $classfilename .= ".class";
    1.55 +
    1.56 +    $classfilename = $classdir . $classfilename;
    1.57 +
    1.58 +
    1.59 +    ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $headermtime,
    1.60 +      $ctime, $blksize, $blocks ) = stat( $headerfilename );
    1.61 +
    1.62 +    ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $classmtime,
    1.63 +      $ctime, $blksize, $blocks ) = stat( $classfilename );
    1.64 +
    1.65 +    if( $headermtime < $classmtime )
    1.66 +    {
    1.67 +	# NOTE:  Since this is used by "javah", and "javah" refuses to overwrite
    1.68 +	#        an existing file, we force an unlink from this script, since
    1.69 +	#        we actually want to regenerate the header file at this time.
    1.70 +        unlink $headerfilename;
    1.71 +        push @filelist, $filename;
    1.72 +    }
    1.73 +}
    1.74 +
    1.75 +if( @filelist ) {
    1.76 +    $cmd = "$javah " . join(" ",@filelist);
    1.77 +    $cmd =~ s/\'/\"/g;  # because windows doesn't understand single quote
    1.78 +    print "$cmd\n";
    1.79 +    exit (system($cmd) >> 8);
    1.80 +} else {
    1.81 +    print "All JNI header files up to date.\n"
    1.82 +}

mercurial