0001: /*
0002: *
0003: *
0004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
0005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
0006: *
0007: * This program is free software; you can redistribute it and/or
0008: * modify it under the terms of the GNU General Public License version
0009: * 2 only, as published by the Free Software Foundation.
0010: *
0011: * This program is distributed in the hope that it will be useful, but
0012: * WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014: * General Public License version 2 for more details (a copy is
0015: * included at /legal/license.txt).
0016: *
0017: * You should have received a copy of the GNU General Public License
0018: * version 2 along with this work; if not, write to the Free Software
0019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020: * 02110-1301 USA
0021: *
0022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0023: * Clara, CA 95054 or visit www.sun.com if you need additional
0024: * information or have any questions.
0025: */
0026:
0027: package makedep;
0028:
0029: import java.io.*;
0030: import java.util.*;
0031:
0032: public class WinCEGammaPlatform extends Platform {
0033: public String fileSeparator() {
0034: return "\\";
0035: }
0036:
0037: private static String[] suffixes = { ".cpp", ".c" };
0038:
0039: public String[] outerSuffixes() {
0040: return suffixes;
0041: }
0042:
0043: public String objFileSuffix() {
0044: return ".obj";
0045: }
0046:
0047: public String asmFileSuffix() {
0048: return ".asm";
0049: }
0050:
0051: public String dependentPrefix() {
0052: return "$(VM_PATH)";
0053: }
0054:
0055: public boolean fileNameStringEquality(String s1, String s2) {
0056: return s1.equalsIgnoreCase(s2);
0057: }
0058:
0059: private void usage() throws IllegalArgumentException {
0060: System.err
0061: .println("WinCEGammaPlatform platform-specific options:");
0062: System.err
0063: .println(" -sourceBase <path to directory (workspace) "
0064: + "containing source files; no trailing slash>");
0065: System.err
0066: .println(" -vcpFileName <full pathname to which .vcp file "
0067: + "will be written; all parent directories must "
0068: + "already exist>");
0069: System.err
0070: .println(" -envVar <environment variable to be inserted "
0071: + "into .vcp file, substituting for path given in "
0072: + "-sourceBase. Example: HotSpotWorkSpace>");
0073: System.err
0074: .println(" -exeLoc <path to directory in which to put "
0075: + "cldc_vm.exe and cldc_vm_g.exe; no trailing slash>");
0076: System.err.println(" If any of the above are specified, "
0077: + "they must all be.");
0078: System.err
0079: .println(" Additional, optional arguments, which can be "
0080: + "specified multiple times:");
0081: System.err
0082: .println(" -absoluteInclude <string containing absolute "
0083: + "path to include directory>");
0084: System.err
0085: .println(" -relativeInclude <string containing include "
0086: + "directory relative to -envVar>");
0087: System.err
0088: .println(" -define <preprocessor flag to be #defined "
0089: + "(note: doesn't yet support "
0090: + "#define (flag) (value))>");
0091: System.err.println(" -perFileLine <file> <line>");
0092: System.err
0093: .println(" -conditionalPerFileLine <file> <line for "
0094: + "release build> <line for debug build>");
0095: System.err
0096: .println(" (NOTE: To work around a bug in nmake, where "
0097: + "you can't have a '#' character in a quoted "
0098: + "string, all of the lines outputted have \"#\""
0099: + "prepended)");
0100: System.err.println(" -startAt <subdir of sourceBase>");
0101: System.err
0102: .println(" -ignoreFile <file which won't be able to be "
0103: + "found in the sourceBase because it's generated "
0104: + "later>");
0105: System.err
0106: .println(" -additionalFile <file not in database but "
0107: + "which should show up in .vcp file, like "
0108: + "includeDB_core>");
0109: System.err
0110: .println(" -additionalGeneratedFile <environment variable of "
0111: + "generated file's location> <relative path to "
0112: + "directory containing file; no trailing slash> "
0113: + "<name of file generated later in the build process>");
0114: System.err.println(" Default includes: \".\"");
0115: System.err.println(" Default defines: WINCE, _CONSOLE");
0116: throw new IllegalArgumentException();
0117: }
0118:
0119: private String getVcpName(String fullPath)
0120: throws IllegalArgumentException, IOException {
0121: File file = new File(fullPath).getCanonicalFile();
0122: fullPath = file.getCanonicalPath();
0123: String parent = file.getParent();
0124: String separator = System.getProperty("file.separator");
0125: String vcpString = ".vcp";
0126:
0127: if (!fullPath.endsWith(vcpString)) {
0128: throw new IllegalArgumentException(".vcp file name \""
0129: + fullPath + "\" does not end in .vcp");
0130: }
0131:
0132: if ((parent != null) && (!fullPath.startsWith(parent))) {
0133: throw new RuntimeException(
0134: "Internal error: parent of file name \"" + parent
0135: + "\" does not match file name \""
0136: + fullPath + "\"");
0137: }
0138:
0139: int len = parent.length();
0140: if (!parent.endsWith(separator)) {
0141: len += separator.length();
0142: }
0143:
0144: int end = fullPath.length() - vcpString.length();
0145:
0146: if (len == end) {
0147: throw new RuntimeException(
0148: "Internal error: file name was empty");
0149: }
0150:
0151: return fullPath.substring(len, end);
0152: }
0153:
0154: public void addPerFileLine(Hashtable table, String fileName,
0155: String line) {
0156: Vector v = (Vector) table.get(fileName);
0157: if (v != null) {
0158: v.add(line);
0159: } else {
0160: v = new Vector();
0161: v.add(line);
0162: table.put(fileName, v);
0163: }
0164: }
0165:
0166: private static class PerFileCondData {
0167: public String releaseString;
0168: public String debugString;
0169: }
0170:
0171: private void addConditionalPerFileLine(Hashtable table,
0172: String fileName, String releaseLine, String debugLine) {
0173: PerFileCondData data = new PerFileCondData();
0174: data.releaseString = releaseLine;
0175: data.debugString = debugLine;
0176: Vector v = (Vector) table.get(fileName);
0177: if (v != null) {
0178: v.add(data);
0179: } else {
0180: v = new Vector();
0181: v.add(data);
0182: table.put(fileName, v);
0183: }
0184: }
0185:
0186: public boolean findString(Vector v, String s) {
0187: for (Iterator iter = v.iterator(); iter.hasNext();) {
0188: if (((String) iter.next()).equals(s)) {
0189: return true;
0190: }
0191: }
0192:
0193: return false;
0194: }
0195:
0196: /* This returns a String containing the full path to the passed
0197: file name, or null if an error occurred. If the file was not
0198: found or was a duplicate and couldn't be resolved using the
0199: preferred paths, the file name is added to the appropriate
0200: Vector of Strings. */
0201: private String findFileInDirectory(String fileName,
0202: DirectoryTree directory, Vector preferredPaths,
0203: Vector filesNotFound, Vector filesDuplicate) {
0204: List locationsInTree = directory.findFile(fileName);
0205: String name = null;
0206: if ((locationsInTree == null) || (locationsInTree.size() == 0)) {
0207: filesNotFound.add(fileName);
0208: } else if (locationsInTree.size() > 1) {
0209: // Iterate through them, trying to find one with a
0210: // preferred path
0211: search: {
0212: for (Iterator locIter = locationsInTree.iterator(); locIter
0213: .hasNext();) {
0214: DirectoryTreeNode node = (DirectoryTreeNode) locIter
0215: .next();
0216: String tmpName = node.getName();
0217: for (Iterator prefIter = preferredPaths.iterator(); prefIter
0218: .hasNext();) {
0219: if (tmpName.indexOf((String) prefIter.next()) != -1) {
0220: name = tmpName;
0221: break search;
0222: }
0223: }
0224: }
0225: }
0226:
0227: if (name == null) {
0228: filesDuplicate.add(fileName);
0229: }
0230: } else {
0231: name = ((DirectoryTreeNode) locationsInTree.get(0))
0232: .getName();
0233: }
0234:
0235: return name;
0236: }
0237:
0238: private void outputSourceFiles(Vector outputStrings,
0239: Vector fileNames, Hashtable perFileLines,
0240: Hashtable conditionalPerFileLines, PrintWriter vcpFile,
0241: String vcpName) {
0242: Iterator outputIter = outputStrings.iterator();
0243: Iterator fileIter = fileNames.iterator();
0244: while (outputIter.hasNext()) {
0245: String outStr = (String) outputIter.next();
0246: String fileStr = (String) fileIter.next();
0247:
0248: vcpFile.println("# Begin Source File");
0249: vcpFile.println("");
0250: if (fileStr.endsWith(asmFileSuffix())) {
0251: vcpFile.println("SOURCE=.\\" + fileStr);
0252: } else {
0253: vcpFile.println("SOURCE=\"" + outStr + "\"");
0254: }
0255: Vector v = null;
0256:
0257: v = (Vector) perFileLines.get(fileStr);
0258: if (v != null) {
0259: for (Iterator lineIter = v.iterator(); lineIter
0260: .hasNext();) {
0261: String str = (String) lineIter.next();
0262: vcpFile.println("# " + str);
0263: }
0264: }
0265: v = (Vector) conditionalPerFileLines.get(fileStr);
0266: if (v != null) {
0267: vcpFile.println("!IF \"$(CFG)\" == \"" + vcpName
0268: + " - WinCE Release\"");
0269: vcpFile.println("");
0270: for (Iterator lineIter = v.iterator(); lineIter
0271: .hasNext();) {
0272: PerFileCondData data = (PerFileCondData) lineIter
0273: .next();
0274: vcpFile.println("#" + data.releaseString);
0275: }
0276: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName
0277: + " - WinCE Debug\"");
0278: vcpFile.println("");
0279: for (Iterator lineIter = v.iterator(); lineIter
0280: .hasNext();) {
0281: PerFileCondData data = (PerFileCondData) lineIter
0282: .next();
0283: vcpFile.println("#" + data.debugString);
0284: }
0285: vcpFile.println("!ENDIF");
0286: }
0287: vcpFile.println("# End Source File");
0288: }
0289: }
0290:
0291: private void outputInterpreterDirectives(PrintWriter vcpFile,
0292: String vcpName) {
0293: String fileStr = "Interpreter_arm";
0294: String projectName = "Win32 (WCE ARM)";
0295: String assemblyCommand = "\"$(ASMDIR_ARM)\\armasm.exe\" -o $(OutDir)\\$(InputName).obj $(InputPath)";
0296:
0297: vcpFile.println("");
0298: vcpFile.println("# Begin Source File");
0299: vcpFile.println("");
0300: vcpFile
0301: .println("SOURCE=\"..\\target\\product\\Interpreter_arm.asm\"");
0302: vcpFile.println("");
0303: vcpFile.println("!IF \"$(CFG)\" == \"" + vcpName + " - "
0304: + projectName + " Product\"");
0305: vcpFile.println("");
0306: vcpFile
0307: .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
0308: vcpFile.println("OutDir=.\\ARMPrd");
0309: vcpFile.println("InputPath=\".\\" + fileStr + "\"");
0310: vcpFile.println("InputName=" + fileStr);
0311: vcpFile.println("");
0312: vcpFile
0313: .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
0314: vcpFile.println(" " + assemblyCommand);
0315: vcpFile.println("# End Custom Build");
0316: vcpFile.println("");
0317: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0318: + projectName + " Release\"");
0319: vcpFile.println("");
0320: vcpFile.println("# PROP Exclude_From_Build 1");
0321: vcpFile.println("");
0322: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0323: + projectName + " Debug\"");
0324: vcpFile.println("");
0325: vcpFile.println("# PROP Exclude_From_Build 1");
0326: vcpFile.println("");
0327: vcpFile.println("!ENDIF");
0328: vcpFile.println("");
0329: vcpFile.println("# End Source File");
0330:
0331: vcpFile.println("");
0332: vcpFile.println("# Begin Source File");
0333: vcpFile.println("");
0334: vcpFile
0335: .println("SOURCE=\"..\\target\\release\\Interpreter_arm.asm\"");
0336: vcpFile.println("");
0337: vcpFile.println("!IF \"$(CFG)\" == \"" + vcpName + " - "
0338: + projectName + " Product\"");
0339: vcpFile.println("");
0340: vcpFile.println("# PROP Exclude_From_Build 1");
0341: vcpFile.println("");
0342: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0343: + projectName + " Release\"");
0344: vcpFile.println("");
0345: vcpFile
0346: .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
0347: vcpFile.println("OutDir=.\\ARMRel");
0348: vcpFile.println("InputPath=\".\\" + fileStr + "\"");
0349: vcpFile.println("InputName=" + fileStr);
0350: vcpFile.println("");
0351: vcpFile
0352: .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
0353: vcpFile.println(" " + assemblyCommand);
0354: vcpFile.println("# End Custom Build");
0355: vcpFile.println("");
0356: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0357: + projectName + " Debug\"");
0358: vcpFile.println("");
0359: vcpFile.println("# PROP Exclude_From_Build 1");
0360: vcpFile.println("");
0361: vcpFile.println("!ENDIF");
0362: vcpFile.println("");
0363: vcpFile.println("# End Source File");
0364:
0365: vcpFile.println("");
0366: vcpFile.println("# Begin Source File");
0367: vcpFile.println("");
0368: vcpFile
0369: .println("SOURCE=\"..\\target\\debug\\Interpreter_arm.asm\"");
0370: vcpFile.println("");
0371: vcpFile.println("!IF \"$(CFG)\" == \"" + vcpName + " - "
0372: + projectName + " Product\"");
0373: vcpFile.println("");
0374: vcpFile.println("# PROP Exclude_From_Build 1");
0375: vcpFile.println("");
0376: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0377: + projectName + " Release\"");
0378: vcpFile.println("");
0379: vcpFile.println("# PROP Exclude_From_Build 1");
0380: vcpFile.println("");
0381: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName + " - "
0382: + projectName + " Debug\"");
0383: vcpFile.println("");
0384: vcpFile
0385: .println("# Begin Custom Build - Performing Custom Build Step on $(InputName).asm");
0386: vcpFile.println("OutDir=.\\ARMDbg");
0387: vcpFile.println("InputPath=\".\\" + fileStr + "\"");
0388: vcpFile.println("InputName=" + fileStr);
0389: vcpFile.println("");
0390: vcpFile
0391: .println("\"$(OutDir)\\$(InputName).obj\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"");
0392: vcpFile.println(" " + assemblyCommand);
0393: vcpFile.println("# End Custom Build");
0394: vcpFile.println("");
0395: vcpFile.println("!ENDIF");
0396: vcpFile.println("");
0397: vcpFile.println("# End Source File");
0398: }
0399:
0400: private boolean databaseAllFilesEqual(Database previousDB,
0401: Database currentDB) {
0402: Iterator i1 = previousDB.getAllFiles().iterator();
0403: Iterator i2 = currentDB.getAllFiles().iterator();
0404:
0405: while (i1.hasNext() && i2.hasNext()) {
0406: FileList fl1 = (FileList) i1.next();
0407: FileList fl2 = (FileList) i2.next();
0408: if (!fl1.getName().equals(fl2.getName())) {
0409: return false;
0410: }
0411: }
0412:
0413: if (i1.hasNext() != i2.hasNext()) {
0414: // Different lengths
0415: return false;
0416: }
0417:
0418: return true;
0419: }
0420:
0421: private String envVarPrefixedFileName(String fileName,
0422: int sourceBaseLen, String envVar, DirectoryTree tree,
0423: Vector preferredPaths, Vector filesNotFound,
0424: Vector filesDuplicate) {
0425: String fullName = findFileInDirectory(fileName, tree,
0426: preferredPaths, filesNotFound, filesDuplicate);
0427: if (fullName == null) {
0428: return null;
0429: }
0430: return "$(" + envVar + ")" + fullName.substring(sourceBaseLen);
0431: }
0432:
0433: public void writePlatformSpecificFiles(Database previousDB,
0434: Database currentDB, String[] args)
0435: throws IllegalArgumentException, IOException {
0436: if (args.length == 0) {
0437: return;
0438: }
0439:
0440: String sourceBase = null;
0441: String startAt = null;
0442: String vcpFileName = null;
0443: String envVar = null;
0444: String exeLoc = null;
0445: // This contains Strings: list of all file names (database +
0446: // additional files)
0447: Vector allFileNames = new Vector();
0448: // This contains Strings: any extra includes with absolute paths
0449: Vector absoluteIncludes = new Vector();
0450: // This contains Strings: any extra includes with paths
0451: // relative to -envVar
0452: Vector relativeIncludes = new Vector();
0453: // This contains Strings: preprocessor flags to #define
0454: Vector defines = new Vector();
0455: // This maps Strings containing file names to Vectors of
0456: // Strings
0457: Hashtable perFileLines = new Hashtable();
0458: // This maps Strings containing file names to Vectors of
0459: // PerFileCondData objects
0460: Hashtable conditionalPerFileLines = new Hashtable();
0461: // This contains Strings: additional files to add to the
0462: // project file (i.e., includeDB, for convenience)
0463: Vector additionalFiles = new Vector();
0464: // This contains Strings: files in the database to be ignored
0465: // because they're autogenerated later (compiler2 files
0466: // ad_<arch>.[ch]pp, dfa_<arch>.cpp)
0467: Vector ignoredFiles = new Vector();
0468: // This contains Strings: lines to be added for the ignored
0469: // files
0470: Vector additionalGeneratedFileStrings = new Vector();
0471: // Just the file names of the above strings
0472: Vector additionalGeneratedFileNames = new Vector();
0473:
0474: int i = 0;
0475:
0476: System.err
0477: .println("WinCEGammaPlatform platform-specific arguments:");
0478: for (int j = 0; j < args.length; j++) {
0479: System.err.print(args[j] + " ");
0480: }
0481: System.err.println();
0482:
0483: try {
0484: while (i < args.length) {
0485: if (args[i].equals("-sourceBase")) {
0486: sourceBase = args[i + 1];
0487: if (sourceBase.charAt(0) == '-') {
0488: System.err
0489: .println("** Error: empty -sourceBase");
0490: System.err
0491: .println(" (Did you set the HotSpotWorkSpace environment variable?)");
0492: usage();
0493: }
0494: i += 2;
0495: } else if (args[i].equals("-vcpFileName")) {
0496: vcpFileName = args[i + 1];
0497: if (vcpFileName.charAt(0) == '-') {
0498: System.err
0499: .println("** Error: empty -vcpFileName");
0500: usage();
0501: }
0502: i += 2;
0503: } else if (args[i].equals("-envVar")) {
0504: envVar = args[i + 1];
0505: if (envVar.charAt(0) == '-') {
0506: System.err.println("** Error: empty -envVar");
0507: usage();
0508: }
0509: i += 2;
0510: } else if (args[i].equals("-exeLoc")) {
0511: exeLoc = args[i + 1];
0512: if (exeLoc.charAt(0) == '-') {
0513: System.err.println("** Error: empty -exeLoc");
0514: usage();
0515: }
0516: i += 2;
0517: } else if (args[i].equals("-absoluteInclude")) {
0518: absoluteIncludes.add(args[i + 1]);
0519: if (args[i + 1].charAt(0) == '-') {
0520: System.err
0521: .println("** Error: empty -absoluteInclude");
0522: usage();
0523: }
0524: i += 2;
0525: } else if (args[i].equals("-relativeInclude")) {
0526: relativeIncludes.add(args[i + 1]);
0527: if (args[i + 1].charAt(0) == '-') {
0528: System.err
0529: .println("** Error: empty -relativeInclude");
0530: usage();
0531: }
0532: i += 2;
0533: } else if (args[i].equals("-define")) {
0534: defines.add(args[i + 1]);
0535: if (args[i + 1].charAt(0) == '-') {
0536: System.err.println("** Error: empty -define");
0537: usage();
0538: }
0539: i += 2;
0540: } else if (args[i].equals("-perFileLine")) {
0541: addPerFileLine(perFileLines, args[i + 1],
0542: args[i + 2]);
0543: if (args[i + 1].charAt(0) == '-'
0544: || args[i + 2].charAt(0) == '-') {
0545: System.err
0546: .println("** Error: wrong number of args to -perFileLine");
0547: usage();
0548: }
0549: i += 3;
0550: } else if (args[i].equals("-conditionalPerFileLine")) {
0551: addConditionalPerFileLine(conditionalPerFileLines,
0552: args[i + 1], args[i + 2], args[i + 3]);
0553: if (((args[i + 1].length() > 0) && (args[i + 1]
0554: .charAt(0) == '-'))
0555: || ((args[i + 2].length() > 0) && (args[i + 2]
0556: .charAt(0) == '-'))
0557: || ((args[i + 3].length() > 0) && (args[i + 3]
0558: .charAt(0) == '-'))) {
0559: System.err
0560: .println("** Error: wrong number of args to -conditionalPerFileLine");
0561: usage();
0562: }
0563: i += 4;
0564: } else if (args[i].equals("-startAt")) {
0565: if (startAt != null) {
0566: System.err
0567: .println("** Error: multiple -startAt");
0568: usage();
0569: }
0570: startAt = args[i + 1];
0571: if (args[i + 1].charAt(0) == '-') {
0572: System.err.println("** Error: empty -startAt");
0573: usage();
0574: }
0575: i += 2;
0576: } else if (args[i].equals("-ignoreFile")) {
0577: ignoredFiles.add(args[i + 1]);
0578: if (args[i + 1].charAt(0) == '-') {
0579: System.err
0580: .println("** Error: empty -ignoreFile");
0581: usage();
0582: }
0583: i += 2;
0584: } else if (args[i].equals("-additionalFile")) {
0585: additionalFiles.add(args[i + 1]);
0586: if (args[i + 1].charAt(0) == '-') {
0587: System.err
0588: .println("** Error: empty -additionalFile");
0589: usage();
0590: }
0591: i += 2;
0592: } else if (args[i].equals("-additionalGeneratedFile")) {
0593: String var = args[i + 1];
0594: String dir = args[i + 2];
0595: String fileName = args[i + 3];
0596: additionalGeneratedFileStrings.add("$(" + var
0597: + ")\\" + dir + "\\" + fileName);
0598: additionalGeneratedFileNames.add(fileName);
0599: if (args[i + 1].charAt(0) == '-'
0600: || args[i + 2].charAt(0) == '-'
0601: || args[i + 3].charAt(0) == '-') {
0602: System.err
0603: .println("** Error: wrong number of args to -additionalGeneratedFile");
0604: usage();
0605: }
0606: i += 4;
0607: } else {
0608: System.err.println("Illegal argument: " + args[i]);
0609: usage();
0610: }
0611: }
0612: } catch (ArrayIndexOutOfBoundsException e) {
0613: usage();
0614: }
0615:
0616: if ((sourceBase == null) || (vcpFileName == null)
0617: || (envVar == null) || (exeLoc == null)) {
0618: usage();
0619: }
0620:
0621: // Compare contents of allFiles of previousDB and includeDB.
0622: // If these haven't changed, then skip writing the .vcp file.
0623: if (databaseAllFilesEqual(previousDB, currentDB)
0624: && new File(vcpFileName).exists()) {
0625: System.out
0626: .println(" Databases unchanged; skipping overwrite of .vcp file.");
0627: return;
0628: }
0629:
0630: String vcpName = getVcpName(vcpFileName);
0631:
0632: System.out.print(" Reading directory...");
0633: System.out.flush();
0634: DirectoryTree tree = new DirectoryTree();
0635: tree.addSubdirToIgnore("Codemgr_wsdata");
0636: tree.addSubdirToIgnore("deleted_files");
0637: tree.addSubdirToIgnore("SCCS");
0638: tree.setVerbose(true);
0639: if (startAt != null)
0640: tree.readDirectory(sourceBase + File.separator + startAt);
0641: else
0642: tree.readDirectory(sourceBase);
0643: int sourceBaseLen = sourceBase.length();
0644: // Contains Strings which are the source file names to be
0645: // written to the .vcp file
0646: Vector outputStrings = new Vector();
0647: Vector preferredPaths = new Vector();
0648: // In the case of multiple files with the same name in
0649: // different subdirectories, prefer the versions specified in
0650: // the platform file as the "os_family" and "arch" macros.
0651: String v;
0652: if ((v = currentDB.getMacroContent("os_family")) != null) {
0653: preferredPaths.add(v);
0654: }
0655: if ((v = currentDB.getMacroContent("arch")) != null) {
0656: preferredPaths.add(v);
0657: }
0658: // Also prefer "opto" over "adlc" for adlcVMDeps.hpp
0659: preferredPaths.add("opto");
0660: // Hold errors until end
0661: Vector filesNotFound = new Vector();
0662: Vector filesDuplicate = new Vector();
0663:
0664: System.out.println();
0665: System.out.print(" Looking up files in database...");
0666: System.out.flush();
0667: for (Iterator iter = currentDB.getAllFiles().iterator(); iter
0668: .hasNext();) {
0669: FileList fl = (FileList) iter.next();
0670: String fileName = fl.getName();
0671: // Add to all files only if not ignored
0672: if (!findString(ignoredFiles, fileName)) {
0673: allFileNames.add(fileName);
0674: String prefixedName = envVarPrefixedFileName(fileName,
0675: sourceBaseLen, envVar, tree, preferredPaths,
0676: filesNotFound, filesDuplicate);
0677: if (prefixedName != null) {
0678: outputStrings.add(prefixedName);
0679: }
0680: System.out.print(".");
0681: System.out.flush();
0682: }
0683: }
0684:
0685: for (Iterator iter = additionalFiles.iterator(); iter.hasNext();) {
0686: String fileName = (String) iter.next();
0687: allFileNames.add(fileName);
0688: String prefixedName = envVarPrefixedFileName(fileName,
0689: sourceBaseLen, envVar, tree, preferredPaths,
0690: filesNotFound, filesDuplicate);
0691: if (prefixedName != null) {
0692: outputStrings.add(prefixedName);
0693: }
0694: }
0695:
0696: if ((filesNotFound.size() != 0) || (filesDuplicate.size() != 0)) {
0697: System.err.println("Error: some files were not found or "
0698: + "appeared in multiple subdirectories of "
0699: + "directory " + sourceBase + " and could not "
0700: + "be resolved with the os_family and arch "
0701: + "macros in the platform file.");
0702: if (filesNotFound.size() != 0) {
0703: System.err.println("Files not found:");
0704: for (Iterator iter = filesNotFound.iterator(); iter
0705: .hasNext();) {
0706: System.err.println(" " + (String) iter.next());
0707: }
0708: }
0709: if (filesDuplicate.size() != 0) {
0710: System.err.println("Duplicate files:");
0711: for (Iterator iter = filesDuplicate.iterator(); iter
0712: .hasNext();) {
0713: System.err.println(" " + (String) iter.next());
0714: }
0715: }
0716: throw new RuntimeException();
0717: }
0718:
0719: System.out.println();
0720: System.out.println(" Writing .vcp file...");
0721: // If we got this far without an error, we're safe to actually
0722: // write the .vcp file
0723: PrintWriter vcpFile = new PrintWriter(new FileWriter(
0724: vcpFileName));
0725: System.out.println("Writing " + vcpFileName);
0726: vcpFile
0727: .println("# Microsoft eMbedded Visual Tools Project File - Name=\""
0728: + vcpName + "\" - Package Owner=<4>");
0729: vcpFile
0730: .println("# Microsoft eMbedded Visual Tools Generated Build File, Format Version 6.02");
0731: vcpFile.println("# ** DO NOT EDIT **");
0732: vcpFile.println("");
0733: vcpFile
0734: .println("# TARGTYPE \"Win32 (WCE ARM) Application\" 0x8501");
0735: vcpFile.println("");
0736: vcpFile.println("CFG=" + vcpName + " - Win32 (WCE ARM) Debug");
0737:
0738: vcpFile
0739: .println("!MESSAGE This is not a valid makefile. To build this project using NMAKE,");
0740: vcpFile
0741: .println("!MESSAGE use the Export Makefile command and run");
0742: vcpFile.println("!MESSAGE ");
0743: vcpFile.println("!MESSAGE NMAKE /f \"cldc_vm.vcn\".");
0744: vcpFile.println("!MESSAGE ");
0745: vcpFile
0746: .println("!MESSAGE You can specify a configuration when running NMAKE");
0747: vcpFile
0748: .println("!MESSAGE by defining the macro CFG on the command line. For example:");
0749: vcpFile.println("!MESSAGE ");
0750: vcpFile
0751: .println("!MESSAGE NMAKE /f \"cldc_vm.vcn\" CFG=\"cldc_vm - Win32 (WCE ARM) Debug\"");
0752: vcpFile.println("!MESSAGE ");
0753: vcpFile
0754: .println("!MESSAGE Possible choices for configuration are:");
0755: vcpFile.println("!MESSAGE ");
0756: vcpFile
0757: .println("!MESSAGE \"cldc_vm - Win32 (WCE ARM) Release\" (based on \"Win32 (WCE ARM) Application\")");
0758: vcpFile
0759: .println("!MESSAGE \"cldc_vm - Win32 (WCE ARM) Product\" (based on \"Win32 (WCE ARM) Application\")");
0760: vcpFile
0761: .println("!MESSAGE \"cldc_vm - Win32 (WCE ARM) Debug\" (based on \"Win32 (WCE ARM) Application\")");
0762: vcpFile.println("!MESSAGE ");
0763: vcpFile.println("");
0764: vcpFile.println("# Begin Project");
0765: vcpFile.println("# PROP AllowPerConfigDependencies 0");
0766: vcpFile.println("# PROP Scc_ProjName \"\"");
0767: vcpFile.println("# PROP Scc_LocalPath \"\"");
0768: vcpFile.println("# PROP ATL_Project 2");
0769: vcpFile.println("");
0770:
0771: vcpFile.println("!IF \"$(CFG)\" == \"" + vcpName
0772: + " - Win32 (WCE ARM) Release\"");
0773: vcpFile.println("");
0774:
0775: vcpFile.println("# PROP BASE Use_MFC 0");
0776: vcpFile.println("# PROP BASE Use_Debug_Libraries 0");
0777: vcpFile.println("# PROP BASE Output_Dir \"ARMRel\"");
0778: vcpFile.println("# PROP BASE Intermediate_Dir \"ARMRel\"");
0779: vcpFile
0780: .println("# PROP BASE CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0781: vcpFile
0782: .println("# PROP BASE Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0783: vcpFile.println("# PROP BASE Target_Dir \"\"");
0784:
0785: vcpFile.println("# PROP Use_MFC 0");
0786: vcpFile.println("# PROP Use_Debug_Libraries 0");
0787: vcpFile.println("# PROP Output_Dir \"ARMRel\"");
0788: vcpFile.println("# PROP Intermediate_Dir \"ARMRel\"");
0789: vcpFile
0790: .println("# PROP CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0791: vcpFile
0792: .println("# PROP Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0793: vcpFile.println("# PROP Target_Dir \"\"");
0794:
0795: vcpFile.println("RSC=rc.exe");
0796: vcpFile
0797: .println("# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"NDEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0798: vcpFile
0799: .println("# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"NDEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0800: vcpFile.println("CPP=clarm.exe");
0801:
0802: vcpFile
0803: .println("# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /YX /Ox /Os /M$(CECrtMT) /c");
0804: vcpFile.print("# ADD CPP /nologo /W3 /I \".\" ");
0805: for (Iterator iter = absoluteIncludes.iterator(); iter
0806: .hasNext();) {
0807: String include = (String) iter.next();
0808: vcpFile.print(" /I \"" + include + "\"");
0809: }
0810: for (Iterator iter = relativeIncludes.iterator(); iter
0811: .hasNext();) {
0812: String include = (String) iter.next();
0813: vcpFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
0814: }
0815: for (Iterator iter = defines.iterator(); iter.hasNext();) {
0816: String define = (String) iter.next();
0817: vcpFile.print(" /D \"" + define + "\"");
0818: }
0819: vcpFile
0820: .println(" /Yu\"incls/_precompiled.incl\" /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /YX /Ox /Os /M$(CECrtMT) /c");
0821:
0822: vcpFile.println("MTL=midl.exe");
0823: vcpFile
0824: .println("# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32");
0825: vcpFile
0826: .println("# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32");
0827: vcpFile.println("BSC32=bscmake.exe");
0828: vcpFile.println("# ADD BASE BSC32 /nologo");
0829: vcpFile.println("# ADD BSC32 /nologo");
0830: vcpFile.println("LINK32=link.exe");
0831: vcpFile
0832: .println("# ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0833: vcpFile
0834: .println("# ADD LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0835:
0836: vcpFile.println("");
0837:
0838: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName
0839: + " - Win32 (WCE ARM) Product\"");
0840: vcpFile.println("");
0841:
0842: vcpFile.println("# PROP BASE Use_MFC 0");
0843: vcpFile.println("# PROP BASE Use_Debug_Libraries 0");
0844: vcpFile.println("# PROP BASE Output_Dir \"ARMPrd\"");
0845: vcpFile.println("# PROP BASE Intermediate_Dir \"ARMPrd\"");
0846: vcpFile
0847: .println("# PROP BASE CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0848: vcpFile
0849: .println("# PROP BASE Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0850: vcpFile.println("# PROP BASE Target_Dir \"\"");
0851:
0852: vcpFile.println("# PROP Use_MFC 0");
0853: vcpFile.println("# PROP Use_Debug_Libraries 0");
0854: vcpFile.println("# PROP Output_Dir \"ARMPrd\"");
0855: vcpFile.println("# PROP Intermediate_Dir \"ARMPrd\"");
0856: vcpFile
0857: .println("# PROP CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0858: vcpFile
0859: .println("# PROP Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0860: vcpFile.println("# PROP Target_Dir \"\"");
0861:
0862: vcpFile.println("RSC=rc.exe");
0863: vcpFile
0864: .println("# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"NDEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0865: vcpFile
0866: .println("# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"NDEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0867: vcpFile.println("CPP=clarm.exe");
0868:
0869: vcpFile
0870: .println("# ADD BASE CPP /nologo /W3 /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /YX /Ox /Os /M$(CECrtMT) /c");
0871: vcpFile.print("# ADD CPP /nologo /W3 /D \"PRODUCT\" /I \".\" ");
0872: for (Iterator iter = absoluteIncludes.iterator(); iter
0873: .hasNext();) {
0874: String include = (String) iter.next();
0875: vcpFile.print(" /I \"" + include + "\"");
0876: }
0877: for (Iterator iter = relativeIncludes.iterator(); iter
0878: .hasNext();) {
0879: String include = (String) iter.next();
0880: vcpFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
0881: }
0882: for (Iterator iter = defines.iterator(); iter.hasNext();) {
0883: String define = (String) iter.next();
0884: vcpFile.print(" /D \"" + define + "\"");
0885: }
0886: vcpFile
0887: .println(" /Yu\"incls/_precompiled.incl\" /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D \"UNICODE\" /D \"_UNICODE\" /D \"NDEBUG\" /YX /Ox /Os /M$(CECrtMT) /c");
0888:
0889: vcpFile.println("MTL=midl.exe");
0890: vcpFile
0891: .println("# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32");
0892: vcpFile
0893: .println("# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /o \"NUL\" /win32");
0894: vcpFile.println("BSC32=bscmake.exe");
0895: vcpFile.println("# ADD BASE BSC32 /nologo");
0896: vcpFile.println("# ADD BSC32 /nologo");
0897: vcpFile.println("LINK32=link.exe");
0898: vcpFile
0899: .println("# ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0900: vcpFile
0901: .println("# ADD LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0902:
0903: vcpFile.println("");
0904:
0905: vcpFile.println("!ELSEIF \"$(CFG)\" == \"" + vcpName
0906: + " - Win32 (WCE ARM) Debug\"");
0907:
0908: vcpFile.println("");
0909: vcpFile.println("# PROP BASE Use_MFC 0");
0910: vcpFile.println("# PROP BASE Use_Debug_Libraries 1");
0911: vcpFile.println("# PROP BASE Output_Dir \"ARMDbg\"");
0912: vcpFile.println("# PROP BASE Intermediate_Dir \"ARMDbg\"");
0913: vcpFile
0914: .println("# PROP BASE CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0915: vcpFile
0916: .println("# PROP BASE Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0917: vcpFile.println("# PROP BASE Target_Dir \"\"");
0918:
0919: vcpFile.println("# PROP Use_MFC 0");
0920: vcpFile.println("# PROP Use_Debug_Libraries 1");
0921: vcpFile.println("# PROP Output_Dir \"ARMDbg\"");
0922: vcpFile.println("# PROP Intermediate_Dir \"ARMDbg\"");
0923: vcpFile
0924: .println("# PROP CPU_ID \"{D6518FFC-710F-11D3-99F2-00105A0DF099}\"");
0925: vcpFile
0926: .println("# PROP Platform_ID \"{8A9A2F80-6887-11D3-842E-005004848CBA}\"");
0927: vcpFile.println("# PROP Target_Dir \"\"");
0928:
0929: vcpFile.println("RSC=rc.exe");
0930: vcpFile
0931: .println("# ADD BASE RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"DEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0932: vcpFile
0933: .println("# ADD RSC /l 0x409 /d UNDER_CE=$(CEVersion) /d _WIN32_WCE=$(CEVersion) /d \"UNICODE\" /d \"_UNICODE\" /d \"DEBUG\" /d \"$(CePlatform)\" /d \"ARM\" /d \"_ARM_\" /r");
0934: vcpFile.println("CPP=clarm.exe");
0935: vcpFile
0936: .println("# ADD BASE CPP /nologo /W3 /Zi /Od /D \"DEBUG\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"UNICODE\" /D \"_UNICODE\" /YX /M$(CECrtMTDebug) /c");
0937: vcpFile.print("# ADD CPP /nologo /W3 /I \".\" ");
0938:
0939: for (Iterator iter = absoluteIncludes.iterator(); iter
0940: .hasNext();) {
0941: String include = (String) iter.next();
0942: vcpFile.print(" /I \"" + include + "\"");
0943: }
0944: for (Iterator iter = relativeIncludes.iterator(); iter
0945: .hasNext();) {
0946: String include = (String) iter.next();
0947: vcpFile.print(" /I \"$(" + envVar + ")\\" + include + "\"");
0948: }
0949: for (Iterator iter = defines.iterator(); iter.hasNext();) {
0950: String define = (String) iter.next();
0951: vcpFile.print(" /D \"" + define + "\"");
0952: }
0953: vcpFile
0954: .println(" /Yu\"incls/_precompiled.incl\" /Zi /Od /D \"_DEBUG\" /D \"AZZERT\" /D \"DEBUG\" /D \"ARM\" /D \"_ARM_\" /D UNDER_CE=$(CEVersion) /D _WIN32_WCE=$(CEVersion) /D \"$(CePlatform)\" /D \"UNICODE\" /D \"_UNICODE\" /YX /M$(CECrtMTDebug) /c");
0955:
0956: vcpFile.println("MTL=midl.exe");
0957: vcpFile
0958: .println("# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /o \"NUL\" /win32");
0959: vcpFile
0960: .println("# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /o \"NUL\" /win32");
0961: vcpFile.println("BSC32=bscmake.exe");
0962: vcpFile.println("# ADD BASE BSC32 /nologo");
0963: vcpFile.println("# ADD BSC32 /nologo");
0964: vcpFile.println("LINK32=link.exe");
0965: vcpFile
0966: .println("# ADD BASE LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /debug /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0967: vcpFile
0968: .println("# ADD LINK32 commctrl.lib coredll.lib aygshell.lib gx.lib winsock.lib /nologo /base:\"0x00010000\" /stack:0x10000,0x1000 /entry:\"WinMainCRTStartup\" /debug /nodefaultlib:\"$(CENoDefaultLib)\" /subsystem:$(CESubsystem) /align:\"4096\" /MACHINE:ARM");
0969:
0970: vcpFile.println("");
0971:
0972: vcpFile.println("!ENDIF ");
0973: vcpFile.println("");
0974: vcpFile.println("# Begin Target");
0975: vcpFile.println("");
0976: vcpFile.println("# Name \"" + vcpName
0977: + " - Win32 (WCE ARM) Release\"");
0978: vcpFile.println("# Name \"" + vcpName
0979: + " - Win32 (WCE ARM) Product\"");
0980: vcpFile.println("# Name \"" + vcpName
0981: + " - Win32 (WCE ARM) Debug\"");
0982: vcpFile.println("# Begin Group \"Source Files\"");
0983: vcpFile.println("");
0984: vcpFile
0985: .println("# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"");
0986:
0987: outputSourceFiles(outputStrings, allFileNames, perFileLines,
0988: conditionalPerFileLines, vcpFile, vcpName);
0989:
0990: outputSourceFiles(additionalGeneratedFileStrings,
0991: additionalGeneratedFileNames, perFileLines,
0992: conditionalPerFileLines, vcpFile, vcpName);
0993:
0994: outputInterpreterDirectives(vcpFile, vcpName);
0995:
0996: vcpFile.println("# End Group");
0997: vcpFile.println("# Begin Group \"Header Files\"");
0998: vcpFile.println("");
0999: vcpFile.println("# PROP Default_Filter \"h;hpp;hxx;hm;inl\"");
1000: vcpFile.println("# End Group");
1001: vcpFile.println("# Begin Group \"Resource Files\"");
1002: vcpFile.println("");
1003: vcpFile
1004: .println("# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"");
1005: vcpFile.println("# End Group");
1006: vcpFile.println("# End Target");
1007: vcpFile.println("# End Project");
1008:
1009: vcpFile.close();
1010: System.out.println(" Done.");
1011: }
1012: }
|