]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Linker.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / sun / C89Linker.java
CommitLineData
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
17package net.sf.antcontrib.cpptasks.sun;\r
18import java.io.File;\r
19import java.util.Vector;\r
20\r
21import net.sf.antcontrib.cpptasks.CCTask;\r
22import net.sf.antcontrib.cpptasks.CUtil;\r
23import net.sf.antcontrib.cpptasks.compiler.CommandLineLinker;\r
24import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
25import net.sf.antcontrib.cpptasks.compiler.Linker;\r
26import net.sf.antcontrib.cpptasks.types.LibrarySet;\r
27import net.sf.antcontrib.cpptasks.types.LibraryTypeEnum;\r
28\r
29/**\r
30 * Adapter for the Sun C89 Linker\r
31 * \r
32 * @author Hiram Chirino (cojonudo14@hotmail.com)\r
33 */\r
34public final class C89Linker extends CommandLineLinker {\r
35 private static final C89Linker dllLinker = new C89Linker("lib", ".so");\r
36 private static final C89Linker instance = new C89Linker("", "");\r
37 public static C89Linker getInstance() {\r
38 return instance;\r
39 }\r
40 private String outputPrefix;\r
41 private C89Linker(String outputPrefix, String outputSuffix) {\r
42 super("ld", "/bogus", new String[]{".o", ".a", ".lib", ".x"},\r
43 new String[]{}, outputSuffix, false, null);\r
44 this.outputPrefix = outputPrefix;\r
45 }\r
46 protected void addBase(long base, Vector args) {\r
47 }\r
48 protected void addFixed(Boolean fixed, Vector args) {\r
49 }\r
50 protected void addImpliedArgs(boolean debug, LinkType linkType, Vector args, Boolean defaultflag) {\r
51 if (linkType.isSharedLibrary()) {\r
52 args.addElement("-G");\r
53 }\r
54 }\r
55 protected void addIncremental(boolean incremental, Vector args) {\r
56 }\r
57 public String[] addLibrarySets(CCTask task, LibrarySet[] libsets,\r
58 Vector preargs, Vector midargs, Vector endargs) {\r
59 super.addLibrarySets(task, libsets, preargs, midargs, endargs);\r
60 StringBuffer buf = new StringBuffer("-l");\r
61 for (int i = 0; i < libsets.length; i++) {\r
62 LibrarySet set = libsets[i];\r
63 File libdir = set.getDir(null);\r
64 String[] libs = set.getLibs();\r
65 if (libdir != null) {\r
66 endargs.addElement("-L");\r
67 endargs.addElement(libdir.getAbsolutePath());\r
68 }\r
69 for (int j = 0; j < libs.length; j++) {\r
70 //\r
71 // reset the buffer to just "-l"\r
72 //\r
73 buf.setLength(2);\r
74 //\r
75 // add the library name\r
76 buf.append(libs[j]);\r
77 //\r
78 // add the argument to the list\r
79 endargs.addElement(buf.toString());\r
80 }\r
81 }\r
82 return null;\r
83 }\r
84 protected void addMap(boolean map, Vector args) {\r
85 }\r
86 protected void addStack(int stack, Vector args) {\r
87 }\r
88 /* (non-Javadoc)\r
89 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)\r
90 */\r
91 protected void addEntry(String entry, Vector args) {\r
92 }\r
93 \r
94 public String getCommandFileSwitch(String commandFile) {\r
95 return "@" + commandFile;\r
96 }\r
97 public File[] getLibraryPath() {\r
98 return CUtil.getPathFromEnvironment("LIB", ";");\r
99 }\r
100 public String[] getLibraryPatterns(String[] libnames, LibraryTypeEnum libType) {\r
101 return C89Processor.getLibraryPatterns(libnames, libType);\r
102 }\r
103 public Linker getLinker(LinkType linkType) {\r
104 if (linkType.isSharedLibrary()) {\r
105 return dllLinker;\r
106 }\r
107 /*\r
108 * if(linkType.isStaticLibrary()) { return\r
109 * OS390Librarian.getInstance(); }\r
110 */\r
111 return instance;\r
112 }\r
113 public int getMaximumCommandLength() {\r
114 return Integer.MAX_VALUE;\r
115 }\r
116 public String getOutputFileName(String baseName) {\r
117 return outputPrefix + super.getOutputFileName(baseName);\r
118 }\r
119 public String[] getOutputFileSwitch(String outputFile) {\r
120 return new String[]{"-o", outputFile};\r
121 }\r
122 public boolean isCaseSensitive() {\r
123 return C89Processor.isCaseSensitive();\r
124 }\r
125}\r