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.makeproject.api.compilers;
043:
044: import org.netbeans.modules.cnd.api.compilers.CompilerProvider;
045: import org.netbeans.modules.cnd.api.compilers.CompilerSet.CompilerFlavor;
046: import org.netbeans.modules.cnd.api.compilers.Tool;
047: import org.openide.util.NbBundle;
048:
049: /**
050: * Override the cnd default compiler type "Tool". MakeProjects uses classes derived from Tool but cnd/core
051: * can't depend on makeproject classes. So this allows makeproject to provide a tool creator factory.
052: *
053: * @author gordonp
054: */
055: public class MakeProjectCompilerProvider extends CompilerProvider {
056:
057: /**
058: * Create a class derived from Tool
059: *
060: * Thomas: If you want/need different informatio to choose which Tool derived class to create we can change
061: * this method. We can also add others, if desired. This was mainly a proof-of-concept that tool creation
062: * could be deferred to makeproject.
063: */
064: public Tool createCompiler(CompilerFlavor flavor, int kind,
065: String name, String displayName, String path) {
066: if (flavor.isSunCompiler()) {
067: if (kind == Tool.CCompiler) {
068: return new SunCCompiler(flavor, kind, name,
069: displayName, path);
070: } else if (kind == Tool.CCCompiler) {
071: return new SunCCCompiler(flavor, kind, name,
072: displayName, path);
073: } else if (kind == Tool.FortranCompiler) {
074: return new SunFortranCompiler(flavor, kind, name,
075: displayName, path);
076: } else if (kind == Tool.MakeTool) {
077: return new SunMaketool(flavor, name, displayName, path);
078: } else if (kind == Tool.DebuggerTool) {
079: return new SunDebuggerTool(flavor, name, displayName,
080: path);
081: }
082: } else /* if (flavor.isGnuCompiler()) */{ // Assume GNU (makeproject system doesn't handle Unknown)
083: if (kind == Tool.CCompiler) {
084: return new GNUCCompiler(flavor, kind, name,
085: displayName, path);
086: } else if (kind == Tool.CCCompiler) {
087: return new GNUCCCompiler(flavor, kind, name,
088: displayName, path);
089: } else if (kind == Tool.FortranCompiler) {
090: return new GNUFortranCompiler(flavor, kind, name,
091: displayName, path);
092: } else if (kind == Tool.MakeTool) {
093: return new GNUMaketool(flavor, name, displayName, path);
094: } else if (kind == Tool.DebuggerTool) {
095: return new GNUDebuggerTool(flavor, name, displayName,
096: path);
097: }
098: }
099: if (kind == Tool.CustomTool) {
100: return new CustomTool();
101: }
102: throw new IllegalArgumentException(NbBundle.getMessage(
103: MakeProjectCompilerProvider.class,
104: "ERR_UnrecognizedCompilerType")); // NOI18N
105: }
106:
107: }
|