annotate src/share/tools/MakeDeps/Database.java @ 1673:6709c14587c2 jdk7-b105

Added tag jdk7-b104 for changeset b4acf10eb134
author cl
date Fri, 06 Aug 2010 12:51:54 -0700
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 830
diff changeset
2 * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 830
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 830
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 830
diff changeset
21 * questions.
0
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 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);
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
60 platformDepFiles = new HashMap<String,String>();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 threshold = t;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 nOuterFiles = 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
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
212 // 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
213 // dependencies for precompiled headers can mention it.
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
214 platformDepFiles.put(newIncluder, includer);
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
215
0
a61af66fc99e Initial load
duke
parents:
diff changeset
216 // Add an implicit dependency on platform
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // specific file for the generic file
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 p = platformFiles.listForFile(newIncluder);
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // if this list is empty then this is 1st
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // occurance of a platform dependent file and
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // we need a new version of the include file.
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Otherwise we just append to the current
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // file.
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 PrintWriter pdFile =
a61af66fc99e Initial load
duke
parents:
diff changeset
228 new PrintWriter(
a61af66fc99e Initial load
duke
parents:
diff changeset
229 new FileWriter(pdName.dirPreStemSuff(),
a61af66fc99e Initial load
duke
parents:
diff changeset
230 !p.isEmpty())
a61af66fc99e Initial load
duke
parents:
diff changeset
231 );
a61af66fc99e Initial load
duke
parents:
diff changeset
232 pdFile.println("# include \"" + includer + "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
233 pdFile.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // Add the platform specific file to the list
a61af66fc99e Initial load
duke
parents:
diff changeset
236 // for this generic file.
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 FileList q = allFiles.listForFile(includer);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 p.addIfAbsent(q);
a61af66fc99e Initial load
duke
parents:
diff changeset
240 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 FileList p = allFiles.listForFile(includer);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 if (isOuterFile(includer))
a61af66fc99e Initial load
duke
parents:
diff changeset
243 outerFiles.addIfAbsent(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 if (includee.equals(plat.noGrandInclude())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
246 p.setUseGrandInclude(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
247 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 FileList q = allFiles.listForFile(includee);
a61af66fc99e Initial load
duke
parents:
diff changeset
249 p.addIfAbsent(q);
a61af66fc99e Initial load
duke
parents:
diff changeset
250 }
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 } while (line != null);
a61af66fc99e Initial load
duke
parents:
diff changeset
255 reader.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // Keep allFiles in well-known order so we can easily determine
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // whether the known files are the same
a61af66fc99e Initial load
duke
parents:
diff changeset
259 allFiles.sortByName();
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Add first and last files differently to prevent a mistake
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // in ordering in the include databases from breaking the
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // error reporting in the VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (firstFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 FileList p = allFiles.listForFile(firstFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
266 allFiles.setFirstFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 outerFiles.setFirstFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 if (lastFile != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 FileList p = allFiles.listForFile(lastFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
272 allFiles.setLastFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 outerFiles.setLastFile(p);
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 public void compute() {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 System.out.println("\tcomputing closures\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // build both indiv and grand results
a61af66fc99e Initial load
duke
parents:
diff changeset
280 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
281 indivIncludes.add(((FileList) iter.next()).doCFile());
a61af66fc99e Initial load
duke
parents:
diff changeset
282 ++nOuterFiles;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 }
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 if (!plat.haveGrandInclude())
a61af66fc99e Initial load
duke
parents:
diff changeset
286 return; // nothing in grand include
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // count how many times each include is included & add em to grand
a61af66fc99e Initial load
duke
parents:
diff changeset
289 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
290 FileList indivInclude = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
291 if (!indivInclude.getUseGrandInclude()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
292 continue; // do not bump count if my files cannot be
a61af66fc99e Initial load
duke
parents:
diff changeset
293 // in grand include
a61af66fc99e Initial load
duke
parents:
diff changeset
294 }
a61af66fc99e Initial load
duke
parents:
diff changeset
295 indivInclude.doFiles(grandInclude); // put em on
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // grand_include list
a61af66fc99e Initial load
duke
parents:
diff changeset
297 for (Iterator incListIter = indivInclude.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
298 incListIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 ((FileList) incListIter.next()).incrementCount();
a61af66fc99e Initial load
duke
parents:
diff changeset
300 }
a61af66fc99e Initial load
duke
parents:
diff changeset
301 }
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303
a61af66fc99e Initial load
duke
parents:
diff changeset
304 // Not sure this is necessary in Java
a61af66fc99e Initial load
duke
parents:
diff changeset
305 public void verify() {
a61af66fc99e Initial load
duke
parents:
diff changeset
306 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
307 if (iter.next() == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 plat.abort();
a61af66fc99e Initial load
duke
parents:
diff changeset
309 }
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 public void put() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 writeIndividualIncludes();
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 if (plat.haveGrandInclude())
a61af66fc99e Initial load
duke
parents:
diff changeset
317 writeGrandInclude();
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319 writeGrandUnixMakefile();
a61af66fc99e Initial load
duke
parents:
diff changeset
320 }
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 private void writeIndividualIncludes() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 System.out.println("\twriting individual include files\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
324
a61af66fc99e Initial load
duke
parents:
diff changeset
325 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
326 FileList list = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 System.out.println("\tcreating " + list.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
328 list.putInclFile(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 private void writeGrandInclude() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
333 System.out.println("\twriting grand include file\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
334 PrintWriter inclFile =
a61af66fc99e Initial load
duke
parents:
diff changeset
335 new PrintWriter(new FileWriter(plat.getGIFileTemplate().dirPreStemSuff()));
a61af66fc99e Initial load
duke
parents:
diff changeset
336 plat.writeGIPragma(inclFile);
a61af66fc99e Initial load
duke
parents:
diff changeset
337 for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
338 FileList list = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if (list.getCount() >= threshold) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 inclFile.println("# include \"" +
a61af66fc99e Initial load
duke
parents:
diff changeset
341 plat.getGIFileTemplate().getInvDir() +
a61af66fc99e Initial load
duke
parents:
diff changeset
342 list.getName() +
a61af66fc99e Initial load
duke
parents:
diff changeset
343 "\"");
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345 }
a61af66fc99e Initial load
duke
parents:
diff changeset
346 inclFile.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 inclFile.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 private void writeGrandUnixMakefile() throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 if (!plat.writeDeps())
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 System.out.println("\twriting dependencies file\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
355 PrintWriter gd =
a61af66fc99e Initial load
duke
parents:
diff changeset
356 new PrintWriter(new FileWriter(
a61af66fc99e Initial load
duke
parents:
diff changeset
357 plat.getGDFileTemplate().dirPreStemSuff())
a61af66fc99e Initial load
duke
parents:
diff changeset
358 );
a61af66fc99e Initial load
duke
parents:
diff changeset
359 gd.println("# generated by makeDeps");
a61af66fc99e Initial load
duke
parents:
diff changeset
360 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
361
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // HACK ALERT. The compilation of ad_<arch> files is very slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // We want to start compiling them as early as possible. The compilation
605
98cb887364d3 6810672: Comment typos
twisti
parents: 213
diff changeset
365 // order on unix is dependent on the order we emit files here.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
366 // By sorting the output before emitting it, we expect
a61af66fc99e Initial load
duke
parents:
diff changeset
367 // that ad_<arch> will be compiled early.
a61af66fc99e Initial load
duke
parents:
diff changeset
368 boolean shouldSortObjFiles = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
369
a61af66fc99e Initial load
duke
parents:
diff changeset
370 if (shouldSortObjFiles) {
a61af66fc99e Initial load
duke
parents:
diff changeset
371 ArrayList sortList = new ArrayList();
a61af66fc99e Initial load
duke
parents:
diff changeset
372
a61af66fc99e Initial load
duke
parents:
diff changeset
373 // We need to preserve the ordering of the first and last items
a61af66fc99e Initial load
duke
parents:
diff changeset
374 // in outerFiles.
a61af66fc99e Initial load
duke
parents:
diff changeset
375 int size = outerFiles.size() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 String firstName = removeSuffixFrom(((FileList)outerFiles.get(0)).getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
377 String lastName = removeSuffixFrom(((FileList)outerFiles.get(size)).getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
378
a61af66fc99e Initial load
duke
parents:
diff changeset
379 for (int i=1; i<size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
380 FileList anOuterFile = (FileList)outerFiles.get(i);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
382 sortList.add(stemName);
a61af66fc99e Initial load
duke
parents:
diff changeset
383 }
a61af66fc99e Initial load
duke
parents:
diff changeset
384 Collections.sort(sortList);
a61af66fc99e Initial load
duke
parents:
diff changeset
385
a61af66fc99e Initial load
duke
parents:
diff changeset
386 // write Obj_Files = ...
a61af66fc99e Initial load
duke
parents:
diff changeset
387 gd.println("Obj_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
388 gd.println(firstName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
389 for (Iterator iter = sortList.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 gd.println(iter.next() + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
391 }
a61af66fc99e Initial load
duke
parents:
diff changeset
392 gd.println(lastName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
393 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
394 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
395 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
396 // write Obj_Files = ...
a61af66fc99e Initial load
duke
parents:
diff changeset
397 gd.println("Obj_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
398 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
399 FileList anOuterFile = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
402 gd.println(stemName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
403 }
a61af66fc99e Initial load
duke
parents:
diff changeset
404 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
405 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
406 }
a61af66fc99e Initial load
duke
parents:
diff changeset
407
830
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
408 // write Precompiled_Files = ...
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
409 gd.println("Precompiled_Files = \\");
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
410 for (Iterator iter = grandInclude.iterator(); iter.hasNext(); ) {
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
411 FileList list = (FileList) iter.next();
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
412 if (list.getCount() >= threshold) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
413 gd.println(list.getName() + " \\");
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
414 String platformDep = platformDepFiles.get(list.getName());
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
415 if (platformDep != null) {
830
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
416 // make sure changes to the platform dependent file will
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
417 // cause regeneration of the pch file.
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
418 gd.println(platformDep + " \\");
213
8b48a7bd2bf7 6697238: missing dependencies for precompiled headers with platform dependent includes
never
parents: 0
diff changeset
419 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421 }
830
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
422 gd.println();
00f7ec32f290 6854027: Precompiled headers are not being updated in Linux/GCC builds
apetrusenko
parents: 605
diff changeset
423 gd.println();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 gd.println("DTraced_Files = \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
426 for (Iterator iter = outerFiles.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
427 FileList anOuterFile = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 if (anOuterFile.hasListForFile("dtrace.hpp")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 String stemName = removeSuffixFrom(anOuterFile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
431 gd.println(stemName + plat.objFileSuffix() + " \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
432 }
a61af66fc99e Initial load
duke
parents:
diff changeset
433 }
a61af66fc99e Initial load
duke
parents:
diff changeset
434 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
435 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
436
a61af66fc99e Initial load
duke
parents:
diff changeset
437 {
a61af66fc99e Initial load
duke
parents:
diff changeset
438 // write each dependency
a61af66fc99e Initial load
duke
parents:
diff changeset
439
a61af66fc99e Initial load
duke
parents:
diff changeset
440 for (Iterator iter = indivIncludes.iterator(); iter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 FileList anII = (FileList) iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
443
a61af66fc99e Initial load
duke
parents:
diff changeset
444 String stemName = removeSuffixFrom(anII.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
445 String inclFileName =
a61af66fc99e Initial load
duke
parents:
diff changeset
446 plat.getInclFileTemplate().copyStem(anII.getName()).
a61af66fc99e Initial load
duke
parents:
diff changeset
447 preStemSuff();
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 gd.println(stemName + plat.objFileSuffix() + " " +
a61af66fc99e Initial load
duke
parents:
diff changeset
450 stemName + plat.asmFileSuffix() + ": \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
451
a61af66fc99e Initial load
duke
parents:
diff changeset
452 printDependentOn(gd, anII.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
453 // this gets the include file that includes all that
a61af66fc99e Initial load
duke
parents:
diff changeset
454 // this file needs (first level) since nested includes
a61af66fc99e Initial load
duke
parents:
diff changeset
455 // are skipped to avoid cycles.
a61af66fc99e Initial load
duke
parents:
diff changeset
456 printDependentOn(gd, inclFileName);
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 if ( plat.haveGrandInclude() ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
459 printDependentOn(gd,
a61af66fc99e Initial load
duke
parents:
diff changeset
460 plat.getGIFileTemplate().preStemSuff());
a61af66fc99e Initial load
duke
parents:
diff changeset
461 }
a61af66fc99e Initial load
duke
parents:
diff changeset
462
a61af66fc99e Initial load
duke
parents:
diff changeset
463 for (Iterator iiIter = anII.iterator(); iiIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
464 FileList hfile = (FileList) iiIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
465 if (!hfileIsInGrandInclude(hfile, anII) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
466 plat.writeDependenciesOnHFilesFromGI()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
467 printDependentOn(gd, hfile.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
468 }
a61af66fc99e Initial load
duke
parents:
diff changeset
469 if (platformFiles.hasListForFile(hfile.getName())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
470 FileList p =
a61af66fc99e Initial load
duke
parents:
diff changeset
471 platformFiles.listForFile(hfile.getName());;
a61af66fc99e Initial load
duke
parents:
diff changeset
472 for (Iterator hiIter = p.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
473 hiIter.hasNext(); ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
474 FileList hi2 = (FileList) hiIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
475 if (!hfileIsInGrandInclude(hi2, p)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 printDependentOn(gd, hi2.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478 }
a61af66fc99e Initial load
duke
parents:
diff changeset
479 }
a61af66fc99e Initial load
duke
parents:
diff changeset
480 }
a61af66fc99e Initial load
duke
parents:
diff changeset
481
a61af66fc99e Initial load
duke
parents:
diff changeset
482 if (plat.includeGIDependencies()
a61af66fc99e Initial load
duke
parents:
diff changeset
483 && anII.getUseGrandInclude()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
484 gd.println(" $(Precompiled_Files) \\");
a61af66fc99e Initial load
duke
parents:
diff changeset
485 }
a61af66fc99e Initial load
duke
parents:
diff changeset
486 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
487 gd.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
488 }
a61af66fc99e Initial load
duke
parents:
diff changeset
489 }
a61af66fc99e Initial load
duke
parents:
diff changeset
490
a61af66fc99e Initial load
duke
parents:
diff changeset
491 gd.close();
a61af66fc99e Initial load
duke
parents:
diff changeset
492 }
a61af66fc99e Initial load
duke
parents:
diff changeset
493
a61af66fc99e Initial load
duke
parents:
diff changeset
494 public void putDiffs(Database previous) throws IOException {
a61af66fc99e Initial load
duke
parents:
diff changeset
495 System.out.println("\tupdating output files\n");
a61af66fc99e Initial load
duke
parents:
diff changeset
496
a61af66fc99e Initial load
duke
parents:
diff changeset
497 if (!indivIncludes.compareLists(previous.indivIncludes)
a61af66fc99e Initial load
duke
parents:
diff changeset
498 || !grandInclude.compareLists(previous.grandInclude)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
499 System.out.println("The order of .c or .s has changed, or " +
a61af66fc99e Initial load
duke
parents:
diff changeset
500 "the grand include file has changed.");
a61af66fc99e Initial load
duke
parents:
diff changeset
501 put();
a61af66fc99e Initial load
duke
parents:
diff changeset
502 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
503 }
a61af66fc99e Initial load
duke
parents:
diff changeset
504
a61af66fc99e Initial load
duke
parents:
diff changeset
505 Iterator curIter = indivIncludes.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
506 Iterator prevIter = previous.indivIncludes.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
507
a61af66fc99e Initial load
duke
parents:
diff changeset
508 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
509 while (curIter.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
510 FileList newCFileList = (FileList) curIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
511 FileList prevCFileList = (FileList) prevIter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
512 if (!newCFileList.compareLists(prevCFileList)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
513 System.out.println("\tupdating " + newCFileList.getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
514 newCFileList.putInclFile(this);
a61af66fc99e Initial load
duke
parents:
diff changeset
515 }
a61af66fc99e Initial load
duke
parents:
diff changeset
516 }
a61af66fc99e Initial load
duke
parents:
diff changeset
517 }
a61af66fc99e Initial load
duke
parents:
diff changeset
518 catch (Exception e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
519 throw new InternalError("assertion failure: cur and prev " +
a61af66fc99e Initial load
duke
parents:
diff changeset
520 "database lists changed unexpectedly.");
a61af66fc99e Initial load
duke
parents:
diff changeset
521 }
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523 writeGrandUnixMakefile();
a61af66fc99e Initial load
duke
parents:
diff changeset
524 }
a61af66fc99e Initial load
duke
parents:
diff changeset
525
a61af66fc99e Initial load
duke
parents:
diff changeset
526 private void printDependentOn(PrintWriter gd, String name) {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 gd.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
528 gd.print(plat.dependentPrefix() + name);
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530
a61af66fc99e Initial load
duke
parents:
diff changeset
531 private boolean isOuterFile(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
532 int len = s.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
533 String[] suffixes = plat.outerSuffixes();
a61af66fc99e Initial load
duke
parents:
diff changeset
534 for (int i = 0; i < suffixes.length; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
535 String suffix = suffixes[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
536 int suffLen = suffix.length();
a61af66fc99e Initial load
duke
parents:
diff changeset
537 if ((len >= suffLen) &&
a61af66fc99e Initial load
duke
parents:
diff changeset
538 (plat.fileNameStringEquality(s.substring(len - suffLen),
a61af66fc99e Initial load
duke
parents:
diff changeset
539 suffix))) {
a61af66fc99e Initial load
duke
parents:
diff changeset
540 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
541 }
a61af66fc99e Initial load
duke
parents:
diff changeset
542 }
a61af66fc99e Initial load
duke
parents:
diff changeset
543 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
544 }
a61af66fc99e Initial load
duke
parents:
diff changeset
545
a61af66fc99e Initial load
duke
parents:
diff changeset
546 private String removeSuffixFrom(String s) {
a61af66fc99e Initial load
duke
parents:
diff changeset
547 int idx = s.lastIndexOf('.');
a61af66fc99e Initial load
duke
parents:
diff changeset
548 if (idx <= 0)
a61af66fc99e Initial load
duke
parents:
diff changeset
549 plat.abort();
a61af66fc99e Initial load
duke
parents:
diff changeset
550 return s.substring(0, idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
551 }
a61af66fc99e Initial load
duke
parents:
diff changeset
552 }