Don't bother tracing some elem sets yet (bug 561939, r=gal).
[mozilla-central.git] / config / outofdate.pl
blob26a05c2e3303237b0074ce4485db9f77a2883d0c
1 #!perl
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
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/
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.
16 # The Original Code is mozilla.org code.
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1998
21 # the Initial Developer. All Rights Reserved.
23 # Contributor(s):
25 # Alternatively, the contents of this file may be used under the terms of
26 # either of the GNU General Public License Version 2 or later (the "GPL"),
27 # or 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.
37 # ***** END LICENSE BLOCK *****
40 #Input: [-d dir] foo1.java foo2.java
41 #Compares with: foo1.class foo2.class (if -d specified, checks in 'dir',
42 # otherwise assumes .class files in same directory as .java files)
43 #Returns: list of input arguments which are newer than corresponding class
44 #files (non-existant class files are considered to be real old :-)
47 $found = 1;
49 # GLOBALS
50 $SEP = 0; # the paltform independent path separator
51 $CFG = 0; # the value of the -cfg flag
53 # determine the path separator
54 $_ = $ENV{"PATH"};
55 if (m|/|) {
56 $SEP = "/";
58 else {
59 $SEP = "\\";
62 if ($ARGV[0] eq '-d') {
63 $classdir = $ARGV[1];
64 $classdir .= $SEP;
65 shift;
66 shift;
67 } else {
68 $classdir = "." . $SEP;
71 # if -cfg is specified, print out the contents of the cfg file to stdout
72 if ($ARGV[0] eq '-cfg') {
73 $CFG = $ARGV[1];
74 shift;
75 shift;
78 $_ = $ARGV[0];
79 if (m/\*.java/) {
80 # Account for the fact that the shell didn't expand *.java by doing it
81 # manually.
82 &manuallyExpandArgument("java");
85 $printFile = 0;
87 foreach $filename (@ARGV) {
88 $classfilename = $classdir;
89 $classfilename .= $filename;
90 $classfilename =~ s/.java$/.class/;
91 # workaround to only build sun/io/* classes when necessary
92 # change the pathname of target file to be consistent
93 # with sun/io subdirectories
95 # sun/io was always getting rebuilt because the java files
96 # were split into subdirectories, but the package names
97 # remained the same. This was confusing outofdate.pl
99 $classfilename =~ s/sun\/io\/extended.\//sun\/io\//;
100 $classfilename =~ s/\.\.\/\.\.\/sun-java\/classsrc\///;
101 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,
102 $ctime,$blksize,$blocks) = stat($filename);
103 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$classmtime,
104 $ctime,$blksize,$blocks) = stat($classfilename);
105 # print $filename, " ", $mtime, ", ", $classfilename, " ", $classmtime, "\n";
106 if ($mtime > $classmtime) {
108 # Only print the file header if we actually have some files to
109 # compile.
110 if (!$printFile) {
111 $printFile = 1;
112 &printFile($CFG);
114 print $filename, " ";
115 $found = 0;
119 print "\n";
121 # push onto $ARG array all filenames with extension $ext
123 # @param ext the extension of the file
125 sub manuallyExpandArgument {
126 local($ext) = @_;
127 $ext = "\." . $ext; # put it in regexp
129 $result = opendir(DIR, ".");
131 @allfiles = grep(/$ext/, readdir(DIR));
132 $i = 0;
133 foreach $file (@allfiles) {
134 #skip emacs save files
135 $_ = $file;
136 if (!/~/) {
137 $ARGV[$i++] = $file;
142 sub printFile {
143 local($file) = @_;
145 $result = open(CFG, $file);
146 while (<CFG>) {
147 chop;
148 print $_;