]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/Cpptasks/net/sf/antcontrib/cpptasks/hp/aCCLinker.java
Initial import.
[mirror_edk2.git] / Tools / Source / Cpptasks / net / sf / antcontrib / cpptasks / hp / aCCLinker.java
1 /*
2 *
3 * Copyright 2001-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.hp;
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.LinkType;
23 import net.sf.antcontrib.cpptasks.compiler.Linker;
24 import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;
25 /**
26 * Adapter for Sun (r) Forte(tm) C++ Linker
27 *
28 * @author Curt Arnold
29 */
30 public final class aCCLinker extends AbstractLdLinker {
31 private static final String[] discardFiles = new String[0];
32 private static final String[] objFiles = new String[]{".o", ".a", ".lib",
33 ".dll", ".so", ".sl"};
34 private static final aCCLinker arLinker = new aCCLinker("aCC", objFiles,
35 discardFiles, "", ".a");
36 private static final aCCLinker dllLinker = new aCCLinker("aCC", objFiles,
37 discardFiles, "lib", ".sl");
38 private static final aCCLinker instance = new aCCLinker("aCC", objFiles,
39 discardFiles, "", "");
40 public static aCCLinker getInstance() {
41 return instance;
42 }
43 private File[] libDirs;
44 private aCCLinker(String command, String[] extensions,
45 String[] ignoredExtensions, String outputPrefix, String outputSuffix) {
46 super(command, "-help", extensions, ignoredExtensions, outputPrefix,
47 outputSuffix, false, null);
48 }
49 public void addImpliedArgs(boolean debug, LinkType linkType, Vector args) {
50 if (debug) {
51 args.addElement("-g");
52 }
53 /*
54 * if(linkType.isStaticRuntime()) { args.addElement("-static"); }
55 */
56 if (linkType.isSharedLibrary()) {
57 args.addElement("-b");
58 }
59 /*
60 * if (linkType.isStaticLibrary()) { args.addElement("-Wl,-noshared"); }
61 */
62 }
63 public void addIncremental(boolean incremental, Vector args) {
64 /*
65 * if (incremental) { args.addElement("-xidlon"); } else {
66 * args.addElement("-xidloff"); }
67 */
68 }
69 /**
70 * Returns library path.
71 *
72 */
73 public File[] getLibraryPath() {
74 if (libDirs == null) {
75 File CCloc = CUtil.getExecutableLocation("aCC");
76 if (CCloc != null) {
77 File compilerLib = new File(new File(CCloc, "../lib")
78 .getAbsolutePath());
79 if (compilerLib.exists()) {
80 libDirs = new File[2];
81 libDirs[0] = compilerLib;
82 }
83 }
84 if (libDirs == null) {
85 libDirs = new File[1];
86 }
87 }
88 libDirs[libDirs.length - 1] = new File("/usr/lib");
89 return libDirs;
90 }
91 public Linker getLinker(LinkType type) {
92 if (type.isStaticLibrary()) {
93 return arLinker;
94 }
95 if (type.isSharedLibrary()) {
96 return dllLinker;
97 }
98 return instance;
99 }
100 }