Source Code Cross Referenced for WinGammaPlatform.java in  » 6.0-JDK-Modules » j2me » makedep » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » makedep 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *   
003:         *
004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006:         * 
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License version
009:         * 2 only, as published by the Free Software Foundation.
010:         * 
011:         * This program is distributed in the hope that it will be useful, but
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014:         * General Public License version 2 for more details (a copy is
015:         * included at /legal/license.txt).
016:         * 
017:         * You should have received a copy of the GNU General Public License
018:         * version 2 along with this work; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA
021:         * 
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023:         * Clara, CA 95054 or visit www.sun.com if you need additional
024:         * information or have any questions.
025:         */
026:
027:        package makedep;
028:
029:        import java.io.*;
030:        import java.util.*;
031:
032:        public class WinGammaPlatform extends Platform {
033:            private static String[] suffixes = { ".cpp", ".c" };
034:
035:            public String[] outerSuffixes() {
036:                return suffixes;
037:            }
038:
039:            public String fileSeparator() {
040:                return "\\";
041:            }
042:
043:            public String objFileSuffix() {
044:                return ".obj";
045:            }
046:
047:            public String asmFileSuffix() {
048:                return ".asm";
049:            }
050:
051:            public String dependentPrefix() {
052:                return "$(VM_PATH)";
053:            }
054:
055:            public boolean includeGIInEachIncl() {
056:                return false;
057:            }
058:
059:            public boolean fileNameStringEquality(String s1, String s2) {
060:                return s1.equalsIgnoreCase(s2);
061:            }
062:
063:            private void usage() throws IllegalArgumentException {
064:                System.err
065:                        .println("WinGammaPlatform platform-specific options:");
066:                System.err
067:                        .println("  -sourceBase <path to directory (workspace) "
068:                                + "containing source files; no trailing slash>");
069:                System.err
070:                        .println("  -dspFileName <full pathname to which .dsp file "
071:                                + "will be written; all parent directories must "
072:                                + "already exist>");
073:                System.err
074:                        .println("  -envVar <environment variable to be inserted "
075:                                + "into .dsp file, substituting for path given in "
076:                                + "-sourceBase. Example: JVMWorkSpace>");
077:                System.err
078:                        .println("  -exeLoc <path to directory in which to put "
079:                                + "cldc_vm.exe and cldc_vm_g.exe; no trailing slash>");
080:                System.err.println("  If any of the above are specified, "
081:                        + "they must all be.");
082:                System.err
083:                        .println("  Additional, optional arguments, which can be "
084:                                + "specified multiple times:");
085:                System.err
086:                        .println("    -absoluteInclude <string containing absolute "
087:                                + "path to include directory>");
088:                System.err
089:                        .println("    -relativeInclude <string containing include "
090:                                + "directory relative to -envVar>");
091:                System.err
092:                        .println("    -define <preprocessor flag to be #defined "
093:                                + "(note: doesn't yet support "
094:                                + "#define (flag) (value))>");
095:                System.err.println("    -perFileLine <file> <line>");
096:                System.err
097:                        .println("    -conditionalPerFileLine <file> <line for "
098:                                + "release build> <line for debug build>");
099:                System.err
100:                        .println("  (NOTE: To work around a bug in nmake, where "
101:                                + "you can't have a '#' character in a quoted "
102:                                + "string, all of the lines outputted have \"#\""
103:                                + "prepended)");
104:                System.err.println("    -startAt <subdir of sourceBase>");
105:                System.err
106:                        .println("    -ignoreFile <file which won't be able to be "
107:                                + "found in the sourceBase because it's generated "
108:                                + "later>");
109:                System.err
110:                        .println("    -additionalFile <file not in database but "
111:                                + "which should show up in .dsp file, like "
112:                                + "includeDB_core>");
113:                System.err
114:                        .println("    -additionalGeneratedFile <environment variable of "
115:                                + "generated file's location> <relative path to "
116:                                + "directory containing file; no trailing slash> "
117:                                + "<name of file generated later in the build process>");
118:                System.err.println("    Default includes: \".\"");
119:                System.err.println("    Default defines: WIN32, _CONSOLE");
120:                throw new IllegalArgumentException();
121:            }
122:
123:            private String getDspName(String fullPath)
124:                    throws IllegalArgumentException, IOException {
125:                File file = new File(fullPath).getCanonicalFile();
126:                fullPath = file.getCanonicalPath();
127:                String parent = file.getParent();
128:                String separator = System.getProperty("file.separator");
129:                String dspString = ".dsp";
130:
131:                if (!fullPath.endsWith(dspString)) {
132:                    throw new IllegalArgumentException(".dsp file name \""
133:                            + fullPath + "\" does not end in .dsp");
134:                }
135:
136:                if ((parent != null) && (!fullPath.startsWith(parent))) {
137:                    throw new RuntimeException(
138:                            "Internal error: parent of file name \"" + parent
139:                                    + "\" does not match file name \""
140:                                    + fullPath + "\"");
141:                }
142:
143:                int len = parent.length();
144:                if (!parent.endsWith(separator)) {
145:                    len += separator.length();
146:                }
147:
148:                int end = fullPath.length() - dspString.length();
149:
150:                if (len == end) {
151:                    throw new RuntimeException(
152:                            "Internal error: file name was empty");
153:                }
154:
155:                return fullPath.substring(len, end);
156:            }
157:
158:            public void addPerFileLine(Hashtable table, String fileName,
159:                    String line) {
160:                Vector v = (Vector) table.get(fileName);
161:                if (v != null) {
162:                    v.add(line);
163:                } else {
164:                    v = new Vector();
165:                    v.add(line);
166:                    table.put(fileName, v);
167:                }
168:            }
169:
170:            private static class PerFileCondData {
171:                public String releaseString;
172:                public String debugString;
173:            }
174:
175:            private void addConditionalPerFileLine(Hashtable table,
176:                    String fileName, String releaseLine, String debugLine) {
177:                PerFileCondData data = new PerFileCondData();
178:                data.releaseString = releaseLine;
179:                data.debugString = debugLine;
180:                Vector v = (Vector) table.get(fileName);
181:                if (v != null) {
182:                    v.add(data);
183:                } else {
184:                    v = new Vector();
185:                    v.add(data);
186:                    table.put(fileName, v);
187:                }
188:            }
189:
190:            public boolean findString(Vector v, String s) {
191:                for (Iterator iter = v.iterator(); iter.hasNext();) {
192:                    if (((String) iter.next()).equals(s)) {
193:                        return true;
194:                    }
195:                }
196:
197:                return false;
198:            }
199:
200:            /* This returns a String containing the full path to the passed
201:               file name, or null if an error occurred. If the file was not
202:               found or was a duplicate and couldn't be resolved using the
203:               preferred paths, the file name is added to the appropriate
204:               Vector of Strings. */
205:            private String findFileInDirectory(String fileName,
206:                    DirectoryTree directory, Vector preferredPaths,
207:                    Vector filesNotFound, Vector filesDuplicate) {
208:                List locationsInTree = directory.findFile(fileName);
209:                String name = null;
210:                if ((locationsInTree == null) || (locationsInTree.size() == 0)) {
211:                    filesNotFound.add(fileName);
212:                } else if (locationsInTree.size() > 1) {
213:                    // Iterate through them, trying to find one with a
214:                    // preferred path
215:                    search: {
216:                        for (Iterator locIter = locationsInTree.iterator(); locIter
217:                                .hasNext();) {
218:                            DirectoryTreeNode node = (DirectoryTreeNode) locIter
219:                                    .next();
220:                            String tmpName = node.getName();
221:                            for (Iterator prefIter = preferredPaths.iterator(); prefIter
222:                                    .hasNext();) {
223:                                if (tmpName.indexOf((String) prefIter.next()) != -1) {
224:                                    name = tmpName;
225:                                    break search;
226:                                }
227:                            }
228:                        }
229:                    }
230:
231:                    if (name == null) {
232:                        filesDuplicate.add(fileName);
233:                    }
234:                } else {
235:                    name = ((DirectoryTreeNode) locationsInTree.get(0))
236:                            .getName();
237:                }
238:
239:                return name;
240:            }
241:
242:            private void outputSourceFiles(Vector outputStrings,
243:                    Vector fileNames, Hashtable perFileLines,
244:                    Hashtable conditionalPerFileLines, PrintWriter dspFile,
245:                    String dspName) {
246:                Iterator outputIter = outputStrings.iterator();
247:                Iterator fileIter = fileNames.iterator();
248:                while (outputIter.hasNext()) {
249:                    String outStr = (String) outputIter.next();
250:                    String fileStr = (String) fileIter.next();
251:
252:                    dspFile.println("# Begin Source File");
253:                    dspFile.println("");
254:                    dspFile.println("SOURCE=\"" + outStr + "\"");
255:                    Vector v = null;
256:
257:                    v = (Vector) perFileLines.get(fileStr);
258:                    if (v != null) {
259:                        for (Iterator lineIter = v.iterator(); lineIter
260:                                .hasNext();) {
261:                            String str = (String) lineIter.next();
262:                            dspFile.println("# " + str);
263:                        }
264:                    }
265:                    v = (Vector) conditionalPerFileLines.get(fileStr);
266:                    if (v != null) {
267:                        dspFile.println("!IF  \"$(CFG)\" == \"" + dspName
268:                                + " - Win32 Release\"");
269:                        dspFile.println("");
270:                        for (Iterator lineIter = v.iterator(); lineIter
271:                                .hasNext();) {
272:                            PerFileCondData data = (PerFileCondData) lineIter
273:                                    .next();
274:                            dspFile.println("#" + data.releaseString);
275:                        }
276:                        dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
277:                                + " - Win32 Debug\"");
278:                        dspFile.println("");
279:                        for (Iterator lineIter = v.iterator(); lineIter
280:                                .hasNext();) {
281:                            PerFileCondData data = (PerFileCondData) lineIter
282:                                    .next();
283:                            dspFile.println("#" + data.debugString);
284:                        }
285:                        dspFile.println("!ENDIF");
286:                    }
287:
288:                    dspFile.println("# End Source File");
289:                }
290:            }
291:
292:            private void outputInterpreterDirectives(PrintWriter dspFile,
293:                    String dspName) {
294:                dspFile.println("");
295:                dspFile.println("# Begin Source File");
296:                dspFile.println("");
297:                dspFile
298:                        .println("SOURCE=\"..\\target\\product\\Interpreter_i386.asm\"");
299:                dspFile.println("");
300:                dspFile.println("!IF  \"$(CFG)\" == \"" + dspName
301:                        + " - Win32 Product\"");
302:                dspFile.println("");
303:                dspFile
304:                        .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
305:                dspFile.println("OutDir=.\\Product");
306:                dspFile.println("InputName=Interpreter_i386");
307:                dspFile.println("");
308:                dspFile
309:                        .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
310:                dspFile
311:                        .println("    \"$(ASMDIR_X86)\\ml\" /nologo /c /coff /Zi /FR /Fo$(OutDir)\\$(InputName).obj ..\\target\\product\\Interpreter_i386.asm\"");
312:                dspFile.println("# End Custom Build");
313:                dspFile.println("");
314:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
315:                        + " - Win32 Release\"");
316:                dspFile.println("");
317:                dspFile.println("# PROP Exclude_From_Build 1");
318:                dspFile.println("");
319:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
320:                        + " - Win32 Debug\"");
321:                dspFile.println("");
322:                dspFile.println("# PROP Exclude_From_Build 1");
323:                dspFile.println("");
324:                dspFile.println("!ENDIF");
325:                dspFile.println("");
326:                dspFile.println("# End Source File");
327:
328:                dspFile.println("");
329:                dspFile.println("# Begin Source File");
330:                dspFile.println("");
331:                dspFile
332:                        .println("SOURCE=\"..\\target\\release\\Interpreter_i386.asm\"");
333:                dspFile.println("");
334:                dspFile.println("!IF  \"$(CFG)\" == \"" + dspName
335:                        + " - Win32 Product\"");
336:                dspFile.println("");
337:                dspFile.println("# PROP Exclude_From_Build 1");
338:                dspFile.println("");
339:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
340:                        + " - Win32 Release\"");
341:                dspFile.println("");
342:                dspFile
343:                        .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
344:                dspFile.println("OutDir=.\\Release");
345:                dspFile.println("InputName=Interpreter_i386");
346:                dspFile.println("");
347:                dspFile
348:                        .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
349:                dspFile
350:                        .println("    \"$(ASMDIR_X86)\\ml\" /nologo /c /coff /Zi /FR /Fo$(OutDir)\\$(InputName).obj ..\\target\\release\\Interpreter_i386.asm\"");
351:                dspFile.println("# End Custom Build");
352:                dspFile.println("");
353:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
354:                        + " - Win32 Debug\"");
355:                dspFile.println("");
356:                dspFile.println("# PROP Exclude_From_Build 1");
357:                dspFile.println("");
358:                dspFile.println("!ENDIF");
359:                dspFile.println("");
360:                dspFile.println("# End Source File");
361:
362:                dspFile.println("");
363:                dspFile.println("# Begin Source File");
364:                dspFile.println("");
365:                dspFile
366:                        .println("SOURCE=\"..\\target\\debug\\Interpreter_i386.asm\"");
367:                dspFile.println("");
368:                dspFile.println("!IF  \"$(CFG)\" == \"" + dspName
369:                        + " - Win32 Product\"");
370:                dspFile.println("");
371:                dspFile.println("# PROP Exclude_From_Build 1");
372:                dspFile.println("");
373:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
374:                        + " - Win32 Release\"");
375:                dspFile.println("");
376:                dspFile.println("# PROP Exclude_From_Build 1");
377:                dspFile.println("");
378:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
379:                        + " - Win32 Debug\"");
380:                dspFile.println("");
381:                dspFile
382:                        .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
383:                dspFile.println("OutDir=.\\Debug");
384:                dspFile.println("InputName=Interpreter_i386");
385:                dspFile.println("");
386:                dspFile
387:                        .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
388:                dspFile
389:                        .println("    \"$(ASMDIR_X86)\\ml\" /nologo /c /coff /Zi /FR /Fo$(OutDir)\\$(InputName).obj ..\\target\\debug\\Interpreter_i386.asm\"");
390:                dspFile.println("# End Custom Build");
391:                dspFile.println("");
392:                dspFile.println("!ENDIF");
393:                dspFile.println("");
394:                dspFile.println("# End Source File");
395:            }
396:
397:            private boolean databaseAllFilesEqual(Database previousDB,
398:                    Database currentDB) {
399:                Iterator i1 = previousDB.getAllFiles().iterator();
400:                Iterator i2 = currentDB.getAllFiles().iterator();
401:
402:                while (i1.hasNext() && i2.hasNext()) {
403:                    FileList fl1 = (FileList) i1.next();
404:                    FileList fl2 = (FileList) i2.next();
405:                    if (!fl1.getName().equals(fl2.getName())) {
406:                        return false;
407:                    }
408:                }
409:
410:                if (i1.hasNext() != i2.hasNext()) {
411:                    // Different lengths
412:                    return false;
413:                }
414:
415:                return true;
416:            }
417:
418:            private String envVarPrefixedFileName(String fileName,
419:                    int sourceBaseLen, String envVar, DirectoryTree tree,
420:                    Vector preferredPaths, Vector filesNotFound,
421:                    Vector filesDuplicate) {
422:                String fullName = findFileInDirectory(fileName, tree,
423:                        preferredPaths, filesNotFound, filesDuplicate);
424:                if (fullName == null) {
425:                    return null;
426:                }
427:                return "$(" + envVar + ")" + fullName.substring(sourceBaseLen);
428:            }
429:
430:            public void writePlatformSpecificFiles(Database previousDB,
431:                    Database currentDB, String[] args)
432:                    throws IllegalArgumentException, IOException {
433:                if (args.length == 0) {
434:                    return;
435:                }
436:
437:                String sourceBase = null;
438:                String startAt = null;
439:                String dspFileName = null;
440:                String envVar = null;
441:                String exeLoc = null;
442:                // This contains Strings: list of all file names (database +
443:                // additional files)
444:                Vector allFileNames = new Vector();
445:                // This contains Strings: any extra includes with absolute paths
446:                Vector absoluteIncludes = new Vector();
447:                // This contains Strings: any extra includes with paths
448:                // relative to -envVar
449:                Vector relativeIncludes = new Vector();
450:                // This contains Strings: preprocessor flags to #define
451:                Vector defines = new Vector();
452:                // This maps Strings containing file names to Vectors of
453:                // Strings
454:                Hashtable perFileLines = new Hashtable();
455:                // This maps Strings containing file names to Vectors of
456:                // PerFileCondData objects
457:                Hashtable conditionalPerFileLines = new Hashtable();
458:                // This contains Strings: additional files to add to the
459:                // project file (i.e., includeDB, for convenience)
460:                Vector additionalFiles = new Vector();
461:                // This contains Strings: files in the database to be ignored
462:                // because they're autogenerated later (compiler2 files
463:                // ad_<arch>.[ch]pp, dfa_<arch>.cpp)
464:                Vector ignoredFiles = new Vector();
465:                // This contains Strings: lines to be added for the ignored
466:                // files
467:                Vector additionalGeneratedFileStrings = new Vector();
468:                // Just the file names of the above strings
469:                Vector additionalGeneratedFileNames = new Vector();
470:
471:                int i = 0;
472:
473:                System.err
474:                        .println("WinGammaPlatform platform-specific arguments:");
475:                for (int j = 0; j < args.length; j++) {
476:                    System.err.print(args[j] + " ");
477:                }
478:                System.err.println();
479:
480:                try {
481:                    while (i < args.length) {
482:                        if (args[i].equals("-sourceBase")) {
483:                            sourceBase = args[i + 1];
484:                            if (sourceBase.charAt(0) == '-') {
485:                                System.err
486:                                        .println("** Error: empty -sourceBase");
487:                                System.err
488:                                        .println("   (Did you set the JVMWorkSpace environment variable?)");
489:                                usage();
490:                            }
491:                            i += 2;
492:                        } else if (args[i].equals("-dspFileName")) {
493:                            dspFileName = args[i + 1];
494:                            if (dspFileName.charAt(0) == '-') {
495:                                System.err
496:                                        .println("** Error: empty -dspFileName");
497:                                usage();
498:                            }
499:                            i += 2;
500:                        } else if (args[i].equals("-envVar")) {
501:                            envVar = args[i + 1];
502:                            if (envVar.charAt(0) == '-') {
503:                                System.err.println("** Error: empty -envVar");
504:                                usage();
505:                            }
506:                            i += 2;
507:                        } else if (args[i].equals("-exeLoc")) {
508:                            exeLoc = args[i + 1];
509:                            if (exeLoc.charAt(0) == '-') {
510:                                System.err.println("** Error: empty -exeLoc");
511:                                usage();
512:                            }
513:                            i += 2;
514:                        } else if (args[i].equals("-absoluteInclude")) {
515:                            absoluteIncludes.add(args[i + 1]);
516:                            if (args[i + 1].charAt(0) == '-') {
517:                                System.err
518:                                        .println("** Error: empty -absoluteInclude");
519:                                usage();
520:                            }
521:                            i += 2;
522:                        } else if (args[i].equals("-relativeInclude")) {
523:                            relativeIncludes.add(args[i + 1]);
524:                            if (args[i + 1].charAt(0) == '-') {
525:                                System.err
526:                                        .println("** Error: empty -relativeInclude");
527:                                usage();
528:                            }
529:                            i += 2;
530:                        } else if (args[i].equals("-define")) {
531:                            defines.add(args[i + 1]);
532:                            if (args[i + 1].charAt(0) == '-') {
533:                                System.err.println("** Error: empty -define");
534:                                usage();
535:                            }
536:                            i += 2;
537:                        } else if (args[i].equals("-perFileLine")) {
538:                            addPerFileLine(perFileLines, args[i + 1],
539:                                    args[i + 2]);
540:                            if (args[i + 1].charAt(0) == '-'
541:                                    || args[i + 2].charAt(0) == '-') {
542:                                System.err
543:                                        .println("** Error: wrong number of args to -perFileLine");
544:                                usage();
545:                            }
546:                            i += 3;
547:                        } else if (args[i].equals("-conditionalPerFileLine")) {
548:                            addConditionalPerFileLine(conditionalPerFileLines,
549:                                    args[i + 1], args[i + 2], args[i + 3]);
550:                            if (((args[i + 1].length() > 0) && (args[i + 1]
551:                                    .charAt(0) == '-'))
552:                                    || ((args[i + 2].length() > 0) && (args[i + 2]
553:                                            .charAt(0) == '-'))
554:                                    || ((args[i + 3].length() > 0) && (args[i + 3]
555:                                            .charAt(0) == '-'))) {
556:                                System.err
557:                                        .println("** Error: wrong number of args to -conditionalPerFileLine");
558:                                usage();
559:                            }
560:                            i += 4;
561:                        } else if (args[i].equals("-startAt")) {
562:                            if (startAt != null) {
563:                                System.err
564:                                        .println("** Error: multiple -startAt");
565:                                usage();
566:                            }
567:                            startAt = args[i + 1];
568:                            if (args[i + 1].charAt(0) == '-') {
569:                                System.err.println("** Error: empty -startAt");
570:                                usage();
571:                            }
572:                            i += 2;
573:                        } else if (args[i].equals("-ignoreFile")) {
574:                            ignoredFiles.add(args[i + 1]);
575:                            if (args[i + 1].charAt(0) == '-') {
576:                                System.err
577:                                        .println("** Error: empty -ignoreFile");
578:                                usage();
579:                            }
580:                            i += 2;
581:                        } else if (args[i].equals("-additionalFile")) {
582:                            additionalFiles.add(args[i + 1]);
583:                            if (args[i + 1].charAt(0) == '-') {
584:                                System.err
585:                                        .println("** Error: empty -additionalFile");
586:                                usage();
587:                            }
588:                            i += 2;
589:                        } else if (args[i].equals("-additionalGeneratedFile")) {
590:                            String var = args[i + 1];
591:                            String dir = args[i + 2];
592:                            String fileName = args[i + 3];
593:                            additionalGeneratedFileStrings.add("$(" + var
594:                                    + ")\\" + dir + "\\" + fileName);
595:                            additionalGeneratedFileNames.add(fileName);
596:                            if (args[i + 1].charAt(0) == '-'
597:                                    || args[i + 2].charAt(0) == '-'
598:                                    || args[i + 3].charAt(0) == '-') {
599:                                System.err
600:                                        .println("** Error: wrong number of args to -additionalGeneratedFile");
601:                                usage();
602:                            }
603:                            i += 4;
604:                        } else {
605:                            System.err.println("Illegal argument: " + args[i]);
606:                            usage();
607:                        }
608:                    }
609:                } catch (ArrayIndexOutOfBoundsException e) {
610:                    usage();
611:                }
612:
613:                if ((sourceBase == null) || (dspFileName == null)
614:                        || (envVar == null) || (exeLoc == null)) {
615:                    usage();
616:                }
617:
618:                // Compare contents of allFiles of previousDB and includeDB.
619:                // If these haven't changed, then skip writing the .dsp file.
620:                if (databaseAllFilesEqual(previousDB, currentDB)
621:                        && new File(dspFileName).exists()) {
622:                    System.out
623:                            .println("    Databases unchanged; skipping overwrite of .dsp file.");
624:                    return;
625:                }
626:
627:                String dspName = getDspName(dspFileName);
628:
629:                System.out.print("    Reading directory...");
630:                System.out.flush();
631:                DirectoryTree tree = new DirectoryTree();
632:                tree.addSubdirToIgnore("Codemgr_wsdata");
633:                tree.addSubdirToIgnore("deleted_files");
634:                tree.addSubdirToIgnore("SCCS");
635:                tree.setVerbose(true);
636:                if (startAt != null)
637:                    tree.readDirectory(sourceBase + File.separator + startAt);
638:                else
639:                    tree.readDirectory(sourceBase);
640:                int sourceBaseLen = sourceBase.length();
641:                // Contains Strings which are the source file names to be
642:                // written to the .dsp file
643:                Vector outputStrings = new Vector();
644:                Vector preferredPaths = new Vector();
645:                // In the case of multiple files with the same name in
646:                // different subdirectories, prefer the versions specified in
647:                // the platform file as the "os_family" and "arch" macros.
648:                String v;
649:                if ((v = currentDB.getMacroContent("os_family")) != null) {
650:                    preferredPaths.add(v);
651:                }
652:                if ((v = currentDB.getMacroContent("arch")) != null) {
653:                    preferredPaths.add(v);
654:                }
655:                // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
656:                preferredPaths.add("opto");
657:                // Hold errors until end
658:                Vector filesNotFound = new Vector();
659:                Vector filesDuplicate = new Vector();
660:
661:                System.out.println();
662:                System.out.print("    Looking up files in database...");
663:                System.out.flush();
664:                for (Iterator iter = currentDB.getAllFiles().iterator(); iter
665:                        .hasNext();) {
666:                    FileList fl = (FileList) iter.next();
667:                    String fileName = fl.getName();
668:                    // Add to all files only if not ignored
669:                    if (!findString(ignoredFiles, fileName)) {
670:                        allFileNames.add(fileName);
671:                        String prefixedName = envVarPrefixedFileName(fileName,
672:                                sourceBaseLen, envVar, tree, preferredPaths,
673:                                filesNotFound, filesDuplicate);
674:                        if (prefixedName != null) {
675:                            outputStrings.add(prefixedName);
676:                        }
677:                        System.out.print(".");
678:                        System.out.flush();
679:                    }
680:                }
681:
682:                for (Iterator iter = additionalFiles.iterator(); iter.hasNext();) {
683:                    String fileName = (String) iter.next();
684:                    allFileNames.add(fileName);
685:                    String prefixedName = envVarPrefixedFileName(fileName,
686:                            sourceBaseLen, envVar, tree, preferredPaths,
687:                            filesNotFound, filesDuplicate);
688:                    if (prefixedName != null) {
689:                        outputStrings.add(prefixedName);
690:                    }
691:                }
692:
693:                if ((filesNotFound.size() != 0) || (filesDuplicate.size() != 0)) {
694:                    System.err.println("Error: some files were not found or "
695:                            + "appeared in multiple subdirectories of "
696:                            + "directory " + sourceBase + " and could not "
697:                            + "be resolved with the os_family and arch "
698:                            + "macros in the platform file.");
699:                    if (filesNotFound.size() != 0) {
700:                        System.err.println("Files not found:");
701:                        for (Iterator iter = filesNotFound.iterator(); iter
702:                                .hasNext();) {
703:                            System.err.println("  " + (String) iter.next());
704:                        }
705:                    }
706:                    if (filesDuplicate.size() != 0) {
707:                        System.err.println("Duplicate files:");
708:                        for (Iterator iter = filesDuplicate.iterator(); iter
709:                                .hasNext();) {
710:                            System.err.println("  " + (String) iter.next());
711:                        }
712:                    }
713:                    throw new RuntimeException();
714:                }
715:
716:                System.out.println();
717:                System.out.println("    Writing .dsp file...");
718:                // If we got this far without an error, we're safe to actually
719:                // write the .dsp file
720:                PrintWriter dspFile = new PrintWriter(new FileWriter(
721:                        dspFileName));
722:                dspFile
723:                        .println("# Microsoft Developer Studio Project File - Name=\""
724:                                + dspName + "\" - Package Owner=<4>");
725:                dspFile
726:                        .println("# Microsoft Developer Studio Generated Build File, Format Version 6.00");
727:                dspFile.println("# ** DO NOT EDIT **");
728:                dspFile.println("");
729:                dspFile
730:                        .println("# TARGTYPE \"Win32 (x86) Console Application\" 0x0103");
731:                dspFile.println("");
732:                dspFile.println("CFG=" + dspName + " - Win32 Release");
733:                dspFile
734:                        .println("!MESSAGE This is not a valid makefile. To build this project using NMAKE,");
735:                dspFile
736:                        .println("!MESSAGE use the Export Makefile command and run");
737:                dspFile.println("!MESSAGE ");
738:                dspFile.println("!MESSAGE NMAKE /f \"" + dspName + ".mak\".");
739:                dspFile.println("!MESSAGE ");
740:                dspFile
741:                        .println("!MESSAGE You can specify a configuration when running NMAKE");
742:                dspFile
743:                        .println("!MESSAGE by defining the macro CFG on the command line. For example:");
744:                dspFile.println("!MESSAGE ");
745:                dspFile.println("!MESSAGE NMAKE /f \"" + dspName
746:                        + ".mak\" CFG=\"" + dspName + " - Win32 Release\"");
747:                dspFile.println("!MESSAGE ");
748:                dspFile
749:                        .println("!MESSAGE Possible choices for configuration are:");
750:                dspFile.println("!MESSAGE ");
751:                dspFile
752:                        .println("!MESSAGE \""
753:                                + dspName
754:                                + " - Win32 Product\" (based on \"Win32 (x86) Console Application\")");
755:                dspFile
756:                        .println("!MESSAGE \""
757:                                + dspName
758:                                + " - Win32 Release\" (based on \"Win32 (x86) Console Application\")");
759:                dspFile
760:                        .println("!MESSAGE \""
761:                                + dspName
762:                                + " - Win32 Debug\" (based on \"Win32 (x86) Console Application\")");
763:                dspFile.println("!MESSAGE ");
764:                dspFile.println("");
765:                dspFile.println("# Begin Project");
766:                dspFile.println("# PROP AllowPerConfigDependencies 0");
767:                dspFile.println("# PROP Scc_ProjName \"\"");
768:                dspFile.println("# PROP Scc_LocalPath \"\"");
769:                dspFile.println("CPP=cl.exe");
770:                dspFile.println("MTL=midl.exe");
771:                dspFile.println("RSC=rc.exe");
772:                dspFile.println("");
773:
774:                dspFile.println("!IF  \"$(CFG)\" == \"" + dspName
775:                        + " - Win32 Product\"");
776:                dspFile.println("");
777:                dspFile.println("# PROP BASE Use_MFC 0");
778:                dspFile.println("# PROP BASE Use_Debug_Libraries 0");
779:                dspFile.println("# PROP BASE Output_Dir \".\\Product\"");
780:                dspFile.println("# PROP BASE Intermediate_Dir \".\\Product\"");
781:                dspFile.println("# PROP BASE Target_Dir \"\"");
782:                dspFile.println("# PROP Use_MFC 0");
783:                dspFile.println("# PROP Use_Debug_Libraries 0");
784:                dspFile.println("# PROP Output_Dir \"Product\"");
785:                dspFile.println("# PROP Intermediate_Dir \"Product\"");
786:                dspFile.println("# PROP Ignore_Export_Lib 0");
787:                dspFile.println("# PROP Target_Dir \"\"");
788:                dspFile
789:                        .println("# ADD BASE CPP /nologo /W3 /O2 /D \"WIN32\" /D \"PRODUCT\" /D \"NDEBUG\" /D \"_CONSOLE\" /YX /FR /FD /c");
790:
791:                dspFile.print("# ADD CPP /nologo /W3 /WX /O2 /I \".\"");
792:                for (Iterator iter = absoluteIncludes.iterator(); iter
793:                        .hasNext();) {
794:                    String include = (String) iter.next();
795:                    dspFile.print(" /I \"" + include + "\"");
796:                }
797:                for (Iterator iter = relativeIncludes.iterator(); iter
798:                        .hasNext();) {
799:                    String include = (String) iter.next();
800:                    dspFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
801:                }
802:                dspFile
803:                        .print("  /D \"PRODUCT\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\"");
804:                for (Iterator iter = defines.iterator(); iter.hasNext();) {
805:                    String define = (String) iter.next();
806:                    dspFile.print(" /D \"" + define + "\"");
807:                }
808:                dspFile.println(" /FR /Yu\"incls/_precompiled.incl\" /FD /c");
809:                dspFile.println("# ADD BASE RSC /l 0x406 /d \"NDEBUG\"");
810:                dspFile.println("# ADD RSC /l 0x406 /d \"NDEBUG\"");
811:                dspFile.println("BSC32=bscmake.exe");
812:                dspFile.println("# ADD BASE BSC32 /nologo");
813:                dspFile.println("# ADD BSC32 /nologo");
814:                dspFile.println("LINK32=link.exe");
815:                dspFile
816:                        .println("# ADD BASE LINK32 gdi32.lib user32.lib wsock32.lib /nologo /subsystem:console /incremental:no /machine:I386");
817:                dspFile
818:                        .println("# ADD LINK32 gdi32.lib user32.lib wsock32.lib /nologo /subsystem:console /incremental:no /machine:I386");
819:                dspFile.println("");
820:
821:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
822:                        + " - Win32 Release\"");
823:                dspFile.println("");
824:                dspFile.println("# PROP BASE Use_MFC 0");
825:                dspFile.println("# PROP BASE Use_Debug_Libraries 0");
826:                dspFile.println("# PROP BASE Output_Dir \".\\Release\"");
827:                dspFile.println("# PROP BASE Intermediate_Dir \".\\Release\"");
828:                dspFile.println("# PROP BASE Target_Dir \"\"");
829:                dspFile.println("# PROP Use_MFC 0");
830:                dspFile.println("# PROP Use_Debug_Libraries 0");
831:                dspFile.println("# PROP Output_Dir \"Release\"");
832:                dspFile.println("# PROP Intermediate_Dir \"Release\"");
833:                dspFile.println("# PROP Ignore_Export_Lib 0");
834:                dspFile.println("# PROP Target_Dir \"\"");
835:                dspFile
836:                        .println("# ADD BASE CPP /nologo /W3 /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /YX /FR /FD /c");
837:
838:                dspFile.print("# ADD CPP /nologo /W3 /WX /O2 /I \".\"");
839:                for (Iterator iter = absoluteIncludes.iterator(); iter
840:                        .hasNext();) {
841:                    String include = (String) iter.next();
842:                    dspFile.print(" /I \"" + include + "\"");
843:                }
844:                for (Iterator iter = relativeIncludes.iterator(); iter
845:                        .hasNext();) {
846:                    String include = (String) iter.next();
847:                    dspFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
848:                }
849:                dspFile.print("  /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\"");
850:                for (Iterator iter = defines.iterator(); iter.hasNext();) {
851:                    String define = (String) iter.next();
852:                    dspFile.print(" /D \"" + define + "\"");
853:                }
854:                dspFile.println(" /FR /Yu\"incls/_precompiled.incl\" /FD /c");
855:                dspFile.println("# ADD BASE RSC /l 0x406 /d \"NDEBUG\"");
856:                dspFile.println("# ADD RSC /l 0x406 /d \"NDEBUG\"");
857:                dspFile.println("BSC32=bscmake.exe");
858:                dspFile.println("# ADD BASE BSC32 /nologo");
859:                dspFile.println("# ADD BSC32 /nologo");
860:                dspFile.println("LINK32=link.exe");
861:                dspFile
862:                        .println("# ADD BASE LINK32 gdi32.lib user32.lib wsock32.lib /nologo /subsystem:console /incremental:no /machine:I386");
863:                dspFile
864:                        .println("# ADD LINK32 gdi32.lib user32.lib wsock32.lib  /nologo /subsystem:console /incremental:no /machine:I386");
865:                dspFile.println("");
866:
867:                dspFile.println("!ELSEIF  \"$(CFG)\" == \"" + dspName
868:                        + " - Win32 Debug\"");
869:                dspFile.println("");
870:                dspFile.println("# PROP BASE Use_MFC 0");
871:                dspFile.println("# PROP BASE Use_Debug_Libraries 1");
872:                dspFile.println("# PROP BASE Output_Dir \".\\Debug\"");
873:                dspFile.println("# PROP BASE Intermediate_Dir \".\\Debug\"");
874:                dspFile.println("# PROP BASE Target_Dir \"\"");
875:                dspFile.println("# PROP Use_MFC 0");
876:                dspFile.println("# PROP Use_Debug_Libraries 1");
877:                dspFile.println("# PROP Output_Dir \"Debug\"");
878:                dspFile.println("# PROP Intermediate_Dir \"Debug\"");
879:                dspFile.println("# PROP Ignore_Export_Lib 0");
880:                dspFile.println("# PROP Target_Dir \"\"");
881:                dspFile
882:                        .println("# ADD BASE CPP /nologo /W3 /Gm /Zi /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /YX /FR /FD /GZ /c");
883:
884:                dspFile.print("# ADD CPP /nologo /W3 /WX /Gm /Zi /Od /I \".\"");
885:
886:                for (Iterator iter = absoluteIncludes.iterator(); iter
887:                        .hasNext();) {
888:                    String include = (String) iter.next();
889:                    dspFile.print(" /I \"" + include + "\"");
890:                }
891:                for (Iterator iter = relativeIncludes.iterator(); iter
892:                        .hasNext();) {
893:                    String include = (String) iter.next();
894:                    dspFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
895:                }
896:                dspFile
897:                        .print(" /D \"_DEBUG\" /D \"AZZERT\" /D \"WIN32\" /D \"_CONSOLE\"");
898:                for (Iterator iter = defines.iterator(); iter.hasNext();) {
899:                    String define = (String) iter.next();
900:                    dspFile.print(" /D \"" + define + "\"");
901:                }
902:                dspFile
903:                        .println(" /FR /Yu\"incls/_precompiled.incl\" /FD /GZ /c");
904:                dspFile.println("# ADD BASE RSC /l 0x406 /d \"_DEBUG\"");
905:                dspFile.println("# ADD RSC /l 0x406 /d \"_DEBUG\"");
906:                dspFile.println("BSC32=bscmake.exe");
907:                dspFile.println("# ADD BASE BSC32 /nologo");
908:                dspFile.println("# ADD BSC32 /nologo");
909:                dspFile.println("LINK32=link.exe");
910:                dspFile
911:                        .println("# ADD BASE LINK32 gdi32.lib user32.lib wsock32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept");
912:                dspFile
913:                        .println("# ADD LINK32 gdi32.lib user32.lib wsock32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept");
914:                dspFile.println("");
915:                dspFile.println("!ENDIF ");
916:                dspFile.println("");
917:                dspFile.println("# Begin Target");
918:                dspFile.println("");
919:                dspFile.println("# Name \"" + dspName + " - Win32 Product\"");
920:                dspFile.println("# Name \"" + dspName + " - Win32 Release\"");
921:                dspFile.println("# Name \"" + dspName + " - Win32 Debug\"");
922:                dspFile.println("# Begin Group \"Source Files\"");
923:                dspFile.println("");
924:                dspFile
925:                        .println("# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90\"");
926:
927:                outputSourceFiles(outputStrings, allFileNames, perFileLines,
928:                        conditionalPerFileLines, dspFile, dspName);
929:
930:                outputSourceFiles(additionalGeneratedFileStrings,
931:                        additionalGeneratedFileNames, perFileLines,
932:                        conditionalPerFileLines, dspFile, dspName);
933:
934:                outputInterpreterDirectives(dspFile, dspName);
935:
936:                dspFile.println("# End Group");
937:                dspFile.println("# Begin Group \"Header Files\"");
938:                dspFile.println("");
939:                dspFile
940:                        .println("# PROP Default_Filter \"h;hpp;hxx;hm;inl;fi;fd\"");
941:                dspFile.println("# End Group");
942:                dspFile.println("# Begin Group \"Resource Files\"");
943:                dspFile.println("");
944:                dspFile
945:                        .println("# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe\"");
946:                dspFile.println("# End Group");
947:                dspFile.println("# End Target");
948:                dspFile.println("# End Project");
949:
950:                dspFile.close();
951:                System.out.println("    Done.");
952:            }
953:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.