annotate src/share/tools/ProjectCreator/FileTreeCreatorVC10.java @ 11122:81b6cb70717c jdk8-b99

Merge
author katleman
date Tue, 16 Jul 2013 15:15:43 -0700
parents 1a9b9cfcef41
children 482037339440 31f3b1e1c5e5
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 FileTreeCreatorVC10 extends FileTreeCreator {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
13
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
14 public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
15 super(startDir, allConfigs, wg);
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 // TODO hideFile
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
27
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
28 // usePch applies to all configs for a file.
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
29 if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
30 usePch = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
31 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
32
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
33 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
34 if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
35 useIgnore = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
36 currentFileAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
37 } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
38 useIgnore = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
39 currentFileAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
40 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
41
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
42 if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
43 disablePch = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
44 currentFileAttr.setDisablePch(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
45 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
46
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
47 Vector<String> rv = new Vector<String>();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
48 cfg.collectRelevantVectors(rv, "AdditionalFile");
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
49 for(String addFile : rv) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
50 if (addFile.equals(fileName)) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
51 // supress any ignore
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
52 // TODO - may need some adjustments
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
53 if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
54 currentFileAttr.removeFromIgnored(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
55 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
56 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
57 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
58 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
59
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
60 String tagName = wg.getFileTagFromSuffix(fileName);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
61 String fileLoc = vcProjLocation.relativize(file).toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
62
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
63 if (!useIgnore && !disablePch && !usePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
64 wg.tag(tagName, new String[] { "Include", fileLoc});
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
65 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
66 wg.startTag(
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
67 tagName,
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
68 new String[] { "Include", fileLoc});
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
69
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
70 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
71 boolean ignore = currentFileAttr.hasIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
72 if (ignore) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
73 wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
74 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
75 if (usePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
76 wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
77 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
78 if (disablePch) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
79 wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'");
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
80 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
81 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
82 wg.endTag();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
83 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
84
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
85 String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
86 wg.addFilterDependency(fileLoc, filter);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
87
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
88 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
89 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
90
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
91 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
92 public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
93 throws IOException {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
94 Boolean hide = false;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
95 // TODO remove attrs, if path is matched in this dir, then it is too in every subdir.
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
96 // And we will check anyway
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
97 DirAttributes newAttr = attributes.peek().clone();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
98
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
99 // check per config ignorePaths!
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
100 for (BuildConfig cfg : allConfigs) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
101 if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
102 newAttr.setIgnore(cfg);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
103 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
104
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
105 // Hide is always on all configs. And additional files are never hiddden
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
106 if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
107 hide = true;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
108 break;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
109 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
110 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
111
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
112 if (!hide) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
113 String name = startDir.relativize(path.toAbsolutePath()).toString();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
114 if (!"".equals(name)) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
115 wg.addFilter(name);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
116 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
117
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
118 attributes.push(newAttr);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
119 return super.preVisitDirectory(path, attrs);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
120 } else {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
121 return FileVisitResult.SKIP_SUBTREE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
122 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
123 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
124
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
125 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
126 public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
127 //end matching attributes set by ignorepath
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
128 attributes.pop();
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
129 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
130 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
131
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
132 @Override
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
133 public FileVisitResult visitFileFailed(Path file, IOException exc) {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
134 return CONTINUE;
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
135 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
136
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
137 public void writeFileTree() throws IOException {
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
138 Files.walkFileTree(this.startDir, this);
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
139 }
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
140
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
141
1a9b9cfcef41 7163863: Updated projectcreator
neliasso
parents:
diff changeset
142 }