+++ /dev/null
-/*\r
- * \r
- * Copyright 2001-2004 The Ant-Contrib project\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-package net.sf.antcontrib.cpptasks.gcc.cross;\r
-import java.io.File;\r
-\r
-import net.sf.antcontrib.cpptasks.CCTask;\r
-import net.sf.antcontrib.cpptasks.LinkerParam;\r
-import net.sf.antcontrib.cpptasks.compiler.CommandLineLinkerConfiguration;\r
-import net.sf.antcontrib.cpptasks.compiler.LinkType;\r
-import net.sf.antcontrib.cpptasks.compiler.Linker;\r
-import net.sf.antcontrib.cpptasks.gcc.AbstractLdLinker;\r
-\r
-import org.apache.tools.ant.BuildException;\r
-/**\r
- * Adapter for the 'ld' linker\r
- * \r
- * @author Curt Arnold\r
- */\r
-public final class LdLinker extends AbstractLdLinker {\r
- private static final String[] libtoolObjFiles = new String[]{".fo", ".a",\r
- ".lib", ".dll", ".so", ".sl"};\r
- private static final String[] objFiles = new String[]{".o", ".a", ".lib",\r
- ".dll", ".so", ".sl"};\r
- private static final String[] discardFiles = new String[0];\r
- private static final LdLinker dllLinker = new LdLinker("ld", objFiles,\r
- discardFiles, "lib", ".so", false, new LdLinker("ld", objFiles,\r
- discardFiles, "lib", ".so", true, null));\r
- private static final LdLinker instance = new LdLinker("ld", objFiles,\r
- discardFiles, "", "", false, null);\r
- public static LdLinker getInstance() {\r
- return instance;\r
- }\r
- private File[] libDirs;\r
- private LdLinker(String command, String[] extensions,\r
- String[] ignoredExtensions, String outputPrefix,\r
- String outputSuffix, boolean isLibtool, LdLinker libtoolLinker) {\r
- super(command, "-version", extensions, ignoredExtensions, outputPrefix,\r
- outputSuffix, isLibtool, libtoolLinker);\r
- }\r
- protected Object clone() throws CloneNotSupportedException {\r
- LdLinker clone = (LdLinker) super.clone();\r
- return clone;\r
- }\r
- public Linker getLinker(LinkType type) {\r
- if (type.isStaticLibrary()) {\r
- return GccLibrarian.getInstance();\r
- }\r
- if (type.isSharedLibrary()) {\r
- return dllLinker;\r
- }\r
- return instance;\r
- }\r
- public void link(CCTask task, File outputFile, String[] sourceFiles,\r
- CommandLineLinkerConfiguration config) throws BuildException {\r
- try {\r
- LdLinker clone = (LdLinker) this.clone();\r
- LinkerParam param = config.getParam("target");\r
- if (param != null)\r
- clone.setCommand(param.getValue() + "-" + this.getCommand());\r
- clone.superlink(task, outputFile, sourceFiles, config);\r
- } catch (CloneNotSupportedException e) {\r
- superlink(task, outputFile, sourceFiles, config);\r
- }\r
- }\r
- private void superlink(CCTask task, File outputFile, String[] sourceFiles,\r
- CommandLineLinkerConfiguration config) throws BuildException {\r
- super.link(task, outputFile, sourceFiles, config);\r
- }\r
-}\r