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