Mercurial > hg > truffle
annotate src/share/tools/MakeDeps/MakeDeps.java @ 1408:0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
author | lstadler |
---|---|
date | Wed, 12 May 2010 15:01:05 +0200 |
parents | a61af66fc99e |
children | 2d26b0046e0d |
rev | line source |
---|---|
1408
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
0
diff
changeset
|
1 import java.util.Map; |
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
0
diff
changeset
|
2 import java.util.Map.Entry; |
0ba67bb5392c
added c1x build directory, added MSVC Win64 project support
lstadler
parents:
0
diff
changeset
|
3 |
0 | 4 /* |
5 * Copyright 1999-2001 Sun Microsystems, Inc. All Rights Reserved. | |
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
7 * | |
8 * This code is free software; you can redistribute it and/or modify it | |
9 * under the terms of the GNU General Public License version 2 only, as | |
10 * published by the Free Software Foundation. | |
11 * | |
12 * This code is distributed in the hope that it will be useful, but WITHOUT | |
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 * version 2 for more details (a copy is included in the LICENSE file that | |
16 * accompanied this code). | |
17 * | |
18 * You should have received a copy of the GNU General Public License version | |
19 * 2 along with this work; if not, write to the Free Software Foundation, | |
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 * | |
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
23 * CA 95054 USA or visit www.sun.com if you need additional information or | |
24 * have any questions. | |
25 * | |
26 */ | |
27 | |
28 // This program reads an include file database. | |
29 // The database should cover each self .c and .h file, | |
30 // but not files in /usr/include | |
31 // The database consists of pairs of nonblank words, where the first word is | |
32 // the filename that needs to include the file named by the second word. | |
33 // For each .c file, this program generates a fooIncludes.h file that | |
34 // the .c file may include to include all the needed files in the right order. | |
35 // It also generates a foo.dep file to include in the makefile. | |
36 // Finally it detects cycles, and can work with two files, an old and a new one. | |
37 // To incrementally write out only needed files after a small change. | |
38 // | |
39 // Based on a suggestion by Roland Conybeare, algorithm suggested by Craig | |
40 // Chambers, written by David Ungar, 3/1/89. | |
41 // Added PREFIX, {DEP/INC}_DIR, smaller dep output 10/92 -Urs | |
42 | |
43 // Add something for precompiled headers | |
44 | |
45 // To handle different platforms, I am introducing a platform file. | |
46 // The platform file contains lines like: | |
47 // os = svr4 | |
48 // | |
49 // Then, when processing the includeDB file, a token such as <os> | |
50 // gets replaced by svr4. -- dmu 3/25/97 | |
51 | |
52 // Modified to centralize Dependencies to speed up make -- dmu 5/97 | |
53 | |
54 public class MakeDeps { | |
55 | |
56 public static void usage() { | |
57 System.out.println("usage:"); | |
58 System.out.println("\tmakeDeps platform-name platform-file database-file [MakeDeps args] [platform args]"); | |
59 System.out.println("\tmakeDeps diffs platform-name old-platform-file old-database-file new-platform-file new-database-file [MakeDeps args] [platform args]"); | |
60 System.out.println("where platform-name is the name of a platform MakeDeps supports"); | |
61 System.out.println("(currently \"WinGammaPlatform\" or \"UnixPlatform\")"); | |
62 System.out.println("MakeDeps options:"); | |
63 System.out.println(" -firstFile [filename]: Specify the first file in link order (i.e.,"); | |
64 System.out.println(" to have a well-known function at the start of the output file)"); | |
65 System.out.println(" -lastFile [filename]: Specify the last file in link order (i.e.,"); | |
66 System.out.println(" to have a well-known function at the end of the output file)"); | |
67 System.err.println("WinGammaPlatform platform-specific options:"); | |
68 System.err.println(" -sourceBase <path to directory (workspace) " + | |
69 "containing source files; no trailing slash>"); | |
70 System.err.println(" -dspFileName <full pathname to which .dsp file " + | |
71 "will be written; all parent directories must " + | |
72 "already exist>"); | |
73 System.err.println(" -envVar <environment variable to be inserted " + | |
74 "into .dsp file, substituting for path given in " + | |
75 "-sourceBase. Example: HotSpotWorkSpace>"); | |
76 System.err.println(" -dllLoc <path to directory in which to put " + | |
77 "jvm.dll and jvm_g.dll; no trailing slash>"); | |
78 System.err.println(" If any of the above are specified, "+ | |
79 "they must all be."); | |
80 System.err.println(" Additional, optional arguments, which can be " + | |
81 "specified multiple times:"); | |
82 System.err.println(" -absoluteInclude <string containing absolute " + | |
83 "path to include directory>"); | |
84 System.err.println(" -relativeInclude <string containing include " + | |
85 "directory relative to -envVar>"); | |
86 System.err.println(" -define <preprocessor flag to be #defined " + | |
87 "(note: doesn't yet support " + | |
88 "#define (flag) (value))>"); | |
89 System.err.println(" -perFileLine <file> <line>"); | |
90 System.err.println(" -conditionalPerFileLine <file> <line for " + | |
91 "release build> <line for debug build>"); | |
92 System.err.println(" (NOTE: To work around a bug in nmake, where " + | |
93 "you can't have a '#' character in a quoted " + | |
94 "string, all of the lines outputted have \"#\"" + | |
95 "prepended)"); | |
96 System.err.println(" -startAt <subdir of sourceBase>"); | |
97 System.err.println(" -ignoreFile <file which won't be able to be " + | |
98 "found in the sourceBase because it's generated " + | |
99 "later>"); | |
100 System.err.println(" -additionalFile <file not in database but " + | |
101 "which should show up in .dsp file, like " + | |
102 "includeDB_core>"); | |
103 System.err.println(" -additionalGeneratedFile <environment variable of " + | |
104 "generated file's location> <relative path to " + | |
105 "directory containing file; no trailing slash> " + | |
106 "<name of file generated later in the build process>"); | |
107 System.err.println(" -prelink <build> <desc> <cmds>:"); | |
108 System.err.println(" Generate a set of prelink commands for the given BUILD"); | |
109 System.err.println(" (\"Debug\" or \"Release\"). The prelink description and commands"); | |
110 System.err.println(" are both quoted strings."); | |
111 System.err.println(" Default includes: \".\""); | |
112 System.err.println(" Default defines: WIN32, _WINDOWS, \"HOTSPOT_BUILD_USER=$(USERNAME)\""); | |
113 } | |
114 | |
115 public static void main(String[] args) { | |
116 try { | |
117 if (args.length < 3) { | |
118 usage(); | |
119 System.exit(1); | |
120 } | |
121 | |
122 int argc = 0; | |
123 boolean diffMode = false; | |
124 if (args[argc].equals("diffs")) { | |
125 diffMode = true; | |
126 ++argc; | |
127 } | |
128 | |
129 String platformName = args[argc++]; | |
130 Class platformClass = Class.forName(platformName); | |
131 | |
132 String plat1 = null; | |
133 String db1 = null; | |
134 String plat2 = null; | |
135 String db2 = null; | |
136 | |
137 String firstFile = null; | |
138 String lastFile = null; | |
139 | |
140 int numOptionalArgs = | |
141 (diffMode ? (args.length - 6) : (args.length - 3)); | |
142 if (numOptionalArgs < 0) { | |
143 usage(); | |
144 System.exit(1); | |
145 } | |
146 | |
147 plat1 = args[argc++]; | |
148 db1 = args[argc++]; | |
149 | |
150 if (diffMode) { | |
151 plat2 = args[argc++]; | |
152 db2 = args[argc++]; | |
153 } | |
154 | |
155 // argc now points at start of optional arguments, if any | |
156 | |
157 try { | |
158 boolean gotOne = true; | |
159 while (gotOne && (argc < args.length - 1)) { | |
160 gotOne = false; | |
161 String arg = args[argc]; | |
162 if (arg.equals("-firstFile")) { | |
163 firstFile = args[argc + 1]; | |
164 argc += 2; | |
165 gotOne = true; | |
166 } else if (arg.equals("-lastFile")) { | |
167 lastFile = args[argc + 1]; | |
168 argc += 2; | |
169 gotOne = true; | |
170 } | |
171 } | |
172 } | |
173 catch (Exception e) { | |
174 e.printStackTrace(); | |
175 usage(); | |
176 System.exit(1); | |
177 } | |
178 | |
179 Platform platform = (Platform) platformClass.newInstance(); | |
180 platform.setupFileTemplates(); | |
181 long t = platform.defaultGrandIncludeThreshold(); | |
182 | |
183 String[] platformArgs = null; | |
184 int numPlatformArgs = args.length - argc; | |
185 if (numPlatformArgs > 0) { | |
186 platformArgs = new String[numPlatformArgs]; | |
187 int offset = argc; | |
188 while (argc < args.length) { | |
189 platformArgs[argc - offset] = args[argc]; | |
190 ++argc; | |
191 } | |
192 } | |
193 | |
194 // If you want to change the threshold, change the default | |
195 // "grand include" threshold in Platform.java, or override | |
196 // it in the platform-specific file like UnixPlatform.java | |
197 | |
198 Database previous = new Database(platform, t); | |
199 Database current = new Database(platform, t); | |
200 | |
201 previous.canBeMissing(); | |
202 | |
203 if (firstFile != null) { | |
204 previous.setFirstFile(firstFile); | |
205 current.setFirstFile(firstFile); | |
206 } | |
207 if (lastFile != null) { | |
208 previous.setLastFile(lastFile); | |
209 current.setLastFile(lastFile); | |
210 } | |
211 | |
212 if (diffMode) { | |
213 System.out.println("Old database:"); | |
214 previous.get(plat1, db1); | |
215 previous.compute(); | |
216 System.out.println("New database:"); | |
217 current.get(plat2, db2); | |
218 current.compute(); | |
219 System.out.println("Deltas:"); | |
220 current.putDiffs(previous); | |
221 } else { | |
222 System.out.println("New database:"); | |
223 current.get(plat1, db1); | |
224 current.compute(); | |
225 current.put(); | |
226 } | |
227 | |
228 if (platformArgs != null) { | |
229 // Allow the platform to write platform-specific files | |
230 platform.writePlatformSpecificFiles(previous, current, | |
231 platformArgs); | |
232 } | |
233 } | |
234 catch (Exception e) { | |
235 e.printStackTrace(); | |
236 System.exit(1); | |
237 } | |
238 } | |
239 } |