]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Processor.java
Changed spelling to manifest
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / sun / C89Processor.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.sun;
18 import java.util.Vector;
19 import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;
20
21 /**
22 * A add-in class for Sun C89 compilers and linkers
23 *
24 * @author Hiram Chirino (cojonudo14@hotmail.com)
25 */
26 public class C89Processor {
27 private static int addLibraryPatterns(String[] libnames, StringBuffer buf,
28 String prefix, String extension, String[] patterns, int offset) {
29 for (int i = 0; i < libnames.length; i++) {
30 buf.setLength(0);
31 buf.append(prefix);
32 buf.append(libnames[i]);
33 buf.append(extension);
34 patterns[offset + i] = buf.toString();
35 }
36 return offset + libnames.length;
37 }
38 public static void addWarningSwitch(Vector args, int level) {
39 switch (level) {
40 /*
41 * case 0: args.addElement("/W0"); break;
42 *
43 * case 1: args.addElement("/W1"); break;
44 *
45 * case 2: break;
46 *
47 * case 3: args.addElement("/W3"); break;
48 *
49 * case 4: args.addElement("/W4"); break;
50 */
51 }
52 }
53 public static String getCommandFileSwitch(String cmdFile) {
54 StringBuffer buf = new StringBuffer("@");
55 if (cmdFile.indexOf(' ') >= 0) {
56 buf.append('\"');
57 buf.append(cmdFile);
58 buf.append('\"');
59 } else {
60 buf.append(cmdFile);
61 }
62 return buf.toString();
63 }
64 public static void getDefineSwitch(StringBuffer buf, String define,
65 String value) {
66 buf.setLength(0);
67 buf.append("-D");
68 buf.append(define);
69 if (value != null && value.length() > 0) {
70 buf.append('=');
71 buf.append(value);
72 }
73 }
74 public static String getIncludeDirSwitch(String includeDir) {
75 return "-I" + includeDir;
76 }
77 public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {
78 StringBuffer buf = new StringBuffer();
79 int patternCount = libnames.length*2;
80 if (libType != null) {
81 patternCount = libnames.length;
82 }
83 String[] patterns = new String[patternCount];
84 int offset = 0;
85 if (libType == null || "static".equals(libType.getValue())) {
86 offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);
87 }
88 if (libType == null || !"static".equals(libType.getValue())) {
89 offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,
90 offset);
91 }
92 return patterns;
93 }
94 public static String[] getOutputFileSwitch(String outPath) {
95 StringBuffer buf = new StringBuffer("-o ");
96 if (outPath.indexOf(' ') >= 0) {
97 buf.append('\"');
98 buf.append(outPath);
99 buf.append('\"');
100 } else {
101 buf.append(outPath);
102 }
103 String[] retval = new String[]{buf.toString()};
104 return retval;
105 }
106 public static void getUndefineSwitch(StringBuffer buf, String define) {
107 buf.setLength(0);
108 buf.append("-U");
109 buf.append(define);
110 }
111 public static boolean isCaseSensitive() {
112 return true;
113 }
114 private C89Processor() {
115 }
116 }