4019N/Aimport static java.nio.file.FileVisitResult.CONTINUE;
4019N/A
4019N/Aimport java.io.IOException;
4019N/Aimport java.nio.file.FileSystems;
4019N/Aimport java.nio.file.FileVisitResult;
4019N/Aimport java.nio.file.Files;
4019N/Aimport java.nio.file.Path;
4019N/Aimport java.nio.file.attribute.BasicFileAttributes;
4019N/Aimport java.util.Stack;
4019N/Aimport java.util.Vector;
4019N/A
4019N/Apublic class FileTreeCreatorVC10 extends FileTreeCreator {
4019N/A
4019N/A public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) {
4019N/A super(startDir, allConfigs, wg);
4019N/A }
4019N/A
4019N/A @Override
4019N/A public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
4019N/A DirAttributes currentFileAttr = attributes.peek().clone();
4019N/A boolean usePch = false;
4019N/A boolean disablePch = false;
4019N/A boolean useIgnore = false;
4019N/A String fileName = file.getFileName().toString();
4019N/A
4019N/A // TODO hideFile
4019N/A
4019N/A // usePch applies to all configs for a file.
4019N/A if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
4019N/A usePch = true;
4019N/A }
4019N/A
4019N/A for (BuildConfig cfg : allConfigs) {
4019N/A if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
4019N/A useIgnore = true;
4019N/A currentFileAttr.setIgnore(cfg);
4019N/A } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
4019N/A useIgnore = true;
4019N/A currentFileAttr.setIgnore(cfg);
4019N/A }
4019N/A
4019N/A if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
4019N/A disablePch = true;
4019N/A currentFileAttr.setDisablePch(cfg);
4019N/A }
4019N/A
4019N/A Vector<String> rv = new Vector<String>();
4019N/A cfg.collectRelevantVectors(rv, "AdditionalFile");
4019N/A for(String addFile : rv) {
4019N/A if (addFile.equals(fileName)) {
4019N/A // supress any ignore
4019N/A // TODO - may need some adjustments
4019N/A if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) {
4019N/A currentFileAttr.removeFromIgnored(cfg);
4019N/A }
4019N/A }
4019N/A }
4019N/A }
4019N/A
4019N/A String tagName = wg.getFileTagFromSuffix(fileName);
4019N/A String fileLoc = vcProjLocation.relativize(file).toString();
4019N/A
4019N/A if (!useIgnore && !disablePch && !usePch) {
4019N/A wg.tag(tagName, new String[] { "Include", fileLoc});
4019N/A } else {
4019N/A wg.startTag(
4019N/A tagName,
4019N/A new String[] { "Include", fileLoc});
4019N/A
4019N/A for (BuildConfig cfg : allConfigs) {
4019N/A boolean ignore = currentFileAttr.hasIgnore(cfg);
4019N/A if (ignore) {
4019N/A wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
4019N/A }
4019N/A if (usePch) {
4019N/A wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
4019N/A }
4019N/A if (disablePch) {
4019N/A wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
4019N/A }
4019N/A }
4019N/A wg.endTag();
4019N/A }
4019N/A
4019N/A String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString();
4019N/A wg.addFilterDependency(fileLoc, filter);
4019N/A
4019N/A return CONTINUE;
4019N/A }
4019N/A
4019N/A @Override
4019N/A public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
4019N/A throws IOException {
4019N/A Boolean hide = false;
4019N/A // TODO remove attrs, if path is matched in this dir, then it is too in every subdir.
4019N/A // And we will check anyway
4019N/A DirAttributes newAttr = attributes.peek().clone();
4019N/A
4019N/A // check per config ignorePaths!
4019N/A for (BuildConfig cfg : allConfigs) {
4019N/A if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
4019N/A newAttr.setIgnore(cfg);
4019N/A }
4019N/A
4019N/A // Hide is always on all configs. And additional files are never hiddden
4019N/A if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
4019N/A hide = true;
4019N/A break;
4019N/A }
4019N/A }
4019N/A
4019N/A if (!hide) {
4019N/A String name = startDir.relativize(path.toAbsolutePath()).toString();
4019N/A if (!"".equals(name)) {
4019N/A wg.addFilter(name);
4019N/A }
4019N/A
4019N/A attributes.push(newAttr);
4019N/A return super.preVisitDirectory(path, attrs);
4019N/A } else {
4019N/A return FileVisitResult.SKIP_SUBTREE;
4019N/A }
4019N/A }
4019N/A
4019N/A @Override
4019N/A public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
4019N/A //end matching attributes set by ignorepath
4019N/A attributes.pop();
4019N/A return CONTINUE;
4019N/A }
4019N/A
4019N/A @Override
4019N/A public FileVisitResult visitFileFailed(Path file, IOException exc) {
4019N/A return CONTINUE;
4019N/A }
4019N/A
4019N/A public void writeFileTree() throws IOException {
4019N/A Files.walkFileTree(this.startDir, this);
4019N/A }
4019N/A
4019N/A
4019N/A }