]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/os400/IccCompiler.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / os400 / IccCompiler.java
CommitLineData
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
17package net.sf.antcontrib.cpptasks.os400;\r
18import java.io.File;\r
19import java.util.Vector;\r
20\r
21import net.sf.antcontrib.cpptasks.CUtil;\r
22import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;\r
23import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;\r
24import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
25import net.sf.antcontrib.cpptasks.compiler.Linker;\r
26import net.sf.antcontrib.cpptasks.compiler.Processor;\r
27import net.sf.antcontrib.cpptasks.OptimizationEnum;\r
28\r
29\r
30import org.apache.tools.ant.types.Environment;\r
31/**\r
32 * Adapter for the IBM (R) OS/390 (tm) C++ Compiler\r
33 * \r
34 * @author Hiram Chirino (cojonudo14@hotmail.com)\r
35 */\r
36public class IccCompiler extends CommandLineCCompiler {\r
37 private static final AbstractCompiler instance = new IccCompiler(false,\r
38 null);\r
39 public static AbstractCompiler getInstance() {\r
40 return instance;\r
41 }\r
42 private IccCompiler(boolean newEnvironment, Environment env) {\r
43 super("icc", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++",\r
44 ".s"}, new String[]{".h", ".hpp"}, ".o", false, null,\r
45 newEnvironment, env);\r
46 }\r
47 protected void addImpliedArgs(final Vector args, \r
48 final boolean debug,\r
49 final boolean multithreaded, \r
50 final boolean exceptions, \r
51 final LinkType linkType,\r
52 final Boolean rtti,\r
53 final OptimizationEnum optimization,\r
54 final Boolean defaultflag) {\r
55 // Specifies that only compilations and assemblies be done.\r
56 // Link-edit is not done\r
57 args.addElement("-c");\r
58 /*\r
59 * if (exceptions) { args.addElement("/GX"); }\r
60 */\r
61 if (debug) {\r
62 args.addElement("-g");\r
63 /*\r
64 * args.addElement("-D"); args.addElement("_DEBUG"); if\r
65 * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {\r
66 * args.addElement("/MTd"); } else { args.addElement("/MDd");\r
67 * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }\r
68 */\r
69 } else {\r
70 /*\r
71 * args.addElement("-D"); args.addElement("NEBUG"); if\r
72 * (multithreaded) { args.addElement("/D_MT"); if (staticLink) {\r
73 * args.addElement("/MT"); } else { args.addElement("/MD");\r
74 * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }\r
75 */\r
76 }\r
77 }\r
78 protected void addWarningSwitch(Vector args, int level) {\r
79 IccProcessor.addWarningSwitch(args, level);\r
80 }\r
81 public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r
82 if (newEnvironment || env != null) {\r
83 return new IccCompiler(newEnvironment, env);\r
84 }\r
85 return this;\r
86 }\r
87 /*\r
88 * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)\r
89 */\r
90 protected void getDefineSwitch(StringBuffer buffer, String define,\r
91 String value) {\r
92 buffer.append("-q");\r
93 buffer.append(define);\r
94 if (value != null && value.length() > 0) {\r
95 buffer.append('=');\r
96 buffer.append(value);\r
97 }\r
98 }\r
99 protected File[] getEnvironmentIncludePath() {\r
100 return CUtil.getPathFromEnvironment("INCLUDE", ":");\r
101 }\r
102 protected String getIncludeDirSwitch(String includeDir) {\r
103 return IccProcessor.getIncludeDirSwitch(includeDir);\r
104 }\r
105 public Linker getLinker(LinkType type) {\r
106 return IccLinker.getInstance().getLinker(type);\r
107 }\r
108 public int getMaximumCommandLength() {\r
109 return Integer.MAX_VALUE;\r
110 }\r
111 /* Only compile one file at time for now */\r
112 protected int getMaximumInputFilesPerCommand() {\r
113 return 1;\r
114 //return Integer.MAX_VALUE;\r
115 }\r
116 /*\r
117 * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)\r
118 */\r
119 protected void getUndefineSwitch(StringBuffer buffer, String define) {\r
120 /*\r
121 * buffer.addElement("-q"); buf.append(define);\r
122 */\r
123 }\r
124}\r