⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 proj_tree_builder.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
/* * =========================================================================== * PRODUCTION $Log: proj_tree_builder.cpp,v $ * PRODUCTION Revision 1000.3  2004/06/16 17:02:39  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.13 * PRODUCTION * =========================================================================== *//* $Id: proj_tree_builder.cpp,v 1000.3 2004/06/16 17:02:39 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Author:  Viatcheslav Gorelenkov * */#include <ncbi_pch.hpp>#include <app/project_tree_builder/proj_tree_builder.hpp>#include <app/project_tree_builder/proj_builder_app.hpp>#include <app/project_tree_builder/proj_src_resolver.hpp>#include <app/project_tree_builder/msvc_prj_defines.hpp>#include <app/project_tree_builder/proj_projects.hpp>BEGIN_NCBI_SCOPEstruct PLibExclude{    PLibExclude(const list<string>& excluded_lib_ids)    {        copy(excluded_lib_ids.begin(), excluded_lib_ids.end(),              inserter(m_ExcludedLib, m_ExcludedLib.end()) );    }    bool operator() (const string& lib_id) const    {        return m_ExcludedLib.find(lib_id) != m_ExcludedLib.end();    }private:    set<string> m_ExcludedLib;};//-----------------------------------------------------------------------------CProjItem::TProjType SMakeProjectT::GetProjType(const string& base_dir,                                                const string& projname){    string fname = "Makefile." + projname;        if ( CDirEntry(CDirEntry::ConcatPath               (base_dir, fname + ".lib")).Exists() )        return CProjKey::eLib;    else if (CDirEntry(CDirEntry::ConcatPath               (base_dir, fname + ".app")).Exists() )        return CProjKey::eApp;    else if (CDirEntry(CDirEntry::ConcatPath               (base_dir, fname + ".msvcproj")).Exists() )        return CProjKey::eMsvc;    LOG_POST(Error << "No .lib or .app projects for : " + projname +                      " in directory: " + base_dir);    return CProjKey::eNoProj;}bool SMakeProjectT::IsMakeInFile(const string& name){    return name == "Makefile.in";}bool SMakeProjectT::IsMakeLibFile(const string& name){    return NStr::StartsWith(name, "Makefile")  &&  	       NStr::EndsWith(name, ".lib");}bool SMakeProjectT::IsMakeAppFile(const string& name){    return NStr::StartsWith(name, "Makefile")  &&  	       NStr::EndsWith(name, ".app");}bool SMakeProjectT::IsUserProjFile(const string& name){    return NStr::StartsWith(name, "Makefile")  &&  	       NStr::EndsWith(name, ".msvcproj");}void SMakeProjectT::DoResolveDefs(CSymResolver& resolver,                                   TFiles& files,                                  const set<string>& keys){    NON_CONST_ITERATE(CProjectTreeBuilder::TFiles, p, files) {	    NON_CONST_ITERATE(CSimpleMakeFileContents::TContents,                           n,                           p->second.m_Contents) {                        const string& key    = n->first;            list<string>& values = n->second;		    if (keys.find(key) != keys.end()) {                list<string> new_vals;                bool modified = false;                NON_CONST_ITERATE(list<string>, k, values) {                    //iterate all values and try to resolve                     const string& val = *k;                    if( !CSymResolver::IsDefine(val) ) {                        new_vals.push_back(val);                    } else {                        list<string> resolved_def;                        string val_define = FilterDefine(val);	                    resolver.Resolve(val_define, &resolved_def);	                    if ( resolved_def.empty() )		                    new_vals.push_back(val); //not resolved - keep old val                        else {                            //was resolved                            ITERATE(list<string>, l, resolved_def) {                                const string& define = *l;                                if ( IsConfigurableDefine(define) ) {                                    string resolved_def_str =                                         GetApp().GetSite().ResolveDefine                                                     (StripConfigurableDefine                                                                     (define));                                    if ( !resolved_def_str.empty() ) {                                        list<string> resolved_defs;                                        NStr::Split(resolved_def_str,                                                     LIST_SEPARATOR,                                                     resolved_defs);                                        copy(resolved_defs.begin(),                                             resolved_defs.end(),                                             back_inserter(new_vals));                                    } else {                                        new_vals.push_back(define);                                    }                                } else {                                    new_vals.push_back(define);                                }                            }		                    modified = true;                        }                    }                }                if (modified)                    values = new_vals; // by ref!		    }        }    }}string SMakeProjectT::GetOneIncludeDir(const string& flag, const string& token){    size_t token_pos = flag.find(token);    if (token_pos != NPOS &&         token_pos + token.length() < flag.length()) {        return flag.substr(token_pos + token.length());     }    return "";}void SMakeProjectT::CreateIncludeDirs(const list<string>& cpp_flags,                                      const string&       source_base_dir,                                      list<string>*       include_dirs){    include_dirs->clear();    ITERATE(list<string>, p, cpp_flags) {        const string& flag = *p;        const string token("-I$(includedir)");        // process -I$(includedir)        string token_val;        token_val = SMakeProjectT::GetOneIncludeDir(flag, "-I$(includedir)");        if ( !token_val.empty() ) {            string dir =                 CDirEntry::ConcatPath(GetApp().GetProjectTreeInfo().m_Include,                                      token_val);            dir = CDirEntry::NormalizePath(dir);            dir = CDirEntry::AddTrailingPathSeparator(dir);            include_dirs->push_back(dir);        }        // process -I$(srcdir)        token_val = SMakeProjectT::GetOneIncludeDir(flag, "-I$(srcdir)");        if ( !token_val.empty() )  {            string dir =                 CDirEntry::ConcatPath(source_base_dir,                                      token_val);            dir = CDirEntry::NormalizePath(dir);            dir = CDirEntry::AddTrailingPathSeparator(dir);            include_dirs->push_back(dir);        }                // process defines like NCBI_C_INCLUDE        if(CSymResolver::IsDefine(flag)) {            string dir = GetApp().GetSite().ResolveDefine                                             (CSymResolver::StripDefine(flag));            if ( !dir.empty() && CDirEntry(dir).IsDir() ) {                include_dirs->push_back(dir);                }        }        // process additional include dirs for LibChoices        if(CSymResolver::IsDefine(flag)) {            string sflag = CSymResolver::StripDefine(flag);            list<string> libchoices_abs_includes ;            GetApp().GetSite().GetLibChoiceIncludes(sflag,                                                     &libchoices_abs_includes);            ITERATE(list<string>, n, libchoices_abs_includes) {                const string& dir = *n;                if ( !dir.empty() && CDirEntry(dir).IsDir() ) {                    include_dirs->push_back(dir);                    }            }        }    }    include_dirs->sort();    include_dirs->unique();}void SMakeProjectT::CreateDefines(const list<string>& cpp_flags,                                  list<string>*       defines){    defines->clear();    ITERATE(list<string>, p, cpp_flags) {        const string& flag = *p;        if ( NStr::StartsWith(flag, "-D") ) {            defines->push_back(flag.substr(2));        }    }}void SMakeProjectT::Create3PartyLibs(const list<string>& libs_flags,                                      list<string>*       libs_list){    libs_list->clear();    ITERATE(list<string>, p, libs_flags) {        const string& flag = *p;        if ( IsConfigurableDefine(flag) ) {            libs_list->push_back(StripConfigurableDefine(flag));            }    }}void SMakeProjectT::AnalyzeMakeIn    (const CSimpleMakeFileContents& makein_contents,     TMakeInInfoList*               info){    info->clear();    CSimpleMakeFileContents::TContents::const_iterator p =         makein_contents.m_Contents.find("LIB_PROJ");    if (p != makein_contents.m_Contents.end()) {        info->push_back(SMakeInInfo(SMakeInInfo::eLib, p->second));     }    p = makein_contents.m_Contents.find("APP_PROJ");    if (p != makein_contents.m_Contents.end()) {        info->push_back(SMakeInInfo(SMakeInInfo::eApp, p->second));     }    p = makein_contents.m_Contents.find("ASN_PROJ");    if (p != makein_contents.m_Contents.end()) {        info->push_back(SMakeInInfo(SMakeInInfo::eAsn, p->second));     }    p = makein_contents.m_Contents.find("MSVC_PROJ");    if (p != makein_contents.m_Contents.end()) {        info->push_back(SMakeInInfo(SMakeInInfo::eMsvc, p->second));     }    //TODO - DLL_PROJ}string SMakeProjectT::CreateMakeAppLibFileName                (const string&            base_dir,                 const string&            projname){    CProjItem::TProjType proj_type =             SMakeProjectT::GetProjType(base_dir, projname);    string fname = "Makefile." + projname;        if (proj_type==CProjKey::eLib)        return fname + ".lib";    if (proj_type==CProjKey::eApp)        return fname + ".app";    if (proj_type==CProjKey::eMsvc)        return fname + ".msvcproj";    return "";}void SMakeProjectT::CreateFullPathes(const string&      dir,                                      const list<string> files,                                     list<string>*      full_pathes){    ITERATE(list<string>, p, files) {        string full_path = CDirEntry::ConcatPath(dir, *p);        full_pathes->push_back(full_path);    }}void SMakeProjectT::ConvertLibDepends(const list<string>& depends_libs, 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -