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
.compiler
;
18 import net
.sf
.antcontrib
.cpptasks
.CCTask
;
19 import net
.sf
.antcontrib
.cpptasks
.LinkerParam
;
20 import net
.sf
.antcontrib
.cpptasks
.ProcessorParam
;
21 import net
.sf
.antcontrib
.cpptasks
.TargetInfo
;
23 import org
.apache
.tools
.ant
.BuildException
;
25 * A configuration for a command line linker
29 public final class CommandLineLinkerConfiguration
32 private/* final */String
[][] args
;
33 private/* final */String identifier
;
34 private String
[] libraryNames
;
35 private/* final */CommandLineLinker linker
;
36 private/* final */boolean map
;
37 private/* final */ProcessorParam
[] params
;
38 private/* final */boolean rebuild
;
39 private String startupObject
;
40 public CommandLineLinkerConfiguration(CommandLineLinker linker
,
41 String identifier
, String
[][] args
, ProcessorParam
[] params
,
42 boolean rebuild
, boolean map
, String
[] libraryNames
,
43 String startupObject
) {
45 throw new NullPointerException("linker");
48 throw new NullPointerException("args");
50 this.args
= (String
[][]) args
.clone();
53 this.params
= (ProcessorParam
[]) params
.clone();
54 this.rebuild
= rebuild
;
55 this.identifier
= identifier
;
57 if (libraryNames
== null) {
58 this.libraryNames
= new String
[0];
60 this.libraryNames
= (String
[]) libraryNames
.clone();
62 this.startupObject
= startupObject
;
64 public int bid(String filename
) {
65 return linker
.bid(filename
);
67 public String
[] getEndArguments() {
68 String
[] clone
= (String
[]) args
[1].clone();
72 * Returns a string representation of this configuration. Should be
73 * canonical so that equivalent configurations will have equivalent string
76 public String
getIdentifier() {
79 public String
[] getLibraryNames() {
80 String
[] clone
= (String
[]) libraryNames
.clone();
83 public boolean getMap() {
86 public String
getOutputFileName(String inputFile
) {
87 return linker
.getOutputFileName(inputFile
);
89 public LinkerParam
getParam(String name
) {
90 for (int i
= 0; i
< params
.length
; i
++) {
91 if (name
.equals(params
[i
].getName()))
92 return (LinkerParam
) params
[i
];
96 public ProcessorParam
[] getParams() {
99 public String
[] getPreArguments() {
100 String
[] clone
= (String
[]) args
[0].clone();
103 public boolean getRebuild() {
106 public String
getStartupObject() {
107 return startupObject
;
109 public void link(CCTask task
, TargetInfo linkTarget
) throws BuildException
{
111 // AllSourcePath's include any syslibsets
113 String
[] sourcePaths
= linkTarget
.getAllSourcePaths();
114 linker
.link(task
, linkTarget
.getOutput(), sourcePaths
, this);
116 public String
toString() {