fix linker options
[reactos.git] / reactos / tools / rbuild / backend / msvc / vcprojmaker.cpp
index ddac007..7bbb7b5 100644 (file)
@@ -86,6 +86,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        ifs_list.push_back ( &module.non_if_data );\r
 \r
        // this is a define in MinGW w32api, but not Microsoft's headers\r
+       defines.push_back ( "_CRT_SECURE_NO_DEPRECATE" );\r
+       defines.push_back ( "_CRT_NON_CONFORMING_SWPRINTFS" );\r
        defines.push_back ( "STDCALL=__stdcall" );\r
 \r
        while ( ifs_list.size() )\r
@@ -147,6 +149,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
 \r
        cfgs.push_back ( "Debug" );\r
        cfgs.push_back ( "Release" );\r
+    cfgs.push_back ( "Speed" );\r
 \r
        if (!no_cpp)\r
        {\r
@@ -198,7 +201,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        string path = Path::RelativeFromDirectory ( ProjectNode.name, module.GetBasePath() );\r
        path.erase(path.find(ProjectNode.name, 0), ProjectNode.name.size() + 1);\r
 \r
-       fprintf ( OUT, "\t\t\tRelativePath=\"%s/gccasm.rules\"/>\r\n", path.c_str() );\r
+       fprintf ( OUT, "\t\t\tRelativePath=\"%sgccasm.rules\"/>\r\n", path.c_str() );\r
        fprintf ( OUT, "\t</ToolFiles>\r\n" );\r
 \r
        int n = 0;\r
@@ -322,24 +325,31 @@ MSVCBackend::_generate_vcproj ( const Module& module )
 \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\tAdditionalOptions=\" /DRIVER /ALIGN:0x20 /SUBSYSTEM:NATIVE /SECTION:INIT,D /NODEFAULTLIB /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
+                               if ( module.type == Kernel )\r
+                               {\r
+                                       fprintf ( OUT, "\t\t\t\tAdditionalOptions=\" /SUBSYSTEM:NATIVE /NODEFAULTLIB /SECTION:INIT,D /ALIGN:0x80\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"KiSystemStartup\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", module.baseaddress.c_str ());  \r
+                               }\r
+                               else if ( module.type == NativeCUI )\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
+                                       fprintf ( OUT, "\t\t\t\tAdditionalOptions=\" /SUBSYSTEM:NATIVE /NODEFAULTLIB /ALIGN:0x20\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tIgnoreAllDefaultLibraries=\"TRUE\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tEntryPointSymbol=\"NtProcessStartup\"\r\n" );\r
+                                       fprintf ( OUT, "\t\t\t\tBaseAddress=\"%s\"\r\n", module.baseaddress.c_str ());  \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
+                               else if ( module.type == Win32CUI || module.type == Win32GUI )\r
+                               {\r
+                                       fprintf ( OUT, "\t\t\t\tSubSystem=\"%d\"\r\n", console ? 1 : 2 );\r
+                               }\r
                        }\r
                        else if ( dll)\r
                        {\r
@@ -397,29 +407,32 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                fprintf ( OUT, "\t\t\t<File\r\n" );\r
                fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", source_file.c_str() );\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
+               if (configuration.VSProjectVersion < "8.00") {\r
+                       for ( size_t iconfig = 0; iconfig < cfgs.size(); iconfig++ )\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
+                               std::string& config = cfgs[iconfig];\r
+\r
+                               if ((source_file.find(".idl") != string::npos) || ((source_file.find(".asm") != string::npos || tolower(source_file.at(source_file.size() - 1)) == 's')))\r
+                               {\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.find(".idl") != string::npos)\r
+                                       {\r
+                                               fprintf ( OUT, "\t\t\t\t\t\tName=\"VCCustomBuildTool\"\r\n" );\r
+                                               fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\(InputName).obj\"/>\r\n" );\r
+                                       }\r
+                                       else if ((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)\\(InputName).obj&quot;\"\r\n",include_string.c_str() );\r
+                                               fprintf ( OUT, "\t\t\t\t\t\tOutputs=\"$(OutDir)\\(InputName).obj\"/>\r\n" );\r
+                                       }\r
+                                       fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );\r
+                               }\r
                        }\r
-                       fprintf ( OUT, "\t\t\t\t</FileConfiguration>\r\n" );\r
                }\r
                fprintf ( OUT, "\t\t\t</File>\r\n" );\r
        }\r