3 * Copyright 2002-2004 The Ant-Contrib project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package net
.sf
.antcontrib
.cpptasks
.os400
;
19 import java
.util
.Vector
;
21 import net
.sf
.antcontrib
.cpptasks
.CUtil
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.AbstractCompiler
;
23 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineCCompiler
;
24 import net
.sf
.antcontrib
.cpptasks
.compiler
.LinkType
;
25 import net
.sf
.antcontrib
.cpptasks
.compiler
.Linker
;
26 import net
.sf
.antcontrib
.cpptasks
.compiler
.Processor
;
27 import net
.sf
.antcontrib
.cpptasks
.OptimizationEnum
;
30 import org
.apache
.tools
.ant
.types
.Environment
;
32 * Adapter for the IBM (R) OS/390 (tm) C++ Compiler
34 * @author Hiram Chirino (cojonudo14@hotmail.com)
36 public class IccCompiler
extends CommandLineCCompiler
{
37 private static final AbstractCompiler instance
= new IccCompiler(false,
39 public static AbstractCompiler
getInstance() {
42 private IccCompiler(boolean newEnvironment
, Environment env
) {
43 super("icc", null, new String
[]{".c", ".cc", ".cpp", ".cxx", ".c++",
44 ".s"}, new String
[]{".h", ".hpp"}, ".o", false, null,
47 protected void addImpliedArgs(final Vector args
,
49 final boolean multithreaded
,
50 final boolean exceptions
,
51 final LinkType linkType
,
53 final OptimizationEnum optimization
,
54 final Boolean defaultflag
) {
55 // Specifies that only compilations and assemblies be done.
56 // Link-edit is not done
57 args
.addElement("-c");
59 * if (exceptions) { args.addElement("/GX"); }
62 args
.addElement("-g");
64 * args.addElement("-D"); args.addElement("_DEBUG"); if
65 * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
66 * args.addElement("/MTd"); } else { args.addElement("/MDd");
67 * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }
71 * args.addElement("-D"); args.addElement("NEBUG"); if
72 * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
73 * args.addElement("/MT"); } else { args.addElement("/MD");
74 * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }
78 protected void addWarningSwitch(Vector args
, int level
) {
79 IccProcessor
.addWarningSwitch(args
, level
);
81 public Processor
changeEnvironment(boolean newEnvironment
, Environment env
) {
82 if (newEnvironment
|| env
!= null) {
83 return new IccCompiler(newEnvironment
, env
);
88 * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)
90 protected void getDefineSwitch(StringBuffer buffer
, String define
,
93 buffer
.append(define
);
94 if (value
!= null && value
.length() > 0) {
99 protected File
[] getEnvironmentIncludePath() {
100 return CUtil
.getPathFromEnvironment("INCLUDE", ":");
102 protected String
getIncludeDirSwitch(String includeDir
) {
103 return IccProcessor
.getIncludeDirSwitch(includeDir
);
105 public Linker
getLinker(LinkType type
) {
106 return IccLinker
.getInstance().getLinker(type
);
108 public int getMaximumCommandLength() {
109 return Integer
.MAX_VALUE
;
111 /* Only compile one file at time for now */
112 protected int getMaximumInputFilesPerCommand() {
114 //return Integer.MAX_VALUE;
117 * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)
119 protected void getUndefineSwitch(StringBuffer buffer
, String define
) {
121 * buffer.addElement("-q"); buf.append(define);