enhance generated msvc projects - patch by Brezenbak
authorRoyce Mitchell III <royce3@ev1.net>
Tue, 29 Nov 2005 06:24:56 +0000 (06:24 +0000)
committerRoyce Mitchell III <royce3@ev1.net>
Tue, 29 Nov 2005 06:24:56 +0000 (06:24 +0000)
svn path=/trunk/; revision=19743

reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp

index 5c1a7bb..ddac007 100644 (file)
@@ -56,6 +56,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        bool lib = (module.type == ObjectLibrary) || (module_type == ".lib") || (module_type == ".a");\r
        bool dll = (module_type == ".dll") || (module_type == ".cpl");\r
        bool exe = (module_type == ".exe");\r
+       bool sys = (module_type == ".sys");\r
        // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?\r
 \r
        bool console = exe && (module.type == Win32CUI);\r
@@ -172,6 +173,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        }\r
 \r
        string default_cfg = cfgs.back();\r
+       string include_string;\r
 \r
        fprintf ( OUT, "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\r\n" );\r
        fprintf ( OUT, "<VisualStudioProject\r\n" );\r
@@ -232,7 +234,9 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                        {\r
                                if ( multiple_includes )\r
                                        fprintf ( OUT, ";" );\r
+\r
                                fprintf ( OUT, "%s", include.c_str() );\r
+                               include_string += " /I " + include;\r
                                multiple_includes = true;\r
                        }\r
                }\r
@@ -293,7 +297,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                {\r
                        fprintf ( OUT, "\t\t\t<Tool\r\n" );\r
                        fprintf ( OUT, "\t\t\t\tName=\"VCLibrarianTool\"\r\n" );\r
-                       fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s%s\"/>\r\n", module.name.c_str(), module_type.c_str() );\r
+                       fprintf ( OUT, "\t\t\t\tOutputFile=\"$(OutDir)/%s.lib\"/>\r\n", module.name.c_str() );\r
                }\r
                else\r
                {\r
@@ -316,7 +320,32 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                        if ( debug )\r
                                fprintf ( OUT, "\t\t\t\tProgramDatabaseFile=\"$(OutDir)/%s.pdb\"\r\n", module.name.c_str() );\r
 \r
-                       fprintf ( OUT, "\t\t\t\tSubSystem=\"%d\"\r\n", console ? 1 : 2 );\r
+                       if ( sys )\r
+                       {\r
+                               fprintf ( OUT, "\t\t\t\tAdditionalOptions=\" /DRIVER /ALIGN:0x20 /subsystem:NATIVE /SECTION:INIT,D /FORCE:MULTIPLE /IGNORE:4001,4037,4039,4065,4070,4078,4087,4089,4096\"\r\n" );\r
+                               fprintf ( OUT, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );\r
+                               fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.entrypoint == "" ? "DriverEntry" : module.entrypoint.c_str ());\r
+                               fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", module.baseaddress == "" ? "0x10000" : module.baseaddress.c_str ());   \r
+                       }\r
+                       else if ( exe )\r
+                       {\r
+                               if( module.non_if_data.compilationUnits.size () > 0 ) /* native apps */\r
+                               {\r
+                                       fprintf ( OUT, "\t\t\t\tAdditionalOptions=\" /SUBSYSTEM:NATIVE /SECTION:INIT,D /ALIGN:4096 /FORCE:MULTIPLE\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );\r
+                               }\r
+                               else /* non native apps */\r
+                               {\r
+                                       fprintf ( OUT, "\t\t\t\tSubSystem=\"%d\"\r\n", console ? 1 : 2 );\r
+                               }\r
+                               fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.entrypoint.c_str ());\r
+                               fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", module.baseaddress.c_str ());  \r
+                       }\r
+                       else if ( dll)\r
+                       {\r
+                               fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"%s\"\r\n", module.entrypoint == "" ? "DllMain" : module.entrypoint.c_str ());\r
+                               fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", module.baseaddress == "" ? "0x40000" : module.baseaddress.c_str ());\r
+                       }\r
                        fprintf ( OUT, "\t\t\t\tTargetMachine=\"%d\"/>\r\n", 1 );\r
                }\r
                \r
@@ -364,26 +393,33 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        fprintf ( OUT, "\t\t\tFilter=\"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;S\">\r\n" );\r
        for ( size_t isrcfile = 0; isrcfile < source_files.size(); isrcfile++ )\r
        {\r
-               const string& source_file = DosSeparator(source_files[isrcfile]);\r
+               string source_file = DosSeparator(source_files[isrcfile]);\r
                fprintf ( OUT, "\t\t\t<File\r\n" );\r
                fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file.c_str() );\r
 \r
-               if (configuration.VSProjectVersion < "8.00") {\r
-                       if (source_file.at(source_file.size() - 1) == 'S') {\r
-                               for ( size_t iconfig = 0; iconfig < cfgs.size(); iconfig++ )\r
-                               {\r
-                                       std::string& config = cfgs[iconfig];\r
-                                       fprintf ( OUT, "\t\t\t\t<FileConfiguration\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t\tName=\"" );\r
-                                       fprintf ( OUT, config.c_str());\r
-                                       fprintf ( OUT, "|Win32\">\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t\t<Tool\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; | as -o &quot;$(OutDir)\\$(InputName).obj&quot;\"\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\$(InputName).obj\"/>\r\n" );\r
-                                       fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );\r
-                               }\r
+               source_file.erase(0,2);\r
+               source_file = _replace_str(source_file, "\\", "-");\r
+               string src_string = source_file.substr(0, source_file.find("."));\r
+               for ( size_t iconfig = 0; iconfig < cfgs.size(); iconfig++ )\r
+               {\r
+                       std::string& config = cfgs[iconfig];\r
+                       fprintf ( OUT, "\t\t\t\t<FileConfiguration\r\n" );\r
+                       fprintf ( OUT, "\t\t\t\t\tName=\"" );\r
+                       fprintf ( OUT, config.c_str() );\r
+                       fprintf ( OUT, "|Win32\">\r\n" );\r
+                       fprintf ( OUT, "\t\t\t\t\t<Tool\r\n" );\r
+                       if (source_file.at(source_file.size() - 1) == 'c' || source_file.find(".cpp") != string::npos)\r
+                       {\r
+                               fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n" );\r
+                               fprintf ( OUT, "\t\t\t\t\t\tObjectFile=\"$(OutDir)\\%s.obj\"/>\r\n", src_string.c_str());\r
+                       }\r
+                       else if (configuration.VSProjectVersion < "8.00" && (source_file.find(".asm") != string::npos || tolower(source_file.at(source_file.size() - 1)) == 's'))\r
+                       {\r
+                               fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );\r
+                               fprintf ( OUT, "\t\t\t\t\t\tCommandLine=\"cl /E &quot;$(InputPath)&quot; %s /D__ASM__ | as -o &quot;$(OutDir)\\%s.obj&quot;\"\r\n",include_string.c_str(), src_string.c_str() );\r
+                               fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\%s.obj\"/>\r\n",src_string.c_str() );\r
                        }\r
+                       fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );\r
                }\r
                fprintf ( OUT, "\t\t\t</File>\r\n" );\r
        }\r