annotate src/share/tools/MakeDeps/Database.java @ 605:98cb887364d3

6810672: Comment typos Summary: I have collected some typos I have found while looking at the code. Reviewed-by: kvn, never
author twisti
date Fri, 27 Feb 2009 13:27:09 -0800
parents 8b48a7bd2bf7
children 00f7ec32f290
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 public class Database {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 private MacroDefinitions macros;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // allFiles is kept in lexicographically sorted order. See get().
a61af66fc99e Initial load
duke
parents:
diff changeset
31 private FileList allFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // files that have implicit dependency on platform files
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // e.g. os.hpp: os_<os_family>.hpp os_<os_arch>.hpp but only
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // recorded if the platform file was seen.
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private FileList platformFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private FileList outerFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private FileList indivIncludes;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private FileList grandInclude; // the results for the grand include file
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
39 private HashMap<String,String> platformDepFiles;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private long threshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private int nOuterFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private int nPrecompiledFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private boolean missingOk;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private Platform plat;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 /** These allow you to specify files not in the include database
a61af66fc99e Initial load
duke
parents:
diff changeset
46 which are prepended and appended to the file list, allowing
a61af66fc99e Initial load
duke
parents:
diff changeset
47 you to have well-known functions at the start and end of the
a61af66fc99e Initial load
duke
parents:
diff changeset
48 text segment (allows us to find out in a portable fashion
a61af66fc99e Initial load
duke
parents:
diff changeset
49 whether the current PC is in VM code or not upon a crash) */
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private String firstFile;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private String lastFile;
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 public Database(Platform plat, long t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 this.plat = plat;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 macros = new MacroDefinitions();
a61af66fc99e Initial load
duke
parents:
diff changeset
56 allFiles = new FileList("allFiles", plat);
a61af66fc99e Initial load
duke
parents:
diff changeset
57 platformFiles = new FileList("platformFiles", plat);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 outerFiles = new FileList("outerFiles", plat);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 indivIncludes = new FileList("IndivIncludes", plat);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 grandInclude = new FileList(plat.getGIFileTemplate().nameOfList(), plat);
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
61 platformDepFiles = new HashMap<String,String>();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 threshold = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 nOuterFiles = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 nPrecompiledFiles = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 missingOk = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 firstFile = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 lastFile = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 };
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 public FileList getAllFiles() {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 return allFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 public Iterator getMacros() {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return macros.getMacros();
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public void canBeMissing() {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 missingOk = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 public boolean hfileIsInGrandInclude(FileList hfile, FileList cfile) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return ((hfile.getCount() >= threshold) && (cfile.getUseGrandInclude()));
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 /** These allow you to specify files not in the include database
a61af66fc99e Initial load
duke
parents:
diff changeset
88 which are prepended and appended to the file list, allowing
a61af66fc99e Initial load
duke
parents:
diff changeset
89 you to have well-known functions at the start and end of the
a61af66fc99e Initial load
duke
parents:
diff changeset
90 text segment (allows us to find out in a portable fashion
a61af66fc99e Initial load
duke
parents:
diff changeset
91 whether the current PC is in VM code or not upon a crash) */
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public void setFirstFile(String fileName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 firstFile = fileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public void setLastFile(String fileName) {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 lastFile = fileName;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public void get(String platFileName, String dbFileName)
a61af66fc99e Initial load
duke
parents:
diff changeset
101 throws FileFormatException, IOException, FileNotFoundException {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 macros.readFrom(platFileName, missingOk);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 BufferedReader reader = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 reader = new BufferedReader(new FileReader(dbFileName));
a61af66fc99e Initial load
duke
parents:
diff changeset
107 } catch (FileNotFoundException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (missingOk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 throw(e);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 System.out.println("\treading database: " + dbFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 String line;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 int lineNo = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 line = reader.readLine();
a61af66fc99e Initial load
duke
parents:
diff changeset
119 lineNo++;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (line != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 StreamTokenizer tokenizer =
a61af66fc99e Initial load
duke
parents:
diff changeset
122 new StreamTokenizer(new StringReader(line));
a61af66fc99e Initial load
duke
parents:
diff changeset
123 tokenizer.slashSlashComments(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 tokenizer.wordChars('_', '_');
a61af66fc99e Initial load
duke
parents:
diff changeset
125 tokenizer.wordChars('<', '>');
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // NOTE: if we didn't have to do this line by line,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // we could trivially recognize C-style comments as
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // well.
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // tokenizer.slashStarComments(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int numTok = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 int res;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 String unexpandedIncluder = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 String unexpandedIncludee = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 do {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 res = tokenizer.nextToken();
a61af66fc99e Initial load
duke
parents:
diff changeset
136 if (res != StreamTokenizer.TT_EOF) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 if (numTok == 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 unexpandedIncluder = tokenizer.sval;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 } else if (numTok == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 unexpandedIncludee = tokenizer.sval;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 throw new FileFormatException(
a61af66fc99e Initial load
duke
parents:
diff changeset
143 "invalid line: \"" + line +
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "\". Error position: line " + lineNo
a61af66fc99e Initial load
duke
parents:
diff changeset
145 );
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 numTok++;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 } while (res != StreamTokenizer.TT_EOF);
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if ((numTok != 0) && (numTok != 2)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 throw new FileFormatException(
a61af66fc99e Initial load
duke
parents:
diff changeset
153 "invalid line: \"" + line +
a61af66fc99e Initial load
duke
parents:
diff changeset
154 "\". Error position: line " + lineNo
a61af66fc99e Initial load
duke
parents:
diff changeset
155 );
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (numTok == 2) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Non-empty line
a61af66fc99e Initial load
duke
parents:
diff changeset
160 String includer = macros.expand(unexpandedIncluder);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 String includee = macros.expand(unexpandedIncludee);
a61af66fc99e Initial load
duke
parents:
diff changeset
162
a61af66fc99e Initial load
duke
parents:
diff changeset
163 if (includee.equals(plat.generatePlatformDependentInclude())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 MacroDefinitions localExpander = macros.copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 MacroDefinitions localExpander2 = macros.copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
166 localExpander.setAllMacroBodiesTo("pd");
a61af66fc99e Initial load
duke
parents:
diff changeset
167 localExpander2.setAllMacroBodiesTo("");
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // unexpanded_includer e.g. thread_<os_arch>.hpp
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // thread_solaris_i486.hpp -> _thread_pd.hpp.incl
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 FileName pdName =
a61af66fc99e Initial load
duke
parents:
diff changeset
173 plat.getInclFileTemplate().copyStem(
a61af66fc99e Initial load
duke
parents:
diff changeset
174 localExpander.expand(unexpandedIncluder)
a61af66fc99e Initial load
duke
parents:
diff changeset
175 );
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // derive generic name from platform specific name
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // e.g. os_<arch_os>.hpp => os.hpp. We enforce the
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // restriction (imperfectly) noted in includeDB_core
a61af66fc99e Initial load
duke
parents:
diff changeset
180 // that platform specific files will have an underscore
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // preceding the macro invocation.
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 // First expand macro as null string.
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 String newIncluder_temp =
a61af66fc99e Initial load
duke
parents:
diff changeset
186 localExpander2.expand(unexpandedIncluder);
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // Now find "_." and remove the underscore.
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 String newIncluder = "";
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 int len = newIncluder_temp.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
193 int count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 for ( int i = 0; i < len - 1 ; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if (newIncluder_temp.charAt(i) == '_' && newIncluder_temp.charAt(i+1) == '.') {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 count++;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
199 newIncluder += newIncluder_temp.charAt(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202 newIncluder += newIncluder_temp.charAt(len-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 if (count != 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 throw new FileFormatException(
a61af66fc99e Initial load
duke
parents:
diff changeset
206 "Unexpected filename format for platform dependent file.\nline: \"" + line +
a61af66fc99e Initial load
duke
parents:
diff changeset
207 "\".\nError position: line " + lineNo
a61af66fc99e Initial load
duke
parents:
diff changeset
208 );
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 FileList p = allFiles.listForFile(includer);
a61af66fc99e Initial load
duke
parents:
diff changeset
212 p.setPlatformDependentInclude(pdName.dirPreStemSuff());
a61af66fc99e Initial load
duke
parents:
diff changeset
213
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
214 // Record the implicit include of this file so that the
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
215 // dependencies for precompiled headers can mention it.
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
216 platformDepFiles.put(newIncluder, includer);
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
217
0
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // Add an implicit dependency on platform
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // specific file for the generic file
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 p = platformFiles.listForFile(newIncluder);
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // if this list is empty then this is 1st
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // occurance of a platform dependent file and
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // we need a new version of the include file.
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // Otherwise we just append to the current
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // file.
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 PrintWriter pdFile =
a61af66fc99e Initial load
duke
parents:
diff changeset
230 new PrintWriter(
a61af66fc99e Initial load
duke
parents:
diff changeset
231 new FileWriter(pdName.dirPreStemSuff(),
a61af66fc99e Initial load
duke
parents:
diff changeset
232 !p.isEmpty())
a61af66fc99e Initial load
duke
parents:
diff changeset
233 );
a61af66fc99e Initial load
duke
parents:
diff changeset
234 pdFile.println("# include \"" + includer + "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
235 pdFile.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Add the platform specific file to the list
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // for this generic file.
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 FileList q = allFiles.listForFile(includer);
a61af66fc99e Initial load
duke
parents:
diff changeset
241 p.addIfAbsent(q);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 FileList p = allFiles.listForFile(includer);
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (isOuterFile(includer))
a61af66fc99e Initial load
duke
parents:
diff changeset
245 outerFiles.addIfAbsent(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 if (includee.equals(plat.noGrandInclude())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 p.setUseGrandInclude(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 FileList q = allFiles.listForFile(includee);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 p.addIfAbsent(q);
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 } while (line != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 reader.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Keep allFiles in well-known order so we can easily determine
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // whether the known files are the same
a61af66fc99e Initial load
duke
parents:
diff changeset
261 allFiles.sortByName();
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Add first and last files differently to prevent a mistake
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // in ordering in the include databases from breaking the
a61af66fc99e Initial load
duke
parents:
diff changeset
265 // error reporting in the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (firstFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 FileList p = allFiles.listForFile(firstFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 allFiles.setFirstFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 outerFiles.setFirstFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 }
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 if (lastFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
273 FileList p = allFiles.listForFile(lastFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 allFiles.setLastFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
275 outerFiles.setLastFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 }
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 public void compute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 System.out.println("\tcomputing closures\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // build both indiv and grand results
a61af66fc99e Initial load
duke
parents:
diff changeset
282 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 indivIncludes.add(((FileList) iter.next()).doCFile());
a61af66fc99e Initial load
duke
parents:
diff changeset
284 ++nOuterFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 if (!plat.haveGrandInclude())
a61af66fc99e Initial load
duke
parents:
diff changeset
288 return; // nothing in grand include
a61af66fc99e Initial load
duke
parents:
diff changeset
289
a61af66fc99e Initial load
duke
parents:
diff changeset
290 // count how many times each include is included & add em to grand
a61af66fc99e Initial load
duke
parents:
diff changeset
291 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 FileList indivInclude = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
293 if (!indivInclude.getUseGrandInclude()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 continue; // do not bump count if my files cannot be
a61af66fc99e Initial load
duke
parents:
diff changeset
295 // in grand include
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 indivInclude.doFiles(grandInclude); // put em on
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // grand_include list
a61af66fc99e Initial load
duke
parents:
diff changeset
299 for (Iterator incListIter = indivInclude.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 incListIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 ((FileList) incListIter.next()).incrementCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Not sure this is necessary in Java
a61af66fc99e Initial load
duke
parents:
diff changeset
307 public void verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 if (iter.next() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 plat.abort();
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312 }
a61af66fc99e Initial load
duke
parents:
diff changeset
313 }
a61af66fc99e Initial load
duke
parents:
diff changeset
314
a61af66fc99e Initial load
duke
parents:
diff changeset
315 public void put() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 writeIndividualIncludes();
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 if (plat.haveGrandInclude())
a61af66fc99e Initial load
duke
parents:
diff changeset
319 writeGrandInclude();
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 writeGrandUnixMakefile();
a61af66fc99e Initial load
duke
parents:
diff changeset
322 }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 private void writeIndividualIncludes() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
325 System.out.println("\twriting individual include files\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
328 FileList list = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
329 System.out.println("\tcreating " + list.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
330 list.putInclFile(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
331 }
a61af66fc99e Initial load
duke
parents:
diff changeset
332 }
a61af66fc99e Initial load
duke
parents:
diff changeset
333
a61af66fc99e Initial load
duke
parents:
diff changeset
334 private void writeGrandInclude() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
335 System.out.println("\twriting grand include file\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
336 PrintWriter inclFile =
a61af66fc99e Initial load
duke
parents:
diff changeset
337 new PrintWriter(new FileWriter(plat.getGIFileTemplate().dirPreStemSuff()));
a61af66fc99e Initial load
duke
parents:
diff changeset
338 plat.writeGIPragma(inclFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
339 for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 FileList list = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (list.getCount() >= threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
342 inclFile.println("# include \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
343 plat.getGIFileTemplate().getInvDir() +
a61af66fc99e Initial load
duke
parents:
diff changeset
344 list.getName() +
a61af66fc99e Initial load
duke
parents:
diff changeset
345 "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
346 nPrecompiledFiles += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 }
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349 inclFile.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
350 inclFile.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 private void writeGrandUnixMakefile() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 if (!plat.writeDeps())
a61af66fc99e Initial load
duke
parents:
diff changeset
355 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
356
a61af66fc99e Initial load
duke
parents:
diff changeset
357 System.out.println("\twriting dependencies file\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
358 PrintWriter gd =
a61af66fc99e Initial load
duke
parents:
diff changeset
359 new PrintWriter(new FileWriter(
a61af66fc99e Initial load
duke
parents:
diff changeset
360 plat.getGDFileTemplate().dirPreStemSuff())
a61af66fc99e Initial load
duke
parents:
diff changeset
361 );
a61af66fc99e Initial load
duke
parents:
diff changeset
362 gd.println("# generated by makeDeps");
a61af66fc99e Initial load
duke
parents:
diff changeset
363 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // HACK ALERT. The compilation of ad_<arch> files is very slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // We want to start compiling them as early as possible. The compilation
605
98cb887364d3 6810672: Comment typos
twisti
parents: 213
diff changeset
368 // order on unix is dependent on the order we emit files here.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // By sorting the output before emitting it, we expect
a61af66fc99e Initial load
duke
parents:
diff changeset
370 // that ad_<arch> will be compiled early.
a61af66fc99e Initial load
duke
parents:
diff changeset
371 boolean shouldSortObjFiles = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 if (shouldSortObjFiles) {
a61af66fc99e Initial load
duke
parents:
diff changeset
374 ArrayList sortList = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 // We need to preserve the ordering of the first and last items
a61af66fc99e Initial load
duke
parents:
diff changeset
377 // in outerFiles.
a61af66fc99e Initial load
duke
parents:
diff changeset
378 int size = outerFiles.size() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
379 String firstName = removeSuffixFrom(((FileList)outerFiles.get(0)).getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
380 String lastName = removeSuffixFrom(((FileList)outerFiles.get(size)).getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382 for (int i=1; i<size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
383 FileList anOuterFile = (FileList)outerFiles.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
385 sortList.add(stemName);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 }
a61af66fc99e Initial load
duke
parents:
diff changeset
387 Collections.sort(sortList);
a61af66fc99e Initial load
duke
parents:
diff changeset
388
a61af66fc99e Initial load
duke
parents:
diff changeset
389 // write Obj_Files = ...
a61af66fc99e Initial load
duke
parents:
diff changeset
390 gd.println("Obj_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
391 gd.println(firstName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
392 for (Iterator iter = sortList.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
393 gd.println(iter.next() + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
394 }
a61af66fc99e Initial load
duke
parents:
diff changeset
395 gd.println(lastName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
396 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
397 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
398 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 // write Obj_Files = ...
a61af66fc99e Initial load
duke
parents:
diff changeset
400 gd.println("Obj_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
401 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
402 FileList anOuterFile = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
403
a61af66fc99e Initial load
duke
parents:
diff changeset
404 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
405 gd.println(stemName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
408 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
409 }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 if (nPrecompiledFiles > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
412 // write Precompiled_Files = ...
a61af66fc99e Initial load
duke
parents:
diff changeset
413 gd.println("Precompiled_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
414 for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 FileList list = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
416 gd.println(list.getName() + " \\");
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
417 String platformDep = platformDepFiles.get(list.getName());
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
418 if (platformDep != null) {
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
419 // make sure changes to the platform dependent file will
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
420 // cause regeneration of the pch file.
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
421 gd.println(platformDep + " \\");
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
422 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
423 }
a61af66fc99e Initial load
duke
parents:
diff changeset
424 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
425 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
426 }
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 gd.println("DTraced_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
429 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 FileList anOuterFile = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
431
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (anOuterFile.hasListForFile("dtrace.hpp")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
433 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
434 gd.println(stemName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
435 }
a61af66fc99e Initial load
duke
parents:
diff changeset
436 }
a61af66fc99e Initial load
duke
parents:
diff changeset
437 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
438 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 {
a61af66fc99e Initial load
duke
parents:
diff changeset
441 // write each dependency
a61af66fc99e Initial load
duke
parents:
diff changeset
442
a61af66fc99e Initial load
duke
parents:
diff changeset
443 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
444
a61af66fc99e Initial load
duke
parents:
diff changeset
445 FileList anII = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
446
a61af66fc99e Initial load
duke
parents:
diff changeset
447 String stemName = removeSuffixFrom(anII.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
448 String inclFileName =
a61af66fc99e Initial load
duke
parents:
diff changeset
449 plat.getInclFileTemplate().copyStem(anII.getName()).
a61af66fc99e Initial load
duke
parents:
diff changeset
450 preStemSuff();
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 gd.println(stemName + plat.objFileSuffix() + " " +
a61af66fc99e Initial load
duke
parents:
diff changeset
453 stemName + plat.asmFileSuffix() + ": \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
454
a61af66fc99e Initial load
duke
parents:
diff changeset
455 printDependentOn(gd, anII.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
456 // this gets the include file that includes all that
a61af66fc99e Initial load
duke
parents:
diff changeset
457 // this file needs (first level) since nested includes
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // are skipped to avoid cycles.
a61af66fc99e Initial load
duke
parents:
diff changeset
459 printDependentOn(gd, inclFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
460
a61af66fc99e Initial load
duke
parents:
diff changeset
461 if ( plat.haveGrandInclude() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
462 printDependentOn(gd,
a61af66fc99e Initial load
duke
parents:
diff changeset
463 plat.getGIFileTemplate().preStemSuff());
a61af66fc99e Initial load
duke
parents:
diff changeset
464 }
a61af66fc99e Initial load
duke
parents:
diff changeset
465
a61af66fc99e Initial load
duke
parents:
diff changeset
466 for (Iterator iiIter = anII.iterator(); iiIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 FileList hfile = (FileList) iiIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
468 if (!hfileIsInGrandInclude(hfile, anII) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
469 plat.writeDependenciesOnHFilesFromGI()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 printDependentOn(gd, hfile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
471 }
a61af66fc99e Initial load
duke
parents:
diff changeset
472 if (platformFiles.hasListForFile(hfile.getName())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
473 FileList p =
a61af66fc99e Initial load
duke
parents:
diff changeset
474 platformFiles.listForFile(hfile.getName());;
a61af66fc99e Initial load
duke
parents:
diff changeset
475 for (Iterator hiIter = p.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
476 hiIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
477 FileList hi2 = (FileList) hiIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
478 if (!hfileIsInGrandInclude(hi2, p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
479 printDependentOn(gd, hi2.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482 }
a61af66fc99e Initial load
duke
parents:
diff changeset
483 }
a61af66fc99e Initial load
duke
parents:
diff changeset
484
a61af66fc99e Initial load
duke
parents:
diff changeset
485 if (plat.includeGIDependencies()
a61af66fc99e Initial load
duke
parents:
diff changeset
486 && nPrecompiledFiles > 0
a61af66fc99e Initial load
duke
parents:
diff changeset
487 && anII.getUseGrandInclude()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
488 gd.println(" $(Precompiled_Files) \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
490 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
491 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 }
a61af66fc99e Initial load
duke
parents:
diff changeset
494
a61af66fc99e Initial load
duke
parents:
diff changeset
495 gd.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
496 }
a61af66fc99e Initial load
duke
parents:
diff changeset
497
a61af66fc99e Initial load
duke
parents:
diff changeset
498 public void putDiffs(Database previous) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 System.out.println("\tupdating output files\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
500
a61af66fc99e Initial load
duke
parents:
diff changeset
501 if (!indivIncludes.compareLists(previous.indivIncludes)
a61af66fc99e Initial load
duke
parents:
diff changeset
502 || !grandInclude.compareLists(previous.grandInclude)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
503 System.out.println("The order of .c or .s has changed, or " +
a61af66fc99e Initial load
duke
parents:
diff changeset
504 "the grand include file has changed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
505 put();
a61af66fc99e Initial load
duke
parents:
diff changeset
506 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
507 }
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 Iterator curIter = indivIncludes.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
510 Iterator prevIter = previous.indivIncludes.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
511
a61af66fc99e Initial load
duke
parents:
diff changeset
512 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 while (curIter.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
514 FileList newCFileList = (FileList) curIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
515 FileList prevCFileList = (FileList) prevIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
516 if (!newCFileList.compareLists(prevCFileList)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
517 System.out.println("\tupdating " + newCFileList.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
518 newCFileList.putInclFile(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
519 }
a61af66fc99e Initial load
duke
parents:
diff changeset
520 }
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522 catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
523 throw new InternalError("assertion failure: cur and prev " +
a61af66fc99e Initial load
duke
parents:
diff changeset
524 "database lists changed unexpectedly.");
a61af66fc99e Initial load
duke
parents:
diff changeset
525 }
a61af66fc99e Initial load
duke
parents:
diff changeset
526
a61af66fc99e Initial load
duke
parents:
diff changeset
527 writeGrandUnixMakefile();
a61af66fc99e Initial load
duke
parents:
diff changeset
528 }
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 private void printDependentOn(PrintWriter gd, String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
531 gd.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
532 gd.print(plat.dependentPrefix() + name);
a61af66fc99e Initial load
duke
parents:
diff changeset
533 }
a61af66fc99e Initial load
duke
parents:
diff changeset
534
a61af66fc99e Initial load
duke
parents:
diff changeset
535 private boolean isOuterFile(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 int len = s.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
537 String[] suffixes = plat.outerSuffixes();
a61af66fc99e Initial load
duke
parents:
diff changeset
538 for (int i = 0; i < suffixes.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
539 String suffix = suffixes[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
540 int suffLen = suffix.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
541 if ((len >= suffLen) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
542 (plat.fileNameStringEquality(s.substring(len - suffLen),
a61af66fc99e Initial load
duke
parents:
diff changeset
543 suffix))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
544 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 }
a61af66fc99e Initial load
duke
parents:
diff changeset
546 }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
548 }
a61af66fc99e Initial load
duke
parents:
diff changeset
549
a61af66fc99e Initial load
duke
parents:
diff changeset
550 private String removeSuffixFrom(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
551 int idx = s.lastIndexOf('.');
a61af66fc99e Initial load
duke
parents:
diff changeset
552 if (idx <= 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
553 plat.abort();
a61af66fc99e Initial load
duke
parents:
diff changeset
554 return s.substring(0, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }
a61af66fc99e Initial load
duke
parents:
diff changeset
556 }