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 FileTreeCreatorVC7 extends FileTreeCreator {
4019N/A
4019N/A public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
4019N/A super(startDir, allConfigs, null);
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 // 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 currentFileAttr.removeFromIgnored(cfg);
4019N/A }
4019N/A }
4019N/A }
4019N/A
4019N/A if (!useIgnore && !disablePch && !usePch) {
4019N/A wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
4019N/A } else {
4019N/A wg.startTag(
4019N/A "File",
4019N/A new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
4019N/A
4019N/A for (BuildConfig cfg : allConfigs) {
4019N/A boolean ignore = currentFileAttr.hasIgnore(cfg);
4019N/A String [] fileConfAttr;
4019N/A
4019N/A if (ignore) {
4019N/A fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
4019N/A } else {
4019N/A fileConfAttr = new String[] {"Name", cfg.get("Name")};
4019N/A }
4019N/A
4019N/A if (!disablePch && !usePch && !ignore) {
4019N/A continue;
4019N/A } else if (!disablePch && !usePch) {
4019N/A wg.tag("FileConfiguration", fileConfAttr);
4019N/A } else {
4019N/A wg.startTag("FileConfiguration", fileConfAttr);
4019N/A if (usePch) {
4019N/A // usePch always applies to all configs, might not always be so.
4019N/A wg.tag("Tool", new String[] {
4019N/A "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
4019N/A "1" });
4019N/A assert(!disablePch);
4019N/A }
4019N/A if (disablePch) {
4019N/A if (currentFileAttr.hasDisablePch(cfg)) {
4019N/A wg.tag("Tool", new String[] {
4019N/A "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
4019N/A "0" });
4019N/A }
4019N/A assert(!usePch);
4019N/A }
4019N/A wg.endTag();
4019N/A }
4019N/A }
4019N/A wg.endTag();
4019N/A }
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 DirAttributes newAttr = attributes.peek().clone();
4019N/A
4019N/A String rPath;
4019N/A if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
4019N/A rPath = startDir.toString();
4019N/A } else {
4019N/A rPath = path.getFileName().toString();
4019N/A }
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 wg.startTag("Filter", new String[] {
4019N/A "Name", rPath});
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 wg.endTag();
4019N/A attributes.pop();
4019N/A
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 }