3 * Copyright 2001-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
.gcc
;
19 import java
.util
.Vector
;
21 import net
.sf
.antcontrib
.cpptasks
.CCTask
;
22 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineLinker
;
23 import net
.sf
.antcontrib
.cpptasks
.compiler
.CommandLineLinkerConfiguration
;
24 import net
.sf
.antcontrib
.cpptasks
.compiler
.LinkType
;
25 import net
.sf
.antcontrib
.cpptasks
.types
.LibraryTypeEnum
;
27 import org
.apache
.tools
.ant
.BuildException
;
29 * Adapter for the "ar" tool
31 * @author Adam Murdoch
34 public abstract class AbstractArLibrarian
extends CommandLineLinker
{
37 private static String
[] defaultflags
= new String
[]{};
38 protected AbstractArLibrarian(String command
, String identificationArg
,
39 String
[] inputExtensions
, String
[] ignoredExtensions
,
40 String outputPrefix
, String outputExtension
, boolean isLibtool
,
41 AbstractArLibrarian libtoolLibrarian
) {
42 super(command
, identificationArg
, inputExtensions
, ignoredExtensions
,
43 outputExtension
, isLibtool
, libtoolLibrarian
);
44 this.outputPrefix
= outputPrefix
;
46 public void addBase(long base
, Vector args
) {
48 public void addFixed(Boolean fixed
, Vector args
) {
50 public void addImpliedArgs(boolean debug
, LinkType linkType
, Vector args
, Boolean defaultflag
) {
51 if(defaultflag
!= null && defaultflag
.booleanValue()){
52 for (int i
= 0; i
< defaultflags
.length
; i
++) {
53 args
.addElement(defaultflags
[i
]);
57 public void addIncremental(boolean incremental
, Vector args
) {
59 public void addMap(boolean map
, Vector args
) {
61 public void addStack(int stack
, Vector args
) {
64 * @see net.sf.antcontrib.cpptasks.compiler.CommandLineLinker#addEntry(int, java.util.Vector)
66 protected void addEntry(String entry
, Vector args
) {
69 public String
getCommandFileSwitch(String commandFile
) {
72 public File
[] getLibraryPath() {
75 public String
[] getLibraryPatterns(String
[] libnames
, LibraryTypeEnum libType
) {
78 public int getMaximumCommandLength() {
79 return Integer
.MAX_VALUE
;
81 public String
getOutputFileName(String baseName
) {
82 return outputPrefix
+ super.getOutputFileName(baseName
);
84 public String
[] getOutputFileSwitch(String outputFile
) {
85 return GccProcessor
.getOutputFileSwitch("rvs", outputFile
);
87 public boolean isCaseSensitive() {
90 public void link(CCTask task
, File outputFile
, String
[] sourceFiles
,
91 CommandLineLinkerConfiguration config
) throws BuildException
{
93 // if there is an existing library then
94 // we must delete it before executing "ar"
95 if (outputFile
.exists()) {
96 if (!outputFile
.delete()) {
97 throw new BuildException("Unable to delete "
98 + outputFile
.getAbsolutePath());
102 // delegate to CommandLineLinker
104 super.link(task
, outputFile
, sourceFiles
, config
);