Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC7.java
32285 views
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 FileTreeCreatorVC7 extends FileTreeCreator {
13
14
public FileTreeCreatorVC7(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatform 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
// usePch applies to all configs for a file.
27
if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) {
28
usePch = true;
29
}
30
31
for (BuildConfig cfg : allConfigs) {
32
if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) {
33
useIgnore = true;
34
currentFileAttr.setIgnore(cfg);
35
} else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) {
36
useIgnore = true;
37
currentFileAttr.setIgnore(cfg);
38
}
39
40
if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) {
41
disablePch = true;
42
currentFileAttr.setDisablePch(cfg);
43
}
44
45
Vector<String> rv = new Vector<String>();
46
cfg.collectRelevantVectors(rv, "AdditionalFile");
47
for(String addFile : rv) {
48
if (addFile.equals(fileName)) {
49
// supress any ignore
50
currentFileAttr.removeFromIgnored(cfg);
51
}
52
}
53
}
54
55
if (!useIgnore && !disablePch && !usePch) {
56
wg.tag("File", new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
57
} else {
58
wg.startTag(
59
"File",
60
new String[] { "RelativePath", vcProjLocation.relativize(file).toString()});
61
62
for (BuildConfig cfg : allConfigs) {
63
boolean ignore = currentFileAttr.hasIgnore(cfg);
64
String [] fileConfAttr;
65
66
if (ignore) {
67
fileConfAttr = new String[] {"Name", cfg.get("Name"), "ExcludedFromBuild", "TRUE" };
68
} else {
69
fileConfAttr = new String[] {"Name", cfg.get("Name")};
70
}
71
72
if (!disablePch && !usePch && !ignore) {
73
continue;
74
} else if (!disablePch && !usePch) {
75
wg.tag("FileConfiguration", fileConfAttr);
76
} else {
77
wg.startTag("FileConfiguration", fileConfAttr);
78
if (usePch) {
79
// usePch always applies to all configs, might not always be so.
80
wg.tag("Tool", new String[] {
81
"Name", "VCCLCompilerTool", "UsePrecompiledHeader",
82
"1" });
83
assert(!disablePch);
84
}
85
if (disablePch) {
86
if (currentFileAttr.hasDisablePch(cfg)) {
87
wg.tag("Tool", new String[] {
88
"Name", "VCCLCompilerTool", "UsePrecompiledHeader",
89
"0" });
90
}
91
assert(!usePch);
92
}
93
wg.endTag();
94
}
95
}
96
wg.endTag();
97
}
98
99
return CONTINUE;
100
}
101
102
@Override
103
public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs)
104
throws IOException {
105
Boolean hide = false;
106
DirAttributes newAttr = attributes.peek().clone();
107
108
String rPath;
109
if (path.toAbsolutePath().toString().equals(this.startDir.toAbsolutePath().toString())){
110
rPath = startDir.toString();
111
} else {
112
rPath = path.getFileName().toString();
113
}
114
115
// check per config ignorePaths!
116
for (BuildConfig cfg : allConfigs) {
117
if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) {
118
newAttr.setIgnore(cfg);
119
}
120
121
// Hide is always on all configs. And additional files are never hiddden
122
if (cfg.matchesHidePath(path.toAbsolutePath().toString())) {
123
hide = true;
124
break;
125
}
126
}
127
128
if (!hide) {
129
wg.startTag("Filter", new String[] {
130
"Name", rPath});
131
132
attributes.push(newAttr);
133
return super.preVisitDirectory(path, attrs);
134
} else {
135
return FileVisitResult.SKIP_SUBTREE;
136
}
137
}
138
139
@Override
140
public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
141
//end matching attributes set by ignorepath
142
wg.endTag();
143
attributes.pop();
144
145
return CONTINUE;
146
}
147
148
@Override
149
public FileVisitResult visitFileFailed(Path file, IOException exc) {
150
return CONTINUE;
151
}
152
153
public void writeFileTree() throws IOException {
154
Files.walkFileTree(this.startDir, this);
155
}
156
}
157