author | sspitsyn |
Wed, 03 May 2017 02:32:02 +0000 | |
changeset 46426 | 02a1fc064144 |
parent 38247 | 6ff550a6307e |
permissions | -rw-r--r-- |
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
1 |
/* |
38247
6ff550a6307e
8156018: Hotspot visual studio project generation broken
erikj
parents:
19277
diff
changeset
|
2 |
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
4 |
* |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
7 |
* published by the Free Software Foundation. |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
8 |
* |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
13 |
* accompanied this code). |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
14 |
* |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
18 |
* |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
21 |
* questions. |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
22 |
* |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
23 |
*/ |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
24 |
|
38247
6ff550a6307e
8156018: Hotspot visual studio project generation broken
erikj
parents:
19277
diff
changeset
|
25 |
package build.tools.projectcreator; |
6ff550a6307e
8156018: Hotspot visual studio project generation broken
erikj
parents:
19277
diff
changeset
|
26 |
|
13892 | 27 |
import static java.nio.file.FileVisitResult.CONTINUE; |
28 |
||
29 |
import java.io.IOException; |
|
30 |
import java.nio.file.FileSystems; |
|
31 |
import java.nio.file.FileVisitResult; |
|
32 |
import java.nio.file.Files; |
|
33 |
import java.nio.file.Path; |
|
34 |
import java.nio.file.attribute.BasicFileAttributes; |
|
35 |
import java.util.Stack; |
|
36 |
import java.util.Vector; |
|
37 |
||
38 |
public class FileTreeCreatorVC10 extends FileTreeCreator { |
|
39 |
||
40 |
public FileTreeCreatorVC10(Path startDir, Vector<BuildConfig> allConfigs, WinGammaPlatformVC10 wg) { |
|
41 |
super(startDir, allConfigs, wg); |
|
42 |
} |
|
43 |
||
44 |
@Override |
|
45 |
public FileVisitResult visitFile(Path file, BasicFileAttributes attr) { |
|
46 |
DirAttributes currentFileAttr = attributes.peek().clone(); |
|
47 |
boolean usePch = false; |
|
48 |
boolean disablePch = false; |
|
49 |
boolean useIgnore = false; |
|
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
50 |
boolean isAltSrc = false; // only needed as a debugging crumb |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
51 |
boolean isReplacedByAltSrc = false; |
13892 | 52 |
String fileName = file.getFileName().toString(); |
53 |
||
54 |
// TODO hideFile |
|
55 |
||
56 |
// usePch applies to all configs for a file. |
|
57 |
if (fileName.equals(BuildConfig.getFieldString(null, "UseToGeneratePch"))) { |
|
58 |
usePch = true; |
|
59 |
} |
|
60 |
||
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
61 |
String fileLoc = vcProjLocation.relativize(file).toString(); |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
62 |
|
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
63 |
// isAltSrc and isReplacedByAltSrc applies to all configs for a file |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
64 |
if (BuildConfig.matchesRelativeAltSrcInclude( |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
65 |
file.toAbsolutePath().toString())) { |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
66 |
// current file is an alternate source file so track it |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
67 |
isAltSrc = true; |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
68 |
BuildConfig.trackRelativeAltSrcFile( |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
69 |
file.toAbsolutePath().toString()); |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
70 |
} else if (BuildConfig.matchesRelativeAltSrcFile( |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
71 |
file.toAbsolutePath().toString())) { |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
72 |
// current file is a regular file that matches an alternate |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
73 |
// source file so yack about replacing the regular file |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
74 |
isReplacedByAltSrc = true; |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
75 |
System.out.println("INFO: alternate source file '" + |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
76 |
BuildConfig.getMatchingRelativeAltSrcFile( |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
77 |
file.toAbsolutePath().toString()) + |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
78 |
"' replaces '" + fileLoc + "'"); |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
79 |
} |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
80 |
|
13892 | 81 |
for (BuildConfig cfg : allConfigs) { |
82 |
if (cfg.lookupHashFieldInContext("IgnoreFile", fileName) != null) { |
|
83 |
useIgnore = true; |
|
84 |
currentFileAttr.setIgnore(cfg); |
|
85 |
} else if (cfg.matchesIgnoredPath(file.toAbsolutePath().toString())) { |
|
86 |
useIgnore = true; |
|
87 |
currentFileAttr.setIgnore(cfg); |
|
88 |
} |
|
89 |
||
90 |
if (cfg.lookupHashFieldInContext("DisablePch", fileName) != null) { |
|
91 |
disablePch = true; |
|
92 |
currentFileAttr.setDisablePch(cfg); |
|
93 |
} |
|
94 |
||
95 |
Vector<String> rv = new Vector<String>(); |
|
96 |
cfg.collectRelevantVectors(rv, "AdditionalFile"); |
|
97 |
for(String addFile : rv) { |
|
98 |
if (addFile.equals(fileName)) { |
|
99 |
// supress any ignore |
|
100 |
// TODO - may need some adjustments |
|
101 |
if (file.toAbsolutePath().toString().contains(cfg.get("Flavour"))) { |
|
102 |
currentFileAttr.removeFromIgnored(cfg); |
|
103 |
} |
|
104 |
} |
|
105 |
} |
|
106 |
} |
|
107 |
||
19277 | 108 |
String tagName = wg10.getFileTagFromSuffix(fileName); |
13892 | 109 |
|
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
110 |
if (!useIgnore && !disablePch && !usePch && !isReplacedByAltSrc) { |
13892 | 111 |
wg.tag(tagName, new String[] { "Include", fileLoc}); |
112 |
} else { |
|
113 |
wg.startTag( |
|
114 |
tagName, |
|
115 |
new String[] { "Include", fileLoc}); |
|
116 |
||
117 |
for (BuildConfig cfg : allConfigs) { |
|
118 |
boolean ignore = currentFileAttr.hasIgnore(cfg); |
|
119 |
if (ignore) { |
|
120 |
wg.tagData("ExcludedFromBuild", "true", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); |
|
121 |
} |
|
122 |
if (usePch) { |
|
123 |
wg.tagData("PrecompiledHeader", "Create", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); |
|
124 |
} |
|
125 |
if (disablePch) { |
|
126 |
wg.tag("PrecompiledHeader", "Condition", "'$(Configuration)|$(Platform)'=='" + cfg.get("Name") + "'"); |
|
127 |
} |
|
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
128 |
if (isReplacedByAltSrc) { |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
129 |
wg.tagData("ExcludedFromBuild", "true", "Condition", |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
130 |
"'$(Configuration)|$(Platform)'=='" + |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
131 |
cfg.get("Name") + "'"); |
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
132 |
} |
13892 | 133 |
} |
134 |
wg.endTag(); |
|
135 |
} |
|
136 |
||
137 |
String filter = startDir.relativize(file.getParent().toAbsolutePath()).toString(); |
|
19277 | 138 |
wg10.addFilterDependency(fileLoc, filter); |
13892 | 139 |
|
140 |
return CONTINUE; |
|
141 |
} |
|
142 |
||
143 |
@Override |
|
144 |
public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes attrs) |
|
145 |
throws IOException { |
|
146 |
Boolean hide = false; |
|
147 |
// TODO remove attrs, if path is matched in this dir, then it is too in every subdir. |
|
148 |
// And we will check anyway |
|
149 |
DirAttributes newAttr = attributes.peek().clone(); |
|
150 |
||
151 |
// check per config ignorePaths! |
|
152 |
for (BuildConfig cfg : allConfigs) { |
|
153 |
if (cfg.matchesIgnoredPath(path.toAbsolutePath().toString())) { |
|
154 |
newAttr.setIgnore(cfg); |
|
155 |
} |
|
156 |
||
157 |
// Hide is always on all configs. And additional files are never hiddden |
|
158 |
if (cfg.matchesHidePath(path.toAbsolutePath().toString())) { |
|
159 |
hide = true; |
|
160 |
break; |
|
161 |
} |
|
162 |
} |
|
163 |
||
164 |
if (!hide) { |
|
165 |
String name = startDir.relativize(path.toAbsolutePath()).toString(); |
|
166 |
if (!"".equals(name)) { |
|
19277 | 167 |
wg10.addFilter(name); |
13892 | 168 |
} |
169 |
||
170 |
attributes.push(newAttr); |
|
171 |
return super.preVisitDirectory(path, attrs); |
|
172 |
} else { |
|
173 |
return FileVisitResult.SKIP_SUBTREE; |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
@Override |
|
178 |
public FileVisitResult postVisitDirectory(Path dir, IOException exc) { |
|
179 |
//end matching attributes set by ignorepath |
|
180 |
attributes.pop(); |
|
181 |
return CONTINUE; |
|
182 |
} |
|
183 |
||
184 |
@Override |
|
185 |
public FileVisitResult visitFileFailed(Path file, IOException exc) { |
|
186 |
return CONTINUE; |
|
187 |
} |
|
188 |
||
189 |
public void writeFileTree() throws IOException { |
|
190 |
Files.walkFileTree(this.startDir, this); |
|
191 |
} |
|
19270
607d97508c60
8016601: Unable to build hsx24 on Windows using project creator and Visual Studio
dcubed
parents:
13892
diff
changeset
|
192 |
} |