]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /*\r |
2 | * \r | |
3 | * Copyright 2002-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.borland;\r | |
18 | import java.io.File;\r | |
19 | import java.util.Vector;\r | |
20 | \r | |
21 | import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;\r | |
22 | import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
24 | import net.sf.antcontrib.cpptasks.compiler.Linker;\r | |
25 | import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;\r | |
26 | import net.sf.antcontrib.cpptasks.compiler.Processor;\r | |
27 | import net.sf.antcontrib.cpptasks.OptimizationEnum;\r | |
28 | \r | |
29 | import org.apache.tools.ant.types.Environment;\r | |
30 | /**\r | |
31 | * Adapter for the Borland(r) C/C++ compiler.\r | |
32 | * \r | |
33 | * @author Curt Arnold\r | |
34 | */\r | |
35 | public class BorlandCCompiler extends PrecompilingCommandLineCCompiler {\r | |
36 | private static final String[] headerExtensions = new String[]{".h", ".hpp",\r | |
37 | ".inl"};\r | |
38 | private static final String[] sourceExtensions = new String[]{".c", ".cc",\r | |
39 | ".cpp", ".cxx", ".c++"};\r | |
40 | private static final BorlandCCompiler instance = new BorlandCCompiler(\r | |
41 | false, null);\r | |
42 | public static BorlandCCompiler getInstance() {\r | |
43 | return instance;\r | |
44 | }\r | |
45 | private BorlandCCompiler(boolean newEnvironment, Environment env) {\r | |
46 | super("bcc32", "--version", sourceExtensions, headerExtensions, ".obj", false,\r | |
47 | null, newEnvironment, env);\r | |
48 | }\r | |
49 | protected void addImpliedArgs(final Vector args, \r | |
50 | final boolean debug,\r | |
51 | final boolean multithreaded, \r | |
52 | final boolean exceptions, \r | |
53 | final LinkType linkType,\r | |
54 | final Boolean rtti,\r | |
55 | final OptimizationEnum optimization,\r | |
56 | final Boolean defaultflag) {\r | |
57 | args.addElement("-c");\r | |
58 | //\r | |
59 | // turn off compiler autodependency since\r | |
60 | // we do it ourselves\r | |
61 | args.addElement("-X");\r | |
62 | if (exceptions) {\r | |
63 | args.addElement("-x");\r | |
64 | } else {\r | |
65 | args.addElement("-x-");\r | |
66 | }\r | |
67 | if (multithreaded) {\r | |
68 | args.addElement("-tWM");\r | |
69 | }\r | |
70 | if (debug) {\r | |
71 | args.addElement("-Od");\r | |
72 | args.addElement("-v");\r | |
73 | } else {\r | |
74 | if (optimization != null) {\r | |
75 | if (optimization.isSpeed()) {\r | |
76 | args.addElement("-O1");\r | |
77 | } else {\r | |
78 | if (optimization.isSpeed()) {\r | |
79 | args.addElement("-O2");\r | |
80 | } else {\r | |
81 | if (optimization.isNoOptimization()) {\r | |
82 | args.addElement("-Od");\r | |
83 | }\r | |
84 | }\r | |
85 | }\r | |
86 | }\r | |
87 | }\r | |
88 | if (rtti != null && !rtti.booleanValue()) {\r | |
89 | args.addElement("-RT-");\r | |
90 | }\r | |
91 | }\r | |
92 | protected void addWarningSwitch(Vector args, int level) {\r | |
93 | BorlandProcessor.addWarningSwitch(args, level);\r | |
94 | }\r | |
95 | public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r | |
96 | if (newEnvironment || env != null) {\r | |
97 | return new BorlandCCompiler(newEnvironment, env);\r | |
98 | }\r | |
99 | return this;\r | |
100 | }\r | |
101 | protected CompilerConfiguration createPrecompileGeneratingConfig(\r | |
102 | CommandLineCompilerConfiguration baseConfig, File prototype,\r | |
103 | String lastInclude) {\r | |
104 | String[] additionalArgs = new String[]{"-H=" + lastInclude, "-Hc"};\r | |
105 | return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,\r | |
106 | null, true);\r | |
107 | }\r | |
108 | protected CompilerConfiguration createPrecompileUsingConfig(\r | |
109 | CommandLineCompilerConfiguration baseConfig, File prototype,\r | |
110 | String lastInclude, String[] exceptFiles) {\r | |
111 | String[] additionalArgs = new String[]{"-Hu"};\r | |
112 | return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,\r | |
113 | exceptFiles, false);\r | |
114 | }\r | |
115 | protected void getDefineSwitch(StringBuffer buffer, String define,\r | |
116 | String value) {\r | |
117 | BorlandProcessor.getDefineSwitch(buffer, define, value);\r | |
118 | }\r | |
119 | protected File[] getEnvironmentIncludePath() {\r | |
120 | return BorlandProcessor.getEnvironmentPath("bcc32", 'I',\r | |
121 | new String[]{"..\\include"});\r | |
122 | }\r | |
123 | protected String getIncludeDirSwitch(String includeDir) {\r | |
124 | return BorlandProcessor.getIncludeDirSwitch("-I", includeDir);\r | |
125 | }\r | |
126 | public Linker getLinker(LinkType type) {\r | |
127 | return BorlandLinker.getInstance().getLinker(type);\r | |
128 | }\r | |
129 | public int getMaximumCommandLength() {\r | |
130 | return 1024;\r | |
131 | }\r | |
132 | protected void getUndefineSwitch(StringBuffer buffer, String define) {\r | |
133 | BorlandProcessor.getUndefineSwitch(buffer, define);\r | |
134 | }\r | |
135 | }\r |