]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/Cpptasks/net/sf/antcontrib/cpptasks/sun/C89Linker.java
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
.sun
;
19 import java
.util
.Vector
;
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
;
30 * Adapter for the Sun C89 Linker
32 * @author Hiram Chirino (cojonudo14@hotmail.com)
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() {
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
;
46 protected void addBase(long base
, Vector args
) {
48 protected void addFixed(Boolean fixed
, Vector args
) {
50 protected void addImpliedArgs(boolean debug
, LinkType linkType
, Vector args
, Boolean defaultflag
) {
51 if (linkType
.isSharedLibrary()) {
52 args
.addElement("-G");
55 protected void addIncremental(boolean incremental
, Vector args
) {
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();
66 endargs
.addElement("-L");
67 endargs
.addElement(libdir
.getAbsolutePath());
69 for (int j
= 0; j
< libs
.length
; j
++) {
71 // reset the buffer to just "-l"
75 // add the library name
78 // add the argument to the list
79 endargs
.addElement(buf
.toString());
84 protected void addMap(boolean map
, Vector args
) {
86 protected void addStack(int stack
, Vector args
) {
89 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
91 protected void addEntry(String entry
, Vector args
) {
94 public String
getCommandFileSwitch(String commandFile
) {
95 return "@" + commandFile
;
97 public File
[] getLibraryPath() {
98 return CUtil
.getPathFromEnvironment("LIB", ";");
100 public String
[] getLibraryPatterns(String
[] libnames
, LibraryTypeEnum libType
) {
101 return C89Processor
.getLibraryPatterns(libnames
, libType
);
103 public Linker
getLinker(LinkType linkType
) {
104 if (linkType
.isSharedLibrary()) {
108 * if(linkType.isStaticLibrary()) { return
109 * OS390Librarian.getInstance(); }
113 public int getMaximumCommandLength() {
114 return Integer
.MAX_VALUE
;
116 public String
getOutputFileName(String baseName
) {
117 return outputPrefix
+ super.getOutputFileName(baseName
);
119 public String
[] getOutputFileSwitch(String outputFile
) {
120 return new String
[]{"-o", outputFile
};
122 public boolean isCaseSensitive() {
123 return C89Processor
.isCaseSensitive();