annotate src/share/tools/ProjectCreator/FileTreeCreatorVC7.java @ 11981:530fe88b3b2c hs25-b44

Merge
author amurillo
date Fri, 02 Aug 2013 02:54:47 -0700
parents 1a9b9cfcef41
children bd0e82136b03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6801
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
1 import static java.nio.file.FileVisitResult.CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
2
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
3 import java.io.IOException;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
4 import java.nio.file.FileSystems;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
5 import java.nio.file.FileVisitResult;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
6 import java.nio.file.Files;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
7 import java.nio.file.Path;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
8 import java.nio.file.attribute.BasicFileAttributes;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
9 import java.util.Stack;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
10 import java.util.Vector;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
11
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
12 public class FileTreeCreatorVC7 extends FileTreeCreator {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
13
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
14 public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform wg) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
15 super(startDir, allConfigs, null);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
16 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
17
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
18 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
19 public FileVisitResult visitFile(Path file, BasicFileAttributes attr) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
20 DirAttributes currentFileAttr = attributes.peek().clone();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
21 boolean usePch = false;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
22 boolean disablePch = false;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
23 boolean useIgnore = false;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
24 String fileName = file.getFileName().toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
25
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
26 // usePch applies to all configs for a file.
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
27 if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
28 usePch = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
29 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
30
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
31 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
32 if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
33 useIgnore = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
34 currentFileAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
35 } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
36 useIgnore = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
37 currentFileAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
38 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
39
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
40 if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
41 disablePch = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
42 currentFileAttr.setDisablePch(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
43 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
44
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
45 Vector<String> rv = new Vector<String>();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
46 cfg.collectRelevantVectors(rv, "AdditionalFile");
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
47 for(String addFile : rv) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
48 if (addFile.equals(fileName)) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
49 // supress any ignore
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
50 currentFileAttr.removeFromIgnored(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
51 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
52 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
53 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
54
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
55 if (!useIgnore && !disablePch && !usePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
56 wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
57 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
58 wg.startTag(
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
59 "File",
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
60 new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
61
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
62 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
63 boolean ignore = currentFileAttr.hasIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
64 String [] fileConfAttr;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
65
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
66 if (ignore) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
67 fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
68 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
69 fileConfAttr = new String[] {"Name", cfg.get("Name")};
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
70 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
71
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
72 if (!disablePch && !usePch && !ignore) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
73 continue;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
74 } else if (!disablePch && !usePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
75 wg.tag("FileConfiguration", fileConfAttr);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
76 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
77 wg.startTag("FileConfiguration", fileConfAttr);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
78 if (usePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
79 // usePch always applies to all configs, might not always be so.
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
80 wg.tag("Tool", new String[] {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
81 "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
82 "1" });
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
83 assert(!disablePch);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
84 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
85 if (disablePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
86 if (currentFileAttr.hasDisablePch(cfg)) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
87 wg.tag("Tool", new String[] {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
88 "Name", "VCCLCompilerTool", "UsePrecompiledHeader",
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
89 "0" });
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
90 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
91 assert(!usePch);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
92 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
93 wg.endTag();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
94 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
95 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
96 wg.endTag();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
97 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
98
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
99 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
100 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
101
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
102 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
103 public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
104 throws IOException {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
105 Boolean hide = false;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
106 DirAttributes newAttr = attributes.peek().clone();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
107
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
108 String rPath;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
109 if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
110 rPath = startDir.toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
111 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
112 rPath = path.getFileName().toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
113 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
114
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
115 // check per config ignorePaths!
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
116 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
117 if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
118 newAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
119 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
120
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
121 // Hide is always on all configs. And additional files are never hiddden
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
122 if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
123 hide = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
124 break;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
125 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
126 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
127
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
128 if (!hide) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
129 wg.startTag("Filter", new String[] {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
130 "Name", rPath});
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
131
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
132 attributes.push(newAttr);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
133 return super.preVisitDirectory(path, attrs);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
134 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
135 return FileVisitResult.SKIP_SUBTREE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
136 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
137 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
138
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
139 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
140 public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
141 //end matching attributes set by ignorepath
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
142 wg.endTag();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
143 attributes.pop();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
144
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
145 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
146 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
147
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
148 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
149 public FileVisitResult visitFileFailed(Path file, IOException exc) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
150 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
151 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
152
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
153 public void writeFileTree() throws IOException {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
154 Files.walkFileTree(this.startDir, this);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
155 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
156 }