annotate src/share/tools/MakeDeps/Database.java @ 0:a61af66fc99e jdk7-b24

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