wxString CppCheckPlugin::DoGetCommand(ProjectPtr proj) { // Linux / Mac way: spawn the process and execute the command wxString cmd, path; path = clStandardPaths::Get().GetBinaryFullPath("codelite_cppcheck"); ::WrapWithQuotes(path); wxString fileList = DoGenerateFileList(); if(fileList.IsEmpty()) return wxT(""); // build the command cmd << path << " "; cmd << m_settings.GetOptions(); // Append here project specifc search paths if(proj) { wxArrayString projectSearchPaths = proj->GetIncludePaths(); for(size_t i = 0; i < projectSearchPaths.GetCount(); ++i) { wxFileName fnIncPath(projectSearchPaths.Item(i), ""); wxString includePath = fnIncPath.GetPath(true); ::WrapWithQuotes(includePath); cmd << " -I" << includePath; } wxArrayString projMacros = proj->GetPreProcessors(); for(size_t i = 0; i < projMacros.GetCount(); ++i) { cmd << " -D" << projMacros.Item(i); } } cmd << wxT(" --file-list="); cmd << wxT("\"") << fileList << wxT("\""); CL_DEBUG("cppcheck command: %s", cmd); return cmd; }
bool CodeCompletionManager::GetDefinitionsAndSearchPaths(LEditor* editor, wxArrayString& searchPaths, wxArrayString& definitions) { // Sanity CHECK_PTR_RET_FALSE(editor); if(editor->GetProjectName().IsEmpty()) return false; if(!WorkspaceST::Get()->IsOpen()) return false; // Support only C/C++ files if(!FileExtManager::IsCxxFile(editor->GetFileName().GetFullName())) return false; // Get the file's project and get the build configuration settings // for it ProjectPtr proj = WorkspaceST::Get()->GetProject(editor->GetProjectName()); CHECK_PTR_RET_FALSE(proj); BuildConfigPtr buildConf = proj->GetBuildConfiguration(); CHECK_PTR_RET_FALSE(buildConf); CompilerPtr compiler = buildConf->GetCompiler(); CHECK_PTR_RET_FALSE(compiler); if(buildConf->IsCustomBuild()) { // Custom builds are handled differently CompilationDatabase compileDb; compileDb.Open(); if(compileDb.IsOpened()) { // we have compilation database for this workspace wxString compileLine, cwd; compileDb.CompilationLine(editor->GetFileName().GetFullPath(), compileLine, cwd); CL_DEBUG("Pre Processor dimming: %s\n", compileLine); CompilerCommandLineParser cclp(compileLine, cwd); searchPaths = cclp.GetIncludes(); // get the mcros definitions = cclp.GetMacros(); } else { // we will probably will fail... return false; } } else { // get the include paths based on the project settings (this is per build configuration) searchPaths = proj->GetIncludePaths(); CL_DEBUG("CxxPreProcessor will use the following include paths:"); CL_DEBUG_ARR(searchPaths); // get the compiler include paths // wxArrayString compileIncludePaths = compiler->GetDefaultIncludePaths(); // includePaths.insert(includePaths.end(), compileIncludePaths.begin(), compileIncludePaths.end()); definitions = proj->GetPreProcessors(); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); } // Append the compiler builtin macros wxArrayString builtinMacros = compiler->GetBuiltinMacros(); definitions.insert(definitions.end(), builtinMacros.begin(), builtinMacros.end()); return true; }
bool CodeCompletionManager::GetDefinitionsAndSearchPaths(clEditor* editor, wxArrayString& searchPaths, wxArrayString& definitions) { // Sanity CHECK_PTR_RET_FALSE(editor); if(editor->GetProjectName().IsEmpty()) return false; if(!clCxxWorkspaceST::Get()->IsOpen()) return false; // Support only C/C++ files if(!FileExtManager::IsCxxFile(editor->GetFileName().GetFullName())) return false; // Get the file's project and get the build configuration settings // for it ProjectPtr proj = clCxxWorkspaceST::Get()->GetProject(editor->GetProjectName()); CHECK_PTR_RET_FALSE(proj); BuildConfigPtr buildConf = proj->GetBuildConfiguration(); CHECK_PTR_RET_FALSE(buildConf); CompilerPtr compiler = buildConf->GetCompiler(); CHECK_PTR_RET_FALSE(compiler); #if 0 if(buildConf->IsCustomBuild()) { definitions = proj->GetPreProcessors(); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); // Custom builds are handled differently CompilationDatabase compileDb; compileDb.Open(); if(compileDb.IsOpened()) { // we have compilation database for this workspace wxString compileLine, cwd; compileDb.CompilationLine(editor->GetFileName().GetFullPath(), compileLine, cwd); CL_DEBUG("Pre Processor dimming: %s\n", compileLine); CompilerCommandLineParser cclp(compileLine, cwd); searchPaths = cclp.GetIncludes(); // get the mcros definitions << cclp.GetMacros(); } } #endif // get the include paths based on the project settings (this is per build configuration) searchPaths = proj->GetIncludePaths(); CL_DEBUG("CxxPreProcessor will use the following include paths:"); CL_DEBUG_ARR(searchPaths); // get the compiler include paths // wxArrayString compileIncludePaths = compiler->GetDefaultIncludePaths(); // includePaths.insert(includePaths.end(), compileIncludePaths.begin(), compileIncludePaths.end()); definitions = proj->GetPreProcessors(); // get macros out of workspace wxString strWorkspaceMacros = clCxxWorkspaceST::Get()->GetParserMacros(); wxArrayString workspaceMacros = wxStringTokenize(strWorkspaceMacros, wxT("\n\r"), wxTOKEN_STRTOK); for(size_t i = 0; i < workspaceMacros.GetCount(); i++) definitions.Add(workspaceMacros.Item(i).Trim().Trim(false).c_str()); CL_DEBUG("CxxPreProcessor will use the following macros:"); CL_DEBUG_ARR(definitions); // Append the compiler builtin macros wxArrayString builtinMacros = compiler->GetBuiltinMacros(); definitions.insert(definitions.end(), builtinMacros.begin(), builtinMacros.end()); return true; }