src/share/tools/ProjectCreator/FileTreeCreatorVC7.java

changeset 4112
1a9b9cfcef41
child 5507
bd0e82136b03
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java	Thu Mar 29 16:43:21 2012 +0200
     1.3 @@ -0,0 +1,156 @@
     1.4 +import static java.nio.file.FileVisitResult.CONTINUE;
     1.5 +
     1.6 +import java.io.IOException;
     1.7 +import java.nio.file.FileSystems;
     1.8 +import java.nio.file.FileVisitResult;
     1.9 +import java.nio.file.Files;
    1.10 +import java.nio.file.Path;
    1.11 +import java.nio.file.attribute.BasicFileAttributes;
    1.12 +import java.util.Stack;
    1.13 +import java.util.Vector;
    1.14 +
    1.15 +public class FileTreeCreatorVC7 extends FileTreeCreator {
    1.16 +
    1.17 +      public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
    1.18 +         super(startDir, allConfigs, null);
    1.19 +      }
    1.20 +
    1.21 +      @Override
    1.22 +      public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
    1.23 +         DirAttributes currentFileAttr = attributes.peek().clone();
    1.24 +         boolean usePch = false;
    1.25 +         boolean disablePch = false;
    1.26 +         boolean useIgnore = false;
    1.27 +         String fileName = file.getFileName().toString();
    1.28 +
    1.29 +         // usePch applies to all configs for a file.
    1.30 +         if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
    1.31 +            usePch = true;
    1.32 +         }
    1.33 +
    1.34 +         for (BuildConfig cfg : allConfigs) {
    1.35 +            if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
    1.36 +               useIgnore = true;
    1.37 +               currentFileAttr.setIgnore(cfg);
    1.38 +            } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
    1.39 +               useIgnore = true;
    1.40 +               currentFileAttr.setIgnore(cfg);
    1.41 +            }
    1.42 +
    1.43 +            if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
    1.44 +               disablePch = true;
    1.45 +               currentFileAttr.setDisablePch(cfg);
    1.46 +            }
    1.47 +
    1.48 +            Vector<String> rv = new Vector<String>();
    1.49 +            cfg.collectRelevantVectors(rv, "AdditionalFile");
    1.50 +            for(String addFile : rv) {
    1.51 +               if (addFile.equals(fileName)) {
    1.52 +                  // supress any ignore
    1.53 +                  currentFileAttr.removeFromIgnored(cfg);
    1.54 +               }
    1.55 +            }
    1.56 +         }
    1.57 +
    1.58 +         if (!useIgnore && !disablePch && !usePch) {
    1.59 +            wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
    1.60 +         } else {
    1.61 +            wg.startTag(
    1.62 +                  "File",
    1.63 +                  new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
    1.64 +
    1.65 +            for (BuildConfig cfg : allConfigs) {
    1.66 +               boolean ignore = currentFileAttr.hasIgnore(cfg);
    1.67 +               String [] fileConfAttr;
    1.68 +
    1.69 +               if (ignore) {
    1.70 +                  fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
    1.71 +               } else {
    1.72 +                  fileConfAttr = new String[] {"Name", cfg.get("Name")};
    1.73 +               }
    1.74 +
    1.75 +               if (!disablePch && !usePch && !ignore) {
    1.76 +                  continue;
    1.77 +               } else if (!disablePch && !usePch) {
    1.78 +                  wg.tag("FileConfiguration", fileConfAttr);
    1.79 +               } else {
    1.80 +                  wg.startTag("FileConfiguration", fileConfAttr);
    1.81 +                  if (usePch) {
    1.82 +                     // usePch always applies to all configs, might not always be so.
    1.83 +                     wg.tag("Tool", new String[] {
    1.84 +                           "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
    1.85 +                     "1" });
    1.86 +                     assert(!disablePch);
    1.87 +                  }
    1.88 +                  if (disablePch) {
    1.89 +                     if (currentFileAttr.hasDisablePch(cfg)) {
    1.90 +                        wg.tag("Tool", new String[] {
    1.91 +                              "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
    1.92 +                        "0" });
    1.93 +                     }
    1.94 +                     assert(!usePch);
    1.95 +                  }
    1.96 +                  wg.endTag();
    1.97 +               }
    1.98 +            }
    1.99 +            wg.endTag();
   1.100 +         }
   1.101 +
   1.102 +         return CONTINUE;
   1.103 +      }
   1.104 +
   1.105 +      @Override
   1.106 +      public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
   1.107 +            throws IOException {
   1.108 +         Boolean hide = false;
   1.109 +         DirAttributes newAttr = attributes.peek().clone();
   1.110 +
   1.111 +         String rPath;
   1.112 +         if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
   1.113 +            rPath = startDir.toString();
   1.114 +         } else {
   1.115 +            rPath = path.getFileName().toString();
   1.116 +         }
   1.117 +
   1.118 +         // check per config ignorePaths!
   1.119 +         for (BuildConfig cfg : allConfigs) {
   1.120 +            if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
   1.121 +               newAttr.setIgnore(cfg);
   1.122 +            }
   1.123 +
   1.124 +            // Hide is always on all configs. And additional files are never hiddden
   1.125 +            if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
   1.126 +               hide = true;
   1.127 +               break;
   1.128 +            }
   1.129 +         }
   1.130 +
   1.131 +         if (!hide) {
   1.132 +            wg.startTag("Filter", new String[] {
   1.133 +                  "Name", rPath});
   1.134 +
   1.135 +            attributes.push(newAttr);
   1.136 +            return super.preVisitDirectory(path, attrs);
   1.137 +         } else {
   1.138 +            return FileVisitResult.SKIP_SUBTREE;
   1.139 +         }
   1.140 +      }
   1.141 +
   1.142 +      @Override
   1.143 +      public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
   1.144 +         //end matching attributes set by ignorepath
   1.145 +         wg.endTag();
   1.146 +         attributes.pop();
   1.147 +
   1.148 +         return CONTINUE;
   1.149 +      }
   1.150 +
   1.151 +      @Override
   1.152 +      public FileVisitResult visitFileFailed(Path file, IOException exc) {
   1.153 +         return CONTINUE;
   1.154 +      }
   1.155 +
   1.156 +      public void writeFileTree() throws IOException {
   1.157 +         Files.walkFileTree(this.startDir, this);
   1.158 +      }
   1.159 +   }
   1.160 \ No newline at end of file

mercurial