3 * Copyright 2002-2004 The Ant-Contrib project
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net
.sf
.antcontrib
.cpptasks
.devstudio
;
19 import java
.util
.Vector
;
21 import net
.sf
.antcontrib
.cpptasks
.CUtil
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineLinker
;
23 import net
.sf
.antcontrib
.cpptasks
.compiler
.LinkType
;
24 import net
.sf
.antcontrib
.cpptasks
.types
.LibraryTypeEnum
;
26 * Abstract base class for linkers that try to mimic the command line arguments
27 * for the Microsoft (r) Incremental Linker
31 public abstract class DevStudioCompatibleLinker
extends CommandLineLinker
{
32 private static String
[] defaultflags
= new String
[]{"/NOLOGO"};
33 public DevStudioCompatibleLinker(String command
, String identifierArg
,
34 String outputSuffix
) {
35 super(command
, identifierArg
, new String
[]{".obj", ".lib", ".res"},
36 new String
[]{".map", ".pdb", ".lnk", ".dll"}, outputSuffix
,
39 protected void addBase(long base
, Vector args
) {
41 String baseAddr
= Long
.toHexString(base
);
42 args
.addElement("/BASE:0x" + baseAddr
);
45 protected void addFixed(Boolean fixed
, Vector args
) {
47 if (fixed
.booleanValue()) {
48 args
.addElement("/FIXED");
50 args
.addElement("/FIXED:NO");
54 protected void addImpliedArgs(boolean debug
, LinkType linkType
,
55 Vector args
, Boolean defaultflag
) {
56 if(defaultflag
!= null && defaultflag
.booleanValue()){
57 for (int i
= 0; i
< defaultflags
.length
; i
++) {
58 args
.addElement(defaultflags
[i
]);
62 args
.addElement("/DEBUG");
64 if (linkType
.isSharedLibrary()) {
65 args
.addElement("/DLL");
68 * if(linkType.isSubsystemGUI()) {
69 * args.addElement("/SUBSYSTEM:WINDOWS"); } else {
70 * if(linkType.isSubsystemConsole()) {
71 * args.addElement("/SUBSYSTEM:CONSOLE"); } }
74 protected void addIncremental(boolean incremental
, Vector args
) {
76 args
.addElement("/INCREMENTAL:YES");
78 args
.addElement("/INCREMENTAL:NO");
81 protected void addMap(boolean map
, Vector args
) {
83 args
.addElement("/MAP");
86 protected void addStack(int stack
, Vector args
) {
88 String stackStr
= Integer
.toHexString(stack
);
89 args
.addElement("/STACK:0x" + stackStr
);
93 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
95 protected void addEntry(String entry
, Vector args
) {
97 args
.addElement("/ENTRY:" + entry
);
101 public String
getCommandFileSwitch(String commandFile
) {
102 return "@" + commandFile
;
104 public File
[] getLibraryPath() {
105 return CUtil
.getPathFromEnvironment("LIB", ";");
107 public String
[] getLibraryPatterns(String
[] libnames
, LibraryTypeEnum libType
) {
108 StringBuffer buf
= new StringBuffer();
109 String
[] patterns
= new String
[libnames
.length
];
110 for (int i
= 0; i
< libnames
.length
; i
++) {
112 buf
.append(libnames
[i
]);
114 patterns
[i
] = buf
.toString();
118 public int getMaximumCommandLength() {
121 public String
[] getOutputFileSwitch(String outputFile
) {
122 return new String
[]{"/OUT:" + outputFile
};
124 public boolean isCaseSensitive() {