/security/coreconf/jniregen.pl

http://github.com/zpao/v8monkey · Perl · 111 lines · 50 code · 12 blank · 49 comment · 7 complexity · 48aec4b74881f5e516c0deebe0b392f1 MD5 · raw file

  1. #!/usr/local/bin/perl
  2. #
  3. # ***** BEGIN LICENSE BLOCK *****
  4. # Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. #
  6. # The contents of this file are subject to the Mozilla Public License Version
  7. # 1.1 (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. # http://www.mozilla.org/MPL/
  10. #
  11. # Software distributed under the License is distributed on an "AS IS" basis,
  12. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. # for the specific language governing rights and limitations under the
  14. # License.
  15. #
  16. # The Original Code is the Netscape security libraries.
  17. #
  18. # The Initial Developer of the Original Code is
  19. # Netscape Communications Corporation.
  20. # Portions created by the Initial Developer are Copyright (C) 1994-2000
  21. # the Initial Developer. All Rights Reserved.
  22. #
  23. # Contributor(s):
  24. #
  25. # Alternatively, the contents of this file may be used under the terms of
  26. # either the GNU General Public License Version 2 or later (the "GPL"), or
  27. # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. # in which case the provisions of the GPL or the LGPL are applicable instead
  29. # of those above. If you wish to allow use of your version of this file only
  30. # under the terms of either the GPL or the LGPL, and not to allow others to
  31. # use your version of this file under the terms of the MPL, indicate your
  32. # decision by deleting the provisions above and replace them with the notice
  33. # and other provisions required by the GPL or the LGPL. If you do not delete
  34. # the provisions above, a recipient may use your version of this file under
  35. # the terms of any one of the MPL, the GPL or the LGPL.
  36. #
  37. # ***** END LICENSE BLOCK *****
  38. # Input: -d dir -j javahcmd foo1 foo2 . . .
  39. # Compares generated "_jni/foo1.h" file with "foo1.class", and
  40. # generated "_jni/foo2.h" file with "foo2.class", etc.
  41. # (NOTE: unlike its closely related cousin, outofdate.pl,
  42. # the "-d dir" must always be specified)
  43. # Runs the javahcmd on all files that are different.
  44. #
  45. # Returns: list of headers which are OLDER than corresponding class
  46. # files (non-existent class files are considered to be real old :-)
  47. my $javah = "";
  48. my $classdir = "";
  49. while(1) {
  50. if ($ARGV[0] eq '-d') {
  51. $classdir = $ARGV[1];
  52. $classdir .= "/";
  53. shift;
  54. shift;
  55. } elsif($ARGV[0] eq '-j') {
  56. $javah = $ARGV[1];
  57. shift;
  58. shift;
  59. } else {
  60. last;
  61. }
  62. }
  63. if( $javah eq "") {
  64. die "Must specify -j <javah command>";
  65. }
  66. if( $classdir eq "") {
  67. die "Must specify -d <classdir>";
  68. }
  69. foreach $filename (@ARGV)
  70. {
  71. $headerfilename = "_jni/";
  72. $headerfilename .= $filename;
  73. $headerfilename =~ s/\./_/g;
  74. $headerfilename .= ".h";
  75. $classfilename = $filename;
  76. $classfilename =~ s|\.|/|g;
  77. $classfilename .= ".class";
  78. $classfilename = $classdir . $classfilename;
  79. ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $headermtime,
  80. $ctime, $blksize, $blocks ) = stat( $headerfilename );
  81. ( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $classmtime,
  82. $ctime, $blksize, $blocks ) = stat( $classfilename );
  83. if( $headermtime < $classmtime )
  84. {
  85. # NOTE: Since this is used by "javah", and "javah" refuses to overwrite
  86. # an existing file, we force an unlink from this script, since
  87. # we actually want to regenerate the header file at this time.
  88. unlink $headerfilename;
  89. push @filelist, $filename;
  90. }
  91. }
  92. if( @filelist ) {
  93. $cmd = "$javah " . join(" ",@filelist);
  94. $cmd =~ s/\'/\"/g; # because windows doesn't understand single quote
  95. print "$cmd\n";
  96. exit (system($cmd) >> 8);
  97. } else {
  98. print "All JNI header files up to date.\n"
  99. }