Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java
32285 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324import java.io.FileWriter;25import java.io.IOException;26import java.io.PrintWriter;27import java.nio.file.FileSystems;28import java.util.Vector;2930public class WinGammaPlatformVC7 extends WinGammaPlatform {3132// TODO How about moving all globals configs to its own BuildConfig?3334String projectVersion() {35return "7.10";36};3738public void writeProjectFile(String projectFileName, String projectName,39Vector<BuildConfig> allConfigs) throws IOException {40System.out.println();41System.out.println(" Writing .vcproj file: " + projectFileName);42// If we got this far without an error, we're safe to actually43// write the .vcproj file44printWriter = new PrintWriter(new FileWriter(projectFileName));4546printWriter47.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");48startTag("VisualStudioProject", new String[] { "ProjectType",49"Visual C++", "Version", projectVersion(), "Name", projectName,50"ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",51"SccProjectName", "", "SccLocalPath", "" });52startTag("Platforms");53tag("Platform",54new String[] { "Name",55(String) BuildConfig.getField(null, "PlatformName") });56endTag();5758startTag("Configurations");5960for (BuildConfig cfg : allConfigs) {61writeConfiguration(cfg);62}6364endTag();6566tag("References");6768writeFiles(allConfigs);6970tag("Globals");7172endTag();73printWriter.close();7475System.out.println(" Done.");76}7778void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) {79for (BuildConfig cfg : configs) {80startTag("FileConfiguration",81new String[] { "Name", (String) cfg.get("Name") });82tag("Tool", customToolAttrs);8384endTag();85}86}8788void writeFiles(Vector<BuildConfig> allConfigs) {8990// This code assummes there are no config specific includes.91startTag("Files");92String sourceBase = BuildConfig.getFieldString(null, "SourceBase");9394// Use first config for all global absolute includes.95BuildConfig baseConfig = allConfigs.firstElement();96Vector<String> rv = new Vector<String>();9798// Then use first config for all relative includes99Vector<String> ri = new Vector<String>();100baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");101for (String f : ri) {102rv.add(sourceBase + Util.sep + f);103}104105baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");106107handleIncludes(rv, allConfigs);108109startTag("Filter", new String[] { "Name", "Resource Files", "Filter",110"ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" });111endTag();112113endTag();114}115116// Will visit file tree for each include117private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {118for (String path : includes) {119FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this);120try {121ftc.writeFileTree();122} catch (IOException e) {123e.printStackTrace();124}125}126}127128void writeConfiguration(BuildConfig cfg) {129startTag("Configuration", new String[] { "Name", cfg.get("Name"),130"OutputDirectory", cfg.get("OutputDir"),131"IntermediateDirectory", cfg.get("OutputDir"),132"ConfigurationType", "2", "UseOfMFC", "0",133"ATLMinimizesCRunTimeLibraryUsage", "FALSE" });134135tagV("Tool", cfg.getV("CompilerFlags"));136137tag("Tool", new String[] { "Name", "VCCustomBuildTool" });138139tagV("Tool", cfg.getV("LinkerFlags"));140141String postBuildCmd = BuildConfig.getFieldString(null,142"PostbuildCommand");143if (postBuildCmd != null) {144tag("Tool",145new String[] {146"Name",147"VCPostBuildEventTool",148"Description",149BuildConfig150.getFieldString(null, "PostbuildDescription"),151// Caution: String.replace(String,String) is available152// from JDK5 onwards only153"CommandLine",154cfg.expandFormat(postBuildCmd.replace("\t",155"
")) });156}157158tag("Tool", new String[] { "Name", "VCPreBuildEventTool" });159160tag("Tool",161new String[] {162"Name",163"VCPreLinkEventTool",164"Description",165BuildConfig.getFieldString(null, "PrelinkDescription"),166// Caution: String.replace(String,String) is available167// from JDK5 onwards only168"CommandLine",169cfg.expandFormat(BuildConfig.getFieldString(null,170"PrelinkCommand").replace("\t", "
")) });171172tag("Tool", new String[] { "Name", "VCResourceCompilerTool",173"PreprocessorDefinitions", "NDEBUG", "Culture", "1033" });174175tag("Tool", new String[] { "Name", "VCMIDLTool",176"PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible",177"TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment",178"1", "TypeLibraryName",179cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName",180"" });181182endTag();183}184185186187protected String getProjectExt() {188return ".vcproj";189}190}191192class CompilerInterfaceVC7 extends CompilerInterface {193void getBaseCompilerFlags_common(Vector defines, Vector includes,194String outDir, Vector rv) {195196// advanced M$ IDE (2003) can only recognize name if it's first or197// second attribute in the tag - go guess198addAttr(rv, "Name", "VCCLCompilerTool");199addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));200addAttr(rv, "PreprocessorDefinitions",201Util.join(";", defines).replace("\"", """));202addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");203addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch");204addAttr(rv, "AssemblerListingLocation", outDir);205addAttr(rv, "ObjectFile", outDir + Util.sep);206addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb");207// Set /nologo optin208addAttr(rv, "SuppressStartupBanner", "TRUE");209// Surpass the default /Tc or /Tp. 0 is compileAsDefault210addAttr(rv, "CompileAs", "0");211// Set /W3 option. 3 is warningLevel_3212addAttr(rv, "WarningLevel", "3");213// Set /WX option,214addAttr(rv, "WarnAsError", "TRUE");215// Set /GS option216addAttr(rv, "BufferSecurityCheck", "FALSE");217// Set /Zi option. 3 is debugEnabled218addAttr(rv, "DebugInformationFormat", "3");219}220221Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {222Vector rv = new Vector();223224getBaseCompilerFlags_common(defines, includes, outDir, rv);225// Set /Yu option. 3 is pchUseUsingSpecific226// Note: Starting VC8 pchUseUsingSpecific is 2 !!!227addAttr(rv, "UsePrecompiledHeader", "3");228// Set /EHsc- option229addAttr(rv, "ExceptionHandling", "FALSE");230231return rv;232}233234Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {235Vector rv = new Vector();236237addAttr(rv, "Name", "VCLinkerTool");238addAttr(rv, "AdditionalOptions",239"/export:JNI_GetDefaultJavaVMInitArgs "240+ "/export:JNI_CreateJavaVM "241+ "/export:JVM_FindClassFromBootLoader "242+ "/export:JNI_GetCreatedJavaVMs "243+ "/export:jio_snprintf /export:jio_printf "244+ "/export:jio_fprintf /export:jio_vfprintf "245+ "/export:jio_vsnprintf "246+ "/export:JVM_GetVersionInfo "247+ "/export:JVM_GetThreadStateNames "248+ "/export:JVM_GetThreadStateValues "249+ "/export:JVM_InitAgentProperties ");250addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");251addAttr(rv, "OutputFile", outDll);252// Set /INCREMENTAL option. 1 is linkIncrementalNo253addAttr(rv, "LinkIncremental", "1");254addAttr(rv, "SuppressStartupBanner", "TRUE");255addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def");256addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb");257// Set /SUBSYSTEM option. 2 is subSystemWindows258addAttr(rv, "SubSystem", "2");259addAttr(rv, "BaseAddress", "0x8000000");260addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib");261if (platformName.equals("Win32")) {262// Set /MACHINE option. 1 is X86263addAttr(rv, "TargetMachine", "1");264} else {265// Set /MACHINE option. 17 is X64266addAttr(rv, "TargetMachine", "17");267}268269return rv;270}271272void getDebugCompilerFlags_common(String opt, Vector rv) {273274// Set /On option275addAttr(rv, "Optimization", opt);276// Set /FR option. 1 is brAllInfo277addAttr(rv, "BrowseInformation", "1");278addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);279// Set /MD option. 2 is rtMultiThreadedDLL280addAttr(rv, "RuntimeLibrary", "2");281// Set /Oy- option282addAttr(rv, "OmitFramePointers", "FALSE");283284}285286Vector getDebugCompilerFlags(String opt) {287Vector rv = new Vector();288289getDebugCompilerFlags_common(opt, rv);290291return rv;292}293294Vector getDebugLinkerFlags() {295Vector rv = new Vector();296297addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option298299return rv;300}301302void getAdditionalNonKernelLinkerFlags(Vector rv) {303extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace ");304}305306void getProductCompilerFlags_common(Vector rv) {307// Set /O2 option. 2 is optimizeMaxSpeed308addAttr(rv, "Optimization", "2");309// Set /Oy- option310addAttr(rv, "OmitFramePointers", "FALSE");311// Set /Ob option. 1 is expandOnlyInline312addAttr(rv, "InlineFunctionExpansion", "1");313// Set /GF option.314addAttr(rv, "StringPooling", "TRUE");315// Set /MD option. 2 is rtMultiThreadedDLL316addAttr(rv, "RuntimeLibrary", "2");317// Set /Gy option318addAttr(rv, "EnableFunctionLevelLinking", "TRUE");319}320321Vector getProductCompilerFlags() {322Vector rv = new Vector();323324getProductCompilerFlags_common(rv);325326return rv;327}328329Vector getProductLinkerFlags() {330Vector rv = new Vector();331332// Set /OPT:REF option. 2 is optReferences333addAttr(rv, "OptimizeReferences", "2");334// Set /OPT:optFolding option. 2 is optFolding335addAttr(rv, "EnableCOMDATFolding", "2");336337return rv;338}339340String getOptFlag() {341return "2";342}343344String getNoOptFlag() {345return "0";346}347348String makeCfgName(String flavourBuild, String platform) {349return flavourBuild + "|" + platform;350}351352}353354355