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