+++ /dev/null
-/*\r
- * \r
- * Copyright 2002-2004 The Ant-Contrib project\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package net.sf.antcontrib.cpptasks.borland;\r
-import java.io.File;\r
-import java.util.Vector;\r
-\r
-import net.sf.antcontrib.cpptasks.compiler.CommandLineCompilerConfiguration;\r
-import net.sf.antcontrib.cpptasks.compiler.CompilerConfiguration;\r
-import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
-import net.sf.antcontrib.cpptasks.compiler.Linker;\r
-import net.sf.antcontrib.cpptasks.compiler.PrecompilingCommandLineCCompiler;\r
-import net.sf.antcontrib.cpptasks.compiler.Processor;\r
-import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
-\r
-import org.apache.tools.ant.types.Environment;\r
-/**\r
- * Adapter for the Borland(r) C/C++ compiler.\r
- * \r
- * @author Curt Arnold\r
- */\r
-public class BorlandCCompiler extends PrecompilingCommandLineCCompiler {\r
- private static final String[] headerExtensions = new String[]{".h", ".hpp",\r
- ".inl"};\r
- private static final String[] sourceExtensions = new String[]{".c", ".cc",\r
- ".cpp", ".cxx", ".c++"};\r
- private static final BorlandCCompiler instance = new BorlandCCompiler(\r
- false, null);\r
- public static BorlandCCompiler getInstance() {\r
- return instance;\r
- }\r
- private BorlandCCompiler(boolean newEnvironment, Environment env) {\r
- super("bcc32", "--version", sourceExtensions, headerExtensions, ".obj", false,\r
- null, newEnvironment, env);\r
- }\r
- protected void addImpliedArgs(final Vector args, \r
- final boolean debug,\r
- final boolean multithreaded, \r
- final boolean exceptions, \r
- final LinkType linkType,\r
- final Boolean rtti,\r
- final OptimizationEnum optimization,\r
- final Boolean defaultflag) {\r
- args.addElement("-c");\r
- //\r
- // turn off compiler autodependency since\r
- // we do it ourselves\r
- args.addElement("-X");\r
- if (exceptions) {\r
- args.addElement("-x");\r
- } else {\r
- args.addElement("-x-");\r
- }\r
- if (multithreaded) {\r
- args.addElement("-tWM");\r
- }\r
- if (debug) {\r
- args.addElement("-Od");\r
- args.addElement("-v");\r
- } else {\r
- if (optimization != null) {\r
- if (optimization.isSpeed()) {\r
- args.addElement("-O1");\r
- } else {\r
- if (optimization.isSpeed()) {\r
- args.addElement("-O2");\r
- } else {\r
- if (optimization.isNoOptimization()) {\r
- args.addElement("-Od");\r
- }\r
- }\r
- }\r
- }\r
- }\r
- if (rtti != null && !rtti.booleanValue()) {\r
- args.addElement("-RT-");\r
- }\r
- }\r
- protected void addWarningSwitch(Vector args, int level) {\r
- BorlandProcessor.addWarningSwitch(args, level);\r
- }\r
- public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r
- if (newEnvironment || env != null) {\r
- return new BorlandCCompiler(newEnvironment, env);\r
- }\r
- return this;\r
- }\r
- protected CompilerConfiguration createPrecompileGeneratingConfig(\r
- CommandLineCompilerConfiguration baseConfig, File prototype,\r
- String lastInclude) {\r
- String[] additionalArgs = new String[]{"-H=" + lastInclude, "-Hc"};\r
- return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,\r
- null, true);\r
- }\r
- protected CompilerConfiguration createPrecompileUsingConfig(\r
- CommandLineCompilerConfiguration baseConfig, File prototype,\r
- String lastInclude, String[] exceptFiles) {\r
- String[] additionalArgs = new String[]{"-Hu"};\r
- return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,\r
- exceptFiles, false);\r
- }\r
- protected void getDefineSwitch(StringBuffer buffer, String define,\r
- String value) {\r
- BorlandProcessor.getDefineSwitch(buffer, define, value);\r
- }\r
- protected File[] getEnvironmentIncludePath() {\r
- return BorlandProcessor.getEnvironmentPath("bcc32", 'I',\r
- new String[]{"..\\include"});\r
- }\r
- protected String getIncludeDirSwitch(String includeDir) {\r
- return BorlandProcessor.getIncludeDirSwitch("-I", includeDir);\r
- }\r
- public Linker getLinker(LinkType type) {\r
- return BorlandLinker.getInstance().getLinker(type);\r
- }\r
- public int getMaximumCommandLength() {\r
- return 1024;\r
- }\r
- protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
- BorlandProcessor.getUndefineSwitch(buffer, define);\r
- }\r
-}\r