Index: src/cpptasks.types =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/cpptasks.types,v retrieving revision 1.1 diff -u -r1.1 cpptasks.types --- src/cpptasks.types 10 Apr 2002 04:31:53 -0000 1.1 +++ src/cpptasks.types 3 Mar 2004 02:50:58 -0000 @@ -1,3 +1,5 @@ defineset=net.sf.antcontrib.cpptasks.types.DefineSet compiler=net.sf.antcontrib.cpptasks.CompilerDef linker=net.sf.antcontrib.cpptasks.LinkerDef +syslibset=net.sf.antcontrib.cpptasks.types.SystemLibrarySet +libset=net.sf.antcontrib.cpptasks.types.LibrarySet Index: src/net/sf/antcontrib/cpptasks/types/LibrarySet.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/src/net/sf/antcontrib/cpptasks/types/LibrarySet.java,v retrieving revision 1.25 diff -u -r1.25 LibrarySet.java --- src/net/sf/antcontrib/cpptasks/types/LibrarySet.java 28 Feb 2004 20:03:43 -0000 1.25 +++ src/net/sf/antcontrib/cpptasks/types/LibrarySet.java 3 Mar 2004 02:50:58 -0000 @@ -1,5 +1,5 @@ /* - * + * * Copyright 2001-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,22 +27,24 @@ import org.apache.tools.ant.ProjectComponent; import org.apache.tools.ant.types.FileSet; import org.apache.tools.ant.types.PatternSet; +import org.apache.tools.ant.types.DataType; + /** * A set of library names. Libraries can also be added to a link by specifying * them in a fileset. - * + * * For most Unix-like compilers, libset will result in a series of -l and -L * linker arguments. For Windows compilers, the library names will be used to * locate the appropriate library files which will be added to the linkers * input file list as if they had been specified in a fileset. - * + * * @author Mark A Russell mark_russell@csg_systems.com * * @author Adam Murdoch * @author Curt Arnold */ -public class LibrarySet extends ProjectComponent { +public class LibrarySet extends DataType { private String dataset; private boolean explicitCaseSensitive; private String ifCond; @@ -58,7 +60,7 @@ } /** * Gets the dataset. Used on OS390 if the libs are in a dataset. - * + * * @return Returns a String */ public String getDataset() { @@ -111,6 +113,11 @@ return false; } } + if (isReference()) { + LibrarySet master = ((LibrarySet)getCheckedRef(LibrarySet.class, "LibrarySet")); + return master.isActive(project); + } + if (libnames.length == 0) { p.log("libnames not specified or empty.", Project.MSG_WARN); return false; @@ -120,7 +127,7 @@ /** * Sets case sensitivity of the file system. If not set, will default to * the linker's case sensitivity. - * + * * @param isCaseSensitive * "true"|"on"|"yes" if file system is case sensitive, * "false"|"off"|"no" when not. @@ -131,7 +138,7 @@ } /** * Sets the dataset. Used on OS390 if the libs are in a dataset. - * + * * @param dataset * The dataset to set */ @@ -140,23 +147,23 @@ } /** * Library directory. - * + * * @param dir * library directory - * + * */ public void setDir(File dir) throws BuildException { set.setDir(dir); } /** * Sets the property name for the 'if' condition. - * + * * The library set will be ignored unless the property is defined. - * + * * The value of the property is insignificant, but values that would imply * misinterpretation ("false", "no") will throw an exception when * evaluated. - * + * * @param propName * property name */ @@ -166,10 +173,13 @@ /** * Comma-separated list of library names without leading prefixes, such as * "lib", or extensions, such as ".so" or ".a". - * + * */ public void setLibs(CUtil.StringArrayBuilder libs) throws BuildException { libnames = libs.getValue(); + getProject().log("setLibs() libnames = "+java.util.Arrays.asList(libnames), + Project.MSG_DEBUG); + // If this is not active.. then it's ok if the lib names are invalid. // so we can do a: if (!isActive(getProject())) @@ -200,13 +210,13 @@ } /** * Set the property name for the 'unless' condition. - * + * * If named property is set, the library set will be ignored. - * + * * The value of the property is insignificant, but values that would imply * misinterpretation ("false", "no") of the behavior will throw an * exception when evaluated. - * + * * @param propName * name of property */ @@ -215,6 +225,12 @@ } public void visitLibraries(Project project, Linker linker, File[] libpath, FileVisitor visitor) throws BuildException { + if (isReference()) { + LibrarySet master = ((LibrarySet)getCheckedRef(LibrarySet.class, "LibrarySet")); + project.log("LibrarySet is a reference to "+master,Project.MSG_DEBUG); + master.visitLibraries(project,linker,libpath,visitor); + return; + } FileSet localSet = (FileSet) set.clone(); // // unless explicitly set @@ -230,6 +246,8 @@ // if (libnames != null && libnames.length > 0) { String[] patterns = linker.getLibraryPatterns(libnames); + project.log("Library patterns = "+java.util.Arrays.asList(patterns), + Project.MSG_DEBUG); for (int i = 0; i < patterns.length; i++) { PatternSet.NameEntry entry = localSet.createInclude(); entry.setName(patterns[i]); @@ -250,6 +268,8 @@ DirectoryScanner scanner = clone.getDirectoryScanner(project); File basedir = scanner.getBasedir(); String[] files = scanner.getIncludedFiles(); + project.log("Files for libpath '"+libpath[j]+"' = "+java.util.Arrays.asList(files), + Project.MSG_DEBUG); for (int k = 0; k < files.length; k++) { visitor.visit(basedir, files[k]); } @@ -258,6 +278,8 @@ DirectoryScanner scanner = localSet.getDirectoryScanner(project); File basedir = scanner.getBasedir(); String[] files = scanner.getIncludedFiles(); + project.log("Files for dir '"+basedir+"' = "+java.util.Arrays.asList(files), + Project.MSG_DEBUG); for (int k = 0; k < files.length; k++) { visitor.visit(basedir, files[k]); } Index: test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java,v retrieving revision 1.2 diff -u -r1.2 MockBuildListener.java --- test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java 28 Feb 2004 20:04:46 -0000 1.2 +++ test/junit/net/sf/antcontrib/cpptasks/MockBuildListener.java 3 Mar 2004 02:50:58 -0000 @@ -1,5 +1,5 @@ /* - * + * * Copyright 2003-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,12 +16,13 @@ */ package net.sf.antcontrib.cpptasks; import java.util.Vector; +import java.util.Enumeration; import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildListener; /** * Captures build events - * + * */ public class MockBuildListener implements BuildListener { private Vector buildFinishedEvents = new Vector(); @@ -34,11 +35,11 @@ /** * Signals that the last target has finished. This event will still be * fired if an error occurred during the build. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getException() */ public void buildFinished(BuildEvent event) { @@ -47,7 +48,7 @@ /** * Signals that a build has started. This event is fired before any targets * have started. - * + * * @param event * An event with any relevant extra information. Must not be * null. @@ -60,7 +61,7 @@ } /** * Gets a list of buildStarted events - * + * * @return list of build started events */ public Vector getBuildStartedEvents() { @@ -68,15 +69,32 @@ } /** * Gets message logged events - * + * * @return */ public Vector getMessageLoggedEvents() { return new Vector(messageLoggedEvents); } /** + * Gets message logged events for the given priority + * + * @return the vector of message logged events with the specified + * priority + */ + public Vector getMessageLoggedEvents(int priority) { + Vector result = new Vector(); + Enumeration e = messageLoggedEvents.elements(); + while (e.hasMoreElements()) { + BuildEvent evt = (BuildEvent)e.nextElement(); + if (evt.getPriority() == priority) { + result.add(evt); + } + } + return result; + } + /** * Gets target finished events - * + * * @return */ public Vector getTargetFinishedEvents() { @@ -84,7 +102,7 @@ } /** * Gets target started events - * + * * @return */ public Vector getTargetStartedEvents() { @@ -92,7 +110,7 @@ } /** * Gets task finished events - * + * * @return */ public Vector getTaskFinishedEvents() { @@ -100,7 +118,7 @@ } /** * Gets task started events - * + * * @return */ public Vector getTaskStartedEvents() { @@ -108,11 +126,11 @@ } /** * Signals a message logging event. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getMessage() * @see BuildEvent#getPriority() */ @@ -122,11 +140,11 @@ /** * Signals that a target has finished. This event will still be fired if an * error occurred during the build. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getException() */ public void targetFinished(BuildEvent event) { @@ -134,11 +152,11 @@ } /** * Signals that a target is starting. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getTarget() */ public void targetStarted(BuildEvent event) { @@ -147,11 +165,11 @@ /** * Signals that a task has finished. This event will still be fired if an * error occurred during the build. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getException() */ public void taskFinished(BuildEvent event) { @@ -159,11 +177,11 @@ } /** * Signals that a task is starting. - * + * * @param event * An event with any relevant extra information. Must not be * null. - * + * * @see BuildEvent#getTask() */ public void taskStarted(BuildEvent event) { Index: test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java =================================================================== RCS file: /cvsroot/ant-contrib/cpptasks/test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java,v retrieving revision 1.10 diff -u -r1.10 TestLibrarySet.java --- test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java 28 Feb 2004 20:04:47 -0000 1.10 +++ test/junit/net/sf/antcontrib/cpptasks/types/TestLibrarySet.java 3 Mar 2004 02:50:58 -0000 @@ -1,5 +1,5 @@ /* - * + * * Copyright 2002-2004 The Ant-Contrib project * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -108,7 +108,7 @@ libset.setProject(p); CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder("mylib1.1"); libset.setLibs(libs); - assertEquals(0, listener.getMessageLoggedEvents().size()); + assertEquals(0, listener.getMessageLoggedEvents().size(), Project.MSG_WARN); } /** * The libs parameter should not end with .lib, .so, .a etc however the @@ -124,7 +124,7 @@ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder( "mylib1.lib"); libset.setLibs(libs); - assertEquals(1, listener.getMessageLoggedEvents().size()); + assertEquals(1, listener.getMessageLoggedEvents().size(), Project.MSG_INFO); } /** * Use of a libset or syslibset without a libs attribute should log a @@ -164,6 +164,6 @@ CUtil.StringArrayBuilder libs = new CUtil.StringArrayBuilder( "libmylib1"); libset.setLibs(libs); - assertEquals(1, listener.getMessageLoggedEvents().size()); + assertEquals(1, listener.getMessageLoggedEvents(Project.MSG_INFO).size()); } }