--- /dev/null
+/*\r
+ * \r
+ * Copyright 2002-2004 The Ant-Contrib project\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package net.sf.antcontrib.cpptasks.sun;\r
+import java.util.Vector;\r
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;\r
+\r
+/**\r
+ * A add-in class for Sun C89 compilers and linkers\r
+ * \r
+ * @author Hiram Chirino (cojonudo14@hotmail.com)\r
+ */\r
+public class C89Processor {\r
+ private static int addLibraryPatterns(String[] libnames, StringBuffer buf,\r
+ String prefix, String extension, String[] patterns, int offset) {\r
+ for (int i = 0; i < libnames.length; i++) {\r
+ buf.setLength(0);\r
+ buf.append(prefix);\r
+ buf.append(libnames[i]);\r
+ buf.append(extension);\r
+ patterns[offset + i] = buf.toString();\r
+ }\r
+ return offset + libnames.length;\r
+ }\r
+ public static void addWarningSwitch(Vector args, int level) {\r
+ switch (level) {\r
+ /*\r
+ * case 0: args.addElement("/W0"); break;\r
+ * \r
+ * case 1: args.addElement("/W1"); break;\r
+ * \r
+ * case 2: break;\r
+ * \r
+ * case 3: args.addElement("/W3"); break;\r
+ * \r
+ * case 4: args.addElement("/W4"); break;\r
+ */\r
+ }\r
+ }\r
+ public static String getCommandFileSwitch(String cmdFile) {\r
+ StringBuffer buf = new StringBuffer("@");\r
+ if (cmdFile.indexOf(' ') >= 0) {\r
+ buf.append('\"');\r
+ buf.append(cmdFile);\r
+ buf.append('\"');\r
+ } else {\r
+ buf.append(cmdFile);\r
+ }\r
+ return buf.toString();\r
+ }\r
+ public static void getDefineSwitch(StringBuffer buf, String define,\r
+ String value) {\r
+ buf.setLength(0);\r
+ buf.append("-D");\r
+ buf.append(define);\r
+ if (value != null && value.length() > 0) {\r
+ buf.append('=');\r
+ buf.append(value);\r
+ }\r
+ }\r
+ public static String getIncludeDirSwitch(String includeDir) {\r
+ return "-I" + includeDir;\r
+ }\r
+ public static String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {\r
+ StringBuffer buf = new StringBuffer();\r
+ int patternCount = libnames.length*2;\r
+ if (libType != null) {\r
+ patternCount = libnames.length;\r
+ }\r
+ String[] patterns = new String[patternCount];\r
+ int offset = 0;\r
+ if (libType == null || "static".equals(libType.getValue())) {\r
+ offset = addLibraryPatterns(libnames, buf, "lib", ".a", patterns, 0);\r
+ }\r
+ if (libType == null || !"static".equals(libType.getValue())) {\r
+ offset = addLibraryPatterns(libnames, buf, "lib", ".so", patterns,\r
+ offset);\r
+ }\r
+ return patterns;\r
+ }\r
+ public static String[] getOutputFileSwitch(String outPath) {\r
+ StringBuffer buf = new StringBuffer("-o ");\r
+ if (outPath.indexOf(' ') >= 0) {\r
+ buf.append('\"');\r
+ buf.append(outPath);\r
+ buf.append('\"');\r
+ } else {\r
+ buf.append(outPath);\r
+ }\r
+ String[] retval = new String[]{buf.toString()};\r
+ return retval;\r
+ }\r
+ public static void getUndefineSwitch(StringBuffer buf, String define) {\r
+ buf.setLength(0);\r
+ buf.append("-U");\r
+ buf.append(define);\r
+ }\r
+ public static boolean isCaseSensitive() {\r
+ return true;\r
+ }\r
+ private C89Processor() {\r
+ }\r
+}\r