diff options
author | darius42 <[email protected]> | 2007-09-21 17:57:00 +0000 |
---|---|---|
committer | darius42 <[email protected]> | 2007-09-21 17:57:00 +0000 |
commit | 669990903206d83b4f2c11974cc29dce576a5789 (patch) | |
tree | 7386878e21a208ec5f1633d15fa94cd2d46ca213 | |
parent | 91b61f8842a491f1bf9cb6d59f648b6eb5f16190 (diff) |
Fix for bug 1794867 - LinkerDef wasn't correctly handling references.
Refactored code so that it relies on the correct behavior in ProcessorDef.
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/cpptasks/trunk@145 32d7a393-a5a9-423c-abd3-5d954feb1f2f
3 files changed, 49 insertions, 25 deletions
diff --git a/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java b/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java index af1d307..b2e39d7 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/LinkerDef.java @@ -115,30 +115,6 @@ public class LinkerDef extends ProcessorDef { sysLibrarySets.addElement(libset); } - - public ProcessorConfiguration createConfiguration(CCTask task, - LinkType linkType, ProcessorDef baseDef, - TargetDef targetPlatform, - VersionInfo versionInfo) { - // - // must combine some local context (the linkType) - // with the referenced element - // - // get a pointer to the definition (either local or referenced) - ProcessorDef thisDef = this; - if (isReference()) { - thisDef = ((ProcessorDef) getCheckedRef(ProcessorDef.class, - "ProcessorDef")); - } - // - // find the appropriate processor (combines local linkType - // with possibly remote linker name) - Processor proc = getProcessor(); - proc = proc.getLinker(linkType); - ProcessorDef[] defaultProviders = getDefaultProviders(baseDef); - return proc.createConfiguration(task, linkType, defaultProviders, - thisDef, targetPlatform, versionInfo); - } public void execute() throws org.apache.tools.ant.BuildException { throw new org.apache.tools.ant.BuildException( "Not an actual task, but looks like one for documentation purposes"); @@ -281,6 +257,12 @@ public class LinkerDef extends ProcessorDef { } return linker; } + + public Processor getProcessor(LinkType linkType) { + Processor proc = getProcessor(); + return proc.getLinker(linkType); + } + public int getStack(LinkerDef[] defaultProviders, int index) { if (isReference()) { return ((LinkerDef) getCheckedRef(LinkerDef.class, "LinkerDef")) diff --git a/src/main/java/net/sf/antcontrib/cpptasks/ProcessorDef.java b/src/main/java/net/sf/antcontrib/cpptasks/ProcessorDef.java index 334efa6..864be59 100644 --- a/src/main/java/net/sf/antcontrib/cpptasks/ProcessorDef.java +++ b/src/main/java/net/sf/antcontrib/cpptasks/ProcessorDef.java @@ -188,7 +188,7 @@ public abstract class ProcessorDef extends DataType { baseDef, targetPlatform, versionInfo); } ProcessorDef[] defaultProviders = getDefaultProviders(baseDef); - Processor proc = getProcessor(); + Processor proc = getProcessor(linkType); return proc.createConfiguration(task, linkType, defaultProviders, this, targetPlatform, versionInfo); } /** @@ -358,6 +358,17 @@ public abstract class ProcessorDef extends DataType { } return processor; } + + /** + * Obtains the appropriate processor (compiler, linker) based on the + * LinkType. + * + * @return processor + */ + protected Processor getProcessor(LinkType linkType) { + // by default ignore the linkType. + return getProcessor(); + } /** * Gets a boolean value indicating whether all targets must be rebuilt * regardless of dependency analysis. diff --git a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java index 9387d5b..994b068 100644 --- a/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java +++ b/src/test/java/net/sf/antcontrib/cpptasks/TestLinkerDef.java @@ -26,8 +26,10 @@ import net.sf.antcontrib.cpptasks.types.FlexLong; import net.sf.antcontrib.cpptasks.types.LibrarySet; import net.sf.antcontrib.cpptasks.types.LinkerArgument; import net.sf.antcontrib.cpptasks.types.SystemLibrarySet; +import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.types.FlexInteger; +import org.apache.tools.ant.types.Reference; /** * Tests for LinkerDef class. @@ -152,6 +154,35 @@ public final class TestLinkerDef } /** + * Verify linkerarg's that appear in the base linker are effective when + * creating the command line for a linker that extends it, even if the + * linker is brought in through a reference. + */ + public void testExtendsLinkerArgsViaReference() { + Project project = new Project(); + LinkerDef baseLinker = new LinkerDef(); + baseLinker.setProject(project); + baseLinker.setId("base"); + project.addReference("base", baseLinker); + LinkerArgument linkerArg = new LinkerArgument(); + linkerArg.setValue("/base"); + baseLinker.addConfiguredLinkerArg(linkerArg); + + LinkerDef extendedLinker = (LinkerDef) createExtendedProcessorDef( + baseLinker); + extendedLinker.setProject(project); + extendedLinker.setId("extended"); + project.addReference("extended", extendedLinker); + + LinkerDef linkerRef = new LinkerDef(); + linkerRef.setProject(project); + linkerRef.setRefid(new Reference(project, "extended")); + String[] preArgs = getPreArguments(linkerRef); + assertEquals(1, preArgs.length); + assertEquals("/base", preArgs[0]); + } + + /** * Tests that fileset's that appear in the base linker are effective when * creating the command line for a linker that extends it. * @throws IOException if unable to create or delete temporary file |