Code::Blocks backend
authorChristoph von Wittich <christoph_vw@reactos.org>
Wed, 22 Nov 2006 15:18:51 +0000 (15:18 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Wed, 22 Nov 2006 15:18:51 +0000 (15:18 +0000)
svn path=/trunk/; revision=24799

reactos/Makefile
reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp [new file with mode: 0644]
reactos/tools/rbuild/backend/codeblocks/codeblocks.h [new file with mode: 0644]
reactos/tools/rbuild/backend/msvc/msvc.cpp
reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp
reactos/tools/rbuild/configuration.cpp
reactos/tools/rbuild/rbuild.cpp
reactos/tools/rbuild/rbuild.h
reactos/tools/rbuild/rbuild.mak

index aa5edaa..b13b550 100644 (file)
@@ -424,6 +424,12 @@ regtest:
        $(MAKE) bootcdregtest
        $(rm) $(OUTPUT_)cd$(SEP)reactos$(SEP)unattend.inf
 
+.PHONY: cb
+cb: $(RBUILD_TARGET)
+       $(ECHO_RBUILD)
+       $(Q)$(RBUILD_TARGET) $(ROS_RBUILDFLAGS) cb
+
+
 .PHONY: msvc
 msvc: $(RBUILD_TARGET)
        $(ECHO_RBUILD)
diff --git a/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp b/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp
new file mode 100644 (file)
index 0000000..2fc258d
--- /dev/null
@@ -0,0 +1,544 @@
+/*\r
+ * Copyright (C) 2006 Christoph von Wittich\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+#ifdef _MSC_VER\r
+#pragma warning ( disable : 4786 )\r
+#endif//_MSC_VER\r
+\r
+#include <iostream>\r
+#include <fstream>\r
+#include <string>\r
+#include <vector>\r
+\r
+#include <stdio.h>\r
+\r
+#include "codeblocks.h"\r
+#include "../mingw/mingw.h"\r
+\r
+using std::string;\r
+using std::vector;\r
+using std::ifstream;\r
+\r
+#ifdef OUT\r
+#undef OUT\r
+#endif//OUT\r
+\r
+\r
+static class CBFactory : public Backend::Factory\r
+{\r
+       public:\r
+\r
+               CBFactory() : Factory("CB", "Code::Blocks") {}\r
+               Backend *operator() (Project &project,\r
+                                    Configuration& configuration)\r
+               {\r
+                       return new CBBackend(project, configuration);\r
+               }\r
+               \r
+} factory;\r
+\r
+\r
+CBBackend::CBBackend(Project &project,\r
+       Configuration& configuration) : Backend(project, configuration)\r
+{\r
+       m_unitCount = 0;\r
+}\r
+\r
+void CBBackend::Process()\r
+{\r
+\r
+       while ( m_configurations.size () > 0 )\r
+       {\r
+               const CBConfiguration* cfg = m_configurations.back();\r
+               m_configurations.pop_back();\r
+               delete cfg;\r
+       }\r
+\r
+       m_configurations.push_back ( new CBConfiguration( Debug ));\r
+       m_configurations.push_back ( new CBConfiguration( Release ));\r
+\r
+       string filename_wrkspace ( ProjectNode.name );\r
+       filename_wrkspace += "_auto.workspace";\r
+\r
+       printf ( "Creating Code::Blocks workspace: %s\n", filename_wrkspace.c_str() );\r
+       \r
+       ProcessModules();\r
+       m_wrkspaceFile = fopen ( filename_wrkspace.c_str(), "wb" );\r
+\r
+       if ( !m_wrkspaceFile )\r
+       {\r
+               printf ( "Could not create file '%s'.\n", filename_wrkspace.c_str() );\r
+               return;\r
+       }\r
+\r
+       _generate_workspace ( m_wrkspaceFile );\r
+\r
+       fclose ( m_wrkspaceFile );\r
+       printf ( "Done.\n" );\r
+}\r
+\r
+void CBBackend::ProcessModules()\r
+{\r
+       for(size_t i = 0; i < ProjectNode.modules.size(); i++)\r
+       {\r
+               Module &module = *ProjectNode.modules[i];\r
+               _generate_cbproj ( module );\r
+       }\r
+}\r
+\r
+static bool FileExists(string &filename)\r
+{\r
+       ifstream file(filename.c_str());\r
+\r
+       if(!file.is_open())\r
+               return false;\r
+\r
+       file.close();\r
+       return true;\r
+}\r
+\r
+void CBBackend::ProcessFile(string &filepath)\r
+{\r
+       // Remove the .\ at the start of the filenames\r
+       if ( filepath[0] == '.' && strchr ( "/\\", filepath[1] ) )\r
+               filepath.erase(0, 2);\r
+\r
+       if(!FileExists(filepath))\r
+               return;\r
+\r
+       // Change the \ to /\r
+       for(size_t i = 0; i < filepath.length(); i++)\r
+       {\r
+               if(filepath[i] == '\\')\r
+                       filepath[i] = '/';\r
+       }\r
+\r
+       // Remove the filename from the path\r
+       string folder = "";\r
+\r
+       size_t pos = filepath.rfind(string("/"), filepath.length() - 1);\r
+\r
+       if(pos != string::npos)\r
+       {\r
+               folder = filepath;\r
+               folder.erase(pos, folder.length() - pos);\r
+       }\r
+       \r
+       FileUnit fileUnit;\r
+       fileUnit.filename = filepath;\r
+       fileUnit.folder = folder;\r
+\r
+       m_fileUnits.push_back(fileUnit);\r
+\r
+       if(folder != "")\r
+               AddFolders(folder);\r
+\r
+       m_unitCount++;\r
+}\r
+\r
+bool CBBackend::CheckFolderAdded(string &folder)\r
+{\r
+       for(size_t i = 0; i < m_folders.size(); i++)\r
+       {\r
+               if(m_folders[i] == folder)\r
+                       return true;\r
+       }\r
+\r
+       return false;\r
+}\r
+\r
+void CBBackend::AddFolders(string &folder)\r
+{\r
+       // Check if this folder was already added. true if it was, false otherwise.\r
+       if(CheckFolderAdded(folder))\r
+               return;\r
+       \r
+       m_folders.push_back(folder);\r
+       \r
+       size_t pos = folder.rfind(string("/"), folder.length() - 1);\r
+\r
+       if(pos == string::npos)\r
+               return;\r
+\r
+       folder.erase(pos, folder.length() - pos);\r
+       AddFolders(folder);\r
+}\r
+\r
+void CBBackend::OutputFolders()\r
+{\r
+#if 0\r
+       m_devFile << "Folders=";\r
+\r
+       for(size_t i = 0; i < m_folders.size(); i++)\r
+       {\r
+               if(i > 0)\r
+                       m_devFile << ",";\r
+\r
+               m_devFile << m_folders[i];\r
+       }\r
+#endif\r
+}\r
+\r
+std::string\r
+CBBackend::CbpFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), + "_auto.cbp" )\r
+               );\r
+}\r
+\r
+std::string\r
+CBBackend::LayoutFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), + "_auto.layout" )\r
+               );\r
+}\r
+\r
+std::string\r
+CBBackend::DependFileName ( const Module& module ) const\r
+{\r
+       return DosSeparator(\r
+               ReplaceExtension ( module.GetPath(), + "_auto.depend" )\r
+               );\r
+}\r
+\r
+void \r
+CBBackend::_get_object_files ( const Module& module, vector<string>& out) const\r
+{\r
+       string basepath = module.GetBasePath ();\r
+       size_t i;\r
+       string intenv = Environment::GetIntermediatePath () + "\\" + basepath + "\\";\r
+       string outenv = Environment::GetOutputPath () + "\\" + basepath + "\\";\r
+\r
+       vector<string> cfgs;\r
+\r
+       if ( configuration.UseConfigurationInPath )\r
+       {\r
+               cfgs.push_back ( intenv + "Debug" );\r
+               cfgs.push_back ( intenv + "Release" );\r
+               cfgs.push_back ( outenv + "Debug" );\r
+               cfgs.push_back ( outenv + "Release" );\r
+       }\r
+       else\r
+       {\r
+               cfgs.push_back ( intenv );\r
+               cfgs.push_back ( outenv );\r
+       }\r
+\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
+       while ( ifs_list.size () )\r
+       {\r
+               const IfableData& data = *ifs_list.back();\r
+               ifs_list.pop_back();\r
+               const vector<File*>& files = data.files;\r
+               for ( i = 0; i < files.size (); i++ )\r
+               {\r
+                       string file = files[i]->name;\r
+                       string::size_type pos = file.find_last_of ("\\");\r
+                       if ( pos != string::npos )\r
+                               file.erase ( 0, pos+1 );\r
+                       if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )\r
+                               file = ReplaceExtension ( file, ".res" );\r
+                       else\r
+                               file = ReplaceExtension ( file, ".obj" );\r
+                       for ( size_t j = 0; j < cfgs.size () / 2; j++ )\r
+                               out.push_back ( cfgs[j] + "\\" + file );\r
+               }\r
+\r
+       }\r
+}\r
+\r
+void\r
+CBBackend::_clean_project_files ( void )\r
+{\r
+       for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )\r
+       {\r
+               Module& module = *ProjectNode.modules[i];\r
+               vector<string> out;\r
+               printf("Cleaning project %s %s\n", module.name.c_str (), module.GetBasePath ().c_str () );\r
+               \r
+               string basepath = module.GetBasePath ();\r
+               remove ( CbpFileName ( module ).c_str () );     \r
+               remove ( DependFileName ( module ).c_str () );  \r
+               remove ( LayoutFileName ( module ).c_str () );  \r
+\r
+               _get_object_files ( module, out );\r
+               for ( size_t j = 0; j < out.size (); j++)\r
+               {\r
+                       //printf("Cleaning file %s\n", out[j].c_str () );\r
+                       remove ( out[j].c_str () );\r
+               }\r
+       }\r
+\r
+       string filename_wrkspace = ProjectNode.name + ".workspace";\r
+\r
+       remove ( filename_wrkspace.c_str () );\r
+}\r
+\r
+void\r
+CBBackend::_generate_workspace ( FILE* OUT )\r
+{\r
+       fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n" );\r
+       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++ )\r
+       {\r
+               Module& module = *ProjectNode.modules[i];\r
+               \r
+               std::string Cbp_file = CbpFileName ( module );\r
+               fprintf ( OUT, "\t\t<Project filename=\"%s\" />\r\n", Cbp_file.c_str());
+               \r
+       }\r
+       fprintf ( OUT, "\t</Workspace>\r\n" );
+       fprintf ( OUT, "</CodeBlocks_workspace_file>\r\n" );
+}\r
+\r
+void\r
+CBBackend::_generate_cbproj ( const Module& module )\r
+{\r
+\r
+       size_t i;\r
+\r
+       string cbproj_file = CbpFileName(module);\r
+       string outdir;\r
+       string intdir;\r
+       string path_basedir = module.GetPathToBaseDir ();\r
+       string intenv = Environment::GetIntermediatePath ();\r
+       string outenv = Environment::GetOutputPath ();\r
+       string module_type = GetExtension(module.GetTargetName());\r
+       string cbproj_path = module.GetBasePath();      \r
+\r
+       //bool lib = (module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a");\r
+       //bool dll = (module_type == ".dll") || (module_type == ".cpl");\r
+       bool exe = (module_type == ".exe") || (module_type == ".scr");\r
+       //bool sys = (module_type == ".sys");\r
+\r
+       vector<string> source_files, resource_files, includes, libraries, libpaths;\r
+       vector<string> header_files, common_defines;\r
+       \r
+       if ( module.pch != NULL )\r
+       {\r
+               string pch_path = Path::RelativeFromDirectory (\r
+                                       module.pch->file.name,\r
+                                       module.GetBasePath() );\r
+\r
+               header_files.push_back ( pch_path );\r
+       }\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
+       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
+       while ( ifs_list.size() )\r
+       {\r
+               const IfableData& data = *ifs_list.back();\r
+               ifs_list.pop_back();\r
+               const vector<File*>& files = data.files;\r
+               for ( i = 0; i < files.size(); i++ )\r
+               {\r
+                       string file = string(".") + &files[i]->name[cbproj_path.size()];\r
+\r
+                       if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )\r
+                               resource_files.push_back ( file );\r
+                       else\r
+                               source_files.push_back ( file );\r
+               }\r
+               const vector<Include*>& incs = data.includes;\r
+               for ( i = 0; i < incs.size(); i++ )\r
+               {\r
+                       string path = Path::RelativeFromDirectory (\r
+                               incs[i]->directory,\r
+                               module.GetBasePath() );\r
+\r
+                       includes.push_back ( path );\r
+               }\r
+               const vector<Library*>& libs = data.libraries;\r
+               for ( i = 0; i < libs.size(); i++ )\r
+               {\r
+                       string libpath = outdir + "\\" + libs[i]->importedModule->GetBasePath() + "\\" + libs[i]->name;\r
+                       libraries.push_back ( libs[i]->name );\r
+                       libpaths.push_back ( libpath );\r
+               }\r
+               const vector<Define*>& defs = data.defines;\r
+               for ( i = 0; i < defs.size(); i++ )\r
+               {\r
+                       if ( defs[i]->value[0] )\r
+                               common_defines.push_back( defs[i]->name + "=" + defs[i]->value );\r
+                       else\r
+                               common_defines.push_back( defs[i]->name );\r
+               }\r
+       }\r
+\r
+       FILE* OUT = fopen ( cbproj_file.c_str(), "wb" );\r
+\r
+       fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n" );
+       fprintf ( OUT, "<CodeBlocks_project_file>\r\n" );
+       fprintf ( OUT, "\t<FileVersion major=\"1\" minor=\"5\" />\r\n" );\r
+       fprintf ( OUT, "\t<Project>\r\n" );\r
+       fprintf ( OUT, "\t\t<Option title=\"%s\" />\r\n", module.name.c_str() );
+       fprintf ( OUT, "\t\t<Option pch_mode=\"2\" />\r\n" );
+       fprintf ( OUT, "\t\t<Option default_target=\"\" />\r\n" );
+       fprintf ( OUT, "\t\t<Option compiler=\"gcc\" />\r\n" );
+       fprintf ( OUT, "\t\t<Option virtualFolders=\"\" />\r\n" );
+       fprintf ( OUT, "\t\t<Build>\r\n" );\r
+\r
+       for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )\r
+       {\r
+               const CBConfiguration& cfg = *m_configurations[icfg];\r
+               fprintf ( OUT, "\t\t\t<Target title=\"%s\">\r\n", cfg.name.c_str() );\r
+\r
+               if ( configuration.UseConfigurationInPath )\r
+               {\r
+                       fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s%s\\%s%s\" prefix_auto=\"1\" extension_auto=\"1\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), cfg.name.c_str(), module.name.c_str(), module_type.c_str());\r
+                       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() );\r
+               }\r
+               else\r
+               {\r
+                       fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s\\%s%s\" prefix_auto=\"1\" extension_auto=\"1\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), module.name.c_str(), module_type.c_str() );\r
+                       fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str () );\r
+               }\r
+\r
+               bool console = exe && (module.type == Win32CUI);\r
+\r
+               if ( console )\r
+                       fprintf ( OUT, "\t\t\t\t<Option type=\"1\" />\r\n" );\r
+               else /* Win32 GUI */\r
+                       fprintf ( OUT, "\t\t\t\t<Option type=\"0\" />\r\n" );\r
+               /* TODO: other subsystems */\r
+                       \r
+               fprintf ( OUT, "\t\t\t\t<Option compiler=\"gcc\" />\r\n" );\r
+               fprintf ( OUT, "\t\t\t\t<Compiler>\r\n" );\r
+               /* defines */\r
+               for ( i = 0; i < common_defines.size(); i++ )\r
+               {\r
+                       const string& define = common_defines[i];\r
+                       fprintf ( OUT, "\t\t\t\t\t<Add option=\"-D%s\" />\r\n", define.c_str() );\r
+               }\r
+               /* includes */\r
+               for ( i = 0; i < includes.size(); i++ )\r
+               {\r
+                       const string& include = includes[i];\r
+                       fprintf ( OUT, "\t\t\t\t\t<Add directory=\"%s\" />\r\n", include.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t\t\t</Compiler>\r\n" );\r
+\r
+               /* includes */\r
+               fprintf ( OUT, "\t\t\t\t<ResourceCompiler>\r\n" );\r
+               for ( i = 0; i < includes.size(); i++ )\r
+               {\r
+                       const string& include = includes[i];\r
+                       fprintf ( OUT, "\t\t\t\t\t<Add directory=\"%s\" />\r\n", include.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t\t\t</ResourceCompiler>\r\n" );\r
+\r
+               /* libraries */\r
+               fprintf ( OUT, "\t\t\t\t<Linker>\r\n" );\r
+               for ( i = 0; i < libraries.size(); i++ )\r
+               {\r
+                       const string& lib = libraries[i];\r
+                       fprintf ( OUT, "\t\t\t\t\t<Add library=\"%s\" />\r\n", lib.c_str() );\r
+               }\r
+               for ( i = 0; i < libpaths.size(); i++ )\r
+               {\r
+                       const string& lib = libpaths[i];\r
+                       fprintf ( OUT, "\t\t\t\t\t<Add directory=\"%s\" />\r\n", lib.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t\t\t</Linker>\r\n" );\r
+\r
+               fprintf ( OUT, "\t\t\t</Target>\r\n" );\r
+\r
+       }\r
+       fprintf ( OUT, "\t\t</Build>\r\n" );
+\r
+       /* header files */\r
+       for ( i = 0; i < header_files.size(); i++ )\r
+       {\r
+               const string& header_file = header_files[i];\r
+               fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", header_file.c_str() );\r
+               fprintf ( OUT, "\t\t\t<Option compilerVar=\"CPP\" />\r\n" );
+               fprintf ( OUT, "\t\t\t<Option compile=\"0\" />\r\n" );
+               fprintf ( OUT, "\t\t\t<Option link=\"0\" />\r\n" );
+               for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )\r
+               {\r
+                       const CBConfiguration& cfg = *m_configurations[icfg];\r
+                       fprintf ( OUT, "\t\t\t<Option target=\"%s\" />\r\n" , cfg.name.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t</Unit>\r\n" );\r
+       }\r
+\r
+       /* source files */\r
+       for ( size_t isrcfile = 0; isrcfile < source_files.size(); isrcfile++ )\r
+       {\r
+               string source_file = DosSeparator(source_files[isrcfile]);\r
+               fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", source_file.c_str() );\r
+               for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )\r
+               {\r
+                       const CBConfiguration& cfg = *m_configurations[icfg];\r
+                       fprintf ( OUT, "\t\t\t<Option target=\"%s\" />\r\n" , cfg.name.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t</Unit>\r\n" );\r
+       }\r
+\r
+       /* resource files */\r
+       for ( i = 0; i < resource_files.size(); i++ )\r
+       {\r
+               const string& resource_file = resource_files[i];\r
+               fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", resource_file.c_str() );\r
+               fprintf ( OUT, "\t\t\t<Option compilerVar=\"WINDRES\" />\r\n" );
+               for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )\r
+               {\r
+                       const CBConfiguration& cfg = *m_configurations[icfg];\r
+                       fprintf ( OUT, "\t\t\t<Option target=\"%s\" />\r\n" , cfg.name.c_str() );\r
+               }\r
+               fprintf ( OUT, "\t\t</Unit>\r\n" );\r
+       }\r
+\r
+       fprintf ( OUT, "\t\t<Extensions />\r\n" );\r
+       fprintf ( OUT, "\t</Project>\r\n" );
+       fprintf ( OUT, "</CodeBlocks_project_file>\r\n" );
+\r
+\r
+       fclose ( OUT );\r
+}\r
+\r
+CBConfiguration::CBConfiguration ( const OptimizationType optimization, const std::string &name )\r
+{\r
+       this->optimization = optimization;\r
+       if ( name != "" )\r
+               this->name = name;\r
+       else\r
+       {\r
+               if ( optimization == Debug )\r
+                       this->name = "Debug";\r
+               else if ( optimization == Release )\r
+                       this->name = "Release";\r
+               else\r
+                       this->name = "Unknown";\r
+       }\r
+}\r
diff --git a/reactos/tools/rbuild/backend/codeblocks/codeblocks.h b/reactos/tools/rbuild/backend/codeblocks/codeblocks.h
new file mode 100644 (file)
index 0000000..e054466
--- /dev/null
@@ -0,0 +1,101 @@
+/*\r
+ * Copyright (C) 2005 Trevor McCort\r
+ * Copyright (C) 2005 Casper S. Hornstrup\r
+ *\r
+ * This program is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
+ */\r
+#ifndef __CODEBLOCKS_H__\r
+#define __CODEBLOCKS_H__\r
+\r
+#include <fstream>\r
+#include <vector>\r
+#include <string>\r
+\r
+#include "../backend.h"\r
+\r
+class FileUnit\r
+{\r
+       public:\r
+               std::string filename;\r
+               std::string folder;\r
+};\r
+\r
+enum OptimizationType\r
+{\r
+       Debug,\r
+       Release\r
+};\r
+\r
+class CBConfiguration\r
+{\r
+       public:\r
+               CBConfiguration(const OptimizationType optimization,\r
+                                 const std::string &name = "");\r
+               virtual ~CBConfiguration() {}\r
+               std::string name;\r
+               OptimizationType optimization;\r
+};\r
+\r
+class CBBackend : public Backend\r
+{\r
+       public:\r
+\r
+               CBBackend(Project &project,\r
+                             Configuration& configuration);\r
+               virtual ~CBBackend() {}\r
+\r
+               virtual void Process();\r
+\r
+       private:\r
+\r
+               void ProcessModules();\r
+               void ProcessFile(std::string &filename);\r
+               \r
+               bool CheckFolderAdded(std::string &folder);\r
+               void AddFolders(std::string &folder);\r
+\r
+               void OutputFolders();\r
+               void OutputFileUnits();\r
+\r
+               std::string CbpFileName ( const Module& module ) const;\r
+               std::string LayoutFileName ( const Module& module ) const;\r
+               std::string DependFileName ( const Module& module ) const;\r
+\r
+               std::vector<CBConfiguration*> m_configurations;\r
+\r
+               std::vector<FileUnit> m_fileUnits;\r
+               std::vector<std::string> m_folders;\r
+\r
+               int m_unitCount;\r
+\r
+               FILE* m_wrkspaceFile;\r
+\r
+               std::string _replace_str(\r
+                       std::string string1,\r
+                       const std::string &find_str,\r
+                       const std::string &replace_str);\r
+\r
+               void _generate_workspace ( FILE* OUT );\r
+               void _generate_cbproj ( const Module& module );\r
+\r
+               void _clean_project_files ( void );\r
+               void _get_object_files ( const Module& module, std::vector<std::string>& out ) const;\r
+               void _install_files ( const std::string& vcdir, const std::string& config );\r
+               bool _copy_file ( const std::string& inputname, const std::string& targetname ) const;\r
+               const Property* _lookup_property ( const Module& module, const std::string& name ) const;\r
+};\r
+\r
+#endif // __MSVC_H__\r
+\r
index df11911..20f8e77 100644 (file)
@@ -310,7 +310,7 @@ MSVCBackend::_get_object_files ( const Module& module, vector<string>& out) cons
 
        vector<string> cfgs;
 
-       if ( configuration.UseVSConfigurationInPath )
+       if ( configuration.UseConfigurationInPath )
        {
                cfgs.push_back ( intenv + "Debug" );
                cfgs.push_back ( intenv + "Release" );
index 1c2043b..2d21f5d 100644 (file)
@@ -238,7 +238,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
                fprintf ( OUT, "\t\t<Configuration\r\n" );
                fprintf ( OUT, "\t\t\tName=\"%s|Win32\"\r\n", cfg.name.c_str() );
 
-               if ( configuration.UseVSConfigurationInPath )
+               if ( configuration.UseConfigurationInPath )
                {
                        fprintf ( OUT, "\t\t\tOutputDirectory=\"%s\\%s%s\\%s\"\r\n", outdir.c_str (), module.GetBasePath ().c_str (), vcdir.c_str (), cfg.name.c_str() );
                        fprintf ( OUT, "\t\t\tIntermediateDirectory=\"%s\\%s%s\\%s\"\r\n", intdir.c_str (), module.GetBasePath ().c_str (), vcdir.c_str (), cfg.name.c_str() );
index 3cefcc4..28ad3e0 100644 (file)
@@ -30,7 +30,7 @@ Configuration::Configuration ()
        MakeHandlesInstallDirectories = false;
        GenerateProxyMakefilesInSourceTree = false;
        InstallFiles = false;
-       UseVSConfigurationInPath = false;
+       UseConfigurationInPath = false;
        UseVSVersionInPath = false;
 }
 
index 3766852..e49f3ad 100644 (file)
@@ -122,7 +122,7 @@ ParseVCProjectSwitch (
                        }
                        temp = string (&switchStart[3]);
                        if ( temp.find ("configuration") != string::npos )
-                               configuration.UseVSConfigurationInPath = true;
+                               configuration.UseConfigurationInPath = true;
                        
                        if ( temp.find ("version") != string::npos )
                                configuration.UseVSVersionInPath = true;
index f45b53f..ee204ca 100644 (file)
@@ -143,7 +143,7 @@ public:
        std::string VSProjectVersion;
        std::string VSConfigurationType;
        bool UseVSVersionInPath;
-       bool UseVSConfigurationInPath;
+       bool UseConfigurationInPath;
        bool MakeHandlesInstallDirectories;
        bool GenerateProxyMakefilesInSourceTree;
        bool InstallFiles;
index 5e8d3ab..cc7b536 100644 (file)
@@ -102,6 +102,24 @@ $(RBUILD_DEVCPP_OUT): | $(RBUILD_BACKEND_OUT)
        ${mkdir} $@
 endif
 
+RBUILD_CODEBLOCKS_BASE = $(RBUILD_BACKEND_BASE_)codeblocks
+RBUILD_CODEBLOCKS_BASE_ = $(RBUILD_CODEBLOCKS_BASE)$(SEP)
+RBUILD_CODEBLOCKS_INT = $(INTERMEDIATE_)$(RBUILD_CODEBLOCKS_BASE)
+RBUILD_CODEBLOCKS_INT_ = $(RBUILD_CODEBLOCKS_INT)$(SEP)
+RBUILD_CODEBLOCKS_OUT = $(OUTPUT_)$(RBUILD_CODEBLOCKS_BASE)
+RBUILD_CODEBLOCKS_OUT_ = $(RBUILD_CODEBLOCKS_OUT)$(SEP)
+
+$(RBUILD_CODEBLOCKS_INT): | $(RBUILD_BACKEND_INT)
+       $(ECHO_MKDIR)
+       ${mkdir} $@
+
+ifneq ($(INTERMEDIATE),$(OUTPUT))
+$(RBUILD_CODEBLOCKS_OUT): | $(RBUILD_BACKEND_OUT)
+       $(ECHO_MKDIR)
+       ${mkdir} $@
+endif
+
+
 RBUILD_MSVC_BASE = $(RBUILD_BACKEND_BASE_)msvc
 RBUILD_MSVC_BASE_ = $(RBUILD_MSVC_BASE)$(SEP)
 RBUILD_MSVC_INT = $(INTERMEDIATE_)$(RBUILD_MSVC_BASE)
@@ -136,6 +154,10 @@ RBUILD_BACKEND_DEVCPP_BASE_SOURCES = $(addprefix $(RBUILD_DEVCPP_BASE_), \
        devcpp.cpp \
        )
 
+RBUILD_BACKEND_CODEBLOCKS_BASE_SOURCES = $(addprefix $(RBUILD_CODEBLOCKS_BASE_), \
+       codeblocks.cpp \
+       )
+
 RBUILD_BACKEND_MSVC_BASE_SOURCES = $(addprefix $(RBUILD_MSVC_BASE_), \
        genguid.cpp \
        msvc.cpp \
@@ -147,6 +169,7 @@ RBUILD_BACKEND_SOURCES = \
        $(RBUILD_BACKEND_MINGW_BASE_SOURCES) \
        $(RBUILD_BACKEND_DEVCPP_BASE_SOURCES) \
        $(RBUILD_BACKEND_MSVC_BASE_SOURCES) \
+       $(RBUILD_BACKEND_CODEBLOCKS_BASE_SOURCES) \
        $(RBUILD_BACKEND_BASE_)backend.cpp
 
 RBUILD_COMMON_SOURCES = \
@@ -199,6 +222,9 @@ RBUILD_BACKEND_DEVCPP_HEADERS = \
 RBUILD_BACKEND_MSVCCPP_HEADERS = \
        msvc.h
 
+RBUILD_BACKEND_CODEBLOCKS_HEADERS = \
+       codeblocks.h
+
 RBUILD_BACKEND_MINGW_HEADERS = \
        mingw.h \
        modulehandler.h
@@ -207,7 +233,8 @@ RBUILD_BACKEND_HEADERS = \
        backend.h \
        $(addprefix devcpp$(SEP), $(RBUILD_BACKEND_DEVCPP_HEADERS)) \
        $(addprefix msvc$(SEP), $(RBUILD_BACKEND_MSVC_HEADERS)) \
-       $(addprefix mingw$(SEP), $(RBUILD_BACKEND_MINGW_HEADERS))
+       $(addprefix mingw$(SEP), $(RBUILD_BACKEND_MINGW_HEADERS)) \
+       $(addprefix codeblocks$(SEP), $(RBUILD_BACKEND_CODEBLOCKS_HEADERS))
 
 RBUILD_HEADERS = \
        $(addprefix $(RBUILD_BASE_), \
@@ -372,6 +399,10 @@ $(RBUILD_DEVCPP_INT_)devcpp.o: $(RBUILD_DEVCPP_BASE_)devcpp.cpp $(RBUILD_HEADERS
        $(ECHO_CC)
        ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
 
+$(RBUILD_CODEBLOCKS_INT_)codeblocks.o: $(RBUILD_CODEBLOCKS_BASE_)codeblocks.cpp $(RBUILD_HEADERS) | $(RBUILD_CODEBLOCKS_INT)
+       $(ECHO_CC)
+       ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
 $(RBUILD_MSVC_INT_)genguid.o: $(RBUILD_MSVC_BASE_)genguid.cpp $(RBUILD_HEADERS) | $(RBUILD_MSVC_INT)
        $(ECHO_CC)
        ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@