1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java Thu Mar 29 16:43:21 2012 +0200 1.3 @@ -0,0 +1,142 @@ 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 FileTreeCreatorVC10 extends FileTreeCreator { 1.16 + 1.17 + public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) { 1.18 + super(startDir, allConfigs, wg); 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 + // TODO hideFile 1.30 + 1.31 + // usePch applies to all configs for a file. 1.32 + if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) { 1.33 + usePch = true; 1.34 + } 1.35 + 1.36 + for (BuildConfig cfg : allConfigs) { 1.37 + if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) { 1.38 + useIgnore = true; 1.39 + currentFileAttr.setIgnore(cfg); 1.40 + } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) { 1.41 + useIgnore = true; 1.42 + currentFileAttr.setIgnore(cfg); 1.43 + } 1.44 + 1.45 + if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { 1.46 + disablePch = true; 1.47 + currentFileAttr.setDisablePch(cfg); 1.48 + } 1.49 + 1.50 + Vector<String> rv = new Vector<String>(); 1.51 + cfg.collectRelevantVectors(rv, "AdditionalFile"); 1.52 + for(String addFile : rv) { 1.53 + if (addFile.equals(fileName)) { 1.54 + // supress any ignore 1.55 + // TODO - may need some adjustments 1.56 + if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) { 1.57 + currentFileAttr.removeFromIgnored(cfg); 1.58 + } 1.59 + } 1.60 + } 1.61 + } 1.62 + 1.63 + String tagName = wg.getFileTagFromSuffix(fileName); 1.64 + String fileLoc = vcProjLocation.relativize(file).toString(); 1.65 + 1.66 + if (!useIgnore && !disablePch && !usePch) { 1.67 + wg.tag(tagName, new String[] { "Include", fileLoc}); 1.68 + } else { 1.69 + wg.startTag( 1.70 + tagName, 1.71 + new String[] { "Include", fileLoc}); 1.72 + 1.73 + for (BuildConfig cfg : allConfigs) { 1.74 + boolean ignore = currentFileAttr.hasIgnore(cfg); 1.75 + if (ignore) { 1.76 + wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); 1.77 + } 1.78 + if (usePch) { 1.79 + wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); 1.80 + } 1.81 + if (disablePch) { 1.82 + wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); 1.83 + } 1.84 + } 1.85 + wg.endTag(); 1.86 + } 1.87 + 1.88 + String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString(); 1.89 + wg.addFilterDependency(fileLoc, filter); 1.90 + 1.91 + return CONTINUE; 1.92 + } 1.93 + 1.94 + @Override 1.95 + public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) 1.96 + throws IOException { 1.97 + Boolean hide = false; 1.98 + // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. 1.99 + // And we will check anyway 1.100 + DirAttributes newAttr = attributes.peek().clone(); 1.101 + 1.102 + // check per config ignorePaths! 1.103 + for (BuildConfig cfg : allConfigs) { 1.104 + if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { 1.105 + newAttr.setIgnore(cfg); 1.106 + } 1.107 + 1.108 + // Hide is always on all configs. And additional files are never hiddden 1.109 + if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { 1.110 + hide = true; 1.111 + break; 1.112 + } 1.113 + } 1.114 + 1.115 + if (!hide) { 1.116 + String name = startDir.relativize(path.toAbsolutePath()).toString(); 1.117 + if (!"".equals(name)) { 1.118 + wg.addFilter(name); 1.119 + } 1.120 + 1.121 + attributes.push(newAttr); 1.122 + return super.preVisitDirectory(path, attrs); 1.123 + } else { 1.124 + return FileVisitResult.SKIP_SUBTREE; 1.125 + } 1.126 + } 1.127 + 1.128 + @Override 1.129 + public FileVisitResult postVisitDirectory(Path dir, IOException exc) { 1.130 + //end matching attributes set by ignorepath 1.131 + attributes.pop(); 1.132 + return CONTINUE; 1.133 + } 1.134 + 1.135 + @Override 1.136 + public FileVisitResult visitFileFailed(Path file, IOException exc) { 1.137 + return CONTINUE; 1.138 + } 1.139 + 1.140 + public void writeFileTree() throws IOException { 1.141 + Files.walkFileTree(this.startDir, this); 1.142 + } 1.143 + 1.144 + 1.145 + } 1.146 \ No newline at end of file