0N/A/*
2105N/A * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1934N/Aimport java.io.FileWriter;
1934N/Aimport java.io.IOException;
1934N/Aimport java.io.PrintWriter;
4019N/Aimport java.nio.file.FileSystems;
1934N/Aimport java.util.Vector;
0N/A
0N/Apublic class WinGammaPlatformVC7 extends WinGammaPlatform {
0N/A
4019N/A // TODO How about moving all globals configs to its own BuildConfig?
659N/A
4019N/A String projectVersion() {
4019N/A return "7.10";
4019N/A };
0N/A
4019N/A public void writeProjectFile(String projectFileName, String projectName,
4019N/A Vector<BuildConfig> allConfigs) throws IOException {
4019N/A System.out.println();
4019N/A System.out.println(" Writing .vcproj file: " + projectFileName);
4019N/A // If we got this far without an error, we're safe to actually
4019N/A // write the .vcproj file
4019N/A printWriter = new PrintWriter(new FileWriter(projectFileName));
0N/A
4019N/A printWriter
4019N/A .println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
4019N/A startTag("VisualStudioProject", new String[] { "ProjectType",
4019N/A "Visual C++", "Version", projectVersion(), "Name", projectName,
4019N/A "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
4019N/A "SccProjectName", "", "SccLocalPath", "" });
4019N/A startTag("Platforms");
4019N/A tag("Platform",
4019N/A new String[] { "Name",
4019N/A (String) BuildConfig.getField(null, "PlatformName") });
4019N/A endTag();
2105N/A
4019N/A startTag("Configurations");
2105N/A
4019N/A for (BuildConfig cfg : allConfigs) {
4019N/A writeConfiguration(cfg);
4019N/A }
0N/A
4019N/A endTag();
0N/A
4019N/A tag("References");
0N/A
4019N/A writeFiles(allConfigs);
0N/A
4019N/A tag("Globals");
2105N/A
4019N/A endTag();
4019N/A printWriter.close();
2105N/A
4019N/A System.out.println(" Done.");
4019N/A }
2105N/A
4019N/A void writeCustomToolConfig(Vector<BuildConfig> configs, String[] customToolAttrs) {
4019N/A for (BuildConfig cfg : configs) {
4019N/A startTag("FileConfiguration",
4019N/A new String[] { "Name", (String) cfg.get("Name") });
4019N/A tag("Tool", customToolAttrs);
0N/A
4019N/A endTag();
4019N/A }
4019N/A }
0N/A
4019N/A void writeFiles(Vector<BuildConfig> allConfigs) {
0N/A
4019N/A // This code assummes there are no config specific includes.
4019N/A startTag("Files");
4019N/A String sourceBase = BuildConfig.getFieldString(null, "SourceBase");
0N/A
4019N/A // Use first config for all global absolute includes.
4019N/A BuildConfig baseConfig = allConfigs.firstElement();
4019N/A Vector<String> rv = new Vector<String>();
1879N/A
4019N/A // Then use first config for all relative includes
4019N/A Vector<String> ri = new Vector<String>();
4019N/A baseConfig.collectRelevantVectors(ri, "RelativeSrcInclude");
4019N/A for (String f : ri) {
4019N/A rv.add(sourceBase + Util.sep + f);
4019N/A }
1879N/A
4019N/A baseConfig.collectRelevantVectors(rv, "AbsoluteSrcInclude");
0N/A
4019N/A handleIncludes(rv, allConfigs);
0N/A
4019N/A startTag("Filter", new String[] { "Name", "Resource Files", "Filter",
4019N/A "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" });
4019N/A endTag();
0N/A
4019N/A endTag();
4019N/A }
0N/A
4019N/A // Will visit file tree for each include
4019N/A private void handleIncludes(Vector<String> includes, Vector<BuildConfig> allConfigs) {
4019N/A for (String path : includes) {
4019N/A FileTreeCreatorVC7 ftc = new FileTreeCreatorVC7(FileSystems.getDefault().getPath(path) , allConfigs, this);
4019N/A try {
4019N/A ftc.writeFileTree();
4019N/A } catch (IOException e) {
4019N/A e.printStackTrace();
4019N/A }
4019N/A }
4019N/A }
0N/A
4019N/A void writeConfiguration(BuildConfig cfg) {
4019N/A startTag("Configuration", new String[] { "Name", cfg.get("Name"),
4019N/A "OutputDirectory", cfg.get("OutputDir"),
4019N/A "IntermediateDirectory", cfg.get("OutputDir"),
4019N/A "ConfigurationType", "2", "UseOfMFC", "0",
4019N/A "ATLMinimizesCRunTimeLibraryUsage", "FALSE" });
0N/A
4019N/A tagV("Tool", cfg.getV("CompilerFlags"));
0N/A
4019N/A tag("Tool", new String[] { "Name", "VCCustomBuildTool" });
0N/A
4019N/A tagV("Tool", cfg.getV("LinkerFlags"));
0N/A
4019N/A tag("Tool",
4019N/A new String[] {
4019N/A "Name",
4019N/A "VCPostBuildEventTool",
4019N/A "Description",
4019N/A BuildConfig
4019N/A .getFieldString(null, "PostbuildDescription"),
4019N/A // Caution: String.replace(String,String) is available
4019N/A // from JDK5 onwards only
4019N/A "CommandLine",
4019N/A cfg.expandFormat(BuildConfig.getFieldString(null,
4019N/A "PostbuildCommand").replace("\t",
4019N/A "&#x0D;&#x0A;")) });
0N/A
4019N/A tag("Tool", new String[] { "Name", "VCPreBuildEventTool" });
0N/A
4019N/A tag("Tool",
4019N/A new String[] {
4019N/A "Name",
4019N/A "VCPreLinkEventTool",
4019N/A "Description",
4019N/A BuildConfig.getFieldString(null, "PrelinkDescription"),
4019N/A // Caution: String.replace(String,String) is available
4019N/A // from JDK5 onwards only
4019N/A "CommandLine",
4019N/A cfg.expandFormat(BuildConfig.getFieldString(null,
4019N/A "PrelinkCommand").replace("\t", "&#x0D;&#x0A;")) });
0N/A
4019N/A tag("Tool", new String[] { "Name", "VCResourceCompilerTool",
4019N/A "PreprocessorDefinitions", "NDEBUG", "Culture", "1033" });
0N/A
4019N/A tag("Tool", new String[] { "Name", "VCMIDLTool",
4019N/A "PreprocessorDefinitions", "NDEBUG", "MkTypLibCompatible",
4019N/A "TRUE", "SuppressStartupBanner", "TRUE", "TargetEnvironment",
4019N/A "1", "TypeLibraryName",
4019N/A cfg.get("OutputDir") + Util.sep + "vm.tlb", "HeaderFileName",
4019N/A "" });
0N/A
4019N/A endTag();
4019N/A }
0N/A
0N/A
0N/A
4019N/A protected String getProjectExt() {
4019N/A return ".vcproj";
4019N/A }
0N/A}
0N/A
0N/Aclass CompilerInterfaceVC7 extends CompilerInterface {
4019N/A void getBaseCompilerFlags_common(Vector defines, Vector includes,
4019N/A String outDir, Vector rv) {
0N/A
4019N/A // advanced M$ IDE (2003) can only recognize name if it's first or
4019N/A // second attribute in the tag - go guess
4019N/A addAttr(rv, "Name", "VCCLCompilerTool");
4019N/A addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
4019N/A addAttr(rv, "PreprocessorDefinitions",
4019N/A Util.join(";", defines).replace("\"", "&quot;"));
4019N/A addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
4019N/A addAttr(rv, "PrecompiledHeaderFile", outDir + Util.sep + "vm.pch");
4019N/A addAttr(rv, "AssemblerListingLocation", outDir);
4019N/A addAttr(rv, "ObjectFile", outDir + Util.sep);
4019N/A addAttr(rv, "ProgramDataBaseFileName", outDir + Util.sep + "jvm.pdb");
4019N/A // Set /nologo optin
4019N/A addAttr(rv, "SuppressStartupBanner", "TRUE");
4019N/A // Surpass the default /Tc or /Tp. 0 is compileAsDefault
4019N/A addAttr(rv, "CompileAs", "0");
4019N/A // Set /W3 option. 3 is warningLevel_3
4019N/A addAttr(rv, "WarningLevel", "3");
4019N/A // Set /WX option,
4019N/A addAttr(rv, "WarnAsError", "TRUE");
4019N/A // Set /GS option
4019N/A addAttr(rv, "BufferSecurityCheck", "FALSE");
4019N/A // Set /Zi option. 3 is debugEnabled
4019N/A addAttr(rv, "DebugInformationFormat", "3");
4019N/A }
659N/A
4019N/A Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
4019N/A Vector rv = new Vector();
0N/A
4019N/A getBaseCompilerFlags_common(defines, includes, outDir, rv);
4019N/A // Set /Yu option. 3 is pchUseUsingSpecific
4019N/A // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
4019N/A addAttr(rv, "UsePrecompiledHeader", "3");
4019N/A // Set /EHsc- option
4019N/A addAttr(rv, "ExceptionHandling", "FALSE");
0N/A
4019N/A return rv;
4019N/A }
4019N/A
4019N/A Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
4019N/A Vector rv = new Vector();
0N/A
4019N/A addAttr(rv, "Name", "VCLinkerTool");
4019N/A addAttr(rv, "AdditionalOptions",
4019N/A "/export:JNI_GetDefaultJavaVMInitArgs "
4019N/A + "/export:JNI_CreateJavaVM "
4019N/A + "/export:JVM_FindClassFromBootLoader "
4019N/A + "/export:JNI_GetCreatedJavaVMs "
4019N/A + "/export:jio_snprintf /export:jio_printf "
4019N/A + "/export:jio_fprintf /export:jio_vfprintf "
4019N/A + "/export:jio_vsnprintf "
4019N/A + "/export:JVM_GetVersionInfo "
4019N/A + "/export:JVM_GetThreadStateNames "
4019N/A + "/export:JVM_GetThreadStateValues "
4019N/A + "/export:JVM_InitAgentProperties ");
4019N/A addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
4019N/A addAttr(rv, "OutputFile", outDll);
4019N/A // Set /INCREMENTAL option. 1 is linkIncrementalNo
4019N/A addAttr(rv, "LinkIncremental", "1");
4019N/A addAttr(rv, "SuppressStartupBanner", "TRUE");
4019N/A addAttr(rv, "ModuleDefinitionFile", outDir + Util.sep + "vm.def");
4019N/A addAttr(rv, "ProgramDatabaseFile", outDir + Util.sep + "jvm.pdb");
4019N/A // Set /SUBSYSTEM option. 2 is subSystemWindows
4019N/A addAttr(rv, "SubSystem", "2");
4019N/A addAttr(rv, "BaseAddress", "0x8000000");
4019N/A addAttr(rv, "ImportLibrary", outDir + Util.sep + "jvm.lib");
4019N/A if (platformName.equals("Win32")) {
4019N/A // Set /MACHINE option. 1 is X86
4019N/A addAttr(rv, "TargetMachine", "1");
4019N/A } else {
4019N/A // Set /MACHINE option. 17 is X64
4019N/A addAttr(rv, "TargetMachine", "17");
4019N/A }
0N/A
4019N/A return rv;
4019N/A }
659N/A
4019N/A void getDebugCompilerFlags_common(String opt, Vector rv) {
659N/A
4019N/A // Set /On option
4019N/A addAttr(rv, "Optimization", opt);
4019N/A // Set /FR option. 1 is brAllInfo
4019N/A addAttr(rv, "BrowseInformation", "1");
4019N/A addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
4019N/A // Set /MD option. 2 is rtMultiThreadedDLL
4019N/A addAttr(rv, "RuntimeLibrary", "2");
4019N/A // Set /Oy- option
4019N/A addAttr(rv, "OmitFramePointers", "FALSE");
659N/A
4019N/A }
4019N/A
4019N/A Vector getDebugCompilerFlags(String opt) {
4019N/A Vector rv = new Vector();
0N/A
4019N/A getDebugCompilerFlags_common(opt, rv);
0N/A
4019N/A return rv;
4019N/A }
0N/A
4019N/A Vector getDebugLinkerFlags() {
4019N/A Vector rv = new Vector();
0N/A
4019N/A addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
0N/A
4019N/A return rv;
4019N/A }
4019N/A
4019N/A void getAdditionalNonKernelLinkerFlags(Vector rv) {
4019N/A extAttr(rv, "AdditionalOptions", "/export:AsyncGetCallTrace ");
4019N/A }
1934N/A
4019N/A void getProductCompilerFlags_common(Vector rv) {
4019N/A // Set /O2 option. 2 is optimizeMaxSpeed
4019N/A addAttr(rv, "Optimization", "2");
4019N/A // Set /Oy- option
4019N/A addAttr(rv, "OmitFramePointers", "FALSE");
4019N/A // Set /Ob option. 1 is expandOnlyInline
4019N/A addAttr(rv, "InlineFunctionExpansion", "1");
4019N/A // Set /GF option.
4019N/A addAttr(rv, "StringPooling", "TRUE");
4019N/A // Set /MD option. 2 is rtMultiThreadedDLL
4019N/A addAttr(rv, "RuntimeLibrary", "2");
4019N/A // Set /Gy option
4019N/A addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
4019N/A }
2105N/A
4019N/A Vector getProductCompilerFlags() {
4019N/A Vector rv = new Vector();
2105N/A
4019N/A getProductCompilerFlags_common(rv);
0N/A
4019N/A return rv;
4019N/A }
0N/A
4019N/A Vector getProductLinkerFlags() {
4019N/A Vector rv = new Vector();
0N/A
4019N/A // Set /OPT:REF option. 2 is optReferences
4019N/A addAttr(rv, "OptimizeReferences", "2");
4019N/A // Set /OPT:optFolding option. 2 is optFolding
4019N/A addAttr(rv, "EnableCOMDATFolding", "2");
0N/A
4019N/A return rv;
4019N/A }
0N/A
4019N/A String getOptFlag() {
4019N/A return "2";
4019N/A }
0N/A
4019N/A String getNoOptFlag() {
4019N/A return "0";
4019N/A }
0N/A
4019N/A String makeCfgName(String flavourBuild, String platform) {
4019N/A return flavourBuild + "|" + platform;
4019N/A }
4019N/A
0N/A}