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