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
.compaq
;
19 import java
.util
.Vector
;
21 import net
.sf
.antcontrib
.cpptasks
.CUtil
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineFortranCompiler
;
23 import net
.sf
.antcontrib
.cpptasks
.compiler
.LinkType
;
24 import net
.sf
.antcontrib
.cpptasks
.compiler
.Linker
;
25 import net
.sf
.antcontrib
.cpptasks
.compiler
.Processor
;
26 import net
.sf
.antcontrib
.cpptasks
.OptimizationEnum
;
29 import org
.apache
.tools
.ant
.types
.Environment
;
31 * Adapter for the Compaq(r) Visual Fortran compiler.
35 public class CompaqVisualFortranCompiler
extends CommandLineFortranCompiler
{
36 private static final CompaqVisualFortranCompiler
[] instance
= new CompaqVisualFortranCompiler
[]{new CompaqVisualFortranCompiler(
38 public static CompaqVisualFortranCompiler
getInstance() {
41 private CompaqVisualFortranCompiler(boolean newEnvironment
, Environment env
) {
42 super("DF", null, new String
[]{".f90", ".for", ".f"}, new String
[]{
43 ".i", ".i90", ".fpp", ".inc", ".bak", ".exe"}, ".obj", false,
44 null, newEnvironment
, env
);
46 protected void addImpliedArgs(final Vector args
,
48 final boolean multithreaded
,
49 final boolean exceptions
,
50 final LinkType linkType
,
52 final OptimizationEnum optimization
,
53 final Boolean defaultflag
) {
54 args
.addElement("/nologo");
55 args
.addElement("/compile_only");
57 args
.addElement("/debug:full");
58 args
.addElement("/define:_DEBUG");
60 args
.addElement("/debug:none");
61 args
.addElement("/define:NDEBUG");
64 args
.addElement("/threads");
65 args
.addElement("/define:_MT");
67 args
.addElement("/nothreads");
69 boolean staticRuntime
= linkType
.isStaticRuntime();
71 args
.addElement("/libs:static");
73 args
.addElement("/libs:dll");
75 if (linkType
.isSharedLibrary()) {
76 args
.addElement("/dll");
77 args
.addElement("/define:_DLL");
80 public void addWarningSwitch(Vector args
, int level
) {
83 args
.addElement("/nowarn");
90 args
.addElement("/warn:usage");
93 args
.addElement("/warn:all");
96 args
.addElement("/warn:errors");
100 public Processor
changeEnvironment(boolean newEnvironment
, Environment env
) {
101 if (newEnvironment
|| env
!= null) {
102 return new CompaqVisualFortranCompiler(newEnvironment
, env
);
106 protected void getDefineSwitch(StringBuffer buf
, String define
, String value
) {
107 buf
.append("/define:");
109 if (value
!= null && value
.length() > 0) {
114 protected File
[] getEnvironmentIncludePath() {
115 return CUtil
.getPathFromEnvironment("INCLUDE", ";");
117 protected String
getIncludeDirSwitch(String includeDir
) {
118 StringBuffer buf
= new StringBuffer("/include:");
119 if (includeDir
.indexOf(' ') >= 0) {
121 buf
.append(includeDir
);
124 buf
.append(includeDir
);
126 return buf
.toString();
128 public Linker
getLinker(LinkType type
) {
129 return CompaqVisualFortranLinker
.getInstance().getLinker(type
);
131 public int getMaximumCommandLength() {
134 protected void getUndefineSwitch(StringBuffer buf
, String define
) {
135 buf
.append("/undefine:");