本文整理汇总了C++中ProjectBuildTarget::GetOutputFilename方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectBuildTarget::GetOutputFilename方法的具体用法?C++ ProjectBuildTarget::GetOutputFilename怎么用?C++ ProjectBuildTarget::GetOutputFilename使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectBuildTarget
的用法示例。
在下文中一共展示了ProjectBuildTarget::GetOutputFilename方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CheckRequirements
bool CheckRequirements(wxString& ExeTarget, wxString& CommandLineArguments)
{
cbProject* Project = Manager::Get()->GetProjectManager()->GetActiveProject();
// if no project open, exit
if (!Project)
{
wxString msg = _("You need to open a project\nbefore using the plugin!");
cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
Manager::Get()->GetLogManager()->DebugLog(msg);
return false;
}
// check the project s active target -> it should be executable !!
wxString strTarget = Project->GetActiveBuildTarget();
if(strTarget.empty())
{
wxString msg = _("You need to have an (executable) target in your open project\nbefore using the plugin!");
cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
Manager::Get()->GetLogManager()->DebugLog(msg);
return false;
}
// let's get the target
ProjectBuildTarget* Target = Project->GetBuildTarget(strTarget); // NOT const because of GetNativeFilename() :-(
if(!Target)
{
wxString msg = _("You need to have an (executable) target in your open project\nbefore using the plugin!");
cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
Manager::Get()->GetLogManager()->DebugLog(msg);
return false;
}
// check the type of the target
const TargetType TType = Target->GetTargetType();
if(!(TType == ttExecutable || TType == ttConsoleOnly))
{
wxString msg = _("You need to have an ***executable*** target in your open project\nbefore using the plugin!");
cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
Manager::Get()->GetLogManager()->DebugLog(msg);
return false;
}
else
{
if(TType == ttExecutable || ttConsoleOnly)
{
// ExeTarget = Target->GetExecutableFilename(); /// hmmm : this doesn't return correct stuff !!!
ExeTarget = Target->GetOutputFilename();
}
}
if(Target->GetCompilerOptions().Index(_T("-g")) == wxNOT_FOUND)
{
wxString msg = _("Your target needs to have been compiled with the -g option\nbefore using the plugin!");
cbMessageBox(msg, _("Error"), wxICON_ERROR | wxOK, Manager::Get()->GetAppWindow());
Manager::Get()->GetLogManager()->DebugLog(msg);
return false;
}
CommandLineArguments = Target->GetExecutionParameters();
return true;
} // end of CheckRequirements
示例2: OnProjectTypeChanged
void ProjectOptionsDlg::OnProjectTypeChanged(wxCommandEvent& /*event*/)
{
ProjectBuildTarget* target = m_Project->GetBuildTarget(m_Current_Sel);
if (!target)
return;
wxComboBox* cmb = XRCCTRL(*this, "cmbProjectType", wxComboBox);
wxCheckBox* chkCH = XRCCTRL(*this, "chkCreateHex", wxCheckBox);
wxTextCtrl* txt = XRCCTRL(*this, "txtOutputFilename", wxTextCtrl);
if (!cmb || !txt || !chkCH)
return;
// Default no hex file
target->SetCreateHex(false);
chkCH->SetValue(false);
switch((TargetType)cmb->GetSelection()) {
case ttExecutable :
chkCH->Enable(true);
break;
case ttLibrary :
chkCH->Enable(false);
break;
}
Compiler* compiler = CompilerFactory::GetCompiler(target->GetCompilerID());
wxFileName fname = target->GetOutputFilename();
wxString name = fname.GetName();
wxString ext = fname.GetExt();
wxString extI = fname.GetExt();
wxString extD = fname.GetExt();
wxString libext = compiler ? compiler->GetSwitches().libExtension : FileFilters::LIBRARY_EXT; // TODO: add specialized compiler option for this
wxString execext = compiler ? compiler->GetSwitches().execExtension : FileFilters::EXECUTABLE_EXT;
switch ((TargetType)cmb->GetSelection())
{
case ttExecutable:
fname.SetExt(execext);
txt->SetValue(fname.GetFullPath());
break;
case ttLibrary:
fname.SetExt(libext);
txt->SetValue(fname.GetFullPath());
break;
}
}
示例3: RecalcVars
//.........这里部分代码省略.........
// quote filenames, if they contain spaces
wxString out = UnixFilename(project->GetFile(i)->relativeFilename);
QuoteStringIfNeeded(out);
m_ProjectFiles << out << _T(' ');
}
ClearProjectKeys();
m_Macros[_T("PROJECTFILE")] = m_ProjectFilename;
m_Macros[_T("PROJECT_FILE")] = m_ProjectFilename;
m_Macros[_T("PROJECTFILENAME")] = m_ProjectFilename;
m_Macros[_T("PROJECT_FILENAME")] = m_ProjectFilename;
m_Macros[_T("PROJECT_FILE_NAME")] = m_ProjectFilename;
m_Macros[_T("PROJECTNAME")] = m_ProjectName;
m_Macros[_T("PROJECT_NAME")] = m_ProjectName;
m_Macros[_T("PROJECTDIR")] = m_ProjectDir;
m_Macros[_T("PROJECT_DIR")] = m_ProjectDir;
m_Macros[_T("PROJECTDIRECTORY")] = m_ProjectDir;
m_Macros[_T("PROJECT_DIRECTORY")] = m_ProjectDir;
m_Macros[_T("PROJECTTOPDIR")] = m_ProjectTopDir;
m_Macros[_T("PROJECT_TOPDIR")] = m_ProjectTopDir;
m_Macros[_T("PROJECTTOPDIRECTORY")] = m_ProjectTopDir;
m_Macros[_T("PROJECT_TOPDIRECTORY")] = m_ProjectTopDir;
m_Macros[_T("MAKEFILE")] = m_Makefile;
m_Macros[_T("ALL_PROJECT_FILES")] = m_ProjectFiles;
for (int i = 0; i < project->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* target = project->GetBuildTarget(i);
if (!target)
continue;
wxString title = target->GetTitle().Upper();
while (title.Replace(_T(" "), _T("_")))
; // replace spaces with underscores (what about other invalid chars?)
m_Macros[title + _T("_OUTPUT_FILE")] = UnixFilename(target->GetOutputFilename());
m_Macros[title + _T("_OUTPUT_DIR")] = UnixFilename(target->GetBasePath());
m_Macros[title + _T("_OUTPUT_BASENAME")] = wxFileName(target->GetOutputFilename()).GetName();
}
m_LastProject = project;
}
if (target)
{
const Compiler* compiler = CompilerFactory::GetCompiler(target->GetCompilerID());
if (compiler)
{
const StringHash& v = compiler->GetAllVars();
for (StringHash::const_iterator it = v.begin(); it != v.end(); ++it)
m_Macros[it->first.Upper()] = it->second;
}
}
if (project)
{
const StringHash& v = project->GetAllVars();
for (StringHash::const_iterator it = v.begin(); it != v.end(); ++it)
m_Macros[it->first.Upper()] = it->second;
}
if (!target)
{
m_TargetOutputDir = wxEmptyString;
m_TargetName = wxEmptyString;
m_TargetOutputBaseName = wxEmptyString;
m_TargetOutputFilename = wxEmptyString;
m_TargetFilename = wxEmptyString;
m_LastTarget = 0;
示例4: DoTargetChange
void ProjectOptionsDlg::DoTargetChange(bool saveOld)
{
if (saveOld)
DoBeforeTargetChange();
wxListBox* lstTargets = XRCCTRL(*this, "lstBuildTarget", wxListBox);
if (lstTargets->GetSelection() == -1)
lstTargets->SetSelection(0);
ProjectBuildTarget* target = m_Project->GetBuildTarget(lstTargets->GetSelection());
if (!target)
return;
// global project options
wxComboBox* cmb = XRCCTRL(*this, "cmbProjectType", wxComboBox);
wxCheckBox* chkCH = XRCCTRL(*this, "chkCreateHex", wxCheckBox);
wxTextCtrl* txt = XRCCTRL(*this, "txtOutputFilename", wxTextCtrl);
wxTextCtrl* txtO = XRCCTRL(*this, "txtObjectDir", wxTextCtrl);
wxButton* browse = XRCCTRL(*this, "btnBrowseOutputFilename", wxButton);
wxButton* browseO = XRCCTRL(*this, "btnBrowseObjectDir", wxButton);
chkCH->SetValue(false);
chkCH->Enable(false);
if (cmb && chkCH && txt && txtO && browse && browseO)
{
cmb->SetSelection(target->GetTargetType());
// Compiler* compiler = CompilerFactory::Compilers[target->GetCompilerIndex()];
switch ((TargetType)cmb->GetSelection())
{
case ttExecutable:
chkCH->Enable(true);
chkCH->SetValue(target->GetCreateHex());
case ttLibrary:
txt->SetValue(target->GetOutputFilename());
txt->Enable(true);
txtO->SetValue(target->GetObjectOutput());
txtO->Enable(true);
browse->Enable(true);
browseO->Enable(true);
break;
default: // for commands-only targets
txt->SetValue(_T(""));
txt->Enable(false);
txtO->SetValue(_T(""));
txtO->Enable(false);
browse->Enable(false);
browseO->Enable(false);
break;
}
}
// files options
wxCheckListBox* list = XRCCTRL(*this, "lstFiles", wxCheckListBox);
int count = list->GetCount();
for (int i = 0; i < count; ++i)
{
ProjectFile* pf = m_Project->GetFile(i);
if (!pf)
break;
bool doit = pf->buildTargets.Index(target->GetTitle()) >= 0;
list->Check(i, doit);
}
// update currently selected target
m_Current_Sel = lstTargets->GetSelection();
}
示例5: updateProjects
//.........这里部分代码省略.........
proj = projIt->second;
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Project %s, %d dependencies"), proj._project->GetTitle().wx_str(), proj._dependencyList.GetCount()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Project %s, %d dependencies"), proj._project->GetTitle().c_str(), proj._dependencyList.GetCount()));
#endif
for (i=0; i<proj._dependencyList.GetCount(); ++i) {
depIt = _projects.find(proj._dependencyList[i]);
if ( depIt != _projects.end()) { // dependency found
dep = depIt->second;
Manager::Get()->GetProjectManager()->AddProjectDependency(proj._project, dep._project);
// match target configurations
for (j=0; j<_workspaceConfigurations.GetCount(); ++j) {
ConfigurationMatchings::iterator configIt;
wxString wconfig;
wxString pconfig;
targetProj = 0;
targetDep = 0;
if (proj._configurations.empty()) { // msvc6
wconfig = _workspaceConfigurations[j];
targetProj = proj._project->GetBuildTarget(wconfig);
if (targetProj == 0) {
// look for a project config which is a substring of the workspace config
for (int k=0; k<proj._project->GetBuildTargetsCount(); ++k) {
pconfig = proj._project->GetBuildTarget(k)->GetTitle();
//Manager::Get()->GetLogManager()->DebugLog(_T("Test: %s <-> %s"), wconfig.c_str(), pconfig.c_str());
if (wconfig.StartsWith(pconfig) || pconfig.StartsWith(wconfig))
targetProj = proj._project->GetBuildTarget(k);
}
}
}
else { // msvc7
configIt = proj._configurations.find(_workspaceConfigurations[j]);
if (configIt != proj._configurations.end()) {
targetProj = proj._project->GetBuildTarget(configIt->second);
}
}
if (dep._configurations.empty()) { // msvc6
wconfig = _workspaceConfigurations[j];
targetDep = dep._project->GetBuildTarget(wconfig);
if (targetDep == 0) {
// look for a project config which is a substring of the workspace config
for (int k=0; k<dep._project->GetBuildTargetsCount(); ++k) {
pconfig = dep._project->GetBuildTarget(k)->GetTitle();
//Manager::Get()->GetLogManager()->DebugLog(_T("Test: %s <-> %s"), wconfig.c_str(), pconfig.c_str());
if (wconfig.StartsWith(pconfig) || pconfig.StartsWith(wconfig))
targetDep = dep._project->GetBuildTarget(k);
}
}
}
else { // msvc7
configIt = dep._configurations.find(_workspaceConfigurations[j]);
if (configIt != dep._configurations.end()) {
targetDep = dep._project->GetBuildTarget(configIt->second);
}
}
if ((targetDep==0) || (targetProj==0)) {
Manager::Get()->GetLogManager()->DebugLog(_T("ERROR: could not find targets"));
continue;
}
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Match '%s' to '%s'"), targetProj->GetFullTitle().wx_str(), targetDep->GetFullTitle().wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Match '%s' to '%s'"), targetProj->GetFullTitle().c_str(), targetDep->GetFullTitle().c_str()));
#endif
// now, update dependencies
TargetType type = targetDep->GetTargetType();
wxFileName fname;
if (type==ttDynamicLib) {
// targetDep->GetStaticLibFilename() do not work since it uses the filename instead of output filename
Compiler* compiler = CompilerFactory::GetCompiler(depIt->second._project->GetCompilerID());
wxString prefix = compiler->GetSwitches().libPrefix;
wxString suffix = compiler->GetSwitches().libExtension;
fname = targetDep->GetOutputFilename();
fname.SetName(prefix + fname.GetName());
fname.SetExt(suffix);
}
else if (type==ttStaticLib) fname = targetDep->GetOutputFilename();
targetProj->AddLinkLib(fname.GetFullPath());
targetProj->AddTargetDep(targetDep);
// TO REMOVE
wxString deps = targetProj->GetExternalDeps();
deps <<fname.GetFullPath() << _T(';');
targetProj->SetExternalDeps(deps);
// ---------
}
}
else {
Manager::Get()->GetLogManager()->DebugLog(_T("ERROR: dependency not found ") + proj._dependencyList[i]);
}
}
}
}
示例6: NewProjectFromUserTemplate
//.........这里部分代码省略.........
wxDir dir(path);
if (dir.HasFiles() || dir.HasSubDirs())
{
if (cbMessageBox(path + _(" already contains other files.\n"
"If you continue, files with the same names WILL BE OVERWRITTEN.\n"
"Are you sure you want to continue?"),
_("Files exist in directory"), wxICON_EXCLAMATION | wxYES_NO | wxNO_DEFAULT) != wxID_YES)
{
return 0;
}
}
wxBusyCursor busy;
wxString templ = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + _T("UserTemplates");
templ << sep << dlg.GetSelectedUserTemplate();
if (!wxDirExists(templ))
{
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Cannot open user-template source path '%s'!"), templ.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Cannot open user-template source path '%s'!"), templ.c_str()));
#endif
return NULL;
}
// copy files
wxString project_filename;
wxArrayString files;
wxDir::GetAllFiles(templ, &files);
int count = 0;
int total_count = files.GetCount();
for (size_t i = 0; i < files.GetCount(); ++i)
{
wxFileName dstname(files[i]);
dstname.MakeRelativeTo(templ + sep);
wxString src = files[i];
wxString dst = path + sep + dstname.GetFullPath();
// Manager::Get()->GetLogManager()->DebugLog("dst=%s, dstname=%s", dst.c_str(), dstname.GetFullPath().c_str());
if (!CreateDirRecursively(dst))
Manager::Get()->GetLogManager()->DebugLog(_T("Failed creating directory for ") + dst);
if (wxCopyFile(src, dst, true))
{
if (FileTypeOf(dst) == ftCodeBlocksProject)
project_filename = dst;
++count;
}
else
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.wx_str(), dst.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.c_str(), dst.c_str()));
#endif
}
if (count != total_count)
cbMessageBox(_("Some files could not be loaded with the template..."), _("Error"), wxICON_ERROR);
else
{
// open new project
if (project_filename.IsEmpty())
cbMessageBox(_("User-template saved successfully but no project file exists in it!"));
else
{
// ask to rename the project file, if need be
wxFileName fname(project_filename);
wxString newname = wxGetTextFromUser(_("If you want, you can change the project's filename here (without extension):"), _("Change project's filename"), fname.GetName());
if (!newname.IsEmpty() && newname != fname.GetName())
{
fname.SetName(newname);
wxRenameFile(project_filename, fname.GetFullPath());
project_filename = fname.GetFullPath();
}
prj = Manager::Get()->GetProjectManager()->LoadProject(project_filename);
if(prj && !newname.IsEmpty())
{
prj->SetTitle(newname);
for (int i = 0; i < prj->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* bt = prj->GetBuildTarget(i);
wxString outputFileName = bt->GetOutputFilename();
wxFileName outFname(outputFileName);
if (bt->GetTargetType() == ttLibrary)
{
Compiler* projectCompiler = CompilerFactory::GetCompiler(bt->GetCompilerID());
if (projectCompiler)
newname.Prepend(projectCompiler->GetSwitches().libPrefix);
}
outFname.SetName(newname);
bt->SetOutputFilename(outFname.GetFullPath());
}
Manager::Get()->GetProjectManager()->RebuildTree(); // so the tree shows the new name
CodeBlocksEvent evt(cbEVT_PROJECT_OPEN, 0, prj);
Manager::Get()->ProcessEvent(evt);
}
}
}
if (prj && pFilename)
*pFilename = prj->GetFilename();
return prj;
}