void PSGeneralPage::Load(BuildConfigPtr buildConf) { Clear(); m_configName = buildConf->GetName(); m_checkBoxEnabled->SetValue( buildConf->IsProjectEnabled() ); m_pgPropArgs->SetValue( buildConf->GetCommandArguments() ); m_pgPropDebugArgs->SetValueFromString( buildConf->GetDebugArgs() ); m_pgPropIntermediateFolder->SetValueFromString( buildConf->GetIntermediateDirectory() ); m_pgPropGUIApp->SetValue( buildConf->IsGUIProgram() ); m_pgPropOutputFile->SetValueFromString( buildConf->GetOutputFileName() ); m_pgPropPause->SetValue( buildConf->GetPauseWhenExecEnds() ); m_pgPropProgram->SetValueFromString( buildConf->GetCommand() ); m_pgPropWorkingDirectory->SetValue( buildConf->GetWorkingDirectory() ); // Project type wxPGChoices choices; choices.Add(Project::STATIC_LIBRARY); choices.Add(Project::DYNAMIC_LIBRARY); choices.Add(Project::EXECUTABLE); m_pgPropProjectType->SetChoices( choices ); m_pgPropProjectType->SetChoiceSelection( choices.Index(buildConf->GetProjectType() ) ); // Compilers choices.Clear(); wxString cmpType = buildConf->GetCompilerType(); BuildSettingsConfigCookie cookie; CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie); while (cmp) { choices.Add(cmp->GetName()); cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie); } m_pgPropCompiler->SetChoices( choices ); m_pgPropCompiler->SetChoiceSelection( choices.Index( buildConf->GetCompiler()->GetName() ) ); // Debuggers choices.Clear(); wxString dbgType = buildConf->GetDebuggerType(); wxArrayString dbgs = DebuggerMgr::Get().GetAvailableDebuggers(); choices.Add(dbgs); m_pgPropDebugger->SetChoices( choices ); m_pgPropDebugger->SetChoiceSelection( choices.Index(buildConf->GetDebuggerType()) ); m_pgPropUseSeparateDebuggerArgs->SetValue( buildConf->GetUseSeparateDebugArgs() ); m_dlg->SetIsProjectEnabled( buildConf->IsProjectEnabled() ); }
void MacBundler::showSettingsDialogFor(ProjectPtr project) { // project->GetSettings()->GetGlobalSettings(); // project->GetSettings()->GetBuildConfiguration(name); ProjectSettingsCookie cookie; ProjectSettingsPtr settings = project->GetSettings(); if(not settings) { wxMessageBox(_("Cannot continue, impossible to access project settings.")); return; } std::map<wxString, BuildConfigPtr> configs; wxArrayString choices; // TODO: allow putting the rules in the config root and not in every target BuildConfigPtr buildConfig = settings->GetFirstBuildConfiguration(cookie); while(buildConfig) { configs[buildConfig->GetName()] = buildConfig; choices.Add(buildConfig->GetName()); buildConfig = settings->GetNextBuildConfiguration(cookie); } bool accepted = false; bool generateInfoPlistFile = false; bool generateIcon = false; wxArrayString targetsToSet; wxString iconName(wxT("icon.icns")); { BundleConfigDialog configDlg(project, m_mgr->GetTheApp()->GetTopWindow(), choices, m_mgr); configDlg.ShowModal(); accepted = configDlg.getResults(targetsToSet, &generateInfoPlistFile, &generateIcon); iconName = configDlg.getIconDestName(); if(accepted and generateInfoPlistFile) { wxFileName projPath = project->GetFileName(); projPath.SetFullName(wxT("")); const wxString projectDirName = projPath.GetFullPath(); const wxString infoPlistFile = projectDirName + wxT("/Info.plist"); if(wxFileExists(infoPlistFile)) { int out = wxMessageBox(wxString::Format(_("The following file:\n%s\nalready exists, overwrite it?\n"), infoPlistFile.c_str()), _("Warning"), wxYES_NO); if(out == wxYES) { wxTextFile file; file.Open(infoPlistFile); file.Clear(); configDlg.writeInfoPlistFile(file); file.Close(); } } else { wxTextFile file; if(not file.Create(infoPlistFile)) { wxMessageBox(_("Could not create Info.plist file\n") + infoPlistFile); } else { configDlg.writeInfoPlistFile(file); file.Close(); } } if(wxFileExists(infoPlistFile)) { // FIXME: if the file was already present, it will be added again and appear twice in the file tree wxArrayString paths; paths.Add(infoPlistFile); m_mgr->CreateVirtualDirectory(project->GetName(), wxT("osx")); m_mgr->AddFilesToVirtualFolder(project->GetName() + wxT(":osx"), paths); } } // nend if create info.plist if(accepted and generateIcon) { wxString iconSourcePath = configDlg.getIconSource(); if(not iconSourcePath.IsEmpty()) { // sips doesn't like double slashes in path names iconSourcePath.Replace(wxT("//"), wxT("/")); wxFileName projPath = project->GetFileName(); projPath.SetFullName(wxT("")); const wxString projectDirName = projPath.GetFullPath(); wxString iconFileDest = projectDirName + wxT("/") + configDlg.getIconDestName(); // sips doesn't like double slashes in path names iconFileDest.Replace(wxT("//"), wxT("/")); std::cout << "Copying icon '" << iconSourcePath.mb_str() << "' to project\n"; if(iconSourcePath.EndsWith(wxT(".icns"))) { if(not wxCopyFile(iconSourcePath, iconFileDest)) { wxMessageBox(_("Sorry, could not copy icon")); } } else { wxString cmd = wxT("sips -s format icns '") + iconSourcePath + wxT("' --out '") + iconFileDest + wxT("'"); std::cout << cmd.mb_str() << std::endl; wxExecute(cmd, wxEXEC_SYNC); if(not wxFileExists(iconFileDest)) { wxMessageBox(_("Sorry, could not convert selected icon to icns format")); } } // FIXME: if the file was already present, it will be added again and appear twice in the file tree if(wxFileExists(iconFileDest)) { wxArrayString paths; paths.Add(iconFileDest); m_mgr->CreateVirtualDirectory(project->GetName(), wxT("osx")); m_mgr->AddFilesToVirtualFolder(project->GetName() + wxT(":osx"), paths); } } // end if icon not null } // end if generate icon } if(!accepted) return; for(int n = 0; n < targetsToSet.GetCount(); n++) { BuildConfigPtr buildConfig = configs[targetsToSet[n]]; wxString outputFileName = buildConfig->GetOutputFileName(); wxString output = wxT("$(ProjectName).app/Contents/MacOS/$(ProjectName)"); buildConfig->SetOutputFileName(wxT("$(IntermediateDirectory)/") + output); buildConfig->SetCommand(wxT("./") + output); if(generateInfoPlistFile or generateIcon) { // get existing custom makefile targets, if any wxString customPreBuild = buildConfig->GetPreBuildCustom(); wxString deps, rules; deps = customPreBuild.BeforeFirst(wxT('\n')); rules = customPreBuild.AfterFirst(wxT('\n')); rules = rules.Trim(); rules = rules.Trim(false); deps = deps.Trim(); deps = deps.Trim(false); if(generateInfoPlistFile) { // augment existing rules with new rules to manage Info.plist file deps.Append(wxT(" $(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist")); rules.Append(wxString(wxT("\n## rule to copy the Info.plist file into the bundle\n")) + wxT("$(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist: Info.plist\n") + wxT("\tmkdir -p '$(IntermediateDirectory)/$(ProjectName).app/Contents' && cp -f " "Info.plist '$(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist'")); } if(generateIcon) { // augment existing rules with new rules to manage Info.plist file deps.Append(wxT(" $(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") + iconName); rules.Append( wxT("\n## rule to copy the icon file into the " "bundle\n$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") + iconName + wxT(": ") + iconName + wxT("\n\tmkdir -p '$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/' && cp -f ") + iconName + wxT(" '$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") + iconName + wxT("'")); } // set the new rules rules = rules.Trim(); rules = rules.Trim(false); deps = deps.Trim(); deps = deps.Trim(false); wxString prebuilstep; prebuilstep << deps << wxT("\n"); prebuilstep << rules; prebuilstep << wxT("\n"); // Set the content only if there is real content to add wxString tmpPreBuildStep(prebuilstep); tmpPreBuildStep.Trim().Trim(false); buildConfig->SetPreBuildCustom(prebuilstep); } // end if settings->SetBuildConfiguration(buildConfig); } // end for project->SetSettings(settings); }
void DebugCoreDumpDlg::Initialize() { DebugCoreDumpInfo info; EditorConfigST::Get()->ReadObject(wxT("DebugCoreDumpDlg"), &info); m_choiceDebuggers->Append(DebuggerMgr::Get().GetAvailableDebuggers()); if(m_choiceDebuggers->GetCount()) { m_choiceDebuggers->SetSelection(0); } if(m_choiceDebuggers->GetCount() > (unsigned int)info.GetSelectedDbg()) { m_choiceDebuggers->SetSelection(info.GetSelectedDbg()); } m_Core->Append(info.GetCoreFilepaths()); if(m_Core->GetCount() > 0) { m_Core->SetSelection(0); } m_WD->Append(info.GetWds()); if(m_WD->GetCount() > 0) { m_WD->SetSelection(0); } m_ExeFilepath->Append(info.GetExeFilepaths()); if(m_ExeFilepath->GetCount() > 0) { m_ExeFilepath->SetSelection(0); } else { // determine the executable to debug: // - If the 'Program' field is set - we use it // - Else we use the project's output name wxString activename, conf; ManagerST::Get()->GetActiveProjectAndConf(activename, conf); BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf(activename, conf); if(buildConf) { // expand all macros with their values wxString programToDebug = buildConf->GetCommand(); programToDebug.Trim().Trim(false); if(programToDebug.IsEmpty()) { programToDebug = buildConf->GetOutputFileName(); } wxString outputFile = MacroManager::Instance()->Expand(programToDebug, PluginManager::Get(), activename, conf); if(m_ExeFilepath->Append(outputFile) != wxNOT_FOUND) { m_ExeFilepath->SetSelection(0); } // determine the working directory // if we have a working directory set in the project settings, use it (if it is not an // absolute path, it will be appended to the project's path) wxString projWD = MacroManager::Instance()->Expand( buildConf->GetWorkingDirectory(), PluginManager::Get(), activename, conf); projWD.Trim().Trim(false); wxString wd; ProjectPtr proj = ManagerST::Get()->GetProject(activename); if(proj) { if(projWD.IsEmpty() || !wxFileName(projWD).IsAbsolute()) { wxString basePath = proj->GetFileName().GetPath(); wd << basePath << wxFileName::GetPathSeparator(); } } wd << projWD; if(m_WD->Insert(wd, 0) != wxNOT_FOUND) { m_WD->SetSelection(0); } } } }
void CallGraph::OnShowCallGraph(wxCommandEvent& event) { // myLog("wxThread::IsMain(%d)", (int)wxThread::IsMain()); IConfigTool *config_tool = m_mgr->GetConfigTool(); config_tool->ReadObject(wxT("CallGraph"), &confData); if (!wxFileExists(GetGprofPath()) || !wxFileExists(GetDotPath())) return MessageBox(_T("Failed to locate required tools (gprof, dot). Please check the plugin settings."), wxICON_ERROR); Workspace *ws = m_mgr->GetWorkspace(); if (!ws) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxFileName ws_cfn = ws->GetWorkspaceFileName(); wxString projectName = ws->GetActiveProjectName(); BuildMatrixPtr mtx = ws->GetBuildMatrix(); if (!mtx) return MessageBox(_("Unable to get current build matrix."), wxICON_ERROR); wxString build_config_name = mtx->GetSelectedConfigurationName(); BuildConfigPtr bldConf = ws->GetProjBuildConf(projectName, build_config_name); if (!bldConf) return MessageBox(_("Unable to get opened workspace."), wxICON_ERROR); wxString projOutputFn = bldConf->GetOutputFileName(); wxString projWorkingDir = bldConf->GetWorkingDirectory(); /* myLog("WorkspaceFileName = \"%s\"", ws_cfn.GetFullPath()); myLog("projectName \"%s\"", projectName); myLog("build_config_name = \"%s\"", build_config_name); myLog("projOutputFn = \"%s\"", projOutputFn); myLog("projWorkingDir = \"%s\"", projWorkingDir); */ wxFileName cfn(ws_cfn.GetPath(), projOutputFn); cfn.Normalize(); // base path const wxString base_path = ws_cfn.GetPath(); // check source binary exists wxString bin_fpath = cfn.GetFullPath(); if (!cfn.Exists()) { bin_fpath = wxFileSelector("Please select the binary to analyze", base_path, "", ""); if (bin_fpath.IsEmpty()) return MessageBox("selected binary was canceled", wxICON_ERROR); cfn.Assign(bin_fpath, wxPATH_NATIVE); } if (!cfn.IsFileExecutable()) return MessageBox("bin/exe isn't executable", wxICON_ERROR); // check 'gmon.out' file exists wxFileName gmon_cfn(base_path, GMON_FILENAME_OUT); if (!gmon_cfn.Exists()) gmon_cfn.Normalize(); wxString gmonfn = gmon_cfn.GetFullPath(); if (!gmon_cfn.Exists()) { gmonfn = wxFileSelector("Please select the gprof file", gmon_cfn.GetPath(), "gmon", "out"); if (gmonfn.IsEmpty()) return MessageBox("selected gprof was canceled", wxICON_ERROR); gmon_cfn.Assign(gmonfn, wxPATH_NATIVE); } wxString bin, arg1, arg2; bin = GetGprofPath(); arg1 = bin_fpath; arg2 = gmonfn; wxString cmdgprof = wxString::Format("%s %s %s", bin, arg1, arg2); // myLog("about to wxExecute(\"%s\")", cmdgprof); wxProcess *proc = new wxProcess(wxPROCESS_REDIRECT); // wxStopWatch sw; const int err = ::wxExecute(cmdgprof, wxEXEC_SYNC, proc); // on sync returns 0 (success), -1 (failure / "couldn't be started") // myLog("wxExecute() returned err %d, had pid %d", err, (int)proc->GetPid()); wxInputStream *process_is = proc->GetInputStream(); if (!process_is || !process_is->CanRead()) return MessageBox(_("wxProcess::GetInputStream() can't be opened, aborting"), wxICON_ERROR); // start parsing and writing to dot language file GprofParser pgp; pgp.GprofParserStream(process_is); // myLog("gprof done (read %d lines)", (int) pgp.lines.GetCount()); delete proc; ConfCallGraph conf; config_tool->ReadObject(wxT("CallGraph"), &conf); DotWriter dotWriter; // DotWriter dotWriter.SetLineParser(&(pgp.lines)); int suggestedThreshold = pgp.GetSuggestedNodeThreshold(); if (suggestedThreshold <= conf.GetTresholdNode()) { suggestedThreshold = conf.GetTresholdNode(); dotWriter.SetDotWriterFromDialogSettings(m_mgr); } else { dotWriter.SetDotWriterFromDetails(conf.GetColorsNode(), conf.GetColorsEdge(), suggestedThreshold, conf.GetTresholdEdge(), conf.GetHideParams(), conf.GetStripParams(), conf.GetHideNamespaces()); wxString suggest_msg = wxString::Format(_("The CallGraph plugin has suggested node threshold %d to speed-up the call graph creation. You can alter it on the call graph panel."), suggestedThreshold); MessageBox(suggest_msg, wxICON_INFORMATION); } dotWriter.WriteToDotLanguage(); // build output dir cfn.Assign(base_path, ""); cfn.AppendDir(CALLGRAPH_DIR); cfn.Normalize(); if (!cfn.DirExists()) cfn.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); cfn.SetFullName(DOT_FILENAME_TXT); wxString dot_fn = cfn.GetFullPath(); dotWriter.SendToDotAppOutputDirectory(dot_fn); cfn.SetFullName(DOT_FILENAME_PNG); wxString output_png_fn = cfn.GetFullPath(); // delete any existing PNG if (wxFileExists(output_png_fn)) wxRemoveFile(output_png_fn); wxString cmddot_ln; cmddot_ln << GetDotPath() << " -Tpng -o" << output_png_fn << " " << dot_fn; // myLog("wxExecute(\"%s\")", cmddot_ln); wxExecute(cmddot_ln, wxEXEC_SYNC); // myLog("dot done"); if (!wxFileExists(output_png_fn)) return MessageBox(_("Failed to open file CallGraph.png. Please check the project settings, rebuild the project and try again."), wxICON_INFORMATION); // show image and create table in the editor tab page uicallgraphpanel *panel = new uicallgraphpanel(m_mgr->GetEditorPaneNotebook(), m_mgr, output_png_fn, base_path, suggestedThreshold, &(pgp.lines)); wxString tstamp = wxDateTime::Now().Format(wxT(" %Y-%m-%d %H:%M:%S")); wxString title = wxT("Call graph for \"") + output_png_fn + wxT("\" " + tstamp); m_mgr->AddEditorPage(panel, title); }
wxString MacroManager::DoExpand( const wxString& expression, IManager* manager, const wxString& project, bool applyEnv, const wxString& confToBuild) { wxString expandedString(expression); clCxxWorkspace* workspace = clCxxWorkspaceST::Get(); if(!manager) { manager = clGetManager(); } size_t retries = 0; wxString dummyname, dummfullname; while((retries < 5) && FindVariable(expandedString, dummyname, dummyname)) { ++retries; DollarEscaper de(expandedString); if(workspace) { expandedString.Replace(wxT("$(WorkspaceName)"), workspace->GetName()); ProjectPtr proj = workspace->GetProject(project); if(proj) { wxString prjBuildWd; wxString prjRunWd; wxString project_name(proj->GetName()); // make sure that the project name does not contain any spaces project_name.Replace(wxT(" "), wxT("_")); BuildConfigPtr bldConf = workspace->GetProjBuildConf(proj->GetName(), confToBuild); if(bldConf) { bool isCustom = bldConf->IsCustomBuild(); expandedString.Replace(wxT("$(ProjectOutputFile)"), bldConf->GetOutputFileName()); // An alias expandedString.Replace(wxT("$(OutputFile)"), bldConf->GetOutputFileName()); // When custom build project, use the working directory set in the // custom build tab, otherwise use the project file's path prjBuildWd = isCustom ? bldConf->GetCustomBuildWorkingDir() : proj->GetFileName().GetPath(); prjRunWd = bldConf->GetWorkingDirectory(); } expandedString.Replace(wxT("$(ProjectWorkingDirectory)"), prjBuildWd); expandedString.Replace(wxT("$(ProjectRunWorkingDirectory)"), prjRunWd); expandedString.Replace(wxT("$(ProjectPath)"), proj->GetFileName().GetPath()); expandedString.Replace(wxT("$(WorkspacePath)"), workspace->GetWorkspaceFileName().GetPath()); expandedString.Replace(wxT("$(ProjectName)"), project_name); if(bldConf) { expandedString.Replace(wxT("$(IntermediateDirectory)"), bldConf->GetIntermediateDirectory()); expandedString.Replace(wxT("$(ConfigurationName)"), bldConf->GetName()); expandedString.Replace(wxT("$(OutDir)"), bldConf->GetIntermediateDirectory()); } if(expandedString.Find(wxT("$(ProjectFiles)")) != wxNOT_FOUND) expandedString.Replace(wxT("$(ProjectFiles)"), proj->GetFiles()); if(expandedString.Find(wxT("$(ProjectFilesAbs)")) != wxNOT_FOUND) expandedString.Replace(wxT("$(ProjectFilesAbs)"), proj->GetFiles(true)); } } if(manager) { IEditor* editor = manager->GetActiveEditor(); if(editor) { wxFileName fn(editor->GetFileName()); expandedString.Replace(wxT("$(CurrentFileName)"), fn.GetName()); wxString fpath(fn.GetPath()); fpath.Replace(wxT("\\"), wxT("/")); expandedString.Replace(wxT("$(CurrentFilePath)"), fpath); expandedString.Replace(wxT("$(CurrentFileExt)"), fn.GetExt()); expandedString.Replace(wxT("$(CurrentFileFullName)"), fn.GetFullName()); wxString ffullpath(fn.GetFullPath()); ffullpath.Replace(wxT("\\"), wxT("/")); expandedString.Replace(wxT("$(CurrentFileFullPath)"), ffullpath); expandedString.Replace(wxT("$(CurrentSelection)"), editor->GetSelection()); if(expandedString.Find(wxT("$(CurrentSelectionRange)")) != wxNOT_FOUND) { int start = editor->GetSelectionStart(), end = editor->GetSelectionEnd(); wxString output = wxString::Format(wxT("%i:%i"), start, end); expandedString.Replace(wxT("$(CurrentSelectionRange)"), output); } } } // exapand common macros wxDateTime now = wxDateTime::Now(); expandedString.Replace(wxT("$(User)"), wxGetUserName()); expandedString.Replace(wxT("$(Date)"), now.FormatDate()); if(manager && applyEnv) { expandedString.Replace(wxT("$(CodeLitePath)"), manager->GetInstallDirectory()); // Apply the environment and expand the variables EnvSetter es(NULL, NULL, project, confToBuild); expandedString = manager->GetEnv()->ExpandVariables(expandedString, false); } } return expandedString; }