src/share/tools/MakeDeps/WinGammaPlatformVC7.java

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1279
bd02caa94611
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

     1 /*
     2  * Copyright (c) 2005, 2009, 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  */
    25 import java.io.*;
    26 import java.util.*;
    28 public class WinGammaPlatformVC7 extends WinGammaPlatform {
    30     String projectVersion() {return "7.10";};
    32     public void writeProjectFile(String projectFileName, String projectName,
    33                                  Vector allConfigs) throws IOException {
    34         System.out.println();
    35         System.out.println("    Writing .vcproj file...");
    36         // If we got this far without an error, we're safe to actually
    37         // write the .vcproj file
    38         printWriter = new PrintWriter(new FileWriter(projectFileName));
    40         printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
    41         startTag(
    42             "VisualStudioProject",
    43             new String[] {
    44                 "ProjectType", "Visual C++",
    45                 "Version", projectVersion(),
    46                 "Name", projectName,
    47                 "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
    48                 "SccProjectName", "",
    49                 "SccLocalPath", ""
    50             }
    51             );
    53         startTag("Platforms", null);
    54         tag("Platform", new String[] {"Name", Util.os});
    55         endTag("Platforms");
    57         startTag("Configurations", null);
    59         for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
    60             writeConfiguration((BuildConfig)i.next());
    61         }
    63         endTag("Configurations");
    65         tag("References", null);
    67         writeFiles(allConfigs);
    69         tag("Globals", null);
    71         endTag("VisualStudioProject");
    72         printWriter.close();
    74         System.out.println("    Done.");
    75     }
    78     abstract class NameFilter {
    79         protected String fname;
    81         abstract boolean match(FileInfo fi);
    83         String  filterString() { return ""; }
    84         String name() { return this.fname;}
    85     }
    87     class DirectoryFilter extends NameFilter {
    88         String dir;
    89         int baseLen, dirLen;
    91         DirectoryFilter(String dir, String sbase) {
    92             this.dir = dir;
    93             this.baseLen = sbase.length();
    94             this.dirLen = dir.length();
    95             this.fname = dir;
    96         }
    98         DirectoryFilter(String fname, String dir, String sbase) {
    99             this.dir = dir;
   100             this.baseLen = sbase.length();
   101             this.dirLen = dir.length();
   102             this.fname = fname;
   103         }
   106         boolean match(FileInfo fi) {
   107             return fi.full.regionMatches(true, baseLen, dir, 0, dirLen);
   108         }
   109     }
   111     class TypeFilter extends NameFilter {
   112         String[] exts;
   114         TypeFilter(String fname, String[] exts) {
   115             this.fname = fname;
   116             this.exts = exts;
   117         }
   119         boolean match(FileInfo fi) {
   120             for (int i=0; i<exts.length; i++) {
   121                 if (fi.full.endsWith(exts[i])) {
   122                     return true;
   123                 }
   124             }
   125             return false;
   126         }
   128         String  filterString() {
   129             return Util.join(";", exts);
   130         }
   131     }
   133     class TerminatorFilter extends NameFilter {
   134         TerminatorFilter(String fname) {
   135             this.fname = fname;
   137         }
   138         boolean match(FileInfo fi) {
   139             return true;
   140         }
   142     }
   144     class SpecificNameFilter extends NameFilter {
   145         String pats[];
   147         SpecificNameFilter(String fname, String[] pats) {
   148             this.fname = fname;
   149             this.pats = pats;
   150         }
   152         boolean match(FileInfo fi) {
   153             for (int i=0; i<pats.length; i++) {
   154                 if (fi.attr.shortName.matches(pats[i])) {
   155                     return true;
   156                 }
   157             }
   158             return false;
   159         }
   161     }
   163     class ContainerFilter extends NameFilter {
   164         Vector children;
   166         ContainerFilter(String fname) {
   167             this.fname = fname;
   168             children = new Vector();
   170         }
   171         boolean match(FileInfo fi) {
   172             return false;
   173         }
   175         Iterator babies() { return children.iterator(); }
   177         void add(NameFilter f) {
   178             children.add(f);
   179         }
   180     }
   183     void writeCustomToolConfig(Vector configs, String[] customToolAttrs) {
   184         for (Iterator i = configs.iterator(); i.hasNext(); ) {
   185             startTag("FileConfiguration",
   186                      new String[] {
   187                          "Name",  (String)i.next()
   188                      }
   189                      );
   190             tag("Tool", customToolAttrs);
   192             endTag("FileConfiguration");
   193         }
   194     }
   196     // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC
   197     // Basically there are two types of entities - container filters and real filters
   198     //   - container filter just provides a container to group together real filters
   199     //   - real filter can select elements from the set according to some rule, put it into XML
   200     //     and remove from the list
   201     Vector makeFilters(TreeSet files) {
   202         Vector rv = new Vector();
   203         String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/");
   205         ContainerFilter rt = new ContainerFilter("Runtime");
   206         rt.add(new DirectoryFilter("share/vm/prims", sbase));
   207         rt.add(new DirectoryFilter("share/vm/runtime", sbase));
   208         rt.add(new DirectoryFilter("share/vm/oops", sbase));
   209         rv.add(rt);
   211         ContainerFilter gc = new ContainerFilter("GC");
   212         gc.add(new DirectoryFilter("share/vm/memory", sbase));
   213         gc.add(new DirectoryFilter("share/vm/gc_interface", sbase));
   215         ContainerFilter gc_impl = new ContainerFilter("Implementations");
   216         gc_impl.add(new DirectoryFilter("CMS",
   217                                         "share/vm/gc_implementation/concurrentMarkSweep",
   218                                         sbase));
   219         gc_impl.add(new DirectoryFilter("Parallel Scavenge",
   220                                         "share/vm/gc_implementation/parallelScavenge",
   221                                         sbase));
   222         gc_impl.add(new DirectoryFilter("Shared",
   223                                         "share/vm/gc_implementation/shared",
   224                                         sbase));
   225         // for all leftovers
   226         gc_impl.add(new DirectoryFilter("Misc",
   227                                         "share/vm/gc_implementation",
   228                                         sbase));
   230         gc.add(gc_impl);
   231         rv.add(gc);
   233         rv.add(new DirectoryFilter("C1", "share/vm/c1", sbase));
   235         ContainerFilter c2 = new ContainerFilter("C2");
   236         //c2.add(new DirectoryFilter("share/vm/adlc", sbase));
   237         c2.add(new DirectoryFilter("share/vm/opto", sbase));
   238         c2.add(new SpecificNameFilter("Generated", new String[] {"^ad_.+", "^dfa_.+", "^adGlobals.+"}));
   239         rv.add(c2);
   241         ContainerFilter comp = new ContainerFilter("Compiler Common");
   242         comp.add(new DirectoryFilter("share/vm/asm", sbase));
   243         comp.add(new DirectoryFilter("share/vm/ci", sbase));
   244         comp.add(new DirectoryFilter("share/vm/code", sbase));
   245         comp.add(new DirectoryFilter("share/vm/compiler", sbase));
   246         rv.add(comp);
   248         rv.add(new DirectoryFilter("Interpreter",
   249                                    "share/vm/interpreter",
   250                                    sbase));
   252         ContainerFilter misc = new ContainerFilter("Misc");
   253         //misc.add(new DirectoryFilter("share/vm/launch", sbase));
   254         misc.add(new DirectoryFilter("share/vm/libadt", sbase));
   255         misc.add(new DirectoryFilter("share/vm/services", sbase));
   256         misc.add(new DirectoryFilter("share/vm/utilities", sbase));
   257         rv.add(misc);
   259         rv.add(new DirectoryFilter("os_cpu", sbase));
   261         rv.add(new DirectoryFilter("cpu", sbase));
   263         rv.add(new DirectoryFilter("os", sbase));
   265         rv.add(new SpecificNameFilter("JVMTI Generated", new String[] {"^jvmti.+"}));
   267         rv.add(new SpecificNameFilter("C++ Interpreter Generated", new String[] {"^bytecodeInterpreterWithChecks.+"}));
   269         rv.add(new SpecificNameFilter("Include DBs", new String[] {"^includeDB_.+"}));
   271         // this one is to catch files not caught by other filters
   272         //rv.add(new TypeFilter("Header Files", new String[] {"h", "hpp", "hxx", "hm", "inl", "fi", "fd"}));
   273         rv.add(new TerminatorFilter("Source Files"));
   275         return rv;
   276     }
   278     void writeFiles(Vector allConfigs) {
   280         Hashtable allFiles = computeAttributedFiles(allConfigs);
   282         Vector allConfigNames = new Vector();
   283         for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
   284             allConfigNames.add(((BuildConfig)i.next()).get("Name"));
   285         }
   287         TreeSet sortedFiles = sortFiles(allFiles);
   289         startTag("Files", null);
   291         for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
   292             doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next());
   293         }
   296         startTag("Filter",
   297                  new String[] {
   298                      "Name", "Resource Files",
   299                      "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
   300                  }
   301                  );
   302         endTag("Filter");
   304         endTag("Files");
   305     }
   307     void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) {
   308         startTag("Filter",
   309                  new String[] {
   310                      "Name",   filter.name(),
   311                      "Filter", filter.filterString()
   312                  }
   313                  );
   315         if (filter instanceof ContainerFilter) {
   317             Iterator i = ((ContainerFilter)filter).babies();
   318             while (i.hasNext()) {
   319                 doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next());
   320             }
   322         } else {
   324             Iterator i = allFiles.iterator();
   325             while (i.hasNext()) {
   326                 FileInfo fi = (FileInfo)i.next();
   328                 if (!filter.match(fi)) {
   329                     continue;
   330                 }
   332                 startTag("File",
   333                          new String[] {
   334                              "RelativePath", fi.full.replace('/', '\\')
   335                          }
   336                          );
   338                 FileAttribute a = fi.attr;
   339                 if (a.pchRoot) {
   340                     writeCustomToolConfig(allConfigNames,
   341                                           new String[] {
   342                                               "Name", "VCCLCompilerTool",
   343                                               "UsePrecompiledHeader", "1"
   344                                           });
   345                 }
   347                 if (a.noPch) {
   348                     writeCustomToolConfig(allConfigNames,
   349                                           new String[] {
   350                                               "Name", "VCCLCompilerTool",
   351                                               "UsePrecompiledHeader", "0"
   352                                           });
   353                 }
   355                 if (a.configs != null) {
   356                     for (Iterator j=allConfigNames.iterator(); j.hasNext();) {
   357                         String cfg = (String)j.next();
   358                         if (!a.configs.contains(cfg)) {
   359                             startTag("FileConfiguration",
   360                                      new String[] {
   361                                          "Name", cfg,
   362                                          "ExcludedFromBuild", "TRUE"
   363                                      });
   364                             tag("Tool", new String[] {"Name", "VCCLCompilerTool"});
   365                             endTag("FileConfiguration");
   367                         }
   368                     }
   369                 }
   371                 endTag("File");
   373                 // we not gonna look at this file anymore
   374                 i.remove();
   375             }
   376         }
   378         endTag("Filter");
   379     }
   382     void writeConfiguration(BuildConfig cfg) {
   383         startTag("Configuration",
   384                  new String[] {
   385                      "Name", cfg.get("Name"),
   386                      "OutputDirectory",  cfg.get("OutputDir"),
   387                      "IntermediateDirectory",  cfg.get("OutputDir"),
   388                      "ConfigurationType", "2",
   389                      "UseOfMFC", "0",
   390                      "ATLMinimizesCRunTimeLibraryUsage", "FALSE"
   391                  }
   392                  );
   396         tagV("Tool", cfg.getV("CompilerFlags"));
   398         tag("Tool",
   399             new String[] {
   400                 "Name", "VCCustomBuildTool"
   401             }
   402             );
   404         tagV("Tool", cfg.getV("LinkerFlags"));
   406         tag("Tool",
   407             new String[] {
   408                 "Name", "VCPostBuildEventTool"
   409             }
   410             );
   412         tag("Tool",
   413             new String[] {
   414                 "Name", "VCPreBuildEventTool"
   415             }
   416             );
   418         tag("Tool",
   419             new String[] {
   420                 "Name", "VCPreLinkEventTool",
   421                 "Description", BuildConfig.getFieldString(null, "PrelinkDescription"),
   422                 //Caution: String.replace(String,String) is available from JDK5 onwards only
   423                 "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace
   424                    ("\t", "&#x0D;&#x0A;"))
   425             }
   426             );
   428         tag("Tool",
   429             new String[] {
   430                 "Name", "VCResourceCompilerTool",
   431                 // XXX???
   432                 "PreprocessorDefinitions", "NDEBUG",
   433                 "Culture", "1033"
   434             }
   435             );
   436         tag("Tool",
   437             new String[] {
   438               "Name", "VCWebServiceProxyGeneratorTool"
   439             }
   440             );
   442         tag ("Tool",
   443              new String[] {
   444               "Name", "VCXMLDataGeneratorTool"
   445              }
   446              );
   448         tag("Tool",
   449             new String[] {
   450               "Name", "VCWebDeploymentTool"
   451             }
   452             );
   453         tag("Tool",
   454              new String[] {
   455             "Name", "VCManagedWrapperGeneratorTool"
   456              }
   457             );
   458         tag("Tool",
   459             new String[] {
   460               "Name", "VCAuxiliaryManagedWrapperGeneratorTool"
   461             }
   462             );
   464         tag("Tool",
   465             new String[] {
   466                 "Name", "VCMIDLTool",
   467                 "PreprocessorDefinitions", "NDEBUG",
   468                 "MkTypLibCompatible", "TRUE",
   469                 "SuppressStartupBanner", "TRUE",
   470                 "TargetEnvironment", "1",
   471                 "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb",
   472                 "HeaderFileName", ""
   473             }
   474             );
   476         endTag("Configuration");
   477     }
   479     int indent;
   481     private void startTagPrim(String name,
   482                               String[] attrs,
   483                               boolean close) {
   484         doIndent();
   485         printWriter.print("<"+name);
   486         indent++;
   488         if (attrs != null) {
   489             printWriter.println();
   490             for (int i=0; i<attrs.length; i+=2) {
   491                 doIndent();
   492                 printWriter.println(" " + attrs[i]+"=\""+attrs[i+1]+"\"");
   493             }
   494         }
   496         if (close) {
   497             indent--;
   498             //doIndent();
   499             printWriter.println("/>");
   500         } else {
   501             //doIndent();
   502             printWriter.println(">");
   503         }
   504     }
   506     void startTag(String name, String[] attrs) {
   507         startTagPrim(name, attrs, false);
   508     }
   510     void startTagV(String name, Vector attrs) {
   511         String s[] = new String [attrs.size()];
   512          for (int i=0; i<attrs.size(); i++) {
   513              s[i] = (String)attrs.elementAt(i);
   514          }
   515         startTagPrim(name, s, false);
   516     }
   518     void endTag(String name) {
   519         indent--;
   520         doIndent();
   521         printWriter.println("</"+name+">");
   522     }
   524     void tag(String name, String[] attrs) {
   525         startTagPrim(name, attrs, true);
   526     }
   528      void tagV(String name, Vector attrs) {
   529          String s[] = new String [attrs.size()];
   530          for (int i=0; i<attrs.size(); i++) {
   531              s[i] = (String)attrs.elementAt(i);
   532          }
   533          startTagPrim(name, s, true);
   534     }
   537     void doIndent() {
   538         for (int i=0; i<indent; i++) {
   539             printWriter.print("    ");
   540         }
   541     }
   543     protected String getProjectExt() {
   544         return ".vcproj";
   545     }
   546 }
   548 class CompilerInterfaceVC7 extends CompilerInterface {
   549     void getBaseCompilerFlags_common(Vector defines, Vector includes, String outDir,Vector rv) {
   551         // advanced M$ IDE (2003) can only recognize name if it's first or
   552         // second attribute in the tag - go guess
   553         addAttr(rv, "Name", "VCCLCompilerTool");
   554         addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
   555         addAttr(rv, "PreprocessorDefinitions",
   556                                 Util.join(";", defines).replace("\"","&quot;"));
   557         addAttr(rv, "PrecompiledHeaderThrough",
   558                                 "incls"+Util.sep+"_precompiled.incl");
   559         addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch");
   560         addAttr(rv, "AssemblerListingLocation", outDir);
   561         addAttr(rv, "ObjectFile", outDir+Util.sep);
   562         addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"vm.pdb");
   563         // Set /nologo optin
   564         addAttr(rv, "SuppressStartupBanner", "TRUE");
   565         // Surpass the default /Tc or /Tp. 0 is compileAsDefault
   566         addAttr(rv, "CompileAs", "0");
   567         // Set /W3 option. 3 is warningLevel_3
   568         addAttr(rv, "WarningLevel", "3");
   569         // Set /WX option,
   570         addAttr(rv, "WarnAsError", "TRUE");
   571         // Set /GS option
   572         addAttr(rv, "BufferSecurityCheck", "FALSE");
   573         // Set /Zi option. 3 is debugEnabled
   574         addAttr(rv, "DebugInformationFormat", "3");
   575     }
   576     Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
   577         Vector rv = new Vector();
   579         getBaseCompilerFlags_common(defines,includes, outDir, rv);
   580         // Set /Yu option. 3 is pchUseUsingSpecific
   581         // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
   582         addAttr(rv, "UsePrecompiledHeader", "3");
   583         // Set /EHsc- option
   584         addAttr(rv, "ExceptionHandling", "FALSE");
   586         return rv;
   587     }
   589     Vector getBaseLinkerFlags(String outDir, String outDll) {
   590         Vector rv = new Vector();
   592         addAttr(rv, "Name", "VCLinkerTool");
   593         addAttr(rv, "AdditionalOptions",
   594                 "/export:JNI_GetDefaultJavaVMInitArgs " +
   595                 "/export:JNI_CreateJavaVM " +
   596                 "/export:JNI_GetCreatedJavaVMs "+
   597                 "/export:jio_snprintf /export:jio_printf "+
   598                 "/export:jio_fprintf /export:jio_vfprintf "+
   599                 "/export:jio_vsnprintf ");
   600         addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
   601         addAttr(rv, "OutputFile", outDll);
   602         // Set /INCREMENTAL option. 1 is linkIncrementalNo
   603         addAttr(rv, "LinkIncremental", "1");
   604         addAttr(rv, "SuppressStartupBanner", "TRUE");
   605         addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
   606         addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"vm.pdb");
   607         // Set /SUBSYSTEM option. 2 is subSystemWindows
   608         addAttr(rv, "SubSystem", "2");
   609         addAttr(rv, "BaseAddress", "0x8000000");
   610         addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
   611         // Set /MACHINE option. 1 is machineX86
   612         addAttr(rv, "TargetMachine", "1");
   614         return rv;
   615     }
   617     void  getDebugCompilerFlags_common(String opt,Vector rv) {
   619         // Set /On option
   620         addAttr(rv, "Optimization", opt);
   621         // Set /FR option. 1 is brAllInfo
   622         addAttr(rv, "BrowseInformation", "1");
   623         addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
   624         // Set /MD option. 2 is rtMultiThreadedDLL
   625         addAttr(rv, "RuntimeLibrary", "2");
   626         // Set /Oy- option
   627         addAttr(rv, "OmitFramePointers", "FALSE");
   629     }
   631     Vector getDebugCompilerFlags(String opt) {
   632         Vector rv = new Vector();
   634         getDebugCompilerFlags_common(opt,rv);
   636         return rv;
   637     }
   639     Vector getDebugLinkerFlags() {
   640         Vector rv = new Vector();
   642         addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
   644         return rv;
   645     }
   647     void getProductCompilerFlags_common(Vector rv) {
   648         // Set /O2 option. 2 is optimizeMaxSpeed
   649         addAttr(rv, "Optimization", "2");
   650         // Set /Oy- option
   651         addAttr(rv, "OmitFramePointers", "FALSE");
   652     }
   654     Vector getProductCompilerFlags() {
   655         Vector rv = new Vector();
   657         getProductCompilerFlags_common(rv);
   658         // Set /Ob option.  1 is expandOnlyInline
   659         addAttr(rv, "InlineFunctionExpansion", "1");
   660         // Set /GF option.
   661         addAttr(rv, "StringPooling", "TRUE");
   662         // Set /MD option. 2 is rtMultiThreadedDLL
   663         addAttr(rv, "RuntimeLibrary", "2");
   664         // Set /Gy option
   665         addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
   667         return rv;
   668     }
   670     Vector getProductLinkerFlags() {
   671         Vector rv = new Vector();
   673         // Set /OPT:REF option. 2 is optReferences
   674         addAttr(rv, "OptimizeReferences", "2");
   675         // Set /OPT:optFolding option. 2 is optFolding
   676         addAttr(rv, "EnableCOMDATFolding", "2");
   678         return rv;
   679     }
   681     String getOptFlag() {
   682         return "2";
   683     }
   685     String getNoOptFlag() {
   686         return "0";
   687     }
   689     String makeCfgName(String flavourBuild) {
   690         return  flavourBuild + "|" + Util.os;
   691     }
   692 }

mercurial