001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.makewizard;
043:
044: /**
045: * CompilerFlags contains the flags a user is allowed to set from the IPE.
046: */
047:
048: public final class CompilerFlags {
049:
050: /** Simple Development case: Debug the simple case */
051: private boolean simpleDebug;
052:
053: /** Simple Development case: Optimize the simple case */
054: private boolean simpleOptimize;
055:
056: /** Debug Development case: true means just debug, false means debug+opt */
057: private boolean develDebug;
058:
059: ///** Use the -g compiler flag for compiling */
060: //private boolean develSBrowser;
061:
062: /** Where are compile options coming from? */
063: private OptionSource optionSource;
064:
065: /** Final Development case: Compile with optimization turned on */
066: private boolean finalOptimize;
067:
068: /** Final Development case: Strip the output */
069: private boolean finalStrip;
070:
071: /** Compile 64 bit application */
072: private boolean comp64bit;
073:
074: /** Save the CFLAGS information */
075: private String cFlagsSun;
076: private String cFlagsGNU;
077:
078: /** Save the CCFLAGS information */
079: private String ccFlagsSun;
080: private String ccFlagsGNU;
081:
082: /** Save the F90FLAGS information */
083: private String f90Flags;
084:
085: private String indent;
086:
087: /** List of options we've processed. Used to keep duplicates out */
088:
089: /** Initialize with everything turned off */
090: public CompilerFlags() {
091: simpleDebug = false;
092: simpleOptimize = false;
093:
094: //develDebug = false;
095: develDebug = true;
096: //develSBrowser = false;
097:
098: finalOptimize = false;
099: finalStrip = false;
100: optionSource = OptionSource.DEVELOPMENT;
101:
102: comp64bit = false;
103: }
104:
105: /** Getter for debug option */
106: public boolean isSimpleDebug() {
107: return simpleDebug;
108: }
109:
110: /** Setter for debug option */
111: public void setSimpleDebug(boolean simpleDebug) {
112: this .simpleDebug = simpleDebug;
113: }
114:
115: /** Getter for optimize option */
116: public boolean isSimpleOptimize() {
117: return simpleOptimize;
118: }
119:
120: /** Setter for optimize option */
121: public void setSimpleOptimize(boolean simpleOptimize) {
122: this .simpleOptimize = simpleOptimize;
123: }
124:
125: /** Getter for Debug (Code) Developement debug-only flag */
126: public boolean isDevelDebug() {
127: return develDebug;
128: }
129:
130: /** Setter for Debug (Code) Development debug-only flag */
131: public void setDevelDebug(boolean develDebug) {
132: this .develDebug = develDebug;
133: }
134:
135: ///** Getter for SourceBrowser */
136: //public boolean isDevelSBrowser() {
137: // return develSBrowser;
138: //}
139:
140: ///** Setter for SourceBrowser */
141: //public void setDevelSBrowser(boolean develSBrowser) {
142: // this.develSBrowser = develSBrowser;
143: //}
144:
145: /** What kind of build are we doing? This affects where/what options are used */
146: public OptionSource getOptionSource() {
147: return optionSource;
148: }
149:
150: /** Set final development flag */
151: public void setOptionSource(OptionSource optionSource) {
152: this .optionSource = optionSource;
153: }
154:
155: /** Getter for optimize option */
156: public boolean isFinalOptimize() {
157: return finalOptimize;
158: }
159:
160: /** Setter for optimize option */
161: public void setFinalOptimize(boolean finalOptimize) {
162: this .finalOptimize = finalOptimize;
163: }
164:
165: /** Getter for strip option */
166: public boolean isFinalStrip() {
167: return finalStrip;
168: }
169:
170: /** Setter for strip option */
171: public void setFinalStrip(boolean finalStrip) {
172: this .finalStrip = finalStrip;
173: }
174:
175: /** Getter for 64 bit application flags */
176: public boolean is64Bit() {
177: return comp64bit;
178: }
179:
180: /** Setter for 64 bit application flags */
181: public void set64Bit(boolean comp64bit) {
182: this .comp64bit = comp64bit;
183: }
184:
185: /** Get CFLAGS Sun or GNU */
186: public String getCFlags(int toolset) {
187: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
188: return getCFlagsSun();
189: } else if (toolset == MakefileData.GNU_TOOLSET_TYPE) {
190: return getCFlagsGNU();
191: } else {
192: ; // FIXUP - error
193: }
194: return null;
195: }
196:
197: /** Get CFLAGS Sun*/
198: public String getCFlagsSun() {
199: if (cFlagsSun == null) {
200: cFlagsSun = "$(BASICOPTS) -xCC"; // NOI18N
201: }
202:
203: return cFlagsSun;
204: }
205:
206: /** Get CFLAGS GNU*/
207: public String getCFlagsGNU() {
208: if (cFlagsGNU == null) {
209: cFlagsGNU = "$(BASICOPTS)"; // NOI18N
210: }
211:
212: return cFlagsGNU;
213: }
214:
215: /** Set CFLAGS Sun*/
216: public void setCFlags(int toolset, String cFlags) {
217: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
218: setCFlagsSun(cFlags);
219: } else if (toolset == MakefileData.GNU_TOOLSET_TYPE) {
220: setCFlagsGNU(cFlags);
221: } else {
222: ; // FIXUP - error
223: }
224: }
225:
226: /** Set CFLAGS Sun*/
227: public void setCFlagsSun(String cFlags) {
228: this .cFlagsSun = cFlags;
229: }
230:
231: /** Set CFLAGS GNU*/
232: public void setCFlagsGNU(String cFlags) {
233: this .cFlagsGNU = cFlags;
234: }
235:
236: /** Get CcFLAGS Sun or GNU */
237: public String getCcFlags(int toolset) {
238: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
239: return getCcFlagsSun();
240: } else if (toolset == MakefileData.GNU_TOOLSET_TYPE) {
241: return getCcFlagsGNU();
242: } else {
243: ; // FIXUP - error
244: }
245: return null;
246: }
247:
248: /** Get CcFLAGS Sun*/
249: public String getCcFlagsSun() {
250: if (ccFlagsSun == null) {
251: ccFlagsSun = "$(BASICOPTS)"; // NOI18N
252: }
253:
254: return ccFlagsSun;
255: }
256:
257: /** Get CcFLAGS GNU*/
258: public String getCcFlagsGNU() {
259: if (ccFlagsGNU == null) {
260: ccFlagsGNU = "$(BASICOPTS)"; // NOI18N
261: }
262:
263: return ccFlagsGNU;
264: }
265:
266: /** Set CcFLAGS Sun*/
267: public void setCcFlags(int toolset, String ccFlags) {
268: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
269: setCcFlagsSun(ccFlags);
270: } else if (toolset == MakefileData.GNU_TOOLSET_TYPE) {
271: setCcFlagsGNU(ccFlags);
272: } else {
273: ; // FIXUP - error
274: }
275: }
276:
277: /** Set CcFLAGS Sun*/
278: public void setCcFlagsSun(String ccFlags) {
279: this .ccFlagsSun = ccFlags;
280: }
281:
282: /** Set CcFLAGS GNU*/
283: public void setCcFlagsGNU(String ccFlags) {
284: this .ccFlagsGNU = ccFlags;
285: }
286:
287: /** Get F90FLAGS */
288: public String getF90Flags() {
289: if (f90Flags == null) {
290: f90Flags = "$(BASICOPTS)"; // NOI18N
291: }
292:
293: return f90Flags;
294: }
295:
296: /** Set F90FLAGS */
297: public void setF90Flags(String f90Flags) {
298: this .f90Flags = f90Flags;
299: }
300:
301: /** Get Basic Options Sun or GNU */
302: public String getBasicOptions(int toolset) {
303: if (toolset == MakefileData.SUN_TOOLSET_TYPE) {
304: return getBasicOptionsSun();
305: } else if (toolset == MakefileData.GNU_TOOLSET_TYPE) {
306: return getBasicOptionsGNU();
307: } else {
308: ; // FIXUP - error
309: }
310: return null;
311: }
312:
313: /** Get Basic Options Sun */
314: public String getBasicOptionsSun() {
315: StringBuffer basicOptions;
316:
317: basicOptions = new StringBuffer(64);
318:
319: if (optionSource == OptionSource.SIMPLE) {
320: if (simpleDebug) {
321: basicOptions.append("-g "); // NOI18N
322: }
323: if (simpleOptimize) {
324: basicOptions.append("-xO3 "); // NOI18N
325: }
326: } else if (optionSource == OptionSource.DEVELOPMENT) {
327: if (develDebug) {
328: basicOptions.append("-g "); // NOI18N
329: } else {
330: basicOptions.append("-g -xO3 "); // NOI18N
331: }
332: } else {
333: if (finalOptimize) {
334: basicOptions.append("-xO3 "); // NOI18N
335: }
336: if (finalStrip) {
337: basicOptions.append("-s "); // NOI18N
338: }
339: }
340: if (comp64bit) {
341: basicOptions.append("-xarch=generic64 "); // NOI18N
342: }
343:
344: return basicOptions.toString().trim();
345: }
346:
347: /** Get Basic Options GNU */
348: public String getBasicOptionsGNU() {
349: StringBuffer basicOptions;
350:
351: basicOptions = new StringBuffer(64);
352:
353: if (optionSource == OptionSource.SIMPLE) {
354: if (simpleDebug) {
355: basicOptions.append("-g "); // NOI18N
356: }
357: if (simpleOptimize) {
358: basicOptions.append("-O "); // NOI18N
359: }
360: } else if (optionSource == OptionSource.DEVELOPMENT) {
361: if (develDebug) {
362: basicOptions.append("-g "); // NOI18N
363: } else {
364: basicOptions.append("-g -O "); // NOI18N
365: }
366: } else {
367: if (finalOptimize) {
368: basicOptions.append("-O "); // NOI18N
369: }
370: if (finalStrip) {
371: basicOptions.append("-s "); // NOI18N FIXUP ???
372: }
373: }
374: if (comp64bit) {
375: basicOptions.append("-m64 "); // NOI18N FIXUP ???
376: }
377:
378: return basicOptions.toString().trim();
379: }
380:
381: /** Some debug methods */
382: public void dump() {
383: println("Dumping CompilerFlags {"); // NOI18N
384: println(" Simple Debug = ", simpleDebug); // NOI18N
385: println(" Simple Optimize = ", simpleOptimize); // NOI18N
386: println(" OptionSource = " + optionSource.toString()); // NOI18N
387: println(" Devel Debug = True"); // NOI18N
388: println(" Devel Optimize = ", !develDebug); // NOI18N
389: println(" Final Optimize = ", finalOptimize); // NOI18N
390: println(" FinalStrip = ", finalStrip); // NOI18N
391: println(" 64 Bit = ", comp64bit); // NOI18N
392: println("}"); // NOI18N
393: }
394:
395: /**
396: * Allow caller to indent all data. This is usefull for indenting target
397: * dumps within MakefileData dumps.
398: */
399: public void dump(String in) {
400:
401: setIndent(in);
402: dump();
403: }
404:
405: private void println(String s) {
406: System.out.println(indent + s);
407: }
408:
409: private void println(String s, boolean tf) {
410: System.out.println(indent + s
411: + (String) (tf ? "True" : "False")); // NOI18N
412: }
413:
414: private void setIndent(String indent) {
415: this.indent = indent;
416: }
417: }
|