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/WinGammaPlatformVC7.java
32285 views
1
/*
2
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*
23
*/
24
25
import java.io.FileWriter;
26
import java.io.IOException;
27
import java.io.PrintWriter;
28
import java.nio.file.FileSystems;
29
import java.util.Vector;
30
31
public class WinGammaPlatformVC7 extends WinGammaPlatform {
32
33
// TODO How about moving all globals configs to its own BuildConfig?
34
35
String projectVersion() {
36
return "7.10";
37
};
38
39
public void writeProjectFile(String projectFileName, String projectName,
40
Vector<BuildConfig> allConfigs) throws IOException {
41
System.out.println();
42
System.out.println(" Writing .vcproj file: " + projectFileName);
43
// If we got this far without an error, we're safe to actually
44
// write the .vcproj file
45
printWriter = new PrintWriter(new FileWriter(projectFileName));
46
47
printWriter
48
.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
49
startTag("VisualStudioProject", new String[] { "ProjectType",
50
"Visual C++", "Version", projectVersion(), "Name", projectName,
51
"ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
52
"SccProjectName", "", "SccLocalPath", "" });
53
startTag("Platforms");
54
tag("Platform",
55
new String[] { "Name",
56
(String) BuildConfig.getField(null, "PlatformName") });
57
endTag();
58
59
startTag("Configurations");
60
61
for (BuildConfig cfg : allConfigs) {
62
writeConfiguration(cfg);
63
}
64
65
endTag();
66
67
tag("References");
68
69
writeFiles(allConfigs);
70
71
tag("Globals");
72
73
endTag();
74
printWriter.close();
75
76
System.out.println(" Done.");
77
}
78
79
void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) {
80
for (BuildConfig cfg : configs) {
81
startTag("FileConfiguration",
82
new String[] { "Name", (String) cfg.get("Name") });
83
tag("Tool", customToolAttrs);
84
85
endTag();
86
}
87
}
88
89
void writeFiles(Vector<BuildConfig> allConfigs) {
90
91
// This code assummes there are no config specific includes.
92
startTag("Files");
93
String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
94
95
// Use first config for all global absolute includes.
96
BuildConfig baseConfig = allConfigs.firstElement();
97
Vector<String> rv = new Vector<String>();
98
99
// Then use first config for all relative includes
100
Vector<String> ri = new Vector<String>();
101
baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");
102
for (String f : ri) {
103
rv.add(sourceBase + Util.sep + f);
104
}
105
106
baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");
107
108
handleIncludes(rv, allConfigs);
109
110
startTag("Filter", new String[] { "Name", "Resource Files", "Filter",
111
"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" });
112
endTag();
113
114
endTag();
115
}
116
117
// Will visit file tree for each include
118
private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
119
for (String path : includes) {
120
FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this);
121
try {
122
ftc.writeFileTree();
123
} catch (IOException e) {
124
e.printStackTrace();
125
}
126
}
127
}
128
129
void writeConfiguration(BuildConfig cfg) {
130
startTag("Configuration", new String[] { "Name", cfg.get("Name"),
131
"OutputDirectory", cfg.get("OutputDir"),
132
"IntermediateDirectory", cfg.get("OutputDir"),
133
"ConfigurationType", "2", "UseOfMFC", "0",
134
"ATLMinimizesCRunTimeLibraryUsage", "FALSE" });
135
136
tagV("Tool", cfg.getV("CompilerFlags"));
137
138
tag("Tool", new String[] { "Name", "VCCustomBuildTool" });
139
140
tagV("Tool", cfg.getV("LinkerFlags"));
141
142
String postBuildCmd = BuildConfig.getFieldString(null,
143
"PostbuildCommand");
144
if (postBuildCmd != null) {
145
tag("Tool",
146
new String[] {
147
"Name",
148
"VCPostBuildEventTool",
149
"Description",
150
BuildConfig
151
.getFieldString(null, "PostbuildDescription"),
152
// Caution: String.replace(String,String) is available
153
// from JDK5 onwards only
154
"CommandLine",
155
cfg.expandFormat(postBuildCmd.replace("\t",
156
"&#x0D;&#x0A;")) });
157
}
158
159
tag("Tool", new String[] { "Name", "VCPreBuildEventTool" });
160
161
tag("Tool",
162
new String[] {
163
"Name",
164
"VCPreLinkEventTool",
165
"Description",
166
BuildConfig.getFieldString(null, "PrelinkDescription"),
167
// Caution: String.replace(String,String) is available
168
// from JDK5 onwards only
169
"CommandLine",
170
cfg.expandFormat(BuildConfig.getFieldString(null,
171
"PrelinkCommand").replace("\t", "&#x0D;&#x0A;")) });
172
173
tag("Tool", new String[] { "Name", "VCResourceCompilerTool",
174
"PreprocessorDefinitions", "NDEBUG", "Culture", "1033" });
175
176
tag("Tool", new String[] { "Name", "VCMIDLTool",
177
"PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible",
178
"TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment",
179
"1", "TypeLibraryName",
180
cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName",
181
"" });
182
183
endTag();
184
}
185
186
187
188
protected String getProjectExt() {
189
return ".vcproj";
190
}
191
}
192
193
class CompilerInterfaceVC7 extends CompilerInterface {
194
void getBaseCompilerFlags_common(Vector defines, Vector includes,
195
String outDir, Vector rv) {
196
197
// advanced M$ IDE (2003) can only recognize name if it's first or
198
// second attribute in the tag - go guess
199
addAttr(rv, "Name", "VCCLCompilerTool");
200
addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
201
addAttr(rv, "PreprocessorDefinitions",
202
Util.join(";", defines).replace("\"", "&quot;"));
203
addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
204
addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch");
205
addAttr(rv, "AssemblerListingLocation", outDir);
206
addAttr(rv, "ObjectFile", outDir + Util.sep);
207
addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb");
208
// Set /nologo optin
209
addAttr(rv, "SuppressStartupBanner", "TRUE");
210
// Surpass the default /Tc or /Tp. 0 is compileAsDefault
211
addAttr(rv, "CompileAs", "0");
212
// Set /W3 option. 3 is warningLevel_3
213
addAttr(rv, "WarningLevel", "3");
214
// Set /WX option,
215
addAttr(rv, "WarnAsError", "TRUE");
216
// Set /GS option
217
addAttr(rv, "BufferSecurityCheck", "FALSE");
218
// Set /Zi option. 3 is debugEnabled
219
addAttr(rv, "DebugInformationFormat", "3");
220
}
221
222
Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
223
Vector rv = new Vector();
224
225
getBaseCompilerFlags_common(defines, includes, outDir, rv);
226
// Set /Yu option. 3 is pchUseUsingSpecific
227
// Note: Starting VC8 pchUseUsingSpecific is 2 !!!
228
addAttr(rv, "UsePrecompiledHeader", "3");
229
// Set /EHsc- option
230
addAttr(rv, "ExceptionHandling", "FALSE");
231
232
return rv;
233
}
234
235
Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
236
Vector rv = new Vector();
237
238
addAttr(rv, "Name", "VCLinkerTool");
239
addAttr(rv, "AdditionalOptions",
240
"/export:JNI_GetDefaultJavaVMInitArgs "
241
+ "/export:JNI_CreateJavaVM "
242
+ "/export:JVM_FindClassFromBootLoader "
243
+ "/export:JNI_GetCreatedJavaVMs "
244
+ "/export:jio_snprintf /export:jio_printf "
245
+ "/export:jio_fprintf /export:jio_vfprintf "
246
+ "/export:jio_vsnprintf "
247
+ "/export:JVM_GetVersionInfo "
248
+ "/export:JVM_GetThreadStateNames "
249
+ "/export:JVM_GetThreadStateValues "
250
+ "/export:JVM_InitAgentProperties ");
251
addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
252
addAttr(rv, "OutputFile", outDll);
253
// Set /INCREMENTAL option. 1 is linkIncrementalNo
254
addAttr(rv, "LinkIncremental", "1");
255
addAttr(rv, "SuppressStartupBanner", "TRUE");
256
addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def");
257
addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb");
258
// Set /SUBSYSTEM option. 2 is subSystemWindows
259
addAttr(rv, "SubSystem", "2");
260
addAttr(rv, "BaseAddress", "0x8000000");
261
addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib");
262
if (platformName.equals("Win32")) {
263
// Set /MACHINE option. 1 is X86
264
addAttr(rv, "TargetMachine", "1");
265
} else {
266
// Set /MACHINE option. 17 is X64
267
addAttr(rv, "TargetMachine", "17");
268
}
269
270
return rv;
271
}
272
273
void getDebugCompilerFlags_common(String opt, Vector rv) {
274
275
// Set /On option
276
addAttr(rv, "Optimization", opt);
277
// Set /FR option. 1 is brAllInfo
278
addAttr(rv, "BrowseInformation", "1");
279
addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
280
// Set /MD option. 2 is rtMultiThreadedDLL
281
addAttr(rv, "RuntimeLibrary", "2");
282
// Set /Oy- option
283
addAttr(rv, "OmitFramePointers", "FALSE");
284
285
}
286
287
Vector getDebugCompilerFlags(String opt) {
288
Vector rv = new Vector();
289
290
getDebugCompilerFlags_common(opt, rv);
291
292
return rv;
293
}
294
295
Vector getDebugLinkerFlags() {
296
Vector rv = new Vector();
297
298
addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
299
300
return rv;
301
}
302
303
void getAdditionalNonKernelLinkerFlags(Vector rv) {
304
extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace ");
305
}
306
307
void getProductCompilerFlags_common(Vector rv) {
308
// Set /O2 option. 2 is optimizeMaxSpeed
309
addAttr(rv, "Optimization", "2");
310
// Set /Oy- option
311
addAttr(rv, "OmitFramePointers", "FALSE");
312
// Set /Ob option. 1 is expandOnlyInline
313
addAttr(rv, "InlineFunctionExpansion", "1");
314
// Set /GF option.
315
addAttr(rv, "StringPooling", "TRUE");
316
// Set /MD option. 2 is rtMultiThreadedDLL
317
addAttr(rv, "RuntimeLibrary", "2");
318
// Set /Gy option
319
addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
320
}
321
322
Vector getProductCompilerFlags() {
323
Vector rv = new Vector();
324
325
getProductCompilerFlags_common(rv);
326
327
return rv;
328
}
329
330
Vector getProductLinkerFlags() {
331
Vector rv = new Vector();
332
333
// Set /OPT:REF option. 2 is optReferences
334
addAttr(rv, "OptimizeReferences", "2");
335
// Set /OPT:optFolding option. 2 is optFolding
336
addAttr(rv, "EnableCOMDATFolding", "2");
337
338
return rv;
339
}
340
341
String getOptFlag() {
342
return "2";
343
}
344
345
String getNoOptFlag() {
346
return "0";
347
}
348
349
String makeCfgName(String flavourBuild, String platform) {
350
return flavourBuild + "|" + platform;
351
}
352
353
}
354
355