home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / config / sj.pl < prev    next >
Encoding:
Perl Script  |  1998-04-08  |  2.3 KB  |  90 lines

  1. #!perl
  2. #
  3. # The contents of this file are subject to the Netscape Public License
  4. # Version 1.0 (the "NPL"); you may not use this file except in
  5. # compliance with the NPL.  You may obtain a copy of the NPL at
  6. # http://www.mozilla.org/NPL/
  7. #
  8. # Software distributed under the NPL is distributed on an "AS IS" basis,
  9. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10. # for the specific language governing rights and limitations under the
  11. # NPL.
  12. #
  13. # The Initial Developer of this code under the NPL is Netscape
  14. # Communications Corporation.  Portions created by Netscape are
  15. # Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16. # Reserved.
  17. #
  18.  
  19. #
  20. # Input: output_class_dir argfile javafilelist
  21. #
  22.  
  23. $classdir = $ARGV[0];
  24. $argfile = $ARGV[1];
  25. $filelist = $ARGV[2];
  26. shift;
  27.  
  28. $sjcmd = $ENV{'MOZ_TOOLS'} . '\bin\sj.exe';
  29.  
  30. open(FL, "<$filelist" ) || die "can't open $filelist for reading";
  31.  
  32. while( <FL> ){
  33.     # print;
  34.     @java_files = (@java_files, split(/[ \t\n]/));
  35. }
  36. close (FL);
  37.  
  38. open(FL, "<$argfile" ) || die "can't open $argfile for reading";
  39.  
  40. while( <FL> ){
  41.     chop;
  42.     $args .= $_;
  43. }
  44. close (FL);
  45.  
  46.  
  47. print "Java Files: @java_files\n";
  48.  
  49.  
  50. # compile as many java files as we can in one invocation
  51. # given the limitations of the command line
  52. foreach $filename (@java_files) {
  53.     $classfilename = $classdir;
  54.     $classfilename .= $filename;
  55.     $classfilename =~ s/.java$/.class/;
  56.     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
  57.      $ctime,$blksize,$blocks) = stat($filename);
  58.     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$classmtime,
  59.      $ctime,$blksize,$blocks) = stat($classfilename);
  60. #    print $filename, " ", $mtime, ", ", $classfilename, " ", $classmtime, "\n";
  61.     if ($mtime > $classmtime) {
  62. # are we too big?      
  63.         $len += length($filename);
  64.         if( $len >= 512 ) {
  65.             print "$sjcmd $args $outofdate\n";
  66.             $status = system "$sjcmd $args $outofdate";
  67.             if( $status != 0 ) {
  68.                 exit( $status / 256 );
  69.             }
  70.             $outofdate = "";
  71.             $len = length($filename);
  72.         }
  73.         $outofdate .= $filename;
  74.         $outofdate .= " ";
  75.     }
  76. }
  77.  
  78. if( length($outofdate) > 0 ) {
  79.     print "$sjcmd $args $outofdate\n";
  80.     $status = system "$sjcmd $args $outofdate";
  81.     if( $status != 0 ) {
  82.         exit( $status / 256 );
  83.     }
  84. } else {
  85.     print "Files are up to date.\n";
  86. }
  87.  
  88.  
  89. print "\n";
  90.