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