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

📄 proj_builder_app.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* * =========================================================================== * PRODUCTION $Log: proj_builder_app.cpp,v $ * PRODUCTION Revision 1000.4  2004/06/16 17:02:36  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.43 * PRODUCTION * =========================================================================== *//* $Id: proj_builder_app.cpp,v 1000.4 2004/06/16 17:02:36 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_builder_app.hpp>#include <app/project_tree_builder/proj_item.hpp>#include <app/project_tree_builder/proj_tree_builder.hpp>#include <app/project_tree_builder/msvc_prj_utils.hpp>#include <app/project_tree_builder/msvc_prj_generator.hpp>#include <app/project_tree_builder/msvc_sln_generator.hpp>#include <app/project_tree_builder/msvc_masterproject_generator.hpp>#include <app/project_tree_builder/proj_utils.hpp>#include <app/project_tree_builder/msvc_configure.hpp>#include <app/project_tree_builder/msvc_prj_defines.hpp>#include <app/project_tree_builder/msvc_configure_prj_generator.hpp>#include <app/project_tree_builder/proj_projects.hpp>#include <corelib/ncbitime.hpp>BEGIN_NCBI_SCOPE#ifdef COMBINED_EXCLUDEstruct PIsExcludedByProjectMakefile{    typedef CProjectItemsTree::TProjects::value_type TValueType;    bool operator() (const TValueType& item) const    {        const CProjItem& project = item.second;        CMsvcPrjProjectContext prj_context(project);        const list<string> implicit_exclude_dirs =             GetApp().GetProjectTreeInfo().m_ImplicitExcludedAbsDirs;        ITERATE(list<string>, p, implicit_exclude_dirs) {            const string& dir = *p;            if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {                // implicitly excluded from build                return prj_context.GetMsvcProjectMakefile().IsExcludeProject                                                                        (true);            }        }        // implicitly included to build        return prj_context.GetMsvcProjectMakefile().IsExcludeProject(false);    }};struct PIsExcludedMakefileIn{    typedef CProjectItemsTree::TProjects::value_type TValueType;    PIsExcludedMakefileIn(const string& root_src_dir)        :m_RootSrcDir(CDirEntry::NormalizePath(root_src_dir))    {        ProcessDir(root_src_dir);    }    bool operator() (const TValueType& item) const    {        const CProjItem& project = item.second;        const list<string> implicit_exclude_dirs =             GetApp().GetProjectTreeInfo().m_ImplicitExcludedAbsDirs;        ITERATE(list<string>, p, implicit_exclude_dirs) {            const string& dir = *p;            if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {                // implicitly excluded from build                return !IsExcplicitlyIncluded(project.m_SourcesBaseDir);            }        }        return false;    }private:    string m_RootSrcDir;    typedef map<string, AutoPtr<CNcbiRegistry> > TMakefiles;    TMakefiles m_Makefiles;    void ProcessDir(const string& dir_name)    {        CDir dir(dir_name);        CDir::TEntries contents = dir.GetEntries("*");        ITERATE(CDir::TEntries, i, contents) {            string name  = (*i)->GetName();            if ( name == "."  ||  name == ".."  ||                   name == string(1,CDir::GetPathSeparator()) ) {                continue;            }            string path = (*i)->GetPath();            if ( (*i)->IsFile()        &&                name          == "Makefile.in.msvc" ) {                m_Makefiles[path] =                     AutoPtr<CNcbiRegistry>                         (new CNcbiRegistry(CNcbiIfstream(path.c_str(),                                             IOS_BASE::in | IOS_BASE::binary)));            }             else if ( (*i)->IsDir() ) {                ProcessDir(path);            }        }    }    bool IsExcplicitlyIncluded(const string& project_base_dir) const    {        string dir = project_base_dir;        for(;;) {            if (dir == m_RootSrcDir)                 return false;            string path = CDirEntry::ConcatPath(dir, "Makefile.in.msvc");            TMakefiles::const_iterator p =                 m_Makefiles.find(path);            if ( p != m_Makefiles.end() ) {                string val =                     (p->second)->GetString("Common", "ExcludeProject", "");                if (val == "FALSE")                    return true;            }            dir = CDirEntry::ConcatPath(dir, "..");            dir = CDirEntry::NormalizePath(dir);        }        return false;    }};template <class T1, class T2, class V> class CCombine{public:    CCombine(const T1& t1, const T2& t2)        :m_T1(t1), m_T2(t2)    {    }    bool operator() (const V& v) const    {        return m_T1(v)  &&  m_T2(v);    }private:    const T1 m_T1;    const T2 m_T2;};#else// not def COMBINED_EXCLUDEstruct PIsExcludedByProjectMakefile{    typedef CProjectItemsTree::TProjects::value_type TValueType;    bool operator() (const TValueType& item) const    {        const CProjItem& project = item.second;        CMsvcPrjProjectContext prj_context(project);        const list<string> implicit_exclude_dirs =             GetApp().GetProjectTreeInfo().m_ImplicitExcludedAbsDirs;        ITERATE(list<string>, p, implicit_exclude_dirs) {            const string& dir = *p;            if ( IsSubdir(dir, project.m_SourcesBaseDir) ) {                // implicitly excluded from build                return prj_context.GetMsvcProjectMakefile().IsExcludeProject                                                                        (true);            }        }        // implicitly included to build        return prj_context.GetMsvcProjectMakefile().IsExcludeProject(false);    }};#endifstruct PIsExcludedByRequires{    typedef CProjectItemsTree::TProjects::value_type TValueType;    bool operator() (const TValueType& item) const    {        const CProjItem& project = item.second;        if ( CMsvcPrjProjectContext::IsRequiresOk(project) )            return false;        return true;    }};//-----------------------------------------------------------------------------CProjBulderApp::CProjBulderApp(void){}void CProjBulderApp::Init(void){    // Create command-line argument descriptions class    auto_ptr<CArgDescriptions> arg_desc(new CArgDescriptions);    // Specify USAGE context    arg_desc->SetUsageContext(GetArguments().GetProgramBasename(),                              "MSVC 7.10 projects builder application");    // Programm arguments:    arg_desc->AddPositional("root",                            "Root directory of the build tree. "\                                "This directory ends with \"c++\".",                            CArgDescriptions::eString);    arg_desc->AddPositional("subtree",                            "Subtree to build. Example: src/corelib/ .",                            CArgDescriptions::eString);    arg_desc->AddPositional("solution",                             "MSVC Solution to buld.",						    CArgDescriptions::eString);    arg_desc->AddFlag      ("dll",                             "Dll(s) will be buit instead of static libraries.",						    true);    // Setup arg.descriptions for this application    SetupArgDescriptions(arg_desc.release());}static void s_ReportDependenciesStatus(const CCyclicDepends::TDependsCycles& cycles){   if ( cycles.empty() ) {        LOG_POST(Info << "Ok. No dependencies cycles found.");    } else {        ITERATE(CCyclicDepends::TDependsCycles, p, cycles) {            const CCyclicDepends::TDependsChain& cycle = *p;            LOG_POST(Error << "Dependencies cycle found :");            ITERATE(CCyclicDepends::TDependsChain, n, cycle) {                const CProjKey& proj_id = *n;                LOG_POST(Error << "Cycle with project :" + proj_id.Id());            }        }    }}int CProjBulderApp::Run(void){    // Get and check arguments    ParseArguments();	// Set error posting and tracing on maximum.	SetDiagTrace(eDT_Enable);	SetDiagPostFlag(eDPF_Default);	SetDiagPostLevel(eDiag_Info);    // Start     LOG_POST(Info << "Started at " + CTime(CTime::eCurrent).AsString());    // Configure     CMsvcConfigure configure;    configure(GetSite(),               GetRegSettings().m_ConfigInfo,               GetProjectTreeInfo().m_Root);    // Build projects tree    CProjectItemsTree projects_tree(GetProjectTreeInfo().m_Src);    CProjectTreeBuilder::BuildProjectTree(GetProjectTreeInfo().m_IProjectFilter.get(),                                           GetProjectTreeInfo().m_Src,                                           &projects_tree);        // Analyze tree for dependencies cycles    LOG_POST(Info << "Checking projects inter-dependencies... .");    CCyclicDepends::TDependsCycles cycles;    CCyclicDepends::FindCycles(projects_tree.m_Projects, &cycles);    s_ReportDependenciesStatus(cycles);    // MSVC specific part:        // Exclude some projects from build:#ifdef COMBINED_EXCLUDE    {{        // Implicit/Exclicit exclude by msvc Makefiles.in.msvc        // and project .msvc makefiles.        PIsExcludedMakefileIn          p_make_in(GetProjectTreeInfo().m_Src);        PIsExcludedByProjectMakefile   p_project_makefile;        CCombine<PIsExcludedMakefileIn,                  PIsExcludedByProjectMakefile,                   CProjectItemsTree::TProjects::value_type>                                   logical_combine(p_make_in, p_project_makefile);        EraseIf(projects_tree.m_Projects, logical_combine);

⌨️ 快捷键说明

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