Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java
32285 views
import static java.nio.file.FileVisitResult.CONTINUE;12import java.io.IOException;3import java.nio.file.FileSystems;4import java.nio.file.FileVisitResult;5import java.nio.file.Files;6import java.nio.file.Path;7import java.nio.file.attribute.BasicFileAttributes;8import java.util.Stack;9import java.util.Vector;1011public class FileTreeCreatorVC7 extends FileTreeCreator {1213public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {14super(startDir, allConfigs, wg);15}1617@Override18public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {19DirAttributes currentFileAttr = attributes.peek().clone();20boolean usePch = false;21boolean disablePch = false;22boolean useIgnore = false;23String fileName = file.getFileName().toString();2425// usePch applies to all configs for a file.26if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {27usePch = true;28}2930for (BuildConfig cfg : allConfigs) {31if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {32useIgnore = true;33currentFileAttr.setIgnore(cfg);34} else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {35useIgnore = true;36currentFileAttr.setIgnore(cfg);37}3839if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {40disablePch = true;41currentFileAttr.setDisablePch(cfg);42}4344Vector<String> rv = new Vector<String>();45cfg.collectRelevantVectors(rv, "AdditionalFile");46for(String addFile : rv) {47if (addFile.equals(fileName)) {48// supress any ignore49currentFileAttr.removeFromIgnored(cfg);50}51}52}5354if (!useIgnore && !disablePch && !usePch) {55wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});56} else {57wg.startTag(58"File",59new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});6061for (BuildConfig cfg : allConfigs) {62boolean ignore = currentFileAttr.hasIgnore(cfg);63String [] fileConfAttr;6465if (ignore) {66fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };67} else {68fileConfAttr = new String[] {"Name", cfg.get("Name")};69}7071if (!disablePch && !usePch && !ignore) {72continue;73} else if (!disablePch && !usePch) {74wg.tag("FileConfiguration", fileConfAttr);75} else {76wg.startTag("FileConfiguration", fileConfAttr);77if (usePch) {78// usePch always applies to all configs, might not always be so.79wg.tag("Tool", new String[] {80"Name", "VCCLCompilerTool", "UsePrecompiledHeader",81"1" });82assert(!disablePch);83}84if (disablePch) {85if (currentFileAttr.hasDisablePch(cfg)) {86wg.tag("Tool", new String[] {87"Name", "VCCLCompilerTool", "UsePrecompiledHeader",88"0" });89}90assert(!usePch);91}92wg.endTag();93}94}95wg.endTag();96}9798return CONTINUE;99}100101@Override102public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)103throws IOException {104Boolean hide = false;105DirAttributes newAttr = attributes.peek().clone();106107String rPath;108if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){109rPath = startDir.toString();110} else {111rPath = path.getFileName().toString();112}113114// check per config ignorePaths!115for (BuildConfig cfg : allConfigs) {116if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {117newAttr.setIgnore(cfg);118}119120// Hide is always on all configs. And additional files are never hiddden121if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {122hide = true;123break;124}125}126127if (!hide) {128wg.startTag("Filter", new String[] {129"Name", rPath});130131attributes.push(newAttr);132return super.preVisitDirectory(path, attrs);133} else {134return FileVisitResult.SKIP_SUBTREE;135}136}137138@Override139public FileVisitResult postVisitDirectory(Path dir, IOException exc) {140//end matching attributes set by ignorepath141wg.endTag();142attributes.pop();143144return CONTINUE;145}146147@Override148public FileVisitResult visitFileFailed(Path file, IOException exc) {149return CONTINUE;150}151152public void writeFileTree() throws IOException {153Files.walkFileTree(this.startDir, this);154}155}156157