]>
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.devstudio;\r | |
18 | import java.io.File;\r | |
19 | import java.util.Vector;\r | |
20 | \r | |
21 | import net.sf.antcontrib.cpptasks.CUtil;\r | |
22 | import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
24 | import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;\r | |
25 | /**\r | |
26 | * Abstract base class for linkers that try to mimic the command line arguments\r | |
27 | * for the Microsoft (r) Incremental Linker\r | |
28 | * \r | |
29 | * @author Curt Arnold\r | |
30 | */\r | |
31 | public abstract class DevStudioCompatibleLinker extends CommandLineLinker {\r | |
32 | private static String[] defaultflags = new String[]{"/NOLOGO"};\r | |
33 | public DevStudioCompatibleLinker(String command, String identifierArg,\r | |
34 | String outputSuffix) {\r | |
35 | super(command, identifierArg, new String[]{".obj", ".lib", ".res"},\r | |
36 | new String[]{".map", ".pdb", ".lnk", ".dll"}, outputSuffix,\r | |
37 | false, null);\r | |
38 | }\r | |
39 | protected void addBase(long base, Vector args) {\r | |
40 | if (base >= 0) {\r | |
41 | String baseAddr = Long.toHexString(base);\r | |
42 | args.addElement("/BASE:0x" + baseAddr);\r | |
43 | }\r | |
44 | }\r | |
45 | protected void addFixed(Boolean fixed, Vector args) {\r | |
46 | if (fixed != null) {\r | |
47 | if (fixed.booleanValue()) {\r | |
48 | args.addElement("/FIXED");\r | |
49 | } else {\r | |
50 | args.addElement("/FIXED:NO");\r | |
51 | }\r | |
52 | }\r | |
53 | }\r | |
54 | protected void addImpliedArgs(boolean debug, LinkType linkType,\r | |
55 | Vector args, Boolean defaultflag) {\r | |
56 | if(defaultflag != null && defaultflag.booleanValue()){\r | |
57 | for (int i = 0; i < defaultflags.length; i++) {\r | |
58 | args.addElement(defaultflags[i]);\r | |
59 | }\r | |
60 | }\r | |
61 | if (debug) {\r | |
62 | args.addElement("/DEBUG");\r | |
63 | }\r | |
64 | if (linkType.isSharedLibrary()) {\r | |
65 | args.addElement("/DLL");\r | |
66 | }\r | |
67 | /*\r | |
68 | * if(linkType.isSubsystemGUI()) {\r | |
69 | * args.addElement("/SUBSYSTEM:WINDOWS"); } else {\r | |
70 | * if(linkType.isSubsystemConsole()) {\r | |
71 | * args.addElement("/SUBSYSTEM:CONSOLE"); } }\r | |
72 | */\r | |
73 | }\r | |
74 | protected void addIncremental(boolean incremental, Vector args) {\r | |
75 | if (incremental) {\r | |
76 | args.addElement("/INCREMENTAL:YES");\r | |
77 | } else {\r | |
78 | args.addElement("/INCREMENTAL:NO");\r | |
79 | }\r | |
80 | }\r | |
81 | protected void addMap(boolean map, Vector args) {\r | |
82 | if (map) {\r | |
83 | args.addElement("/MAP");\r | |
84 | }\r | |
85 | }\r | |
86 | protected void addStack(int stack, Vector args) {\r | |
87 | if (stack >= 0) {\r | |
88 | String stackStr = Integer.toHexString(stack);\r | |
89 | args.addElement("/STACK:0x" + stackStr);\r | |
90 | }\r | |
91 | }\r | |
92 | /* (non-Javadoc)\r | |
93 | * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)\r | |
94 | */\r | |
95 | protected void addEntry(String entry, Vector args) {\r | |
96 | if (entry != null) {\r | |
97 | args.addElement("/ENTRY:" + entry);\r | |
98 | }\r | |
99 | }\r | |
100 | \r | |
101 | public String getCommandFileSwitch(String commandFile) {\r | |
102 | return "@" + commandFile;\r | |
103 | }\r | |
104 | public File[] getLibraryPath() {\r | |
105 | return CUtil.getPathFromEnvironment("LIB", ";");\r | |
106 | }\r | |
107 | public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {\r | |
108 | StringBuffer buf = new StringBuffer();\r | |
109 | String[] patterns = new String[libnames.length];\r | |
110 | for (int i = 0; i < libnames.length; i++) {\r | |
111 | buf.setLength(0);\r | |
112 | buf.append(libnames[i]);\r | |
113 | buf.append(".lib");\r | |
114 | patterns[i] = buf.toString();\r | |
115 | }\r | |
116 | return patterns;\r | |
117 | }\r | |
118 | public int getMaximumCommandLength() {\r | |
119 | return 4096;\r | |
120 | }\r | |
121 | public String[] getOutputFileSwitch(String outputFile) {\r | |
122 | return new String[]{"/OUT:" + outputFile};\r | |
123 | }\r | |
124 | public boolean isCaseSensitive() {\r | |
125 | return false;\r | |
126 | }\r | |
127 | }\r |