]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/os390/OS390CCompiler.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / os390 / OS390CCompiler.java
1 /*
2 *
3 * Copyright 2002-2004 The Ant-Contrib project
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17 package net.sf.antcontrib.cpptasks.os390;
18 import java.io.File;
19 import java.util.Vector;
20
21 import net.sf.antcontrib.cpptasks.CUtil;
22 import net.sf.antcontrib.cpptasks.CompilerDef;
23 import net.sf.antcontrib.cpptasks.compiler.AbstractCompiler;
24 import net.sf.antcontrib.cpptasks.compiler.CommandLineCCompiler;
25 import net.sf.antcontrib.cpptasks.compiler.LinkType;
26 import net.sf.antcontrib.cpptasks.compiler.Linker;
27 import net.sf.antcontrib.cpptasks.compiler.Processor;
28 import net.sf.antcontrib.cpptasks.types.DefineArgument;
29 import net.sf.antcontrib.cpptasks.types.UndefineArgument;
30 import net.sf.antcontrib.cpptasks.OptimizationEnum;
31
32
33 import org.apache.tools.ant.types.Environment;
34 /**
35 * Adapter for the IBM (R) OS/390 (tm) C++ Compiler
36 *
37 * @author Hiram Chirino (cojonudo14@hotmail.com)
38 */
39 public class OS390CCompiler extends CommandLineCCompiler {
40 private static final AbstractCompiler instance = new OS390CCompiler(false,
41 null);
42 public static AbstractCompiler getInstance() {
43 return instance;
44 }
45 private OS390CCompiler(boolean newEnvironment, Environment env) {
46 super("cxx", null, new String[]{".c", ".cc", ".cpp", ".cxx", ".c++",
47 ".s"}, new String[]{".h", ".hpp"}, ".o", false, null,
48 newEnvironment, env);
49 }
50 protected void addImpliedArgs(final Vector args,
51 final boolean debug,
52 final boolean multithreaded,
53 final boolean exceptions,
54 final LinkType linkType,
55 final Boolean rtti,
56 final OptimizationEnum optimization,
57 final Boolean defaultflag) {
58 // Specifies that only compilations and assemblies be done.
59 // Link-edit is not done
60 args.addElement("-c");
61 args.addElement("-W");
62 args.addElement("c,NOEXPMAC,NOSHOWINC");
63 /*
64 * if (exceptions) { args.addElement("/GX"); }
65 */
66 if (debug) {
67 args.addElement("-g");
68 args.addElement("-D");
69 args.addElement("_DEBUG");
70 /*
71 * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
72 * args.addElement("/MTd"); } else { args.addElement("/MDd");
73 * args.addElement("/D_DLL"); } } else { args.addElement("/MLd"); }
74 */
75 } else {
76 args.addElement("-D");
77 args.addElement("NEBUG");
78 /*
79 * if (multithreaded) { args.addElement("/D_MT"); if (staticLink) {
80 * args.addElement("/MT"); } else { args.addElement("/MD");
81 * args.addElement("/D_DLL"); } } else { args.addElement("/ML"); }
82 */
83 }
84 }
85 protected void addWarningSwitch(Vector args, int level) {
86 OS390Processor.addWarningSwitch(args, level);
87 }
88 /**
89 * The buildDefineArguments implementation CommandLineCCompiler is not good
90 * for us because os390 defines are give by -D definex instead of
91 * /Ddefinex, 2 args not 1! since we implement this ourslefs, we do not
92 * have to implement the getDefineSwitch() and the getUndefineSwitch().
93 */
94 protected void buildDefineArguments(CompilerDef[] defs, Vector args) {
95 //
96 // assume that we aren't inheriting defines from containing <cc>
97 //
98 UndefineArgument[] merged = defs[0].getActiveDefines();
99 for (int i = 1; i < defs.length; i++) {
100 //
101 // if we are inheriting, merge the specific defines with the
102 // containing defines
103 merged = DefineArgument.merge(defs[i].getActiveDefines(), merged);
104 }
105 StringBuffer buf = new StringBuffer(30);
106 for (int i = 0; i < merged.length; i++) {
107 buf.setLength(0);
108 UndefineArgument current = merged[i];
109 if (current.isDefine()) {
110 args.addElement("-D");
111 buf.append(current.getName());
112 if (current.getValue() != null
113 && current.getValue().length() > 0) {
114 buf.append('=');
115 buf.append(current.getValue());
116 }
117 args.addElement(buf.toString());
118 } else {
119 args.addElement("-U");
120 args.addElement(current.getName());
121 }
122 }
123 }
124 public Processor changeEnvironment(boolean newEnvironment, Environment env) {
125 if (newEnvironment || env != null) {
126 return new OS390CCompiler(newEnvironment, env);
127 }
128 return this;
129 }
130 /*
131 * @see CommandLineCompiler#getDefineSwitch(StringBuffer, String, String)
132 */
133 protected void getDefineSwitch(StringBuffer buffer, String define,
134 String value) {
135 }
136 protected File[] getEnvironmentIncludePath() {
137 return CUtil.getPathFromEnvironment("INCLUDE", ":");
138 }
139 protected String getIncludeDirSwitch(String includeDir) {
140 return OS390Processor.getIncludeDirSwitch(includeDir);
141 }
142 public Linker getLinker(LinkType type) {
143 return OS390Linker.getInstance().getLinker(type);
144 }
145 public int getMaximumCommandLength() {
146 return Integer.MAX_VALUE;
147 }
148 /* Only compile one file at time for now */
149 protected int getMaximumInputFilesPerCommand() {
150 return Integer.MAX_VALUE;
151 }
152 /*
153 * @see CommandLineCompiler#getUndefineSwitch(StringBuffer, String)
154 */
155 protected void getUndefineSwitch(StringBuffer buffer, String define) {
156 }
157 }