Ejemplo n.º 1
0
 public void visitLibraries(
     final Project project, final Linker linker, final File[] libpath, final FileVisitor visitor)
     throws BuildException {
   if (isReference()) {
     final LibrarySet master = (LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet");
     master.visitLibraries(project, linker, libpath, visitor);
   }
   //
   // if there was a libs attribute then
   // add the corresponding patterns to the FileSet
   //
   if (this.libnames != null) {
     for (final String libname : this.libnames) {
       final String[] patterns =
           linker.getLibraryPatterns(new String[] {libname}, this.libraryType);
       if (patterns.length > 0) {
         final FileSet localSet = (FileSet) this.set.clone();
         //
         // unless explicitly set
         // will default to the linker case sensitivity
         //
         if (!this.explicitCaseSensitive) {
           final boolean linkerCaseSensitive = linker.isCaseSensitive();
           localSet.setCaseSensitive(linkerCaseSensitive);
         }
         //
         // add all the patterns for this libname
         //
         for (final String pattern : patterns) {
           final PatternSet.NameEntry entry = localSet.createInclude();
           entry.setName(pattern);
         }
         int matches = 0;
         //
         // if there was no specified directory then
         // run through the libpath backwards
         //
         if (localSet.getDir(project) == null) {
           //
           // scan libpath in reverse order
           // to give earlier entries priority
           //
           for (int j = libpath.length - 1; j >= 0; j--) {
             final FileSet clone = (FileSet) localSet.clone();
             clone.setDir(libpath[j]);
             final DirectoryScanner scanner = clone.getDirectoryScanner(project);
             final File basedir = scanner.getBasedir();
             final String[] files = scanner.getIncludedFiles();
             matches += files.length;
             for (final String file : files) {
               visitor.visit(basedir, file);
             }
           }
         } else {
           final DirectoryScanner scanner = localSet.getDirectoryScanner(project);
           final File basedir = scanner.getBasedir();
           final String[] files = scanner.getIncludedFiles();
           matches += files.length;
           for (final String file : files) {
             visitor.visit(basedir, file);
           }
         }
         //
         // TODO: following section works well for Windows
         // style linkers but unnecessary fails
         // Unix style linkers. Will need to revisit.
         //
         if (matches == 0) {
           final StringBuffer msg = new StringBuffer("No file matching ");
           if (patterns.length == 1) {
             msg.append("pattern (");
             msg.append(patterns[0]);
             msg.append(")");
           } else {
             msg.append("patterns (\"");
             msg.append(patterns[0]);
             for (int k = 1; k < patterns.length; k++) {
               msg.append(", ");
               msg.append(patterns[k]);
             }
             msg.append(")");
           }
           msg.append(" for library name \"");
           msg.append(libname);
           msg.append("\" was found.");
           // TODO: raising the message in the log rather
           // throw new BuildException(msg.toString());
           project.log(msg.toString(), Project.MSG_WARN);
         }
       }
     }
   }
 }