WinGammaPlatformVC7.java 26.1 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25 26 27 28 29 30 31
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.Vector;
D
duke 已提交
32 33 34

public class WinGammaPlatformVC7 extends WinGammaPlatform {

35 36
    String projectVersion() {return "7.10";};

D
duke 已提交
37
    public void writeProjectFile(String projectFileName, String projectName,
38
                                 Vector<BuildConfig> allConfigs) throws IOException {
D
duke 已提交
39
        System.out.println();
40
        System.out.println("    Writing .vcproj file: "+projectFileName);
D
duke 已提交
41 42 43 44 45 46 47 48 49
        // If we got this far without an error, we're safe to actually
        // write the .vcproj file
        printWriter = new PrintWriter(new FileWriter(projectFileName));

        printWriter.println("<?xml version=\"1.0\" encoding=\"windows-1251\"?>");
        startTag(
            "VisualStudioProject",
            new String[] {
                "ProjectType", "Visual C++",
50
                "Version", projectVersion(),
D
duke 已提交
51 52 53 54 55 56
                "Name", projectName,
                "ProjectGUID", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}",
                "SccProjectName", "",
                "SccLocalPath", ""
            }
            );
57
        startTag("Platforms");
58
        tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")});
D
duke 已提交
59 60
        endTag("Platforms");

61
        startTag("Configurations");
D
duke 已提交
62 63 64 65 66 67 68

        for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
            writeConfiguration((BuildConfig)i.next());
        }

        endTag("Configurations");

69
        tag("References");
D
duke 已提交
70 71 72

        writeFiles(allConfigs);

73
        tag("Globals");
D
duke 已提交
74 75 76 77 78 79 80 81 82

        endTag("VisualStudioProject");
        printWriter.close();

        System.out.println("    Done.");
    }


    abstract class NameFilter {
83
                protected String fname;
D
duke 已提交
84 85 86 87 88

        abstract boolean match(FileInfo fi);

        String  filterString() { return ""; }
        String name() { return this.fname;}
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123

        @Override
        // eclipse auto-generated
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            result = prime * result + getOuterType().hashCode();
            result = prime * result + ((fname == null) ? 0 : fname.hashCode());
            return result;
        }

        @Override
        // eclipse auto-generated
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            NameFilter other = (NameFilter) obj;
            if (!getOuterType().equals(other.getOuterType()))
                return false;
            if (fname == null) {
                if (other.fname != null)
                    return false;
            } else if (!fname.equals(other.fname))
                return false;
            return true;
        }

        // eclipse auto-generated
        private WinGammaPlatformVC7 getOuterType() {
            return WinGammaPlatformVC7.this;
        }
D
duke 已提交
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
    }

    class DirectoryFilter extends NameFilter {
        String dir;
        int baseLen, dirLen;

        DirectoryFilter(String dir, String sbase) {
            this.dir = dir;
            this.baseLen = sbase.length();
            this.dirLen = dir.length();
            this.fname = dir;
        }

        DirectoryFilter(String fname, String dir, String sbase) {
            this.dir = dir;
            this.baseLen = sbase.length();
            this.dirLen = dir.length();
            this.fname = fname;
        }


        boolean match(FileInfo fi) {
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
            int lastSlashIndex = fi.full.lastIndexOf('/');
            String fullDir = fi.full.substring(0, lastSlashIndex);
            return fullDir.endsWith(dir);
        }

        @Override
        // eclipse auto-generated
        public int hashCode() {
            final int prime = 31;
            int result = super.hashCode();
            result = prime * result + getOuterType().hashCode();
            result = prime * result + baseLen;
            result = prime * result + ((dir == null) ? 0 : dir.hashCode());
            result = prime * result + dirLen;
            return result;
        }

        @Override
        // eclipse auto-generated
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (!super.equals(obj))
                return false;
            if (getClass() != obj.getClass())
                return false;
            DirectoryFilter other = (DirectoryFilter) obj;
            if (!getOuterType().equals(other.getOuterType()))
                return false;
            if (baseLen != other.baseLen)
                return false;
            if (dir == null) {
                if (other.dir != null)
                    return false;
            } else if (!dir.equals(other.dir))
                return false;
            if (dirLen != other.dirLen)
                return false;
            return true;
        }

        // eclipse auto-generated
        private WinGammaPlatformVC7 getOuterType() {
            return WinGammaPlatformVC7.this;
D
duke 已提交
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
        }
    }

    class TerminatorFilter extends NameFilter {
        TerminatorFilter(String fname) {
            this.fname = fname;

        }
        boolean match(FileInfo fi) {
            return true;
        }

    }

    class SpecificNameFilter extends NameFilter {
        String pats[];

        SpecificNameFilter(String fname, String[] pats) {
            this.fname = fname;
            this.pats = pats;
        }

        boolean match(FileInfo fi) {
            for (int i=0; i<pats.length; i++) {
                if (fi.attr.shortName.matches(pats[i])) {
                    return true;
                }
            }
            return false;
        }

    }

223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
    class SpecificPathFilter extends NameFilter {
        String pats[];

        SpecificPathFilter(String fname, String[] pats) {
            this.fname = fname;
            this.pats = pats;
        }

        boolean match(FileInfo fi) {
            for (int i=0; i<pats.length; i++) {
                if (fi.full.matches(pats[i])) {
                    return true;
                }
            }
            return false;
        }

    }

D
duke 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
    class ContainerFilter extends NameFilter {
        Vector children;

        ContainerFilter(String fname) {
            this.fname = fname;
            children = new Vector();

        }
        boolean match(FileInfo fi) {
            return false;
        }

        Iterator babies() { return children.iterator(); }

        void add(NameFilter f) {
            children.add(f);
        }
    }


    void writeCustomToolConfig(Vector configs, String[] customToolAttrs) {
        for (Iterator i = configs.iterator(); i.hasNext(); ) {
            startTag("FileConfiguration",
                     new String[] {
                         "Name",  (String)i.next()
                     }
                     );
            tag("Tool", customToolAttrs);

            endTag("FileConfiguration");
        }
    }

    // here we define filters, which define layout of what can be seen in 'Solution View' of MSVC
    // Basically there are two types of entities - container filters and real filters
    //   - container filter just provides a container to group together real filters
    //   - real filter can select elements from the set according to some rule, put it into XML
    //     and remove from the list
280 281
    Vector<NameFilter> makeFilters(TreeSet<FileInfo> files) {
        Vector<NameFilter> rv = new Vector<NameFilter>();
D
duke 已提交
282 283
        String sbase = Util.normalize(BuildConfig.getFieldString(null, "SourceBase")+"/src/");

284 285 286 287
        String currentDir = "";
        DirectoryFilter container = null;
        for(FileInfo fileInfo : files) {

288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
            if (!fileInfo.full.startsWith(sbase)) {
                continue;
            }

            int lastSlash = fileInfo.full.lastIndexOf('/');
            String dir = fileInfo.full.substring(sbase.length(), lastSlash);
            if(dir.equals("share/vm")) {
                // skip files directly in share/vm - should only be precompiled.hpp which is handled below
                continue;
            }
            if (!dir.equals(currentDir)) {
                currentDir = dir;
                if (container != null && !rv.contains(container)) {
                    rv.add(container);
                }

                // remove "share/vm/" from names
                String name = dir;
                if (dir.startsWith("share/vm/")) {
                    name = dir.substring("share/vm/".length(), dir.length());
                }
                DirectoryFilter newfilter = new DirectoryFilter(name, dir, sbase);
                int i = rv.indexOf(newfilter);
                if(i == -1) {
                    container = newfilter;
                } else {
                    // if the filter already exists, reuse it
                    container = (DirectoryFilter) rv.get(i);
                }
            }
        }
        if (container != null && !rv.contains(container)) {
            rv.add(container);
321
        }
D
duke 已提交
322

323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
        ContainerFilter generated = new ContainerFilter("Generated");
        ContainerFilter c1Generated = new ContainerFilter("C1");
        c1Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler1/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
        c1Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler1/generated/jvmtifiles/.*"}));
        generated.add(c1Generated);
        ContainerFilter c2Generated = new ContainerFilter("C2");
        c2Generated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*compiler2/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
        c2Generated.add(new SpecificPathFilter("adfiles", new String[] {".*compiler2/generated/adfiles/.*"}));
        c2Generated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*compiler2/generated/jvmtifiles/.*"}));
        generated.add(c2Generated);
        ContainerFilter coreGenerated = new ContainerFilter("Core");
        coreGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*core/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
        coreGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*core/generated/jvmtifiles/.*"}));
        generated.add(coreGenerated);
        ContainerFilter tieredGenerated = new ContainerFilter("Tiered");
        tieredGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*tiered/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
        tieredGenerated.add(new SpecificPathFilter("adfiles", new String[] {".*tiered/generated/adfiles/.*"}));
        tieredGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*tiered/generated/jvmtifiles/.*"}));
        generated.add(tieredGenerated);
        ContainerFilter kernelGenerated = new ContainerFilter("Kernel");
        kernelGenerated.add(new SpecificPathFilter("C++ Interpreter Generated", new String[] {".*kernel/generated/jvmtifiles/bytecodeInterpreterWithChecks.+"}));
        kernelGenerated.add(new SpecificPathFilter("jvmtifiles", new String[] {".*kernel/generated/jvmtifiles/.*"}));
        generated.add(kernelGenerated);
        rv.add(generated);

        rv.add(new SpecificNameFilter("Precompiled Header", new String[] {"precompiled.hpp"}));
D
duke 已提交
349 350 351 352 353 354 355

        // this one is to catch files not caught by other filters
        rv.add(new TerminatorFilter("Source Files"));

        return rv;
    }

356
    void writeFiles(Vector<BuildConfig> allConfigs) {
D
duke 已提交
357 358 359 360 361 362 363 364 365 366

        Hashtable allFiles = computeAttributedFiles(allConfigs);

        Vector allConfigNames = new Vector();
        for (Iterator i = allConfigs.iterator(); i.hasNext(); ) {
            allConfigNames.add(((BuildConfig)i.next()).get("Name"));
        }

        TreeSet sortedFiles = sortFiles(allFiles);

367
        startTag("Files");
D
duke 已提交
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484

        for (Iterator i = makeFilters(sortedFiles).iterator(); i.hasNext(); ) {
            doWriteFiles(sortedFiles, allConfigNames, (NameFilter)i.next());
        }


        startTag("Filter",
                 new String[] {
                     "Name", "Resource Files",
                     "Filter", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
                 }
                 );
        endTag("Filter");

        endTag("Files");
    }

    void doWriteFiles(TreeSet allFiles, Vector allConfigNames, NameFilter filter) {
        startTag("Filter",
                 new String[] {
                     "Name",   filter.name(),
                     "Filter", filter.filterString()
                 }
                 );

        if (filter instanceof ContainerFilter) {

            Iterator i = ((ContainerFilter)filter).babies();
            while (i.hasNext()) {
                doWriteFiles(allFiles, allConfigNames, (NameFilter)i.next());
            }

        } else {

            Iterator i = allFiles.iterator();
            while (i.hasNext()) {
                FileInfo fi = (FileInfo)i.next();

                if (!filter.match(fi)) {
                    continue;
                }

                startTag("File",
                         new String[] {
                             "RelativePath", fi.full.replace('/', '\\')
                         }
                         );

                FileAttribute a = fi.attr;
                if (a.pchRoot) {
                    writeCustomToolConfig(allConfigNames,
                                          new String[] {
                                              "Name", "VCCLCompilerTool",
                                              "UsePrecompiledHeader", "1"
                                          });
                }

                if (a.noPch) {
                    writeCustomToolConfig(allConfigNames,
                                          new String[] {
                                              "Name", "VCCLCompilerTool",
                                              "UsePrecompiledHeader", "0"
                                          });
                }

                if (a.configs != null) {
                    for (Iterator j=allConfigNames.iterator(); j.hasNext();) {
                        String cfg = (String)j.next();
                        if (!a.configs.contains(cfg)) {
                            startTag("FileConfiguration",
                                     new String[] {
                                         "Name", cfg,
                                         "ExcludedFromBuild", "TRUE"
                                     });
                            endTag("FileConfiguration");

                        }
                    }
                }

                endTag("File");

                // we not gonna look at this file anymore
                i.remove();
            }
        }

        endTag("Filter");
    }


    void writeConfiguration(BuildConfig cfg) {
        startTag("Configuration",
                 new String[] {
                     "Name", cfg.get("Name"),
                     "OutputDirectory",  cfg.get("OutputDir"),
                     "IntermediateDirectory",  cfg.get("OutputDir"),
                     "ConfigurationType", "2",
                     "UseOfMFC", "0",
                     "ATLMinimizesCRunTimeLibraryUsage", "FALSE"
                 }
                 );



        tagV("Tool", cfg.getV("CompilerFlags"));

        tag("Tool",
            new String[] {
                "Name", "VCCustomBuildTool"
            }
            );

        tagV("Tool", cfg.getV("LinkerFlags"));

        tag("Tool",
            new String[] {
485 486 487 488 489
               "Name", "VCPostBuildEventTool",
                "Description", BuildConfig.getFieldString(null, "PostbuildDescription"),
                //Caution: String.replace(String,String) is available from JDK5 onwards only
                "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PostbuildCommand").replace
                   ("\t", "&#x0D;&#x0A;"))
D
duke 已提交
490 491 492 493 494 495 496 497 498 499 500 501 502
            }
            );

        tag("Tool",
            new String[] {
                "Name", "VCPreBuildEventTool"
            }
            );

        tag("Tool",
            new String[] {
                "Name", "VCPreLinkEventTool",
                "Description", BuildConfig.getFieldString(null, "PrelinkDescription"),
503 504 505
                //Caution: String.replace(String,String) is available from JDK5 onwards only
                "CommandLine", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace
                   ("\t", "&#x0D;&#x0A;"))
D
duke 已提交
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534
            }
            );

        tag("Tool",
            new String[] {
                "Name", "VCResourceCompilerTool",
                // XXX???
                "PreprocessorDefinitions", "NDEBUG",
                "Culture", "1033"
            }
            );

        tag("Tool",
            new String[] {
                "Name", "VCMIDLTool",
                "PreprocessorDefinitions", "NDEBUG",
                "MkTypLibCompatible", "TRUE",
                "SuppressStartupBanner", "TRUE",
                "TargetEnvironment", "1",
                "TypeLibraryName", cfg.get("OutputDir") + Util.sep + "vm.tlb",
                "HeaderFileName", ""
            }
            );

        endTag("Configuration");
    }

    int indent;

535 536 537 538 539 540
    private void startTagPrim(String name,
            String[] attrs,
            boolean close) {
        startTagPrim(name, attrs, close, true);
    }

D
duke 已提交
541 542
    private void startTagPrim(String name,
                              String[] attrs,
543 544
                              boolean close,
                              boolean newline) {
D
duke 已提交
545 546 547 548
        doIndent();
        printWriter.print("<"+name);
        indent++;

549
        if (attrs != null && attrs.length > 0) {
D
duke 已提交
550
            for (int i=0; i<attrs.length; i+=2) {
551 552 553
                printWriter.print(" " + attrs[i]+"=\""+attrs[i+1]+"\"");
                if (i < attrs.length - 2) {
                }
D
duke 已提交
554 555 556 557 558
            }
        }

        if (close) {
            indent--;
559
            printWriter.print(" />");
D
duke 已提交
560
        } else {
561 562 563 564
                printWriter.print(">");
        }
        if(newline) {
                printWriter.println();
D
duke 已提交
565 566 567
        }
    }

568
    void startTag(String name, String... attrs) {
D
duke 已提交
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
        startTagPrim(name, attrs, false);
    }

    void startTagV(String name, Vector attrs) {
        String s[] = new String [attrs.size()];
         for (int i=0; i<attrs.size(); i++) {
             s[i] = (String)attrs.elementAt(i);
         }
        startTagPrim(name, s, false);
    }

    void endTag(String name) {
        indent--;
        doIndent();
        printWriter.println("</"+name+">");
    }

586
    void tag(String name, String... attrs) {
D
duke 已提交
587 588 589
        startTagPrim(name, attrs, true);
    }

590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
    void tagData(String name, String data) {
        doIndent();
        printWriter.print("<"+name+">");
        printWriter.print(data);
        printWriter.println("</"+name+">");
    }

    void tagData(String name, String data, String... attrs) {
        startTagPrim(name, attrs, false, false);
        printWriter.print(data);
        printWriter.println("</"+name+">");
        indent--;
    }

    void tagV(String name, Vector attrs) {
D
duke 已提交
605 606 607 608 609 610 611 612 613 614
         String s[] = new String [attrs.size()];
         for (int i=0; i<attrs.size(); i++) {
             s[i] = (String)attrs.elementAt(i);
         }
         startTagPrim(name, s, true);
    }


    void doIndent() {
        for (int i=0; i<indent; i++) {
615
            printWriter.print("  ");
D
duke 已提交
616 617 618 619 620 621 622 623 624
        }
    }

    protected String getProjectExt() {
        return ".vcproj";
    }
}

class CompilerInterfaceVC7 extends CompilerInterface {
625
    void getBaseCompilerFlags_common(Vector defines, Vector includes, String outDir,Vector rv) {
D
duke 已提交
626 627 628 629 630

        // advanced M$ IDE (2003) can only recognize name if it's first or
        // second attribute in the tag - go guess
        addAttr(rv, "Name", "VCCLCompilerTool");
        addAttr(rv, "AdditionalIncludeDirectories", Util.join(",", includes));
631 632
        addAttr(rv, "PreprocessorDefinitions",
                                Util.join(";", defines).replace("\"","&quot;"));
633
        addAttr(rv, "PrecompiledHeaderThrough", "precompiled.hpp");
D
duke 已提交
634 635 636
        addAttr(rv, "PrecompiledHeaderFile", outDir+Util.sep+"vm.pch");
        addAttr(rv, "AssemblerListingLocation", outDir);
        addAttr(rv, "ObjectFile", outDir+Util.sep);
637
        addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb");
638
        // Set /nologo optin
D
duke 已提交
639
        addAttr(rv, "SuppressStartupBanner", "TRUE");
640
        // Surpass the default /Tc or /Tp. 0 is compileAsDefault
D
duke 已提交
641
        addAttr(rv, "CompileAs", "0");
642
        // Set /W3 option. 3 is warningLevel_3
D
duke 已提交
643
        addAttr(rv, "WarningLevel", "3");
644
        // Set /WX option,
D
duke 已提交
645
        addAttr(rv, "WarnAsError", "TRUE");
646
        // Set /GS option
D
duke 已提交
647
        addAttr(rv, "BufferSecurityCheck", "FALSE");
648 649 650 651 652 653 654 655 656 657 658
        // Set /Zi option. 3 is debugEnabled
        addAttr(rv, "DebugInformationFormat", "3");
    }
    Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
        Vector rv = new Vector();

        getBaseCompilerFlags_common(defines,includes, outDir, rv);
        // Set /Yu option. 3 is pchUseUsingSpecific
        // Note: Starting VC8 pchUseUsingSpecific is 2 !!!
        addAttr(rv, "UsePrecompiledHeader", "3");
        // Set /EHsc- option
D
duke 已提交
659 660 661 662 663
        addAttr(rv, "ExceptionHandling", "FALSE");

        return rv;
    }

664
    Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
D
duke 已提交
665 666 667 668 669 670
        Vector rv = new Vector();

        addAttr(rv, "Name", "VCLinkerTool");
        addAttr(rv, "AdditionalOptions",
                "/export:JNI_GetDefaultJavaVMInitArgs " +
                "/export:JNI_CreateJavaVM " +
671
                "/export:JVM_FindClassFromBootLoader "+
D
duke 已提交
672 673 674
                "/export:JNI_GetCreatedJavaVMs "+
                "/export:jio_snprintf /export:jio_printf "+
                "/export:jio_fprintf /export:jio_vfprintf "+
675 676 677 678 679
                "/export:jio_vsnprintf "+
                "/export:JVM_GetVersionInfo "+
                "/export:JVM_GetThreadStateNames "+
                "/export:JVM_GetThreadStateValues "+
                "/export:JVM_InitAgentProperties ");
D
duke 已提交
680 681
        addAttr(rv, "AdditionalDependencies", "Wsock32.lib winmm.lib");
        addAttr(rv, "OutputFile", outDll);
682
        // Set /INCREMENTAL option. 1 is linkIncrementalNo
D
duke 已提交
683 684 685
        addAttr(rv, "LinkIncremental", "1");
        addAttr(rv, "SuppressStartupBanner", "TRUE");
        addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
686
        addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb");
687
        // Set /SUBSYSTEM option. 2 is subSystemWindows
D
duke 已提交
688 689 690
        addAttr(rv, "SubSystem", "2");
        addAttr(rv, "BaseAddress", "0x8000000");
        addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
691 692 693 694 695 696 697
        if(platformName.equals("Win32")) {
            // Set /MACHINE option. 1 is X86
            addAttr(rv, "TargetMachine", "1");
        } else {
            // Set /MACHINE option. 17 is X64
            addAttr(rv, "TargetMachine", "17");
        }
D
duke 已提交
698 699 700 701

        return rv;
    }

702
    void  getDebugCompilerFlags_common(String opt,Vector rv) {
D
duke 已提交
703

704
        // Set /On option
D
duke 已提交
705
        addAttr(rv, "Optimization", opt);
706
        // Set /FR option. 1 is brAllInfo
D
duke 已提交
707 708
        addAttr(rv, "BrowseInformation", "1");
        addAttr(rv, "BrowseInformationFile", "$(IntDir)" + Util.sep);
709 710 711 712 713 714 715 716 717 718 719
        // Set /MD option. 2 is rtMultiThreadedDLL
        addAttr(rv, "RuntimeLibrary", "2");
        // Set /Oy- option
        addAttr(rv, "OmitFramePointers", "FALSE");

    }

    Vector getDebugCompilerFlags(String opt) {
        Vector rv = new Vector();

        getDebugCompilerFlags_common(opt,rv);
D
duke 已提交
720 721 722 723 724 725 726

        return rv;
    }

    Vector getDebugLinkerFlags() {
        Vector rv = new Vector();

727
        addAttr(rv, "GenerateDebugInformation", "TRUE"); // == /DEBUG option
D
duke 已提交
728 729 730 731

        return rv;
    }

732 733 734 735 736
    void getAdditionalNonKernelLinkerFlags(Vector rv) {
        extAttr(rv, "AdditionalOptions",
                "/export:AsyncGetCallTrace ");
    }

737 738 739 740 741 742
    void getProductCompilerFlags_common(Vector rv) {
        // Set /O2 option. 2 is optimizeMaxSpeed
        addAttr(rv, "Optimization", "2");
        // Set /Oy- option
        addAttr(rv, "OmitFramePointers", "FALSE");
        // Set /Ob option.  1 is expandOnlyInline
D
duke 已提交
743
        addAttr(rv, "InlineFunctionExpansion", "1");
744
        // Set /GF option.
D
duke 已提交
745
        addAttr(rv, "StringPooling", "TRUE");
746
        // Set /MD option. 2 is rtMultiThreadedDLL
D
duke 已提交
747
        addAttr(rv, "RuntimeLibrary", "2");
748
        // Set /Gy option
D
duke 已提交
749
        addAttr(rv, "EnableFunctionLevelLinking", "TRUE");
750 751 752 753 754 755
    }

    Vector getProductCompilerFlags() {
        Vector rv = new Vector();

        getProductCompilerFlags_common(rv);
D
duke 已提交
756 757 758 759 760 761 762

        return rv;
    }

    Vector getProductLinkerFlags() {
        Vector rv = new Vector();

763
        // Set /OPT:REF option. 2 is optReferences
D
duke 已提交
764
        addAttr(rv, "OptimizeReferences", "2");
765
        // Set /OPT:optFolding option. 2 is optFolding
D
duke 已提交
766 767 768 769 770 771 772 773 774 775 776 777 778
        addAttr(rv, "EnableCOMDATFolding", "2");

        return rv;
    }

    String getOptFlag() {
        return "2";
    }

    String getNoOptFlag() {
        return "0";
    }

779 780
    String makeCfgName(String flavourBuild, String platform) {
        return  flavourBuild + "|" + platform;
D
duke 已提交
781 782
    }
}