-/*\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.os390;\r
-import java.io.File;\r
-import java.util.Vector;\r
-\r
-import net.sf.antcontrib.cpptasks.CUtil;\r
-import net.sf.antcontrib.cpptasks.CompilerDef;\r
-import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;\r
-import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;\r
-import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
-import net.sf.antcontrib.cpptasks.compiler.Linker;\r
-import net.sf.antcontrib.cpptasks.compiler.Processor;\r
-import net.sf.antcontrib.cpptasks.types.DefineArgument;\r
-import net.sf.antcontrib.cpptasks.types.UndefineArgument;\r
-import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
-\r
-\r
-import org.apache.tools.ant.types.Environment;\r
-/**\r
- * Adapter for the IBM (R) OS/390 (tm) C++ Compiler\r
- * \r
- * @author Hiram Chirino (cojonudo14@hotmail.com)\r
- */\r
-public class OS390CCompiler extends CommandLineCCompiler {\r
- private static final AbstractCompiler instance = new OS390CCompiler(false,\r
- null);\r
- public static AbstractCompiler getInstance() {\r
- return instance;\r
- }\r
- private OS390CCompiler(boolean newEnvironment, Environment env) {\r
- super("cxx", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++",\r
- ".s"}, new String[]{".h", ".hpp"}, ".o", false, null,\r
- 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
- // Specifies that only compilations and assemblies be done.\r
- // Link-edit is not done\r
- args.addElement("-c");\r
- args.addElement("-W");\r
- args.addElement("c,NOEXPMAC,NOSHOWINC");\r
- /*\r
- * if (exceptions) { args.addElement("/GX"); }\r
- */\r
- if (debug) {\r
- args.addElement("-g");\r
- args.addElement("-D");\r
- args.addElement("_DEBUG");\r
- /*\r
- * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {\r
- * args.addElement("/MTd"); } else { args.addElement("/MDd");\r
- * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }\r
- */\r
- } else {\r
- args.addElement("-D");\r
- args.addElement("NEBUG");\r
- /*\r
- * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {\r
- * args.addElement("/MT"); } else { args.addElement("/MD");\r
- * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }\r
- */\r
- }\r
- }\r
- protected void addWarningSwitch(Vector args, int level) {\r
- OS390Processor.addWarningSwitch(args, level);\r
- }\r
- /**\r
- * The buildDefineArguments implementation CommandLineCCompiler is not good\r
- * for us because os390 defines are give by -D definex instead of\r
- * /Ddefinex, 2 args not 1! since we implement this ourslefs, we do not\r
- * have to implement the getDefineSwitch() and the getUndefineSwitch().\r
- */\r
- protected void buildDefineArguments(CompilerDef[] defs, Vector args) {\r
- //\r
- // assume that we aren't inheriting defines from containing <cc>\r
- //\r
- UndefineArgument[] merged = defs[0].getActiveDefines();\r
- for (int i = 1; i < defs.length; i++) {\r
- //\r
- // if we are inheriting, merge the specific defines with the\r
- // containing defines\r
- merged = DefineArgument.merge(defs[i].getActiveDefines(), merged);\r
- }\r
- StringBuffer buf = new StringBuffer(30);\r
- for (int i = 0; i < merged.length; i++) {\r
- buf.setLength(0);\r
- UndefineArgument current = merged[i];\r
- if (current.isDefine()) {\r
- args.addElement("-D");\r
- buf.append(current.getName());\r
- if (current.getValue() != null\r
- && current.getValue().length() > 0) {\r
- buf.append('=');\r
- buf.append(current.getValue());\r
- }\r
- args.addElement(buf.toString());\r
- } else {\r
- args.addElement("-U");\r
- args.addElement(current.getName());\r
- }\r
- }\r
- }\r
- public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r
- if (newEnvironment || env != null) {\r
- return new OS390CCompiler(newEnvironment, env);\r
- }\r
- return this;\r
- }\r
- /*\r
- * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)\r
- */\r
- protected void getDefineSwitch(StringBuffer buffer, String define,\r
- String value) {\r
- }\r
- protected File[] getEnvironmentIncludePath() {\r
- return CUtil.getPathFromEnvironment("INCLUDE", ":");\r
- }\r
- protected String getIncludeDirSwitch(String includeDir) {\r
- return OS390Processor.getIncludeDirSwitch(includeDir);\r
- }\r
- public Linker getLinker(LinkType type) {\r
- return OS390Linker.getInstance().getLinker(type);\r
- }\r
- public int getMaximumCommandLength() {\r
- return Integer.MAX_VALUE;\r
- }\r
- /* Only compile one file at time for now */\r
- protected int getMaximumInputFilesPerCommand() {\r
- return Integer.MAX_VALUE;\r
- }\r
- /*\r
- * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)\r
- */\r
- protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
- }\r
-}\r