create only the project files specified on cmdline
[reactos.git] / reactos / tools / rbuild / backend / msvc / msvcmaker.cpp
index debf6e6..0b359b0 100644 (file)
 using std::string;
 using std::vector;
 
+#ifdef OUT
+#undef OUT
+#endif//OUT
+
 void
 MSVCBackend::_generate_dsp ( const Module& module )
 {
@@ -50,7 +54,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
 
        string module_type = GetExtension(module.GetTargetName());
        bool lib = (module_type == ".lib") || (module_type == ".a");
-       bool dll = (module_type == ".dll");
+       bool dll = (module_type == ".dll") || (module_type == ".cpl");
        bool exe = (module_type == ".exe");
        // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?
 
@@ -77,12 +81,10 @@ MSVCBackend::_generate_dsp ( const Module& module )
        string dsp_path = module.GetBasePath();
        vector<string> c_srcs, source_files, resource_files, includes, libraries, defines;
        vector<const IfableData*> ifs_list;
+       ifs_list.push_back ( &module.project.non_if_data );
        ifs_list.push_back ( &module.non_if_data );
 
-       defines.push_back ( "WIN32" );
-       defines.push_back ( "_WINDOWS" );
-       defines.push_back ( "WIN32" );
-       defines.push_back ( "_MBCS" );
+       // this is a define in MinGW w32api, but not Microsoft's headers
        defines.push_back ( "STDCALL=__stdcall" );
 
        while ( ifs_list.size() )
@@ -107,6 +109,15 @@ MSVCBackend::_generate_dsp ( const Module& module )
                const vector<Include*>& incs = data.includes;
                for ( i = 0; i < incs.size(); i++ )
                {
+
+                       // explicitly omit win32api directories
+                       if ( !strncmp(incs[i]->directory.c_str(), "w32api", 6 ) )
+                               continue;
+
+                       // explicitly omit include/wine directories
+                       if ( !strncmp(incs[i]->directory.c_str(), "include\\wine", 12 ) )
+                               continue;
+
                        string path = Path::RelativeFromDirectory (
                                incs[i]->directory,
                                module.GetBasePath() );
@@ -361,13 +372,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
                fprintf ( OUT, " /c" );
                fprintf ( OUT, "\r\n" );
 
-               vector<string> defines2;
-               defines2.push_back ( "WINVER=0x0501" );
-               defines2.push_back ( "_WIN32_WINNT=0x0501" );
-               defines2.push_back ( "_WIN32_IE=0x0600" );
-               defines2.push_back ( "WIN32" );
-               defines2.push_back ( "_WINDOWS" );
-               defines2.push_back ( "_MBCS" );
+               vector<string> defines2 = defines;
                if ( debug )
                {
                        defines2.push_back ( "_DEBUG" );
@@ -433,7 +438,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
                        for ( i = 0; i < includes.size(); i++ )
                        {
                                const string& include = includes[i];
-                               if ( strpbrk ( include.c_str(), "[\\\"]" ) )
+                               if ( strpbrk ( include.c_str(), "[\\\"]" ) || !strncmp ( include.c_str(), "../", 3 ) )
                                {
                                        fprintf ( OUT, " /I \"%s\"", include.c_str() );
                                }
@@ -478,13 +483,18 @@ MSVCBackend::_generate_dsp ( const Module& module )
                        }
                        fprintf ( OUT, "# ADD BASE RSC /l 0x41d /d \"_DEBUG\"\r\n" );
                        fprintf ( OUT, "# ADD RSC /l 0x41d" );
-                       if ( wine )
+                       /*if ( wine )*/
                        {
                                for ( i = 0; i < includes.size(); i++ )
                                {
                                        fprintf ( OUT, " /i \"%s\"", includes[i].c_str() );
                                }
                        }
+
+                       for ( i = 0; i < defines.size(); i++ )
+                       {
+                               fprintf ( OUT, " /D \"%s\"", defines[i].c_str() );
+                       }
                        fprintf ( OUT, " /d \"_DEBUG\"\r\n" );
                }
                else
@@ -502,6 +512,13 @@ MSVCBackend::_generate_dsp ( const Module& module )
                                for ( i = 0; i < includes.size(); i++ )
                                        fprintf ( OUT, " /i \"%s\"", includes[i].c_str() );
                        }
+
+                       for ( i = 0; i < defines.size(); i++ )
+                       {
+                               fprintf ( OUT, " /D \"%s\"", defines[i].c_str() );
+                       }
+
+
                        fprintf ( OUT, "/d \"NDEBUG\"\r\n" );
                }
                fprintf ( OUT, "BSC32=bscmake.exe\r\n" );
@@ -542,6 +559,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
                        // TODO FIXME - do we need their kludge?
                        //if ( module.name == "ntdll" ) fprintf ( OUT, " /nodefaultlib" ); // FIXME: Kludge
                        if ( dll ) fprintf ( OUT, " /def:\"%s.def\"", module.name.c_str() );
+                       if (( dll ) && ( module_type == ".cpl")) fprintf ( OUT, " /out:\"Win32\\%s%s\"", module.name.c_str(), module_type.c_str() );
                        if ( debug ) fprintf ( OUT, " /pdbtype:sept" );
                        fprintf ( OUT, "\r\n" );
                }
@@ -755,7 +773,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
        fprintf ( OUT, "# Begin Group \"Resource Files\"\r\n" );
        fprintf ( OUT, "\r\n" );
        fprintf ( OUT, "# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\r\n" );
-       for ( i = 0; i < resource_files.size(); i++ )
+/*     for ( i = 0; i < resource_files.size(); i++ )
        {
                const string& resource_file = resource_files[i];
                fprintf ( OUT, "# Begin Source File\r\n" );
@@ -763,7 +781,7 @@ MSVCBackend::_generate_dsp ( const Module& module )
                fprintf ( OUT, "SOURCE=.\\%s\r\n", resource_file.c_str() );
                fprintf ( OUT, "# End Source File\r\n" );
        }
-       fprintf ( OUT, "# End Group\r\n" );
+*/     fprintf ( OUT, "# End Group\r\n" );
 
        fprintf ( OUT, "# End Target\r\n" );
        fprintf ( OUT, "# End Project\r\n" );