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