]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/ForteCCCompiler.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / sun / ForteCCCompiler.java
1 /*
2 *
3 * Copyright 2001-2004 The Ant-Contrib project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package net.sf.antcontrib.cpptasks.sun;
18 import java.io.File;
19 import java.util.Vector;
20
21 import net.sf.antcontrib.cpptasks.CUtil;
22 import net.sf.antcontrib.cpptasks.compiler.LinkType;
23 import net.sf.antcontrib.cpptasks.compiler.Linker;
24 import net.sf.antcontrib.cpptasks.gcc.GccCompatibleCCompiler;
25 import net.sf.antcontrib.cpptasks.OptimizationEnum;
26 /**
27 * Adapter for the Sun (r) Forte (tm) C++ compiler
28 *
29 * @author Curt Arnold
30 */
31 public final class ForteCCCompiler extends GccCompatibleCCompiler {
32 private static final ForteCCCompiler instance = new ForteCCCompiler("CC");
33 /**
34 * Gets singleton instance of this class
35 */
36 public static ForteCCCompiler getInstance() {
37 return instance;
38 }
39 private String identifier;
40 private File[] includePath;
41 /**
42 * Private constructor. Use ForteCCCompiler.getInstance() to get singleton
43 * instance of this class.
44 */
45 private ForteCCCompiler(String command) {
46 super(command, "-V", false, null, false, null);
47 }
48 public void addImpliedArgs(final Vector args,
49 final boolean debug,
50 final boolean multithreaded,
51 final boolean exceptions,
52 final LinkType linkType,
53 final Boolean rtti,
54 final OptimizationEnum optimization) {
55 args.addElement("-c");
56 if (debug) {
57 args.addElement("-g");
58 }
59 if (optimization != null) {
60 if (optimization.isSpeed()) {
61 args.addElement("-xO2");
62 }
63 }
64 if (rtti != null) {
65 if (rtti.booleanValue()) {
66 args.addElement("-features=rtti");
67 } else {
68 args.addElement("-features=no%rtti");
69 }
70 }
71 if (multithreaded) {
72 args.addElement("-mt");
73 }
74 if (linkType.isSharedLibrary()) {
75 args.addElement("-KPIC");
76 }
77
78 }
79 public void addWarningSwitch(Vector args, int level) {
80 switch (level) {
81 case 0 :
82 args.addElement("-w");
83 break;
84 case 1 :
85 case 2 :
86 args.addElement("+w");
87 break;
88 case 3 :
89 case 4 :
90 case 5 :
91 args.addElement("+w2");
92 break;
93 }
94 }
95 public File[] getEnvironmentIncludePath() {
96 if (includePath == null) {
97 File ccLoc = CUtil.getExecutableLocation("CC");
98 if (ccLoc != null) {
99 File compilerIncludeDir = new File(
100 new File(ccLoc, "../include").getAbsolutePath());
101 if (compilerIncludeDir.exists()) {
102 includePath = new File[2];
103 includePath[0] = compilerIncludeDir;
104 }
105 }
106 if (includePath == null) {
107 includePath = new File[1];
108 }
109 includePath[includePath.length - 1] = new File("/usr/include");
110 }
111 return includePath;
112 }
113 public Linker getLinker(LinkType linkType) {
114 return ForteCCLinker.getInstance().getLinker(linkType);
115 }
116 public int getMaximumCommandLength() {
117 return Integer.MAX_VALUE;
118 }
119 }