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