]>
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.compiler;\r | |
18 | import net.sf.antcontrib.cpptasks.CCTask;\r | |
19 | import net.sf.antcontrib.cpptasks.LinkerParam;\r | |
20 | import net.sf.antcontrib.cpptasks.ProcessorParam;\r | |
21 | import net.sf.antcontrib.cpptasks.TargetInfo;\r | |
22 | \r | |
23 | import org.apache.tools.ant.BuildException;\r | |
24 | /**\r | |
25 | * A configuration for a command line linker\r | |
26 | * \r | |
27 | * @author Curt Arnold\r | |
28 | */\r | |
29 | public final class CommandLineLinkerConfiguration\r | |
30 | implements\r | |
31 | LinkerConfiguration {\r | |
32 | private/* final */String[][] args;\r | |
33 | private/* final */String identifier;\r | |
34 | private String[] libraryNames;\r | |
35 | private/* final */CommandLineLinker linker;\r | |
36 | private/* final */boolean map;\r | |
37 | private/* final */ProcessorParam[] params;\r | |
38 | private/* final */boolean rebuild;\r | |
39 | private String startupObject;\r | |
40 | public CommandLineLinkerConfiguration(CommandLineLinker linker,\r | |
41 | String identifier, String[][] args, ProcessorParam[] params,\r | |
42 | boolean rebuild, boolean map, String[] libraryNames,\r | |
43 | String startupObject) {\r | |
44 | if (linker == null) {\r | |
45 | throw new NullPointerException("linker");\r | |
46 | }\r | |
47 | if (args == null) {\r | |
48 | throw new NullPointerException("args");\r | |
49 | } else {\r | |
50 | this.args = (String[][]) args.clone();\r | |
51 | }\r | |
52 | this.linker = linker;\r | |
53 | this.params = (ProcessorParam[]) params.clone();\r | |
54 | this.rebuild = rebuild;\r | |
55 | this.identifier = identifier;\r | |
56 | this.map = map;\r | |
57 | if (libraryNames == null) {\r | |
58 | this.libraryNames = new String[0];\r | |
59 | } else {\r | |
60 | this.libraryNames = (String[]) libraryNames.clone();\r | |
61 | }\r | |
62 | this.startupObject = startupObject;\r | |
63 | }\r | |
64 | public int bid(String filename) {\r | |
65 | return linker.bid(filename);\r | |
66 | }\r | |
67 | public String[] getEndArguments() {\r | |
68 | String[] clone = (String[]) args[1].clone();\r | |
69 | return clone;\r | |
70 | }\r | |
71 | /**\r | |
72 | * Returns a string representation of this configuration. Should be\r | |
73 | * canonical so that equivalent configurations will have equivalent string\r | |
74 | * representations\r | |
75 | */\r | |
76 | public String getIdentifier() {\r | |
77 | return identifier;\r | |
78 | }\r | |
79 | public String[] getLibraryNames() {\r | |
80 | String[] clone = (String[]) libraryNames.clone();\r | |
81 | return clone;\r | |
82 | }\r | |
83 | public boolean getMap() {\r | |
84 | return map;\r | |
85 | }\r | |
86 | public String getOutputFileName(String inputFile) {\r | |
87 | return linker.getOutputFileName(inputFile);\r | |
88 | }\r | |
89 | public LinkerParam getParam(String name) {\r | |
90 | for (int i = 0; i < params.length; i++) {\r | |
91 | if (name.equals(params[i].getName()))\r | |
92 | return (LinkerParam) params[i];\r | |
93 | }\r | |
94 | return null;\r | |
95 | }\r | |
96 | public ProcessorParam[] getParams() {\r | |
97 | return params;\r | |
98 | }\r | |
99 | public String[] getPreArguments() {\r | |
100 | String[] clone = (String[]) args[0].clone();\r | |
101 | return clone;\r | |
102 | }\r | |
103 | public boolean getRebuild() {\r | |
104 | return rebuild;\r | |
105 | }\r | |
106 | public String getStartupObject() {\r | |
107 | return startupObject;\r | |
108 | }\r | |
109 | public void link(CCTask task, TargetInfo linkTarget) throws BuildException {\r | |
110 | //\r | |
111 | // AllSourcePath's include any syslibsets\r | |
112 | //\r | |
113 | String[] sourcePaths = linkTarget.getAllSourcePaths();\r | |
114 | linker.link(task, linkTarget.getOutput(), sourcePaths, this);\r | |
115 | }\r | |
116 | public String toString() {\r | |
117 | return identifier;\r | |
118 | }\r | |
119 | }\r |