本文整理汇总了C++中ProjectBuildTarget::GetTargetType方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectBuildTarget::GetTargetType方法的具体用法?C++ ProjectBuildTarget::GetTargetType怎么用?C++ ProjectBuildTarget::GetTargetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectBuildTarget
的用法示例。
在下文中一共展示了ProjectBuildTarget::GetTargetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: if
bool MSVC7Loader::DoImport(TiXmlElement* conf)
{
ProjectBuildTarget* bt = m_pProject->GetBuildTarget(m_ConfigurationName);
if (!bt)
bt = m_pProject->AddBuildTarget(m_ConfigurationName);
bt->SetCompilerID(m_pProject->GetCompilerID());
// See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcext/html/vxlrfvcprojectenginelibraryruntimelibraryoption.asp
m_OutDir = ReplaceMSVCMacros(cbC2U(conf->Attribute("OutputDirectory")));
m_IntDir = ReplaceMSVCMacros(cbC2U(conf->Attribute("IntermediateDirectory")));
if (m_IntDir.StartsWith(_T(".\\"))) m_IntDir.Remove(0,2);
bt->SetObjectOutput(m_IntDir);
// see MSDN: ConfigurationTypes Enumeration
wxString conftype = cbC2U(conf->Attribute("ConfigurationType"));
if (conftype.IsSameAs(_T("1"))) // typeApplication 1, no difference between console or gui here, we must check the subsystem property of the linker
bt->SetTargetType(ttExecutable);
else if (conftype.IsSameAs(_T("2"))) // typeDynamicLibrary 2
bt->SetTargetType(ttDynamicLib);
else if (conftype.IsSameAs(_T("4"))) // typeStaticLibrary 4
bt->SetTargetType(ttStaticLib);
else if (conftype.IsSameAs(_T("-1"))) // typeNative -1, check subsystem property of the linker to make sure
bt->SetTargetType(ttNative);
else if (conftype.IsSameAs(_T("10"))) // typeGeneric 10
bt->SetTargetType(ttCommandsOnly);
else // typeUnknown 0
{
bt->SetTargetType(ttCommandsOnly);
Manager::Get()->GetLogManager()->DebugLog(_T("unrecognized project type"));
}
TiXmlElement* tool = conf->FirstChildElement("Tool");
if (!tool)
{
Manager::Get()->GetLogManager()->DebugLog(_T("No 'Tool' node..."));
return false;
}
for (; tool; tool=tool->NextSiblingElement("Tool"))
{
if (strcmp(tool->Attribute("Name"), "VCLinkerTool") == 0 ||
strcmp(tool->Attribute("Name"), "VCLibrarianTool") == 0)
{
// linker
wxString tmp;
if ((bt->GetTargetType()==ttExecutable) || (bt->GetTargetType()==ttNative))
{
tmp = cbC2U(tool->Attribute("SubSystem"));
//subSystemNotSet 0
//subSystemConsole 1
//subSystemWindows 2
if (tmp.IsSameAs(_T("1")))
{
bt->SetTargetType(ttConsoleOnly);
//bt->AddLinkerOption("/SUBSYSTEM:CONSOLE"); // don't know if it is necessary
}
else if (tmp.IsSameAs(_T("3")))
bt->SetTargetType(ttNative);
} // else we keep executable
tmp = ReplaceMSVCMacros(cbC2U(tool->Attribute("OutputFile")));
tmp = UnixFilename(tmp);
if (tmp.Last() == _T('.')) tmp.RemoveLast();
if (bt->GetTargetType() == ttStaticLib)
{
// convert the lib name
Compiler* compiler = CompilerFactory::GetCompiler(m_pProject->GetCompilerID());
if (compiler)
{
wxString prefix = compiler->GetSwitches().libPrefix;
wxString suffix = compiler->GetSwitches().libExtension;
wxFileName fname = tmp;
if (!fname.GetName().StartsWith(prefix))
fname.SetName(prefix + fname.GetName());
fname.SetExt(suffix);
tmp = fname.GetFullPath();
}
}
bt->SetOutputFilename(tmp);
m_TargetPath = wxFileName(tmp).GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
m_TargetFilename = wxFileName(tmp).GetFullName();
tmp = cbC2U(tool->Attribute("AdditionalLibraryDirectories"));
wxArrayString arr;
ParseInputString(tmp, arr);
for (unsigned int i = 0; i < arr.GetCount(); ++i)
{
bt->AddLibDir(ReplaceMSVCMacros(arr[i]));
}
if (!m_ConvertSwitches) // no point importing this option, if converting to GCC
{
tmp = cbC2U(tool->Attribute("IgnoreDefaultLibraryNames"));
arr = GetArrayFromString(tmp, _T(";"));
if (arr.GetCount()==1) arr = GetArrayFromString(tmp, _T(","));
for (unsigned int i = 0; i < arr.GetCount(); ++i)
{
//.........这里部分代码省略.........
示例3: 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]);
}
}
}
}
示例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: 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;
}