Ticket #7741: 0002-create_msvc-Simplify-createBuildProp.patch

File 0002-create_msvc-Simplify-createBuildProp.patch, 9.2 KB (added by Templier, 16 years ago)

2 - Simplify createBuildProp code

  • tools/create_msvc/create_msvc.cpp

    From a9168a348bbaf73c1648db542d3a413d895c67a9 Mon Sep 17 00:00:00 2001
    From: Julien <littleboy@users.sourceforge.net>
    Date: Sat, 26 Dec 2009 02:12:46 -0500
    Subject: [PATCH 2/7] create_msvc: Simplify createBuildProp
    
    ---
     tools/create_msvc/create_msvc.cpp |  138 +++++++++----------------------------
     1 files changed, 34 insertions(+), 104 deletions(-)
    
    diff --git a/tools/create_msvc/create_msvc.cpp b/tools/create_msvc/create_msvc.cpp
    index 5d0bbe7..a276a57 100644
    a b public:  
    216216         * Generates the project properties for debug and release settings.
    217217         *
    218218         * @param setup Description of the desired build setup.
     219         * @param isRelease Type of property file
     220         * @param isWin32 Bitness of property file
    219221         */
    220         virtual void createBuildProp(const BuildSetup &setup) = 0;
     222        virtual void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32) = 0;
    221223
    222224        /**
    223225         * Get the file extension for project files
    public:  
    281283
    282284        void outputGlobalPropFile(std::ofstream &properties, int bits, const std::string &defines, const std::string &prefix);
    283285
    284         void createBuildProp(const BuildSetup &setup);
     286        void createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32);
    285287
    286288        const char *getProjectExtension();
    287289        const char *getPropertiesExtension();
    void ProjectProvider::createMSVCProject(const BuildSetup &setup) {  
    897899        // Create the global property file
    898900        createGlobalProp(setup);
    899901
    900         // Create the configuration property files
    901         createBuildProp(setup);
     902        // Create the configuration property files (for Debug and Release with 32 and 64bits versions)
     903        createBuildProp(setup, true, false);
     904        createBuildProp(setup, true, true);
     905        createBuildProp(setup, false, false);
     906        createBuildProp(setup, false, true);
    902907}
    903908
    904909void ProjectProvider::createScummVMSolution(const BuildSetup &setup) {
    void VisualStudioProvider::outputGlobalPropFile(std::ofstream &properties, int b  
    15641569        properties.flush();
    15651570}
    15661571
    1567 void VisualStudioProvider::createBuildProp(const BuildSetup &setup) {
    1568         std::ofstream properties((setup.outputDir + '/' + "ScummVM_Debug" + getPropertiesExtension()).c_str());
     1572void VisualStudioProvider::createBuildProp(const BuildSetup &setup, bool isRelease, bool isWin32) {
     1573        const std::string outputType = (isRelease ? "Release" : "Debug");
     1574        const std::string outputBitness = (isWin32 ? "32" : "64");
     1575
     1576        std::ofstream properties((setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension()).c_str());
    15691577        if (!properties)
    1570                 error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug" + + getPropertiesExtension() + "\" for writing");
     1578                error("Could not open \"" + setup.outputDir + '/' + "ScummVM_" + outputType + (isWin32 ? "" : "64") + getPropertiesExtension() + "\" for writing");
    15711579
    15721580        properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
    15731581                      "<VisualStudioPropertySheet\n"
    15741582                      "\tProjectType=\"Visual C++\"\n"
    15751583                      "\tVersion=\"8.00\"\n"
    1576                       "\tName=\"ScummVM_Debug32\"\n"
    1577                       "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n"
     1584                      "\tName=\"ScummVM_" << outputType << outputBitness << "\"\n"
     1585                      "\tInheritedPropertySheets=\".\\ScummVM_Global" << (isWin32 ? "" : "64") << ".vsprops\"\n"
    15781586                      "\t>\n"
    15791587                      "\t<Tool\n"
    1580                       "\t\tName=\"VCCLCompilerTool\"\n"
    1581                       "\t\tOptimization=\"0\"\n"
     1588                      "\t\tName=\"VCCLCompilerTool\"\n";
     1589
     1590        if (isRelease) {
     1591                properties << "\t\tEnableIntrinsicFunctions=\"true\"\n"
     1592                              "\t\tWholeProgramOptimization=\"true\"\n"
    15821593                      "\t\tPreprocessorDefinitions=\"WIN32\"\n"
    1583                       "\t\tMinimalRebuild=\"true\"\n"
    1584                       "\t\tBasicRuntimeChecks=\"3\"\n"
    1585                       "\t\tRuntimeLibrary=\"1\"\n"
    1586                       "\t\tEnableFunctionLevelLinking=\"true\"\n"
    1587                       "\t\tWarnAsError=\"false\"\n"
    1588                       "\t\tDebugInformationFormat=\"4\"\n"
     1594                              "\t\tStringPooling=\"true\"\n"
     1595                              "\t\tBufferSecurityCheck=\"false\"\n"
     1596                              "\t\tDebugInformationFormat=\"0\"\n"
    15891597                      "\t/>\n"
    15901598                      "\t<Tool\n"
    15911599                      "\t\tName=\"VCLinkerTool\"\n"
    1592                       "\t\tLinkIncremental=\"2\"\n"
    1593                       "\t\tGenerateDebugInformation=\"true\"\n"
    1594                       "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n"
    1595                       "\t/>\n"
    1596                       "</VisualStudioPropertySheet>\n";
    1597 
    1598         properties.flush();
    1599         properties.close();
    1600 
    1601         properties.open((setup.outputDir + '/' + "ScummVM_Debug64" + getPropertiesExtension()).c_str());
    1602         if (!properties)
    1603                 error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Debug64" + getPropertiesExtension() + "\" for writing");
    1604 
    1605         properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
    1606                       "<VisualStudioPropertySheet\n"
    1607                       "\tProjectType=\"Visual C++\"\n"
    1608                       "\tVersion=\"8.00\"\n"
    1609                       "\tName=\"ScummVM_Debug64\"\n"
    1610                       "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n"
    1611                       "\t>\n"
    1612                       "\t<Tool\n"
    1613                       "\t\tName=\"VCCLCompilerTool\"\n"
    1614                       "\t\tOptimization=\"0\"\n"
     1600                              "\t\tLinkIncremental=\"1\"\n"
     1601                              "\t\tIgnoreDefaultLibraryNames=\"\"\n"
     1602                              "\t\tSetChecksum=\"true\"\n";
     1603        } else {
     1604                properties << "\t\tOptimization=\"0\"\n"
    16151605                      "\t\tPreprocessorDefinitions=\"WIN32\"\n"
    16161606                      "\t\tMinimalRebuild=\"true\"\n"
    16171607                      "\t\tBasicRuntimeChecks=\"3\"\n"
    16181608                      "\t\tRuntimeLibrary=\"1\"\n"
    16191609                      "\t\tEnableFunctionLevelLinking=\"true\"\n"
    16201610                      "\t\tWarnAsError=\"false\"\n"
    1621                       "\t\tDebugInformationFormat=\"3\"\n"      // For x64 format "4" (Edit and continue) is not supported, thus we default to "3"
     1611                              "\t\tDebugInformationFormat=\"" << (isWin32 ? "4" : "3") << "\"\n"        // For x64 format "4" (Edit and continue) is not supported, thus we default to "3"
    16221612                      "\t/>\n"
    16231613                      "\t<Tool\n"
    16241614                      "\t\tName=\"VCLinkerTool\"\n"
    16251615                      "\t\tLinkIncremental=\"2\"\n"
    16261616                      "\t\tGenerateDebugInformation=\"true\"\n"
    1627                       "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n"
    1628                       "\t/>\n"
    1629                       "</VisualStudioPropertySheet>\n";
    1630 
    1631         properties.flush();
    1632         properties.close();
    1633 
    1634         properties.open((setup.outputDir + '/' + "ScummVM_Release" + getPropertiesExtension()).c_str());
    1635         if (!properties)
    1636                 error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release" + getPropertiesExtension() + "\" for writing");
    1637 
    1638         properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
    1639                       "<VisualStudioPropertySheet\n"
    1640                       "\tProjectType=\"Visual C++\"\n"
    1641                       "\tVersion=\"8.00\"\n"
    1642                       "\tName=\"ScummVM_Release32\"\n"
    1643                       "\tInheritedPropertySheets=\".\\ScummVM_Global.vsprops\"\n"
    1644                       "\t>\n"
    1645                       "\t<Tool\n"
    1646                       "\t\tName=\"VCCLCompilerTool\"\n"
    1647                       "\t\tEnableIntrinsicFunctions=\"true\"\n"
    1648                       "\t\tWholeProgramOptimization=\"true\"\n"
    1649                       "\t\tPreprocessorDefinitions=\"WIN32\"\n"
    1650                       "\t\tStringPooling=\"true\"\n"
    1651                       "\t\tBufferSecurityCheck=\"false\"\n"
    1652                       "\t\tDebugInformationFormat=\"0\"\n"
    1653                       "\t/>\n"
    1654                       "\t<Tool\n"
    1655                       "\t\tName=\"VCLinkerTool\"\n"
    1656                       "\t\tLinkIncremental=\"1\"\n"
    1657                       "\t\tIgnoreDefaultLibraryNames=\"\"\n"
    1658                       "\t\tSetChecksum=\"true\"\n"
    1659                       "\t/>\n"
    1660                       "</VisualStudioPropertySheet>\n";
    1661 
    1662         properties.flush();
    1663         properties.close();
    1664 
    1665         properties.open((setup.outputDir + '/' + "ScummVM_Release64" + getPropertiesExtension()).c_str());
    1666         if (!properties)
    1667                 error("Could not open \"" + setup.outputDir + '/' + "ScummVM_Release64" + getPropertiesExtension() + "\" for writing");
     1617                              "\t\tIgnoreDefaultLibraryNames=\"libcmt.lib\"\n";
     1618        }
    16681619
    1669         properties << "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"
    1670                       "<VisualStudioPropertySheet\n"
    1671                       "\tProjectType=\"Visual C++\"\n"
    1672                       "\tVersion=\"8.00\"\n"
    1673                       "\tName=\"ScummVM_Release64\"\n"
    1674                       "\tInheritedPropertySheets=\".\\ScummVM_Global64.vsprops\"\n"
    1675                       "\t>\n"
    1676                       "\t<Tool\n"
    1677                       "\t\tName=\"VCCLCompilerTool\"\n"
    1678                       "\t\tEnableIntrinsicFunctions=\"true\"\n"
    1679                       "\t\tWholeProgramOptimization=\"true\"\n"
    1680                       "\t\tPreprocessorDefinitions=\"WIN32\"\n"
    1681                       "\t\tStringPooling=\"true\"\n"
    1682                       "\t\tBufferSecurityCheck=\"false\"\n"
    1683                       "\t\tDebugInformationFormat=\"0\"\n"
    1684                       "\t/>\n"
    1685                       "\t<Tool\n"
    1686                       "\t\tName=\"VCLinkerTool\"\n"
    1687                       "\t\tLinkIncremental=\"1\"\n"
    1688                       "\t\tIgnoreDefaultLibraryNames=\"\"\n"
    1689                       "\t\tSetChecksum=\"true\"\n"
    1690                       "\t/>\n"
     1620        properties << "\t/>\n"
    16911621                      "</VisualStudioPropertySheet>\n";
    16921622
    16931623        properties.flush();