]>
Commit | Line | Data |
---|---|---|
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 | |
17 | package net.sf.antcontrib.cpptasks.gcc.cross;\r | |
18 | import java.io.File;\r | |
19 | \r | |
20 | import net.sf.antcontrib.cpptasks.CCTask;\r | |
21 | import net.sf.antcontrib.cpptasks.LinkerParam;\r | |
22 | import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;\r | |
23 | import net.sf.antcontrib.cpptasks.compiler.LinkType;\r | |
24 | import net.sf.antcontrib.cpptasks.compiler.Linker;\r | |
25 | import net.sf.antcontrib.cpptasks.gcc.AbstractArLibrarian;\r | |
26 | \r | |
27 | import org.apache.tools.ant.BuildException;\r | |
28 | /**\r | |
29 | * Adapter for the 'ar' archiver\r | |
30 | * \r | |
31 | * @author Adam Murdoch\r | |
32 | */\r | |
33 | public final class GccLibrarian extends AbstractArLibrarian {\r | |
34 | private static String[] objFileExtensions = new String[]{".o"};\r | |
35 | private static GccLibrarian instance = new GccLibrarian("ar",\r | |
36 | objFileExtensions, false, new GccLibrarian("ar", objFileExtensions,\r | |
37 | true, null));\r | |
38 | public static GccLibrarian getInstance() {\r | |
39 | return instance;\r | |
40 | }\r | |
41 | private GccLibrarian(String command, String[] inputExtensions,\r | |
42 | boolean isLibtool, GccLibrarian libtoolLibrarian) {\r | |
43 | super(command, "V", inputExtensions, new String[0], "lib", ".a",\r | |
44 | isLibtool, libtoolLibrarian);\r | |
45 | }\r | |
46 | protected Object clone() throws CloneNotSupportedException {\r | |
47 | GccLibrarian clone = (GccLibrarian) super.clone();\r | |
48 | return clone;\r | |
49 | }\r | |
50 | public Linker getLinker(LinkType type) {\r | |
51 | return GccLinker.getInstance().getLinker(type);\r | |
52 | }\r | |
53 | public void link(CCTask task, File outputFile, String[] sourceFiles,\r | |
54 | CommandLineLinkerConfiguration config) throws BuildException {\r | |
55 | try {\r | |
56 | GccLibrarian clone = (GccLibrarian) this.clone();\r | |
57 | LinkerParam param = config.getParam("target");\r | |
58 | if (param != null)\r | |
59 | clone.setCommand(param.getValue() + "-" + this.getCommand());\r | |
60 | clone.superlink(task, outputFile, sourceFiles, config);\r | |
61 | } catch (CloneNotSupportedException e) {\r | |
62 | superlink(task, outputFile, sourceFiles, config);\r | |
63 | }\r | |
64 | }\r | |
65 | private void superlink(CCTask task, File outputFile, String[] sourceFiles,\r | |
66 | CommandLineLinkerConfiguration config) throws BuildException {\r | |
67 | super.link(task, outputFile, sourceFiles, config);\r | |
68 | }\r | |
69 | }\r |