michael@0: #!/usr/local/bin/perl michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # Input: -d dir -j javahcmd foo1 foo2 . . . michael@0: # Compares generated "_jni/foo1.h" file with "foo1.class", and michael@0: # generated "_jni/foo2.h" file with "foo2.class", etc. michael@0: # (NOTE: unlike its closely related cousin, outofdate.pl, michael@0: # the "-d dir" must always be specified) michael@0: # Runs the javahcmd on all files that are different. michael@0: # michael@0: # Returns: list of headers which are OLDER than corresponding class michael@0: # files (non-existent class files are considered to be real old :-) michael@0: michael@0: my $javah = ""; michael@0: my $classdir = ""; michael@0: michael@0: while(1) { michael@0: if ($ARGV[0] eq '-d') { michael@0: $classdir = $ARGV[1]; michael@0: $classdir .= "/"; michael@0: shift; michael@0: shift; michael@0: } elsif($ARGV[0] eq '-j') { michael@0: $javah = $ARGV[1]; michael@0: shift; michael@0: shift; michael@0: } else { michael@0: last; michael@0: } michael@0: } michael@0: michael@0: if( $javah eq "") { michael@0: die "Must specify -j "; michael@0: } michael@0: if( $classdir eq "") { michael@0: die "Must specify -d "; michael@0: } michael@0: michael@0: foreach $filename (@ARGV) michael@0: { michael@0: $headerfilename = "_jni/"; michael@0: $headerfilename .= $filename; michael@0: $headerfilename =~ s/\./_/g; michael@0: $headerfilename .= ".h"; michael@0: michael@0: $classfilename = $filename; michael@0: $classfilename =~ s|\.|/|g; michael@0: $classfilename .= ".class"; michael@0: michael@0: $classfilename = $classdir . $classfilename; michael@0: michael@0: michael@0: ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $headermtime, michael@0: $ctime, $blksize, $blocks ) = stat( $headerfilename ); michael@0: michael@0: ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $classmtime, michael@0: $ctime, $blksize, $blocks ) = stat( $classfilename ); michael@0: michael@0: if( $headermtime < $classmtime ) michael@0: { michael@0: # NOTE: Since this is used by "javah", and "javah" refuses to overwrite michael@0: # an existing file, we force an unlink from this script, since michael@0: # we actually want to regenerate the header file at this time. michael@0: unlink $headerfilename; michael@0: push @filelist, $filename; michael@0: } michael@0: } michael@0: michael@0: if( @filelist ) { michael@0: $cmd = "$javah " . join(" ",@filelist); michael@0: $cmd =~ s/\'/\"/g; # because windows doesn't understand single quote michael@0: print "$cmd\n"; michael@0: exit (system($cmd) >> 8); michael@0: } else { michael@0: print "All JNI header files up to date.\n" michael@0: }