]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/devstudio/DevStudioCompatibleLinker.java
Restructuring for better separation of Tool packages.
[mirror_edk2.git] / Tools / Java / Source / Cpptasks / net / sf / antcontrib / cpptasks / devstudio / DevStudioCompatibleLinker.java
1 /*
2 *
3 * Copyright 2002-2004 The Ant-Contrib project
4 *
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
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
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.
16 */
17 package net.sf.antcontrib.cpptasks.devstudio;
18 import java.io.File;
19 import java.util.Vector;
20
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;
25 /**
26 * Abstract base class for linkers that try to mimic the command line arguments
27 * for the Microsoft (r) Incremental Linker
28 *
29 * @author Curt Arnold
30 */
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,
37 false, null);
38 }
39 protected void addBase(long base, Vector args) {
40 if (base >= 0) {
41 String baseAddr = Long.toHexString(base);
42 args.addElement("/BASE:0x" + baseAddr);
43 }
44 }
45 protected void addFixed(Boolean fixed, Vector args) {
46 if (fixed != null) {
47 if (fixed.booleanValue()) {
48 args.addElement("/FIXED");
49 } else {
50 args.addElement("/FIXED:NO");
51 }
52 }
53 }
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]);
59 }
60 }
61 if (debug) {
62 args.addElement("/DEBUG");
63 }
64 if (linkType.isSharedLibrary()) {
65 args.addElement("/DLL");
66 }
67 /*
68 * if(linkType.isSubsystemGUI()) {
69 * args.addElement("/SUBSYSTEM:WINDOWS"); } else {
70 * if(linkType.isSubsystemConsole()) {
71 * args.addElement("/SUBSYSTEM:CONSOLE"); } }
72 */
73 }
74 protected void addIncremental(boolean incremental, Vector args) {
75 if (incremental) {
76 args.addElement("/INCREMENTAL:YES");
77 } else {
78 args.addElement("/INCREMENTAL:NO");
79 }
80 }
81 protected void addMap(boolean map, Vector args) {
82 if (map) {
83 args.addElement("/MAP");
84 }
85 }
86 protected void addStack(int stack, Vector args) {
87 if (stack >= 0) {
88 String stackStr = Integer.toHexString(stack);
89 args.addElement("/STACK:0x" + stackStr);
90 }
91 }
92 /* (non-Javadoc)
93 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
94 */
95 protected void addEntry(String entry, Vector args) {
96 if (entry != null) {
97 args.addElement("/ENTRY:" + entry);
98 }
99 }
100
101 public String getCommandFileSwitch(String commandFile) {
102 return "@" + commandFile;
103 }
104 public File[] getLibraryPath() {
105 return CUtil.getPathFromEnvironment("LIB", ";");
106 }
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++) {
111 buf.setLength(0);
112 buf.append(libnames[i]);
113 buf.append(".lib");
114 patterns[i] = buf.toString();
115 }
116 return patterns;
117 }
118 public int getMaximumCommandLength() {
119 return 4096;
120 }
121 public String[] getOutputFileSwitch(String outputFile) {
122 return new String[]{"/OUT:" + outputFile};
123 }
124 public boolean isCaseSensitive() {
125 return false;
126 }
127 }