+++ /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.devstudio;\r
-import java.io.File;\r
-import java.util.Vector;\r
-import net.sf.antcontrib.cpptasks.CUtil;\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.PrecompilingCommandLineCCompiler;\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.types.Environment;\r
-import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
-\r
-/**\r
- * An abstract base class for compilers that are basically command line\r
- * compatible with Microsoft(r) C/C++ Optimizing Compiler\r
- *\r
- * @author Curt Arnold\r
- */\r
-public abstract class DevStudioCompatibleCCompiler\r
- extends\r
- PrecompilingCommandLineCCompiler {\r
- private static String[] mflags = new String[]{\r
- //\r
- // first four are single-threaded\r
- // (runtime=static,debug=false), (..,debug=true),\r
- // (runtime=dynamic,debug=true), (..,debug=false), (not supported)\r
- // next four are multi-threaded, same sequence\r
- "/ML", "/MLd", null, null, "/MT", "/MTd", "/MD", "/MDd"};\r
- private static String[] defaultflags = new String[]{"/nologo", "/c"};\r
- protected DevStudioCompatibleCCompiler(String command,\r
- String identifierArg, boolean newEnvironment, Environment env) {\r
- super(command, identifierArg, new String[]{".c", ".cc", ".cpp", ".cxx",\r
- ".c++"}, new String[]{".h", ".hpp", ".inl"}, ".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
- if (defaultflag != null && defaultflag.booleanValue()) {\r
- for (int i = 0; i < defaultflags.length; i++) {\r
- args.addElement(defaultflags[i]);\r
- }\r
- }\r
- if (exceptions) {\r
- args.addElement("/GX");\r
- }\r
- int mindex = 0;\r
- if (multithreaded) {\r
- mindex += 4;\r
- }\r
- boolean staticRuntime = linkType.isStaticRuntime();\r
- if (!staticRuntime) {\r
- mindex += 2;\r
- }\r
- if (debug) {\r
- mindex += 1;\r
- args.addElement("/Zi");\r
- args.addElement("/Od");\r
- args.addElement("/GZ");\r
- args.addElement("/D_DEBUG");\r
- } else {\r
- if (optimization != null) {\r
- if (optimization.isSize()) {\r
- args.addElement("/O1");\r
- }\r
- if (optimization.isSpeed()) {\r
- args.addElement("/O2");\r
- }\r
- }\r
- args.addElement("/DNDEBUG");\r
- }\r
- String mflag = mflags[mindex];\r
- if (mflag == null) {\r
- throw new BuildException(\r
- "multithread='false' and runtime='dynamic' not supported");\r
- }\r
- args.addElement(mflag);\r
- if (rtti != null && rtti.booleanValue()) {\r
- args.addElement("/GR");\r
- }\r
- }\r
- protected void addWarningSwitch(Vector args, int level) {\r
- DevStudioProcessor.addWarningSwitch(args, level);\r
- }\r
- protected CompilerConfiguration createPrecompileGeneratingConfig(\r
- CommandLineCompilerConfiguration baseConfig, File prototype,\r
- String lastInclude) {\r
- String[] additionalArgs = new String[]{\r
- "/Fp" + CUtil.getBasename(prototype) + ".pch", "/Yc"};\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[]{\r
- "/Fp" + CUtil.getBasename(prototype) + ".pch",\r
- "/Yu" + lastInclude};\r
- return new CommandLineCompilerConfiguration(baseConfig, additionalArgs,\r
- exceptFiles, false);\r
- }\r
- protected void getDefineSwitch(StringBuffer buffer, String define,\r
- String value) {\r
- DevStudioProcessor.getDefineSwitch(buffer, define, value);\r
- }\r
- protected File[] getEnvironmentIncludePath() {\r
- return CUtil.getPathFromEnvironment("INCLUDE", ";");\r
- }\r
- protected String getIncludeDirSwitch(String includeDir) {\r
- return DevStudioProcessor.getIncludeDirSwitch(includeDir);\r
- }\r
- protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
- DevStudioProcessor.getUndefineSwitch(buffer, define);\r
- }\r
-}\r