--- /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.devstudio;\r
+import java.io.File;\r
+import java.util.Vector;\r
+\r
+import net.sf.antcontrib.cpptasks.CUtil;\r
+import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;\r
+import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
+import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;\r
+/**\r
+ * Abstract base class for linkers that try to mimic the command line arguments\r
+ * for the Microsoft (r) Incremental Linker\r
+ * \r
+ * @author Curt Arnold\r
+ */\r
+public abstract class DevStudioCompatibleLinker extends CommandLineLinker {\r
+ private static String[] defaultflags = new String[]{"/NOLOGO"};\r
+ public DevStudioCompatibleLinker(String command, String identifierArg,\r
+ String outputSuffix) {\r
+ super(command, identifierArg, new String[]{".obj", ".lib", ".res"},\r
+ new String[]{".map", ".pdb", ".lnk", ".dll"}, outputSuffix,\r
+ false, null);\r
+ }\r
+ protected void addBase(long base, Vector args) {\r
+ if (base >= 0) {\r
+ String baseAddr = Long.toHexString(base);\r
+ args.addElement("/BASE:0x" + baseAddr);\r
+ }\r
+ }\r
+ protected void addFixed(Boolean fixed, Vector args) {\r
+ if (fixed != null) {\r
+ if (fixed.booleanValue()) {\r
+ args.addElement("/FIXED");\r
+ } else {\r
+ args.addElement("/FIXED:NO");\r
+ }\r
+ }\r
+ }\r
+ protected void addImpliedArgs(boolean debug, LinkType linkType,\r
+ Vector args, Boolean defaultflag) {\r
+ if(defaultflag != null && defaultflag.booleanValue()){\r
+ for (int i = 0; i < defaultflags.length; i++) {\r
+ args.addElement(defaultflags[i]);\r
+ }\r
+ }\r
+ if (debug) {\r
+ args.addElement("/DEBUG");\r
+ }\r
+ if (linkType.isSharedLibrary()) {\r
+ args.addElement("/DLL");\r
+ }\r
+ /*\r
+ * if(linkType.isSubsystemGUI()) {\r
+ * args.addElement("/SUBSYSTEM:WINDOWS"); } else {\r
+ * if(linkType.isSubsystemConsole()) {\r
+ * args.addElement("/SUBSYSTEM:CONSOLE"); } }\r
+ */\r
+ }\r
+ protected void addIncremental(boolean incremental, Vector args) {\r
+ if (incremental) {\r
+ args.addElement("/INCREMENTAL:YES");\r
+ } else {\r
+ args.addElement("/INCREMENTAL:NO");\r
+ }\r
+ }\r
+ protected void addMap(boolean map, Vector args) {\r
+ if (map) {\r
+ args.addElement("/MAP");\r
+ }\r
+ }\r
+ protected void addStack(int stack, Vector args) {\r
+ if (stack >= 0) {\r
+ String stackStr = Integer.toHexString(stack);\r
+ args.addElement("/STACK:0x" + stackStr);\r
+ }\r
+ }\r
+ /* (non-Javadoc)\r
+ * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)\r
+ */\r
+ protected void addEntry(String entry, Vector args) {\r
+ if (entry != null) {\r
+ args.addElement("/ENTRY:" + entry);\r
+ }\r
+ }\r
+ \r
+ public String getCommandFileSwitch(String commandFile) {\r
+ return "@" + commandFile;\r
+ }\r
+ public File[] getLibraryPath() {\r
+ return CUtil.getPathFromEnvironment("LIB", ";");\r
+ }\r
+ public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {\r
+ StringBuffer buf = new StringBuffer();\r
+ String[] patterns = new String[libnames.length];\r
+ for (int i = 0; i < libnames.length; i++) {\r
+ buf.setLength(0);\r
+ buf.append(libnames[i]);\r
+ buf.append(".lib");\r
+ patterns[i] = buf.toString();\r
+ }\r
+ return patterns;\r
+ }\r
+ public int getMaximumCommandLength() {\r
+ return 4096;\r
+ }\r
+ public String[] getOutputFileSwitch(String outputFile) {\r
+ return new String[]{"/OUT:" + outputFile};\r
+ }\r
+ public boolean isCaseSensitive() {\r
+ return false;\r
+ }\r
+}\r