Don't add underscore prefix to amd64 symbols
[reactos.git] / reactos / tools / rbuild / backend / codeblocks / codeblocks.cpp
index 8e935cd..b1fb3f1 100644 (file)
@@ -11,9 +11,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 #ifdef _MSC_VER
 #pragma warning ( disable : 4786 )
@@ -37,6 +37,7 @@ using std::ifstream;
 #undef OUT
 #endif//OUT
 
+#define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
 
 static class CBFactory : public Backend::Factory
 {
@@ -48,7 +49,7 @@ static class CBFactory : public Backend::Factory
                {
                        return new CBBackend(project, configuration);
                }
-               
+
 } factory;
 
 
@@ -75,7 +76,7 @@ void CBBackend::Process()
        filename_wrkspace += "_auto.workspace";
 
        printf ( "Creating Code::Blocks workspace: %s\n", filename_wrkspace.c_str() );
-       
+
        ProcessModules();
        m_wrkspaceFile = fopen ( filename_wrkspace.c_str(), "wb" );
 
@@ -93,14 +94,26 @@ void CBBackend::Process()
 
 void CBBackend::ProcessModules()
 {
-       for(size_t i = 0; i < ProjectNode.modules.size(); i++)
+       for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
        {
-               Module &module = *ProjectNode.modules[i];
+               Module &module = *p->second;
                MingwAddImplicitLibraries( module );
                _generate_cbproj ( module );
        }
 }
 
+static std::string
+GetExtension ( const std::string& filename )
+{
+       size_t index = filename.find_last_of ( '/' );
+       if (index == string::npos) index = 0;
+       string tmp = filename.substr( index, filename.size() - index );
+       size_t ext_index = tmp.find_last_of( '.' );
+       if (ext_index != string::npos)
+               return filename.substr ( index + ext_index, filename.size() );
+       return "";
+}
+
 static bool FileExists(string &filename)
 {
        ifstream file(filename.c_str());
@@ -138,7 +151,7 @@ void CBBackend::ProcessFile(string &filepath)
                folder = filepath;
                folder.erase(pos, folder.length() - pos);
        }
-       
+
        FileUnit fileUnit;
        fileUnit.filename = filepath;
        fileUnit.folder = folder;
@@ -167,9 +180,9 @@ void CBBackend::AddFolders(string &folder)
        // Check if this folder was already added. true if it was, false otherwise.
        if(CheckFolderAdded(folder))
                return;
-       
+
        m_folders.push_back(folder);
-       
+
        size_t pos = folder.rfind(string("/"), folder.length() - 1);
 
        if(pos == string::npos)
@@ -198,7 +211,7 @@ std::string
 CBBackend::CbpFileName ( const Module& module ) const
 {
        return DosSeparator(
-               ReplaceExtension ( module.GetPath(), + "_auto.cbp" )
+               ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.cbp" )
                );
 }
 
@@ -206,7 +219,7 @@ std::string
 CBBackend::LayoutFileName ( const Module& module ) const
 {
        return DosSeparator(
-               ReplaceExtension ( module.GetPath(), + "_auto.layout" )
+               ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.layout" )
                );
 }
 
@@ -214,17 +227,17 @@ std::string
 CBBackend::DependFileName ( const Module& module ) const
 {
        return DosSeparator(
-               ReplaceExtension ( module.GetPath(), + "_auto.depend" )
+               ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.depend" )
                );
 }
 
-void 
+void
 CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
 {
-       string basepath = module.GetBasePath ();
+       string basepath = module.output->relative_path;
        size_t i;
-       string intenv = Environment::GetIntermediatePath () + "\\" + basepath + "\\";
-       string outenv = Environment::GetOutputPath () + "\\" + basepath + "\\";
+       string intenv = Environment::GetIntermediatePath () + sSep + basepath + sSep;
+       string outenv = Environment::GetOutputPath () + sSep + basepath + sSep;
 
        vector<string> cfgs;
 
@@ -251,8 +264,8 @@ CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
                const vector<File*>& files = data.files;
                for ( i = 0; i < files.size (); i++ )
                {
-                       string file = files[i]->name;
-                       string::size_type pos = file.find_last_of ("\\");
+                       string file = files[i]->file.relative_path + sSep + files[i]->file.name;
+                       string::size_type pos = file.find_last_of (sSep);
                        if ( pos != string::npos )
                                file.erase ( 0, pos+1 );
                        if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
@@ -260,7 +273,7 @@ CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
                        else
                                file = ReplaceExtension ( file, ".obj" );
                        for ( size_t j = 0; j < cfgs.size () / 2; j++ )
-                               out.push_back ( cfgs[j] + "\\" + file );
+                               out.push_back ( cfgs[j] + sSep + file );
                }
 
        }
@@ -269,16 +282,16 @@ CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
 void
 CBBackend::_clean_project_files ( void )
 {
-       for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
+       for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
        {
-               Module& module = *ProjectNode.modules[i];
+               Module& module = *p->second;
                vector<string> out;
-               printf("Cleaning project %s %s\n", module.name.c_str (), module.GetBasePath ().c_str () );
-               
-               string basepath = module.GetBasePath ();
-               remove ( CbpFileName ( module ).c_str () );     
-               remove ( DependFileName ( module ).c_str () );  
-               remove ( LayoutFileName ( module ).c_str () );  
+               printf("Cleaning project %s %s\n", module.name.c_str (), module.output->relative_path.c_str () );
+
+               string basepath = module.output->relative_path;
+               remove ( CbpFileName ( module ).c_str () );
+               remove ( DependFileName ( module ).c_str () );
+               remove ( LayoutFileName ( module ).c_str () );
 
                _get_object_files ( module, out );
                for ( size_t j = 0; j < out.size (); j++)
@@ -299,18 +312,16 @@ CBBackend::_generate_workspace ( FILE* OUT )
        fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n" );
        fprintf ( OUT, "<CodeBlocks_workspace_file>\r\n" );
        fprintf ( OUT, "\t<Workspace title=\"ReactOS\">\r\n" );
-       for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
+       for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
        {
-               Module& module = *ProjectNode.modules[i];
+               Module& module = *p->second;
 
-               if ((module.type != Iso) && 
-                       (module.type != LiveIso) &&
-                       (module.type != IsoRegTest) &&
-                       (module.type != LiveIsoRegTest))
+               if ((module.type != Iso) &&
+                       (module.type != LiveIso))
                {
                        std::string Cbp_file = CbpFileName ( module );
                        fprintf ( OUT, "\t\t<Project filename=\"%s\">\r\n", Cbp_file.c_str());
-                       
+
                        /* dependencies */
                        vector<const IfableData*> ifs_list;
                        ifs_list.push_back ( &module.project.non_if_data );
@@ -321,10 +332,10 @@ CBBackend::_generate_workspace ( FILE* OUT )
                                ifs_list.pop_back();
                                const vector<Library*>& libs = data.libraries;
                                for ( size_t j = 0; j < libs.size(); j++ )
-                                       fprintf ( OUT, "\t\t\t<Depends filename=\"%s\\%s_auto.cbp\" />\r\n", libs[j]->importedModule->GetBasePath().c_str(), libs[j]->name.c_str() );
+                                       fprintf ( OUT, "\t\t\t<Depends filename=\"%s%s%s_auto.cbp\" />\r\n", libs[j]->importedModule->output->relative_path.c_str(), sSep.c_str(), libs[j]->name.c_str() );
                        }
                        fprintf ( OUT, "\t\t</Project>\r\n" );
-               }       
+               }
        }
        fprintf ( OUT, "\t</Workspace>\r\n" );
        fprintf ( OUT, "</CodeBlocks_workspace_file>\r\n" );
@@ -342,8 +353,8 @@ CBBackend::_generate_cbproj ( const Module& module )
        string path_basedir = module.GetPathToBaseDir ();
        string intenv = Environment::GetIntermediatePath ();
        string outenv = Environment::GetOutputPath ();
-       string module_type = GetExtension(module.GetTargetName());
-       string cbproj_path = module.GetBasePath();      
+       string module_type = GetExtension(*module.output);
+       string cbproj_path = module.output->relative_path;
        string CompilerVar;
        string baseaddr;
        string windres_defines;
@@ -351,7 +362,12 @@ CBBackend::_generate_cbproj ( const Module& module )
        string project_linker_flags = "-Wl,--enable-stdcall-fixup ";
        project_linker_flags += GenerateProjectLinkerFlags();
 
-       bool lib = (module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a");
+       bool lib = (module.type == ObjectLibrary) ||
+                  (module.type == RpcClient) ||
+                  (module.type == RpcServer) ||
+                  (module.type == RpcProxy) ||
+                  (module_type == ".lib") ||
+                  (module_type == ".a");
        bool dll = (module_type == ".dll") || (module_type == ".cpl");
        bool exe = (module_type == ".exe") || (module_type == ".scr");
        bool sys = (module_type == ".sys");
@@ -366,8 +382,6 @@ CBBackend::_generate_cbproj ( const Module& module )
        {
                case Iso:
                case LiveIso:
-               case IsoRegTest:
-               case LiveIsoRegTest:
                        return;
                default:
                        break;
@@ -382,8 +396,8 @@ CBBackend::_generate_cbproj ( const Module& module )
        if ( module.pch != NULL )
        {
                string pch_path = Path::RelativeFromDirectory (
-                                       module.pch->file.name,
-                                       module.GetBasePath() );
+                                       module.pch->file->name,
+                                       module.output->relative_path );
 
                header_files.push_back ( pch_path );
        }
@@ -405,20 +419,11 @@ CBBackend::_generate_cbproj ( const Module& module )
        {
                const IfableData& data = *ifs_list.back();
                ifs_list.pop_back();
-               for ( i = 0; i < data.ifs.size(); i++ )
-               {
-                       const Property* property = _lookup_property( module, data.ifs[i]->property );
-                       if ( property != NULL )
-                       {
-                               if ( data.ifs[i]->value == property->value && data.ifs[i]->negated == false ||
-                                       data.ifs[i]->value != property->value && data.ifs[i]->negated)
-                                       ifs_list.push_back ( &data.ifs[i]->data );
-                       }
-               }
                const vector<File*>& files = data.files;
                for ( i = 0; i < files.size(); i++ )
                {
-                       string file = string(".") + &files[i]->name[cbproj_path.size()];
+                       string fullpath = files[i]->file.relative_path + sSep + files[i]->file.name;
+                       string file = string(".") + &fullpath[cbproj_path.size()];
 
                        if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
                                resource_files.push_back ( file );
@@ -429,8 +434,8 @@ CBBackend::_generate_cbproj ( const Module& module )
                for ( i = 0; i < incs.size(); i++ )
                {
                        string path = Path::RelativeFromDirectory (
-                               incs[i]->directory,
-                               module.GetBasePath() );
+                               incs[i]->directory->relative_path,
+                               module.output->relative_path );
 
                        includes.push_back ( path );
                        widl_options += "-I" + path + " ";
@@ -438,7 +443,7 @@ CBBackend::_generate_cbproj ( const Module& module )
                const vector<Library*>& libs = data.libraries;
                for ( i = 0; i < libs.size(); i++ )
                {
-                       string libpath = intdir + "\\" + libs[i]->importedModule->GetBasePath();
+                       string libpath = intdir + sSep + libs[i]->importedModule->output->relative_path;
                        libraries.push_back ( libs[i]->name );
                        libpaths.push_back ( libpath );
                }
@@ -468,9 +473,9 @@ CBBackend::_generate_cbproj ( const Module& module )
                        vars.push_back( variables[i]->name );
                        values.push_back( variables[i]->value );
                }*/
-               for ( i = 0; i < data.properties.size(); i++ )
+               for ( std::map<std::string, Property*>::const_iterator p = data.properties.begin(); p != data.properties.end(); ++ p )
                {
-                       Property& prop = *data.properties[i];
+                       Property& prop = *p->second;
                        if ( strstr ( module.baseaddress.c_str(), prop.name.c_str() ) )
                                baseaddr = prop.value;
                }
@@ -479,7 +484,7 @@ CBBackend::_generate_cbproj ( const Module& module )
        if ( !module.allowWarnings )
                compiler_flags.push_back ( "-Werror" );
 
-       if ( module.type == StaticLibrary && module.isStartupLib )
+       if ( IsStaticLibrary ( module ) && module.isStartupLib )
                compiler_flags.push_back ( "-Wno-main" );
 
 
@@ -506,26 +511,26 @@ CBBackend::_generate_cbproj ( const Module& module )
 
                if ( configuration.UseConfigurationInPath )
                {
-                       if ( module.type == StaticLibrary ||module.type == ObjectLibrary )
-                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s%s\\%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), module.GetBasePath ().c_str (), cfg.name.c_str(), module.name.c_str(), module_type.c_str());
+                       if ( IsStaticLibrary ( module ) ||module.type == ObjectLibrary )
+                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str(), sSep.c_str(), module.name.c_str(), module_type.c_str());
                        else
-                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s%s\\%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), cfg.name.c_str(), module.name.c_str(), module_type.c_str());
-                       fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str (), cfg.name.c_str() );
+                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str(), sSep.c_str(), module.name.c_str(), module_type.c_str());
+                       fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s%s%s%s\" />\r\n", intdir.c_str(), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str() );
                }
                else
                {
-                       if ( module.type == StaticLibrary || module.type == ObjectLibrary )
-                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s\\%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), module.GetBasePath ().c_str (), module.name.c_str(), module_type.c_str() );
+                       if ( IsStaticLibrary ( module ) || module.type == ObjectLibrary )
+                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), sSep.c_str(), module.name.c_str(), module_type.c_str() );
                        else
-                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s\\%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), module.name.c_str(), module_type.c_str() );
-                       fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str () );
+                               fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), sSep.c_str(), module.name.c_str(), module_type.c_str() );
+                       fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s%s%s\" />\r\n", intdir.c_str(), sSep.c_str(), module.output->relative_path.c_str () );
                }
 
                if ( lib )
                {
                        fprintf ( OUT, "\t\t\t\t<Option type=\"2\" />\r\n" );
                }
-               else if ( dll )         
+               else if ( dll )
                        fprintf ( OUT, "\t\t\t\t<Option type=\"3\" />\r\n" );
                else if ( sys )
                        fprintf ( OUT, "\t\t\t\t<Option type=\"5\" />\r\n" );
@@ -543,7 +548,7 @@ CBBackend::_generate_cbproj ( const Module& module )
                                        fprintf ( OUT, "\t\t\t\t<Option type=\"0\" />\r\n" );
                        }
                }
-               
+
                fprintf ( OUT, "\t\t\t\t<Option compiler=\"gcc\" />\r\n" );
 
                if ( module_type == ".cpl" )
@@ -552,7 +557,7 @@ CBBackend::_generate_cbproj ( const Module& module )
                        fprintf ( OUT, "\t\t\t\t<Option host_application=\"rundll32.exe\" />\r\n" );
                }
                fprintf ( OUT, "\t\t\t\t<Compiler>\r\n" );
-               
+
                bool debug = ( cfg.optimization == Debug );
 
                if ( debug )
@@ -587,13 +592,13 @@ CBBackend::_generate_cbproj ( const Module& module )
                        fprintf ( OUT, "\t\t\t\t\t<Add directory=\"%s\" />\r\n", include.c_str() );
                }
                fprintf ( OUT, "\t\t\t\t</ResourceCompiler>\r\n" );
-               
+
                fprintf ( OUT, "\t\t\t\t<Linker>\r\n" );
                fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", project_linker_flags.c_str() );
 
                if ( sys )
                {
-                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint(false) == "" ? "DriverEntry@8" : module.GetEntryPoint(false).c_str ());
+                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint() == "" ? "DriverEntry@8" : module.GetEntryPoint().c_str ());
                        fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x10000" : baseaddr.c_str () );
                        fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--nostdlib\" />\r\n" );
                }
@@ -612,23 +617,23 @@ CBBackend::_generate_cbproj ( const Module& module )
                        }
                        else
                        {
-                               fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.useHostStdlib ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
+                               fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.cplusplus ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
                                fprintf ( OUT, "\t\t\t\t\t<Add library=\"gcc\" />\r\n" );
                        }
                }
                else if ( dll )
                {
-                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint(false).c_str () );
+                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint().c_str () );
                        fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x40000" : baseaddr.c_str () );
 
-                       if ( module.type == Win32DLL )
+                       if ( module.type == Win32DLL)
                                fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--shared\" />\r\n" );
                        else if ( module.type == NativeDLL)
                                fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--shared\" />\r\n" );
                        else if ( module.type == NativeDLL)
                                fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--shared\" />\r\n" );
 
-                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.useHostStdlib ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
+                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.cplusplus ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
                        fprintf ( OUT, "\t\t\t\t\t<Add library=\"gcc\" />\r\n" );
                }
 
@@ -653,30 +658,33 @@ CBBackend::_generate_cbproj ( const Module& module )
 
                fprintf ( OUT, "\t\t\t\t<ExtraCommands>\r\n" );
 
-               if ( module.type == StaticLibrary && module.importLibrary )
+#if 0
+               if ( IsStaticLibrary ( module ) && module.importLibrary )
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"dlltool --dllname %s --def %s --output-lib $exe_output; %s -U\" />\r\n", module.importLibrary->dllname.c_str (), module.importLibrary->definition.c_str(), module.mangledSymbols ? "" : "--kill-at" );
                else if ( module.importLibrary != NULL )
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"dlltool --dllname %s --def %s --output-lib &quot;$(TARGET_OBJECT_DIR)lib$(TARGET_OUTPUT_BASENAME).a&quot; %s\" />\r\n", module.GetTargetName ().c_str(), module.importLibrary->definition.c_str(), module.mangledSymbols ? "" : "--kill-at" );
+#endif
 
 
                for ( i = 0; i < resource_files.size(); i++ )
                {
                        const string& resource_file = resource_files[i];
 #ifdef WIN32
-                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)\\%s.rci.tmp 2&gt;NUL\" />\r\n", resource_file.c_str() );
-                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)\\%s.res.tmp 2&gt;NUL\" />\r\n", resource_file.c_str() );
+                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)%s%s.rci.tmp 2&gt;NUL\" />\r\n", sSep.c_str(), resource_file.c_str() );
+                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)%s%s.res.tmp 2&gt;NUL\" />\r\n", sSep.c_str(), resource_file.c_str() );
 #else
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"rm $(TARGET_OBJECT_DIR)/%s.rci.tmp 2&gt;/dev/null\" />\r\n", resource_file.c_str() );
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"rm $(TARGET_OBJECT_DIR)/%s.res.tmp 2&gt;/dev/null\" />\r\n", resource_file.c_str() );
 #endif
                }
 
+#if 0
                if ( dll )
                {
-                       if (IsWineModule( module ))
-                               fprintf ( OUT, "\t\t\t\t\t<Add before=\"%s\\tools\\winebuild\\winebuild.exe -o %s --def -E %s.spec\" />\r\n", outdir.c_str(), module.importLibrary->definition.c_str(),  module.name.c_str());
+                       if (IsSpecDefinitionFile( module ))
+                               fprintf ( OUT, "\t\t\t\t\t<Add before=\"%s%stools%swinebuild%swinebuild.exe -o %s --def -E %s.spec\" />\r\n", outdir.c_str(), sSep, sSep, sSep, module.importLibrary->definition.c_str(),  module.name.c_str());
                        fprintf ( OUT, "\t\t\t\t\t<Add before=\"dlltool --dllname %s --def %s --output-exp %s.temp.exp %s\" />\r\n", module.GetTargetName ().c_str(), module.importLibrary->definition.c_str(), module.name.c_str(), module.mangledSymbols ? "" : "--kill-at" );
-                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"%s\\tools\\pefixup $exe_output -exports\" />\r\n", outdir.c_str() );
+                       fprintf ( OUT, "\t\t\t\t\t<Add after=\"%s%stools%spefixup $exe_output -exports\" />\r\n", outdir.c_str(), sSep, sSep );
 #ifdef WIN32
                        fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del %s.temp.exp 2&gt;NUL\" />\r\n", module.name.c_str() );
 #else
@@ -684,6 +692,7 @@ CBBackend::_generate_cbproj ( const Module& module )
 #endif
                        fprintf ( OUT, "\t\t\t\t\t<Mode after=\"always\" />\r\n" );
                }
+#endif
 
                fprintf ( OUT, "\t\t\t\t</ExtraCommands>\r\n" );
 
@@ -703,10 +712,14 @@ CBBackend::_generate_cbproj ( const Module& module )
 
        fprintf ( OUT, "\t\t</Build>\r\n" );
 
+#ifdef FORCE_CPP
+       CompilerVar = "CPP"
+#else
        if ( module.cplusplus )
                CompilerVar = "CPP";
        else
                CompilerVar = "CC";
+#endif
 
        /* header files */
        for ( i = 0; i < header_files.size(); i++ )
@@ -738,22 +751,22 @@ CBBackend::_generate_cbproj ( const Module& module )
                        fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
                        fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"gcc -x assembler-with-cpp -c $file -o $link_objects $includes -D__ASM__ $options\" />\r\n" );
                }
-               else if ( extension == ".asm" || extension == ".ASM" )          
+               else if ( extension == ".asm" || extension == ".ASM" )
                {
                        fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
                        fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
                        fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"nasm -f win32 $file -o $link_objects\" />\r\n" );
                }
-               else if ( extension == ".idl" || extension == ".IDL" )          
+               else if ( extension == ".idl" || extension == ".IDL" )
                {
                        fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
-                       fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s\\tools\\widl\\widl.exe %s %s -h -H &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.h&quot; -c -C &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.c&quot; $file\\ngcc %s -c &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.c&quot; -o &quot;$(TARGET_OUTPUT_DIR)$file_c.o&quot;\" />\r\n", outdir.c_str(), widl_options.c_str(), windres_defines.c_str(), widl_options.c_str() );
+                       fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s%stools%swidl%swidl.exe %s %s -h -H &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.h&quot; -c -C &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.c&quot; $file%sngcc %s -c &quot;$(TARGET_OUTPUT_DIR)$filetitle_c.c&quot; -o &quot;$(TARGET_OUTPUT_DIR)$file_c.o&quot;\" />\r\n", outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), widl_options.c_str(), windres_defines.c_str(), sSep.c_str(), widl_options.c_str() );
                }
-               else if ( extension == ".spec" || extension == ".SPEC" )                
+               else if ( extension == ".spec" || extension == ".SPEC" )
                {
                        fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
                        fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
-                       fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s\\tools\\winebuild\\winebuild.exe -o $file.stubs.c --pedll $file\\n$compiler -c $options $includes $file.stubs.c -o $(TARGET_OBJECT_DIR)\\$file.o\" />\r\n", outdir.c_str() );
+                       fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s%stools%swinebuild%swinebuild.exe -o $file.stubs.c --pedll $file\\n$compiler -c $options $includes $file.stubs.c -o $(TARGET_OBJECT_DIR)%s$file.o\" />\r\n", outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str() );
                }
 
                for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
@@ -771,7 +784,7 @@ CBBackend::_generate_cbproj ( const Module& module )
                fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", resource_file.c_str() );
                fprintf ( OUT, "\t\t\t<Option compilerVar=\"WINDRES\" />\r\n" );
                string extension = GetExtension ( resource_file );
-               fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"gcc -xc -E -DRC_INVOKED $includes %s $file -o $(TARGET_OBJECT_DIR)\\$file.rci.tmp\\n%s\\tools\\wrc\\wrc.exe $includes %s $(TARGET_OBJECT_DIR)\\$file.rci.tmp $(TARGET_OBJECT_DIR)\\$file.res.tmp\\n$rescomp --output-format=coff $(TARGET_OBJECT_DIR)\\$file.res.tmp -o $resource_output\" />\r\n" , windres_defines.c_str(), outdir.c_str(),  windres_defines.c_str() );
+               fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"gcc -xc -E -DRC_INVOKED $includes %s $file -o $(TARGET_OBJECT_DIR)%s$file.rci.tmp\\n%s%stools%swrc%swrc.exe $includes %s $(TARGET_OBJECT_DIR)%s$file.rci.tmp $(TARGET_OBJECT_DIR)%s$file.res.tmp\\n$rescomp --output-format=coff $(TARGET_OBJECT_DIR)%s$file.res.tmp -o $resource_output\" />\r\n" , windres_defines.c_str(), sSep.c_str(), outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), windres_defines.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str() );
                for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
                {
                        const CBConfiguration& cfg = *m_configurations[icfg];
@@ -863,33 +876,33 @@ CBBackend::MingwAddImplicitLibraries( Module &module )
        }
 }
 
-const Property* 
+const Property*
 CBBackend::_lookup_property ( const Module& module, const std::string& name ) const
 {
+       std::map<std::string, Property*>::const_iterator p;
+
        /* Check local values */
-       for ( size_t i = 0; i < module.non_if_data.properties.size(); i++ )
-       {
-               const Property& property = *module.non_if_data.properties[i];
-               if ( property.name == name )
-                       return &property;
-       }
+       p = module.non_if_data.properties.find(name);
+
+       if ( p != module.non_if_data.properties.end() )
+               return p->second;
+
        // TODO FIXME - should we check local if-ed properties?
-       for ( size_t i = 0; i < module.project.non_if_data.properties.size(); i++ )
-       {
-               const Property& property = *module.project.non_if_data.properties[i];
-               if ( property.name == name )
-                       return &property;
-       }
+       p = module.project.non_if_data.properties.find(name);
+
+       if ( p != module.project.non_if_data.properties.end() )
+               return p->second;
+
        // TODO FIXME - should we check global if-ed properties?
        return NULL;
 }
 
 bool
-CBBackend::IsWineModule ( const Module& module ) const
+CBBackend::IsSpecDefinitionFile ( const Module& module ) const
 {
        if ( module.importLibrary == NULL)
                return false;
 
-       size_t index = module.importLibrary->definition.rfind ( ".spec.def" );
+       size_t index = module.importLibrary->source->name.rfind ( ".spec" );
        return ( index != string::npos );
 }