当前位置: 首页>>代码示例>>C++>>正文


C++ ProjectBuildTarget::AddCompilerOption方法代码示例

本文整理汇总了C++中ProjectBuildTarget::AddCompilerOption方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectBuildTarget::AddCompilerOption方法的具体用法?C++ ProjectBuildTarget::AddCompilerOption怎么用?C++ ProjectBuildTarget::AddCompilerOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectBuildTarget的用法示例。


在下文中一共展示了ProjectBuildTarget::AddCompilerOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

/** get target specific stuff
  * \param root : the root node of the XML project file (<Project >
  **/
bool MSVC10Loader::GetTargetSpecific(const TiXmlElement* root)
{
    if (!root) return false;

    LogManager* pMsg = Manager::Get()->GetLogManager();
    if (!pMsg) return false;

    bool bResult = false;

    // parse all global parameters
    const TiXmlElement* idef = root->FirstChildElement("ItemDefinitionGroup");
    while (idef)
    {
        const char* attr = idef->Attribute("Condition");
        if (!attr) { idef = idef->NextSiblingElement(); continue; }

        wxString conf = cbC2U(attr);
        for (size_t i=0; i<m_pcNames.Count(); ++i)
        {
            wxString sName = m_pcNames.Item(i);
            wxString sConf = SubstituteConfigMacros(conf);
            if (sConf.IsSameAs(sName))
            {
                const TiXmlElement* comp = idef->FirstChildElement("ClCompile");
                if (comp)
                {
                    const TiXmlElement* pp = comp->FirstChildElement("PreprocessorDefinitions");
                    wxArrayString pps = GetPreprocessors(pp);
                    for (size_t j=0; j<pps.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j));
                    }

                    const TiXmlElement* cinc = comp->FirstChildElement("AdditionalIncludeDirectories");
                    wxArrayString cdirs = GetDirectories(cinc);
                    for (size_t j=0; j<cdirs.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt) bt->AddIncludeDir(cdirs.Item(j));
                    }

                    const TiXmlElement* copt = comp->FirstChildElement("AdditionalOptions");
                    wxArrayString copts = GetOptions(copt);
                    for (size_t j=0; j<copts.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt && !m_ConvertSwitches) bt->AddCompilerOption(copts.Item(j));
                    }
                }

                const TiXmlElement* link = idef->FirstChildElement("Link");
                if (link)
                {
                    const TiXmlElement* llib = link->FirstChildElement("AdditionalDependencies");
                    wxArrayString libs = GetLibs(llib);
                    for (size_t j=0; j<libs.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt) bt->AddLinkLib(libs.Item(j));
                    }

                    const TiXmlElement* linc = link->FirstChildElement("AdditionalLibraryDirectories");
                    wxArrayString ldirs = GetDirectories(linc);
                    for (size_t j=0; j<ldirs.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt) bt->AddLibDir(ldirs.Item(j));
                    }

                    const TiXmlElement* lopt = comp->FirstChildElement("AdditionalOptions");
                    wxArrayString lopts = GetOptions(lopt);
                    for (size_t j=0; j<lopts.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt && !m_ConvertSwitches) bt->AddLinkerOption(lopts.Item(j));
                    }

                    const TiXmlElement* debug = link->FirstChildElement("GenerateDebugInformation");
                    wxString sDebug = GetText(debug);
                    if (sDebug.MakeUpper().IsSameAs(_T("TRUE")))
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt && !m_ConvertSwitches) bt->AddLinkerOption(_T("/debug"));
                    }
                }

                const TiXmlElement* res = idef->FirstChildElement("ResourceCompile");
                if (res)
                {
                    const TiXmlElement* pp = res->FirstChildElement("PreprocessorDefinitions");
                    wxArrayString pps = GetPreprocessors(pp);
                    for (size_t j=0; j<pps.Count(); ++j)
                    {
                        ProjectBuildTarget* bt = m_pc[sName].bt;
                        if (bt) bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j));
                    }
//.........这里部分代码省略.........
开发者ID:Three-DS,项目名称:codeblocks-13.12,代码行数:101,代码来源:msvc10loader.cpp

示例2: if


//.........这里部分代码省略.........

            if (!m_ConvertSwitches)
            {
                tmp = ReplaceMSVCMacros(cbC2U(tool->Attribute("ModuleDefinitionFile")));
                if (!tmp.IsEmpty())
                    bt->AddLinkerOption(_T("/DEF:\"") + tmp + _T("\""));
            }
        }
        else if (strcmp(tool->Attribute("Name"), "VCCLCompilerTool") == 0)
        {
            unsigned int i;
            wxString tmp;
            wxArrayString arr;

            // compiler
            tmp = cbC2U(tool->Attribute("AdditionalIncludeDirectories"));
            // vc70 uses ";" while vc71 uses "," separators
            // NOTE (mandrav#1#): No, that is *not* the case (what were they thinking at MS?)
            // try with comma (,) which is the newest I believe
            ParseInputString(tmp, arr); // This will parse recursively
            for (i = 0; i < arr.GetCount(); ++i)
            {
                bt->AddIncludeDir(ReplaceMSVCMacros(arr[i]));
                bt->AddResourceIncludeDir(ReplaceMSVCMacros(arr[i]));
            }

            tmp = cbC2U(tool->Attribute("PreprocessorDefinitions"));
            arr = GetArrayFromString(tmp, _T(","));
            if (arr.GetCount() == 1) // if it fails, try with semicolon
                arr = GetArrayFromString(tmp, _T(";"));
            for (unsigned int j = 0; j < arr.GetCount(); ++j)
            {
                if (m_ConvertSwitches)
                    bt->AddCompilerOption(wxString(_T("-D")) + arr[j]);
                else
                    bt->AddCompilerOption(wxString(_T("/D")) + arr[j]);
            }

            tmp = cbC2U(tool->Attribute("WarningLevel"));
            if (m_ConvertSwitches)
            {
                if (tmp.IsSameAs(_T("0")))
                    bt->AddCompilerOption(_T("-w"));
                else if (tmp.IsSameAs(_T("1")) || tmp.IsSameAs(_T("2")) || tmp.IsSameAs(_T("3")))
                    bt->AddCompilerOption(_T("-W"));
                else if (tmp.IsSameAs(_T("4")))
                    bt->AddCompilerOption(_T("-Wall"));
            }
            else
            {
                bt->AddCompilerOption(wxString(_T("/W")) + tmp);
            }

/* For more details on "DebugInformationFormat", please visit
   http://msdn2.microsoft.com/en-us/library/aa652260(VS.71).aspx
   http://msdn2.microsoft.com/en-us/library/microsoft.visualstudio.vcprojectengine.debugoption(VS.80).aspx */
            tmp = cbC2U(tool->Attribute("DebugInformationFormat"));
            if (tmp.IsSameAs(_T("3")))
                bt->AddCompilerOption(m_ConvertSwitches ? _T("") : _T("/Zi"));
            else if (tmp.IsSameAs(_T("4")))
                bt->AddCompilerOption(m_ConvertSwitches ? _T("-g") : _T("/ZI"));


            tmp = cbC2U(tool->Attribute("InlineFunctionExpansion"));
            if (!m_ConvertSwitches && tmp.IsSameAs(_T("1"))) bt->AddCompilerOption(_T("/Ob1"));
开发者ID:WinterMute,项目名称:codeblocks_sf,代码行数:66,代码来源:msvc7loader.cpp

示例3: ProcessCompilerOptions

void ProjectOptionsManipulator::ProcessCompilerOptions(cbProject* prj, const wxString& opt, const wxString& opt_new, wxArrayString& result)
{
  ProjectOptionsManipulatorDlg::EProjectScanOption scan_opt = m_Dlg->GetScanOption();
  switch (scan_opt)
  {
    case ProjectOptionsManipulatorDlg::eSearch:
    case ProjectOptionsManipulatorDlg::eSearchNot:
    {
      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
      {
        bool has_opt = HasOption(prj->GetCompilerOptions(), opt);
        if (has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearch)
        {
          result.Add(wxString::Format(_("Project '%s': Contains compiler option '%s'."),
                                      prj->GetTitle().wx_str(), opt.wx_str()));
        }
        else if (!has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearchNot)
        {
          result.Add(wxString::Format(_("Project '%s': Does not contain compiler option '%s'."),
                                      prj->GetTitle().wx_str(), opt.wx_str()));
        }
      }

      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
      {
        for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
        {
          ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
          if (tgt)
          {
            bool has_opt = HasOption(tgt->GetCompilerOptions(), opt);
            if (has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearch)
            {
              result.Add(wxString::Format(_("Project '%s', target '%s': Contains compiler option '%s'."),
                                          prj->GetTitle().wx_str(), tgt->GetTitle().wx_str(), opt.wx_str()));
            }
            else if (!has_opt && scan_opt==ProjectOptionsManipulatorDlg::eSearchNot)
            {
              result.Add(wxString::Format(_("Project '%s', target '%s': Does not contain compiler option '%s'."),
                                          prj->GetTitle().wx_str(), tgt->GetTitle().wx_str(), opt.wx_str()));
            }
          }
        }
      }
    }
    break;

    case ProjectOptionsManipulatorDlg::eRemove:
    {
      wxString full_opt;
      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
      {
        if ( HasOption(prj->GetCompilerOptions(), opt, full_opt) )
          prj->RemoveCompilerOption(full_opt);
      }

      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
      {
        for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
        {
          ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
          if (tgt && HasOption(tgt->GetCompilerOptions(), opt, full_opt))
            tgt->RemoveCompilerOption(opt);
        }
      }
    }
    break;

    case ProjectOptionsManipulatorDlg::eAdd:
    {
      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
      {
        if ( !HasOption(prj->GetCompilerOptions(), opt) )
          prj->AddCompilerOption(opt);
      }

      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
      {
        for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
        {
          ProjectBuildTarget* tgt = prj->GetBuildTarget(i);
          if (tgt && !HasOption(tgt->GetCompilerOptions(), opt))
            tgt->AddCompilerOption(opt);
        }
      }
    }
    break;

    case ProjectOptionsManipulatorDlg::eReplace:
    {
      wxString full_opt;
      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eProject) )
      {
        if ( HasOption(prj->GetCompilerOptions(), opt, full_opt) )
          prj->ReplaceCompilerOption(full_opt, ManipulateOption(full_opt, opt, opt_new));
      }

      if ( m_Dlg->GetOptionActive(ProjectOptionsManipulatorDlg::eTarget) )
      {
        for (int i=0; i<prj->GetBuildTargetsCount(); ++i)
//.........这里部分代码省略.........
开发者ID:DowerChest,项目名称:codeblocks,代码行数:101,代码来源:ProjectOptionsManipulator.cpp

示例4: if

bool MSVC10Loader::GetTargetSpecific(const TiXmlElement* root)
{
    if (!root) return false;

    LogManager* pMsg = Manager::Get()->GetLogManager();
    if (!pMsg) return false;

    bool bResult = false;

    // parse all global parameters
    const TiXmlElement* idef = root->FirstChildElement("ItemDefinitionGroup");
    for (; idef; idef=idef->NextSiblingElement("ItemDefinitionGroup"))
    {
        const char* attr = idef->Attribute("Condition");
        if (!attr) continue;

        wxString conf = cbC2U(attr);
        for (HashProjectsConfs::iterator it=m_pc.begin(); it!=m_pc.end(); ++it)
        {
            wxString sName = it->second.sName;
            wxString sConf = SubstituteConfigMacros(conf);
            if (sConf.IsSameAs(sName))
            {
                assert(m_pc[sName].bt);
                if (!m_pc[sName].bt)
                    continue;

                ProjectBuildTarget* bt = m_pc[sName].bt;
                if (!m_ConvertSwitches && !m_pc[sName].Charset.IsEmpty())
                {
                    if (m_pc[sName].Charset.IsSameAs(_T("NotSet"),false))
                        ; // nop
                    else if (m_pc[sName].Charset.IsSameAs(_T("Unicode"),false))
                        bt->AddCompilerOption(_T("/D_UNICODE /DUNICODE"));
                    else if (m_pc[sName].Charset.IsSameAs(_T("MultiByte"),false))
                        bt->AddCompilerOption(_T("/D_MBCS"));
                    else
                        pMsg->DebugLog(_("Import; Unsupported CharacterSet: ") + m_pc[sName].Charset);
                }
                if (!m_pc[sName].sIntDir.IsEmpty())
                    bt->SetObjectOutput(m_pc[sName].sIntDir);

                if (!m_pc[sName].sOutDir.IsEmpty())
                {
                    bt->SetOutputFilename(m_pc[sName].sOutDir+m_pc[sName].sTargetName+m_pc[sName].sTargetExt);
                    bt->SetDepsOutput(m_pc[sName].sOutDir);
                }

                if (!m_pc[sName].sConf.IsEmpty())
                {
                    if (m_pc[sName].sConf.IsSameAs(_T("Release"), false))
                    {
                        // nop
                    }
                    else if (m_pc[sName].sConf.IsSameAs(_T("Debug"),false))
                        bt->AddCompilerOption(!m_ConvertSwitches ? _T("/Zi") : _T("-g"));
                    else
                        pMsg->DebugLog(_("Import; Unsupported Configuration: ") + m_pc[sName].sConf);
                }

                if (m_pc[sName].bNoImportLib)
                {
                    bt->SetCreateDefFile(false);
                    bt->SetCreateStaticLib(false);
                }

                const TiXmlElement* comp = idef->FirstChildElement("ClCompile");
                if (comp)
                {
                    const TiXmlElement* pp = comp->FirstChildElement("PreprocessorDefinitions");
                    wxArrayString pps = GetArray(pp);
                    for (size_t j=0; j<pps.Count(); ++j)
                        bt->AddCompilerOption((m_ConvertSwitches ? _T("-D") : _T("/D")) + pps.Item(j));

                    const TiXmlElement* cinc = comp->FirstChildElement("AdditionalIncludeDirectories");
                    wxArrayString cdirs = GetArrayPaths(cinc, m_pc[sName]);
                    for (size_t j=0; j<cdirs.Count(); ++j)
                        bt->AddIncludeDir(cdirs.Item(j));

                    const TiXmlElement* copt = comp->FirstChildElement("AdditionalOptions");
                    wxArrayString copts = GetArray(copt,_T(" "));
                    if (!m_ConvertSwitches)
                    {
                        for (size_t j=0; j<copts.Count(); ++j)
                            bt->AddCompilerOption(copts.Item(j));
                    }

                    if ((copt=comp->FirstChildElement("Optimization")))
                    {
                        wxString val = GetText(copt);
                        if (val.IsSameAs(_T("Disabled"),false))
                            bt->AddCompilerOption(!m_ConvertSwitches ? _T("/Od") : _T("-O0"));
                        else if (val.IsSameAs(_T("MinSpace"), false))
                        {
                            if (!m_ConvertSwitches) bt->AddCompilerOption(_T("/O1"));
                            else
                            {
                                bt->AddLinkerOption(_T("-s"));
                                bt->AddCompilerOption(_T("-Os"));
                            }
//.........这里部分代码省略.........
开发者ID:stahta01,项目名称:codeblocks_sf,代码行数:101,代码来源:msvc10loader.cpp


注:本文中的ProjectBuildTarget::AddCompilerOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。