j_anderw@sbox.tugraz.at
[reactos.git] / reactos / tools / rbuild / backend / msvc / vcprojmaker.cpp
index d95a6c2..e73fad1 100644 (file)
@@ -47,16 +47,28 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        FILE* OUT = fopen ( vcproj_file.c_str(), "wb" );\r
 \r
        vector<string> imports;\r
-       for ( i = 0; i < module.non_if_data.libraries.size(); i++ )\r
-       {\r
-               imports.push_back ( module.non_if_data.libraries[i]->name );\r
-       }\r
-\r
        string module_type = GetExtension(module.GetTargetName());\r
        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
+\r
+       string path_basedir = module.GetPathToBaseDir ();\r
+       string intenv = Environment::GetIntermediatePath ();\r
+       string outenv = Environment::GetOutputPath ();\r
+       string outdir;\r
+       string intdir;\r
+       \r
+       if ( intenv == "obj-i386" )\r
+               intdir = path_basedir + "obj-i386"; /* append relative dir from project dir */\r
+       else\r
+               intdir = intenv;\r
+\r
+       if ( outenv == "output-i386" )\r
+               outdir = path_basedir + "output-i386";\r
+       else\r
+               outdir = outenv;\r
+\r
        // TODO FIXME - need more checks here for 'sys' and possibly 'drv'?\r
 \r
        bool console = exe && (module.type == Win32CUI);\r
@@ -78,9 +90,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        //$progress_current++;\r
        //$output->progress("$dsp_file (file $progress_current of $progress_max)");\r
 \r
-       // TODO FIXME - what's diff. betw. 'c_srcs' and 'source_files'?\r
        string vcproj_path = module.GetBasePath();\r
-       vector<string> c_srcs, source_files, resource_files, includes, libraries, defines;\r
+       vector<string> source_files, resource_files, includes, libraries, defines;\r
        vector<const IfableData*> ifs_list;\r
        ifs_list.push_back ( &module.project.non_if_data );\r
        ifs_list.push_back ( &module.non_if_data );\r
@@ -105,9 +116,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                        // TODO FIXME - do we want the full path of the file here?\r
                        string file = string(".") + &files[i]->name[vcproj_path.size()];\r
 \r
-                       source_files.push_back ( file );\r
                        if ( !stricmp ( Right(file,2).c_str(), ".c" ) )\r
-                               c_srcs.push_back ( file );\r
+                               source_files.push_back ( file );\r
                        if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )\r
                                resource_files.push_back ( file );\r
                }\r
@@ -130,7 +140,19 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                const vector<Library*>& libs = data.libraries;\r
                for ( i = 0; i < libs.size(); i++ )\r
                {\r
-                       libraries.push_back ( libs[i]->name + ".lib" );\r
+#if 0\r
+                       // this code is deactivated untill the tree builds fine with msvc\r
+                       // --- is appended to each library path which is later\r
+                       // replaced by the configuration\r
+                       // i.e. ../output-i386/lib/rtl/---/rtl.lib becomes\r
+                       //      ../output-i386/lib/rtl/Debug/rtl.lib \r
+                       // etc\r
+                       libs[i]->importedModule->\r
+                       string libpath = outdir + "\\" + libs[i]->importedModule->GetBasePath() + "\\---\\" + libs[i]->name + ".lib";\r
+                       libraries.push_back ( libpath );\r
+#else\r
+               libraries.push_back ( libs[i]->name + ".lib" );\r
+#endif\r
                }\r
                const vector<Define*>& defs = data.defines;\r
                for ( i = 0; i < defs.size(); i++ )\r
@@ -229,8 +251,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
 \r
                fprintf ( OUT, "\t\t<Configuration\r\n" );\r
                fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.c_str() );\r
-               fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\"\r\n", cfg.c_str() );\r
-               fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\"\r\n", cfg.c_str() );\r
+               fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\\%s\\%s\"\r\n", outdir.c_str (), module.GetBasePath ().c_str (), cfg.c_str() );\r
+               fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\\%s\\%s\"\r\n", intdir.c_str (), module.GetBasePath ().c_str (), cfg.c_str() );\r
                fprintf ( OUT, "\t\t\tConfigurationType=\"%d\"\r\n", exe ? 1 : dll ? 2 : lib ? 4 : -1 );\r
                fprintf ( OUT, "\t\t\tCharacterSet=\"2\">\r\n" );\r
 \r
@@ -316,6 +338,8 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                fprintf ( OUT, "\t\t\t\tDisableSpecificWarnings=\"4201;4127\"\r\n" );\r
                fprintf ( OUT, "\t\t\t\tWarningLevel=\"%s\"\r\n", release ? "0" : "4" );\r
                fprintf ( OUT, "\t\t\t\tDetect64BitPortabilityProblems=\"%s\"\r\n", release ? "FALSE" : "TRUE");\r
+               if ( !module.cplusplus )\r
+                       fprintf ( OUT, "\t\t\t\tCompileAs=\"1\"\r\n" );\r
                fprintf ( OUT, "\t\t\t\tDebugInformationFormat=\"%s\"/>\r\n", speed ? "0" : "4");\r
 \r
                fprintf ( OUT, "\t\t\t<Tool\r\n" );\r
@@ -337,7 +361,17 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                        {\r
                                if ( i > 0 )\r
                                        fprintf ( OUT, " " );\r
+#if 0 \r
+                               // this code is deactivated untill \r
+                               // msvc can build the whole tree\r
+                               string libpath = libraries[i].c_str();\r
+                               libpath.replace (libpath.find("---"), //See HACK\r
+                                                    3,\r
+                                                                cfg);\r
+                               fprintf ( OUT, "%s", libpath.c_str() );\r
+#else\r
                                fprintf ( OUT, "%s", libraries[i].c_str() );\r
+#endif\r
                        }\r
                        fprintf ( OUT, "\"\r\n" );\r
 \r
@@ -493,7 +527,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
        fprintf ( OUT, "\t\t<Filter\r\n" );\r
        fprintf ( OUT, "\t\t\tName=\"Resource Files\"\r\n" );\r
        fprintf ( OUT, "\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\r\n" );\r
-       for ( i = 0; i < header_files.size(); i++ )\r
+       for ( i = 0; i < resource_files.size(); i++ )\r
        {\r
                const string& resource_file = resource_files[i];\r
                fprintf ( OUT, "\t\t\t<File\r\n" );\r