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:
031: /**
032: * Metrowerks CodeWarrior for Windows
033: */
034: public class CWPlatform extends Platform {
035:
036: /**
037: * All C++ sources include the grand include file by the name of
038: * "incls/_precompiled.incl". For VisualC++ the compiler switches
039: * do the magic of using a precompiled header instead of the grand
040: * include file. For CodeWarrior we need to include the
041: * precompiled header explicitly, so "incls/_precompiled.incl" is
042: * a "proxy" file that contains only the #include directive for
043: * the precompiled header. Hence we point giFileTemplate to a
044: * file with a different name, and save in this variable the grand
045: * include name that sources expect.
046: *
047: * @see #setupFileTemplates
048: * @see #writePlatformSpecificFiles
049: */
050: private FileName giMchProxyIncl; // "incls/_precompiled.incl"
051:
052: private static String[] suffixes = { ".cpp", ".c" };
053:
054: public String[] outerSuffixes() {
055: return suffixes;
056: }
057:
058: public String objFileSuffix() {
059: return ".obj";
060: }
061:
062: public String asmFileSuffix() {
063: return ".asm";
064: }
065:
066: public String dependentPrefix() {
067: return "";
068: }
069:
070: public String fileSeparator() {
071: return "\\";
072: }
073:
074: public boolean fileNameStringEquality(String s1, String s2) {
075: return s1.equalsIgnoreCase(s2);
076: }
077:
078: public boolean includeGIInEachIncl() {
079: return false;
080: }
081:
082: public boolean includeGIDependencies() {
083: return false;
084: }
085:
086: /**
087: * @see #giMchProxyIncl
088: * @see #writePlatformSpecificFiles
089: */
090: public void setupFileTemplates() {
091: super .setupFileTemplates();
092:
093: String stem = giFileTemplate.nameOfList();
094:
095: // a funky way to clone a FileName
096: giMchProxyIncl = giFileTemplate.copyStem(stem);
097:
098: // write grand include into a different file that is be used
099: // to generate the precompiled header, but is not used by the
100: // rest of the sources
101: // IMPL_NOTE: hardcoded name, must agree with the makefile
102: giFileTemplate = giFileTemplate.copyStem(stem + "_pch");
103: }
104:
105: /**
106: * @see #giMchProxyIncl
107: * @see #setupFileTemplates
108: */
109: public void writePlatformSpecificFiles(Database previousDB,
110: Database currentDB, String[] args)
111: throws IllegalArgumentException, IOException {
112: // Generate "incls/_precompiled.incl" that is just a proxy
113: // include for the precompiled header.
114: System.out.println("\twriting MCH proxy file");
115:
116: ByteArrayOutputStream baos = new ByteArrayOutputStream();
117: OutputStreamWriter writer = new OutputStreamWriter(baos);
118: PrintWriter inclFile = new PrintWriter(writer);
119:
120: // IMPL_NOTE: hardcoded name, must agree with the makefile
121: inclFile.println("#include \"cldcvm.mch\"");
122:
123: inclFile.flush();
124: currentDB.updateFile(giMchProxyIncl.dirPreStemSuff(), baos);
125: inclFile.close();
126: }
127: }
|