]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package net.sf.antcontrib.cpptasks.compaq;\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.compiler.CommandLineFortranCompiler;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
24 | import net.sf.antcontrib.cpptasks.compiler.Linker;\r | |
25 | import net.sf.antcontrib.cpptasks.compiler.Processor;\r | |
26 | import net.sf.antcontrib.cpptasks.OptimizationEnum;\r | |
27 | \r | |
28 | \r | |
29 | import org.apache.tools.ant.types.Environment;\r | |
30 | /**\r | |
31 | * Adapter for the Compaq(r) Visual Fortran compiler.\r | |
32 | * \r | |
33 | * @author Curt Arnold\r | |
34 | */\r | |
35 | public class CompaqVisualFortranCompiler extends CommandLineFortranCompiler {\r | |
36 | private static final CompaqVisualFortranCompiler[] instance = new CompaqVisualFortranCompiler[]{new CompaqVisualFortranCompiler(\r | |
37 | false, null)};\r | |
38 | public static CompaqVisualFortranCompiler getInstance() {\r | |
39 | return instance[0];\r | |
40 | }\r | |
41 | private CompaqVisualFortranCompiler(boolean newEnvironment, Environment env) {\r | |
42 | super("DF", null, new String[]{".f90", ".for", ".f"}, new String[]{\r | |
43 | ".i", ".i90", ".fpp", ".inc", ".bak", ".exe"}, ".obj", false,\r | |
44 | null, newEnvironment, env);\r | |
45 | }\r | |
46 | protected void addImpliedArgs(final Vector args, \r | |
47 | final boolean debug,\r | |
48 | final boolean multithreaded, \r | |
49 | final boolean exceptions, \r | |
50 | final LinkType linkType,\r | |
51 | final Boolean rtti,\r | |
52 | final OptimizationEnum optimization,\r | |
53 | final Boolean defaultflag) {\r | |
54 | args.addElement("/nologo");\r | |
55 | args.addElement("/compile_only");\r | |
56 | if (debug) {\r | |
57 | args.addElement("/debug:full");\r | |
58 | args.addElement("/define:_DEBUG");\r | |
59 | } else {\r | |
60 | args.addElement("/debug:none");\r | |
61 | args.addElement("/define:NDEBUG");\r | |
62 | }\r | |
63 | if (multithreaded) {\r | |
64 | args.addElement("/threads");\r | |
65 | args.addElement("/define:_MT");\r | |
66 | } else {\r | |
67 | args.addElement("/nothreads");\r | |
68 | }\r | |
69 | boolean staticRuntime = linkType.isStaticRuntime();\r | |
70 | if (staticRuntime) {\r | |
71 | args.addElement("/libs:static");\r | |
72 | } else {\r | |
73 | args.addElement("/libs:dll");\r | |
74 | }\r | |
75 | if (linkType.isSharedLibrary()) {\r | |
76 | args.addElement("/dll");\r | |
77 | args.addElement("/define:_DLL");\r | |
78 | }\r | |
79 | }\r | |
80 | public void addWarningSwitch(Vector args, int level) {\r | |
81 | switch (level) {\r | |
82 | case 0 :\r | |
83 | args.addElement("/nowarn");\r | |
84 | break;\r | |
85 | case 1 :\r | |
86 | break;\r | |
87 | case 2 :\r | |
88 | break;\r | |
89 | case 3 :\r | |
90 | args.addElement("/warn:usage");\r | |
91 | break;\r | |
92 | case 4 :\r | |
93 | args.addElement("/warn:all");\r | |
94 | break;\r | |
95 | case 5 :\r | |
96 | args.addElement("/warn:errors");\r | |
97 | break;\r | |
98 | }\r | |
99 | }\r | |
100 | public Processor changeEnvironment(boolean newEnvironment, Environment env) {\r | |
101 | if (newEnvironment || env != null) {\r | |
102 | return new CompaqVisualFortranCompiler(newEnvironment, env);\r | |
103 | }\r | |
104 | return this;\r | |
105 | }\r | |
106 | protected void getDefineSwitch(StringBuffer buf, String define, String value) {\r | |
107 | buf.append("/define:");\r | |
108 | buf.append(define);\r | |
109 | if (value != null && value.length() > 0) {\r | |
110 | buf.append('=');\r | |
111 | buf.append(value);\r | |
112 | }\r | |
113 | }\r | |
114 | protected File[] getEnvironmentIncludePath() {\r | |
115 | return CUtil.getPathFromEnvironment("INCLUDE", ";");\r | |
116 | }\r | |
117 | protected String getIncludeDirSwitch(String includeDir) {\r | |
118 | StringBuffer buf = new StringBuffer("/include:");\r | |
119 | if (includeDir.indexOf(' ') >= 0) {\r | |
120 | buf.append('"');\r | |
121 | buf.append(includeDir);\r | |
122 | buf.append('"');\r | |
123 | } else {\r | |
124 | buf.append(includeDir);\r | |
125 | }\r | |
126 | return buf.toString();\r | |
127 | }\r | |
128 | public Linker getLinker(LinkType type) {\r | |
129 | return CompaqVisualFortranLinker.getInstance().getLinker(type);\r | |
130 | }\r | |
131 | public int getMaximumCommandLength() {\r | |
132 | return 1024;\r | |
133 | }\r | |
134 | protected void getUndefineSwitch(StringBuffer buf, String define) {\r | |
135 | buf.append("/undefine:");\r | |
136 | buf.append(define);\r | |
137 | }\r | |
138 | }\r |