Mercurial > hg > truffle
annotate src/share/tools/ProjectCreator/WinGammaPlatformVC10.java @ 7666:31540ca73e81
Remove ControlFlowException in SimpleLanguage.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 01 Feb 2013 19:53:52 +0100 |
parents | e522a00b91aa |
children | 836a62f43af9 |
rev | line source |
---|---|
2393 | 1 import java.io.File; |
2 import java.io.FileNotFoundException; | |
3 import java.io.IOException; | |
4 import java.io.PrintWriter; | |
5 import java.io.UnsupportedEncodingException; | |
6801 | 6 import java.nio.file.FileSystems; |
2393 | 7 import java.util.Iterator; |
6801 | 8 import java.util.LinkedList; |
2393 | 9 import java.util.UUID; |
10 import java.util.Vector; | |
11 | |
12 public class WinGammaPlatformVC10 extends WinGammaPlatformVC7 { | |
13 | |
6801 | 14 |
15 LinkedList <String>filters = new LinkedList<String>(); | |
16 LinkedList <String[]>filterDeps = new LinkedList<String[]>(); | |
17 | |
2393 | 18 @Override |
19 protected String getProjectExt() { | |
20 return ".vcxproj"; | |
21 } | |
22 | |
23 @Override | |
24 public void writeProjectFile(String projectFileName, String projectName, | |
25 Vector<BuildConfig> allConfigs) throws IOException { | |
26 System.out.println(); | |
27 System.out.print(" Writing .vcxproj file: " + projectFileName); | |
28 | |
29 String projDir = Util.normalize(new File(projectFileName).getParent()); | |
30 | |
31 printWriter = new PrintWriter(projectFileName, "UTF-8"); | |
32 printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); | |
33 startTag("Project", | |
34 "DefaultTargets", "Build", | |
35 "ToolsVersion", "4.0", | |
36 "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); | |
37 startTag("ItemGroup", | |
38 "Label", "ProjectConfigurations"); | |
39 for (BuildConfig cfg : allConfigs) { | |
40 startTag("ProjectConfiguration", | |
41 "Include", cfg.get("Name")); | |
42 tagData("Configuration", cfg.get("Id")); | |
43 tagData("Platform", cfg.get("PlatformName")); | |
6801 | 44 endTag(); |
2393 | 45 } |
6801 | 46 endTag(); |
2393 | 47 |
48 startTag("PropertyGroup", "Label", "Globals"); | |
49 tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); | |
50 tag("SccProjectName"); | |
51 tag("SccLocalPath"); | |
6801 | 52 endTag(); |
2393 | 53 |
54 tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.Default.props"); | |
55 | |
56 for (BuildConfig cfg : allConfigs) { | |
57 startTag(cfg, "PropertyGroup", "Label", "Configuration"); | |
58 tagData("ConfigurationType", "DynamicLibrary"); | |
59 tagData("UseOfMfc", "false"); | |
6801 | 60 endTag(); |
2393 | 61 } |
62 | |
63 tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.props"); | |
64 startTag("ImportGroup", "Label", "ExtensionSettings"); | |
6801 | 65 endTag(); |
2393 | 66 for (BuildConfig cfg : allConfigs) { |
67 startTag(cfg, "ImportGroup", "Label", "PropertySheets"); | |
68 tag("Import", | |
69 "Project", "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props", | |
70 "Condition", "exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')", | |
71 "Label", "LocalAppDataPlatform"); | |
6801 | 72 endTag(); |
2393 | 73 } |
74 | |
75 tag("PropertyGroup", "Label", "UserMacros"); | |
76 | |
77 startTag("PropertyGroup"); | |
78 tagData("_ProjectFileVersion", "10.0.30319.1"); | |
79 for (BuildConfig cfg : allConfigs) { | |
80 tagData(cfg, "OutDir", cfg.get("OutputDir") + Util.sep); | |
81 tagData(cfg, "IntDir", cfg.get("OutputDir") + Util.sep); | |
82 tagData(cfg, "LinkIncremental", "false"); | |
83 } | |
84 for (BuildConfig cfg : allConfigs) { | |
85 tagData(cfg, "CodeAnalysisRuleSet", "AllRules.ruleset"); | |
86 tag(cfg, "CodeAnalysisRules"); | |
87 tag(cfg, "CodeAnalysisRuleAssemblies"); | |
88 } | |
6801 | 89 endTag(); |
2393 | 90 |
91 for (BuildConfig cfg : allConfigs) { | |
92 startTag(cfg, "ItemDefinitionGroup"); | |
93 startTag("ClCompile"); | |
94 tagV(cfg.getV("CompilerFlags")); | |
6801 | 95 endTag(); |
2393 | 96 |
97 startTag("Link"); | |
98 tagV(cfg.getV("LinkerFlags")); | |
6801 | 99 endTag(); |
2393 | 100 |
101 startTag("PostBuildEvent"); | |
102 tagData("Message", BuildConfig.getFieldString(null, "PostbuildDescription")); | |
103 tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace("\t", "\r\n"))); | |
6801 | 104 endTag(); |
2393 | 105 |
106 startTag("PreLinkEvent"); | |
107 tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription")); | |
108 tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n"))); | |
6801 | 109 endTag(); |
2393 | 110 |
6801 | 111 endTag(); |
2393 | 112 } |
113 | |
114 writeFiles(allConfigs, projDir); | |
115 | |
116 tag("Import", "Project", "$(VCTargetsPath)\\Microsoft.Cpp.targets"); | |
117 startTag("ImportGroup", "Label", "ExtensionTargets"); | |
6801 | 118 endTag(); |
2393 | 119 |
6801 | 120 endTag(); |
2393 | 121 printWriter.close(); |
122 System.out.println(" Done."); | |
123 | |
124 writeFilterFile(projectFileName, projectName, allConfigs, projDir); | |
125 writeUserFile(projectFileName, allConfigs); | |
126 } | |
127 | |
128 | |
129 private void writeUserFile(String projectFileName, Vector<BuildConfig> allConfigs) throws FileNotFoundException, UnsupportedEncodingException { | |
130 String userFileName = projectFileName + ".user"; | |
131 if (new File(userFileName).exists()) { | |
132 return; | |
133 } | |
134 System.out.print(" Writing .vcxproj.user file: " + userFileName); | |
135 printWriter = new PrintWriter(userFileName, "UTF-8"); | |
136 | |
137 printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); | |
138 startTag("Project", | |
139 "ToolsVersion", "4.0", | |
140 "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); | |
141 | |
142 for (BuildConfig cfg : allConfigs) { | |
143 startTag(cfg, "PropertyGroup"); | |
144 tagData("LocalDebuggerCommand", "$(TargetDir)/hotspot.exe"); | |
6801 | 145 endTag(); |
2393 | 146 } |
147 | |
6801 | 148 endTag(); |
2393 | 149 printWriter.close(); |
150 System.out.println(" Done."); | |
151 } | |
152 | |
6801 | 153 public void addFilter(String rPath) { |
154 filters.add(rPath); | |
155 } | |
156 | |
157 public void addFilterDependency(String fileLoc, String filter) { | |
158 filterDeps.add(new String[] {fileLoc, filter}); | |
159 } | |
160 | |
2393 | 161 private void writeFilterFile(String projectFileName, String projectName, |
162 Vector<BuildConfig> allConfigs, String base) throws FileNotFoundException, UnsupportedEncodingException { | |
163 String filterFileName = projectFileName + ".filters"; | |
164 System.out.print(" Writing .vcxproj.filters file: " + filterFileName); | |
165 printWriter = new PrintWriter(filterFileName, "UTF-8"); | |
166 | |
167 printWriter.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); | |
168 startTag("Project", | |
169 "ToolsVersion", "4.0", | |
170 "xmlns", "http://schemas.microsoft.com/developer/msbuild/2003"); | |
171 | |
172 startTag("ItemGroup"); | |
6801 | 173 for (String filter : filters) { |
174 startTag("Filter", "Include",filter); | |
175 UUID uuid = UUID.randomUUID(); | |
176 tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); | |
177 endTag(); | |
2393 | 178 } |
179 startTag("Filter", "Include", "Resource Files"); | |
180 UUID uuid = UUID.randomUUID(); | |
181 tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); | |
182 tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"); | |
6801 | 183 endTag(); |
184 endTag(); | |
2393 | 185 |
6801 | 186 //TODO - do I need to split cpp and hpp files? |
2393 | 187 |
6801 | 188 // then all files |
2393 | 189 startTag("ItemGroup"); |
6801 | 190 for (String[] dep : filterDeps) { |
191 String tagName = getFileTagFromSuffix(dep[0]); | |
2393 | 192 |
6801 | 193 startTag(tagName, "Include", dep[0]); |
194 tagData("Filter", dep[1]); | |
195 endTag(); | |
2393 | 196 } |
6801 | 197 endTag(); |
2393 | 198 |
6801 | 199 endTag(); |
2393 | 200 printWriter.close(); |
201 System.out.println(" Done."); | |
202 } | |
203 | |
6801 | 204 public String getFileTagFromSuffix(String fileName) { |
205 if (fileName.endsWith(".cpp")) { | |
206 return"ClCompile"; | |
207 } else if (fileName.endsWith(".c")) { | |
208 return "ClCompile"; | |
209 } else if (fileName.endsWith(".hpp")) { | |
210 return"ClInclude"; | |
211 } else if (fileName.endsWith(".h")) { | |
212 return "ClInclude"; | |
213 } else { | |
214 return"None"; | |
215 } | |
2393 | 216 } |
217 | |
218 void writeFiles(Vector<BuildConfig> allConfigs, String projDir) { | |
6801 | 219 // This code assummes there are no config specific includes. |
220 startTag("ItemGroup"); | |
2393 | 221 |
6801 | 222 String sourceBase = BuildConfig.getFieldString(null, "SourceBase"); |
223 | |
224 // Use first config for all global absolute includes. | |
225 BuildConfig baseConfig = allConfigs.firstElement(); | |
226 Vector<String> rv = new Vector<String>(); | |
2393 | 227 |
6801 | 228 // Then use first config for all relative includes |
229 Vector<String> ri = new Vector<String>(); | |
230 baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude"); | |
231 for (String f : ri) { | |
232 rv.add(sourceBase + Util.sep + f); | |
233 } | |
2393 | 234 |
6801 | 235 baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude"); |
236 | |
237 handleIncludes(rv, allConfigs); | |
238 | |
239 endTag(); | |
2393 | 240 } |
241 | |
6801 | 242 // Will visit file tree for each include |
243 private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) { | |
244 for (String path : includes) { | |
245 FileTreeCreatorVC10 ftc = new FileTreeCreatorVC10(FileSystems.getDefault().getPath(path) , allConfigs, this); | |
246 try { | |
247 ftc.writeFileTree(); | |
248 } catch (IOException e) { | |
249 e.printStackTrace(); | |
250 } | |
251 } | |
2393 | 252 } |
253 | |
254 String buildCond(BuildConfig cfg) { | |
255 return "'$(Configuration)|$(Platform)'=='"+cfg.get("Name")+"'"; | |
256 } | |
257 | |
258 void tagV(Vector<String> v) { | |
259 Iterator<String> i = v.iterator(); | |
260 while(i.hasNext()) { | |
261 String name = i.next(); | |
262 String data = i.next(); | |
263 tagData(name, data); | |
264 } | |
265 } | |
266 | |
267 void tagData(BuildConfig cfg, String name, String data) { | |
268 tagData(name, data, "Condition", buildCond(cfg)); | |
269 } | |
270 | |
271 void tag(BuildConfig cfg, String name, String... attrs) { | |
272 String[] ss = new String[attrs.length + 2]; | |
273 ss[0] = "Condition"; | |
274 ss[1] = buildCond(cfg); | |
275 System.arraycopy(attrs, 0, ss, 2, attrs.length); | |
276 | |
277 tag(name, ss); | |
278 } | |
279 | |
280 void startTag(BuildConfig cfg, String name, String... attrs) { | |
281 String[] ss = new String[attrs.length + 2]; | |
282 ss[0] = "Condition"; | |
283 ss[1] = buildCond(cfg); | |
284 System.arraycopy(attrs, 0, ss, 2, attrs.length); | |
285 | |
286 startTag(name, ss); | |
287 } | |
6801 | 288 |
2393 | 289 } |
290 | |
291 class CompilerInterfaceVC10 extends CompilerInterface { | |
292 | |
293 @Override | |
294 Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) { | |
295 Vector rv = new Vector(); | |
296 | |
297 addAttr(rv, "AdditionalIncludeDirectories", Util.join(";", includes)); | |
298 addAttr(rv, "PreprocessorDefinitions", | |
299 Util.join(";", defines).replace("\\\"", "\"")); | |
300 addAttr(rv, "PrecompiledHeaderFile", "precompiled.hpp"); | |
301 addAttr(rv, "PrecompiledHeaderOutputFile", outDir+Util.sep+"vm.pch"); | |
302 addAttr(rv, "AssemblerListingLocation", outDir); | |
303 addAttr(rv, "ObjectFileName", outDir+Util.sep); | |
304 addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb"); | |
305 // Set /nologo option | |
306 addAttr(rv, "SuppressStartupBanner", "true"); | |
307 // Surpass the default /Tc or /Tp. | |
308 addAttr(rv, "CompileAs", "Default"); | |
309 // Set /W3 option. | |
310 addAttr(rv, "WarningLevel", "Level3"); | |
311 // Set /WX option, | |
312 addAttr(rv, "TreatWarningAsError", "true"); | |
313 // Set /GS option | |
314 addAttr(rv, "BufferSecurityCheck", "false"); | |
315 // Set /Zi option. | |
316 addAttr(rv, "DebugInformationFormat", "ProgramDatabase"); | |
317 // Set /Yu option. | |
318 addAttr(rv, "PrecompiledHeader", "Use"); | |
319 // Set /EHsc- option | |
320 addAttr(rv, "ExceptionHandling", ""); | |
321 | |
322 addAttr(rv, "MultiProcessorCompilation", "true"); | |
323 | |
324 return rv; | |
325 } | |
326 | |
327 @Override | |
328 Vector getDebugCompilerFlags(String opt) { | |
329 Vector rv = new Vector(); | |
330 | |
331 // Set /On option | |
332 addAttr(rv, "Optimization", opt); | |
333 // Set /FR option. | |
334 addAttr(rv, "BrowseInformation", "true"); | |
335 addAttr(rv, "BrowseInformationFile", "$(IntDir)"); | |
336 // Set /MD option. | |
337 addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); | |
338 // Set /Oy- option | |
339 addAttr(rv, "OmitFramePointers", "false"); | |
340 | |
341 return rv; | |
342 } | |
343 | |
344 @Override | |
345 Vector getProductCompilerFlags() { | |
346 Vector rv = new Vector(); | |
347 | |
348 // Set /O2 option. | |
349 addAttr(rv, "Optimization", "MaxSpeed"); | |
350 // Set /Oy- option | |
351 addAttr(rv, "OmitFramePointers", "false"); | |
352 // Set /Ob option. 1 is expandOnlyInline | |
353 addAttr(rv, "InlineFunctionExpansion", "OnlyExplicitInline"); | |
354 // Set /GF option. | |
355 addAttr(rv, "StringPooling", "true"); | |
356 // Set /MD option. 2 is rtMultiThreadedDLL | |
357 addAttr(rv, "RuntimeLibrary", "MultiThreadedDLL"); | |
358 // Set /Gy option | |
359 addAttr(rv, "FunctionLevelLinking", "true"); | |
360 | |
361 return rv; | |
362 } | |
363 | |
364 @Override | |
365 Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { | |
366 Vector rv = new Vector(); | |
367 | |
368 addAttr(rv, "AdditionalOptions", | |
369 "/export:JNI_GetDefaultJavaVMInitArgs " + | |
370 "/export:JNI_CreateJavaVM " + | |
371 "/export:JVM_FindClassFromBootLoader "+ | |
372 "/export:JNI_GetCreatedJavaVMs "+ | |
373 "/export:jio_snprintf /export:jio_printf "+ | |
374 "/export:jio_fprintf /export:jio_vfprintf "+ | |
375 "/export:jio_vsnprintf "+ | |
376 "/export:JVM_GetVersionInfo "+ | |
377 "/export:JVM_GetThreadStateNames "+ | |
378 "/export:JVM_GetThreadStateValues "+ | |
379 "/export:JVM_InitAgentProperties"); | |
3871
2f27ed2a98fa
7082220: Visual Studio projects broken after change 7016797: Hotspot: securely/restrictive load dlls and new
brutisso
parents:
2475
diff
changeset
|
380 addAttr(rv, "AdditionalDependencies", "kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;Wsock32.lib;winmm.lib;psapi.lib"); |
2393 | 381 addAttr(rv, "OutputFile", outDll); |
382 addAttr(rv, "SuppressStartupBanner", "true"); | |
383 addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def"); | |
384 addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb"); | |
385 addAttr(rv, "SubSystem", "Windows"); | |
386 addAttr(rv, "BaseAddress", "0x8000000"); | |
387 addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); | |
388 | |
389 if(platformName.equals("Win32")) { | |
390 addAttr(rv, "TargetMachine", "MachineX86"); | |
391 } else { | |
392 addAttr(rv, "TargetMachine", "MachineX64"); | |
393 } | |
394 | |
2475
c49c3947b98a
7034625: Product builds in Visual Studio projects should produce full symbol information
brutisso
parents:
2393
diff
changeset
|
395 // We always want the /DEBUG option to get full symbol information in the pdb files |
c49c3947b98a
7034625: Product builds in Visual Studio projects should produce full symbol information
brutisso
parents:
2393
diff
changeset
|
396 addAttr(rv, "GenerateDebugInformation", "true"); |
c49c3947b98a
7034625: Product builds in Visual Studio projects should produce full symbol information
brutisso
parents:
2393
diff
changeset
|
397 |
2393 | 398 return rv; |
399 } | |
400 | |
401 @Override | |
402 Vector getDebugLinkerFlags() { | |
403 Vector rv = new Vector(); | |
404 | |
2475
c49c3947b98a
7034625: Product builds in Visual Studio projects should produce full symbol information
brutisso
parents:
2393
diff
changeset
|
405 // Empty now that /DEBUG option is used by all configs |
2393 | 406 |
407 return rv; | |
408 } | |
409 | |
410 @Override | |
411 Vector getProductLinkerFlags() { | |
412 Vector rv = new Vector(); | |
413 | |
414 // Set /OPT:REF option. | |
415 addAttr(rv, "OptimizeReferences", "true"); | |
416 // Set /OPT:ICF option. | |
417 addAttr(rv, "EnableCOMDATFolding", "true"); | |
418 | |
419 return rv; | |
420 } | |
421 | |
422 @Override | |
423 void getAdditionalNonKernelLinkerFlags(Vector rv) { | |
424 extAttr(rv, "AdditionalOptions", " /export:AsyncGetCallTrace"); | |
425 } | |
426 | |
427 @Override | |
428 String getOptFlag() { | |
429 return "MaxSpeed"; | |
430 } | |
431 | |
432 @Override | |
433 String getNoOptFlag() { | |
434 return "Disabled"; | |
435 } | |
436 | |
437 @Override | |
438 String makeCfgName(String flavourBuild, String platform) { | |
439 return flavourBuild + "|" + platform; | |
440 } | |
441 | |
442 } |