Mercurial > hg > truffle
annotate src/share/tools/ProjectCreator/FileTreeCreatorVC10.java @ 10750:9f5a4074e36b
test for nullness and disjunctive conditions in ConditionalEliminationPhase
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 15 Jul 2013 13:36:59 +0200 |
parents | 482037339440 |
children | 3cce976666d9 |
rev | line source |
---|---|
6801 | 1 import static java.nio.file.FileVisitResult.CONTINUE; |
2 | |
3 import java.io.IOException; | |
4 import java.nio.file.FileSystems; | |
5 import java.nio.file.FileVisitResult; | |
6 import java.nio.file.Files; | |
7 import java.nio.file.Path; | |
8 import java.nio.file.attribute.BasicFileAttributes; | |
9 import java.util.Stack; | |
10 import java.util.Vector; | |
11 | |
12 public class FileTreeCreatorVC10 extends FileTreeCreator { | |
13 | |
14 public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) { | |
15 super(startDir, allConfigs, wg); | |
16 } | |
17 | |
18 @Override | |
19 public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { | |
20 DirAttributes currentFileAttr = attributes.peek().clone(); | |
21 boolean usePch = false; | |
22 boolean disablePch = false; | |
23 boolean useIgnore = false; | |
24 String fileName = file.getFileName().toString(); | |
25 | |
26 // TODO hideFile | |
27 | |
28 // usePch applies to all configs for a file. | |
29 if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) { | |
30 usePch = true; | |
31 } | |
32 | |
33 for (BuildConfig cfg : allConfigs) { | |
34 if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) { | |
35 useIgnore = true; | |
36 currentFileAttr.setIgnore(cfg); | |
37 } else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) { | |
38 useIgnore = true; | |
39 currentFileAttr.setIgnore(cfg); | |
40 } | |
41 | |
42 if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { | |
43 disablePch = true; | |
44 currentFileAttr.setDisablePch(cfg); | |
45 } | |
46 | |
47 Vector<String> rv = new Vector<String>(); | |
48 cfg.collectRelevantVectors(rv, "AdditionalFile"); | |
49 for(String addFile : rv) { | |
50 if (addFile.equals(fileName)) { | |
51 // supress any ignore | |
52 // TODO - may need some adjustments | |
8266
482037339440
ProjectCreator: compare relative path against flavour.
Andreas Woess <andreas.woess@jku.at>
parents:
6801
diff
changeset
|
53 String relativePath = startDir.toUri().relativize(file.toUri()).getPath(); |
482037339440
ProjectCreator: compare relative path against flavour.
Andreas Woess <andreas.woess@jku.at>
parents:
6801
diff
changeset
|
54 if (relativePath.contains(cfg.get("Flavour"))) { |
6801 | 55 currentFileAttr.removeFromIgnored(cfg); |
56 } | |
57 } | |
58 } | |
59 } | |
60 | |
61 String tagName = wg.getFileTagFromSuffix(fileName); | |
62 String fileLoc = vcProjLocation.relativize(file).toString(); | |
63 | |
64 if (!useIgnore && !disablePch && !usePch) { | |
65 wg.tag(tagName, new String[] { "Include", fileLoc}); | |
66 } else { | |
67 wg.startTag( | |
68 tagName, | |
69 new String[] { "Include", fileLoc}); | |
70 | |
71 for (BuildConfig cfg : allConfigs) { | |
72 boolean ignore = currentFileAttr.hasIgnore(cfg); | |
73 if (ignore) { | |
74 wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); | |
75 } | |
76 if (usePch) { | |
77 wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); | |
78 } | |
79 if (disablePch) { | |
80 wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); | |
81 } | |
82 } | |
83 wg.endTag(); | |
84 } | |
85 | |
86 String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString(); | |
87 wg.addFilterDependency(fileLoc, filter); | |
88 | |
89 return CONTINUE; | |
90 } | |
91 | |
92 @Override | |
93 public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) | |
94 throws IOException { | |
95 Boolean hide = false; | |
96 // TODO remove attrs, if path is matched in this dir, then it is too in every subdir. | |
97 // And we will check anyway | |
98 DirAttributes newAttr = attributes.peek().clone(); | |
99 | |
100 // check per config ignorePaths! | |
101 for (BuildConfig cfg : allConfigs) { | |
102 if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { | |
103 newAttr.setIgnore(cfg); | |
104 } | |
105 | |
106 // Hide is always on all configs. And additional files are never hiddden | |
107 if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { | |
108 hide = true; | |
109 break; | |
110 } | |
111 } | |
112 | |
113 if (!hide) { | |
114 String name = startDir.relativize(path.toAbsolutePath()).toString(); | |
115 if (!"".equals(name)) { | |
116 wg.addFilter(name); | |
117 } | |
118 | |
119 attributes.push(newAttr); | |
120 return super.preVisitDirectory(path, attrs); | |
121 } else { | |
122 return FileVisitResult.SKIP_SUBTREE; | |
123 } | |
124 } | |
125 | |
126 @Override | |
127 public FileVisitResult postVisitDirectory(Path dir, IOException exc) { | |
128 //end matching attributes set by ignorepath | |
129 attributes.pop(); | |
130 return CONTINUE; | |
131 } | |
132 | |
133 @Override | |
134 public FileVisitResult visitFileFailed(Path file, IOException exc) { | |
135 return CONTINUE; | |
136 } | |
137 | |
138 public void writeFileTree() throws IOException { | |
139 Files.walkFileTree(this.startDir, this); | |
140 } | |
141 | |
142 | |
143 } |