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

📄 msvc_project_context.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/* * =========================================================================== * PRODUCTION $Log: msvc_project_context.cpp,v $ * PRODUCTION Revision 1000.4  2004/06/16 17:02:34  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.33 * PRODUCTION * =========================================================================== *//* $Id: msvc_project_context.cpp,v 1000.4 2004/06/16 17:02:34 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/stl_msvc_usage.hpp>#include <app/project_tree_builder/msvc_project_context.hpp>#include <app/project_tree_builder/msvc_tools_implement.hpp>#include <app/project_tree_builder/proj_builder_app.hpp>#include <app/project_tree_builder/msvc_site.hpp>#include <app/project_tree_builder/msvc_prj_defines.hpp>#include <set>BEGIN_NCBI_SCOPE//-----------------------------------------------------------------------------CMsvcPrjProjectContext::CMsvcPrjProjectContext(const CProjItem& project){    //MSVC project name created from project type and project ID    m_ProjectName  = CreateProjectName(CProjKey(project.m_ProjType,                                                 project.m_ID));    m_ProjectId    = project.m_ID;    m_ProjType     = project.m_ProjType;    m_SourcesBaseDir = project.m_SourcesBaseDir;    m_Requires       = project.m_Requires;        // Get msvc project makefile    m_MsvcProjectMakefile.reset        (new CMsvcProjectMakefile                    (CDirEntry::ConcatPath                            (m_SourcesBaseDir,                              CreateMsvcProjectMakefileName(project))));    // Done if this is ready MSVC project    if ( project.m_ProjType == CProjKey::eMsvc)        return;    // Collect all dirs of source files into m_SourcesDirsAbs:    set<string> sources_dirs;    sources_dirs.insert(m_SourcesBaseDir);    ITERATE(list<string>, p, project.m_Sources) {        const string& src_rel = *p;        string src_path = CDirEntry::ConcatPath(m_SourcesBaseDir, src_rel);        src_path = CDirEntry::NormalizePath(src_path);        string dir;        CDirEntry::SplitPath(src_path, &dir);        sources_dirs.insert(dir);    }    copy(sources_dirs.begin(),          sources_dirs.end(),          back_inserter(m_SourcesDirsAbs));    // Creating project dir:    if (project.m_ProjType == CProjKey::eDll) {        //For dll - it is so        m_ProjectDir = project.m_SourcesBaseDir;    } else {        m_ProjectDir = GetApp().GetProjectTreeInfo().m_Compilers;        m_ProjectDir =             CDirEntry::ConcatPath(m_ProjectDir,                                   GetApp().GetRegSettings().m_CompilersSubdir);        m_ProjectDir =             CDirEntry::ConcatPath(m_ProjectDir,                                   GetApp().GetBuildType().GetTypeStr());        m_ProjectDir =            CDirEntry::ConcatPath(m_ProjectDir,                                  GetApp().GetRegSettings().m_ProjectsSubdir);        m_ProjectDir =             CDirEntry::ConcatPath(m_ProjectDir,                                   CDirEntry::CreateRelativePath                                      (GetApp().GetProjectTreeInfo().m_Src,                                       m_SourcesBaseDir));        m_ProjectDir = CDirEntry::AddTrailingPathSeparator(m_ProjectDir);    }        // Generate include dirs:    // Include dirs for appropriate src dirs    set<string> include_dirs;    ITERATE(list<string>, p, project.m_Sources) {        //create full path for src file        const string& src_rel = *p;        string src_abs  = CDirEntry::ConcatPath(m_SourcesBaseDir, src_rel);        src_abs = CDirEntry::NormalizePath(src_abs);        //part of path (from <src> dir)        string rel_path  =             CDirEntry::CreateRelativePath(GetApp().GetProjectTreeInfo().m_Src,                                           src_abs);        //add this part to <include> dir        string incl_path =             CDirEntry::ConcatPath(GetApp().GetProjectTreeInfo().m_Include,                                   rel_path);        string incl_dir;        CDirEntry::SplitPath(incl_path, &incl_dir);        include_dirs.insert(incl_dir);        //impl include sub-dir        string impl_dir =             CDirEntry::ConcatPath(incl_dir,                                   GetApp().GetProjectTreeInfo().m_Impl);        impl_dir = CDirEntry::AddTrailingPathSeparator(impl_dir);        include_dirs.insert(impl_dir);    }    copy(include_dirs.begin(),          include_dirs.end(),          back_inserter(m_IncludeDirsAbs));    // Get custom build files and adjust pathes     GetMsvcProjectMakefile().GetCustomBuildInfo(&m_CustomBuildInfo);    NON_CONST_ITERATE(list<SCustomBuildInfo>, p, m_CustomBuildInfo) {       SCustomBuildInfo& build_info = *p;       string file_path_abs =            CDirEntry::ConcatPath(m_SourcesBaseDir, build_info.m_SourceFile);       build_info.m_SourceFile =            CDirEntry::CreateRelativePath(m_ProjectDir, file_path_abs);               }    // Collect include dirs, specified in project Makefiles    m_ProjectIncludeDirs = project.m_IncludeDirs;    // LIBS from Makefiles    // m_ProjectLibs = project.m_Libs3Party;    ITERATE(list<string>, p, project.m_Libs3Party) {        const string& lib_id = *p;        if ( GetApp().GetSite().IsLibWithChoice(lib_id) ) {            if ( GetApp().GetSite().GetChoiceForLib(lib_id) == CMsvcSite::eLib )                m_ProjectLibs.push_back(lib_id);        } else {            m_ProjectLibs.push_back(lib_id);        }    }    // Proprocessor definitions from makefiles:    m_Defines = project.m_Defines;    if (GetApp().GetBuildType().GetType() == CBuildType::eDll) {        m_Defines.push_back(GetApp().GetDllsInfo().GetBuildDefine());        if (project.m_ProjType == CProjKey::eDll) {            CMsvcDllsInfo::SDllInfo dll_info;            GetApp().GetDllsInfo().GetDllInfo(project.m_ID, &dll_info);            m_Defines.push_back(dll_info.m_DllDefine);        }    }    // Pre-Builds for LIB projects:    if (m_ProjType == CProjKey::eLib) {        ITERATE(list<CProjKey>, p, project.m_Depends) {            const CProjKey& proj_key = *p;            if (proj_key.Type() == CProjKey::eLib) {                m_PreBuilds.push_back(CreateProjectName(proj_key));            }        }    }    // Libraries from NCBI C Toolkit    m_NcbiCLibs = project.m_NcbiCLibs;}string CMsvcPrjProjectContext::AdditionalIncludeDirectories                                            (const SConfigInfo& cfg_info) const{    list<string> add_include_dirs_list;    add_include_dirs_list.push_back         (CDirEntry::CreateRelativePath(m_ProjectDir,                                       GetApp().GetProjectTreeInfo().m_Include));        //take into account project include dirs    ITERATE(list<string>, p, m_ProjectIncludeDirs) {        const string& dir_abs = *p;        add_include_dirs_list.push_back(SameRootDirs(m_ProjectDir,dir_abs) ?                CDirEntry::CreateRelativePath(m_ProjectDir, dir_abs) :                dir_abs);    }    //MSVC Makefile additional include dirs    list<string> makefile_add_incl_dirs;    GetMsvcProjectMakefile().GetAdditionalIncludeDirs(cfg_info,                                                     &makefile_add_incl_dirs);    ITERATE(list<string>, p, makefile_add_incl_dirs) {        const string& dir = *p;        string dir_abs =             CDirEntry::AddTrailingPathSeparator                (CDirEntry::ConcatPath(m_SourcesBaseDir, dir));        dir_abs = CDirEntry::NormalizePath(dir_abs);        dir_abs =             CDirEntry::CreateRelativePath                        (m_ProjectDir, dir_abs);        add_include_dirs_list.push_back(dir_abs);    }    // Additional include dirs for 3-party libs    list<string> libs_list;    CreateLibsList(&libs_list);    ITERATE(list<string>, p, libs_list) {        const string& requires = *p;        SLibInfo lib_info;        GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);        if ( !lib_info.m_IncludeDir.empty() ) {            const string& dir_abs = lib_info.m_IncludeDir;            add_include_dirs_list.push_back(SameRootDirs(m_ProjectDir,dir_abs)?                                CDirEntry::CreateRelativePath(m_ProjectDir,                                                               dir_abs) :                                dir_abs);        }    }    //Leave only unique dirs and join them to string    add_include_dirs_list.sort();    add_include_dirs_list.unique();    return NStr::Join(add_include_dirs_list, ", ");}string CMsvcPrjProjectContext::AdditionalLinkerOptions                                            (const SConfigInfo& cfg_info) const{    list<string> additional_libs;    // Take into account requires, default and makefiles libs    list<string> libs_list;    CreateLibsList(&libs_list);    ITERATE(list<string>, p, libs_list) {        const string& requires = *p;        SLibInfo lib_info;        GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);        if ( !lib_info.m_Libs.empty() ) {            copy(lib_info.m_Libs.begin(),                  lib_info.m_Libs.end(),                  back_inserter(additional_libs));        }    }    // NCBI C Toolkit libs    ITERATE(list<string>, p, m_NcbiCLibs) {        string ncbi_lib = *p + ".lib";        additional_libs.push_back(ncbi_lib);            }    additional_libs.sort();    additional_libs.unique();    return NStr::Join(additional_libs, " ");}#if 0string CMsvcPrjProjectContext::AdditionalLibrarianOptions                                            (const SConfigInfo& cfg_info) const{    return AdditionalLinkerOptions(cfg_info);}#endifstring CMsvcPrjProjectContext::AdditionalLibraryDirectories                                            (const SConfigInfo& cfg_info) const{    // Take into account requires, default and makefiles libs    list<string> libs_list;    CreateLibsList(&libs_list);    list<string> dir_list;    ITERATE(list<string>, p, libs_list) {        const string& requires = *p;        SLibInfo lib_info;        GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);        if ( !lib_info.m_LibPath.empty() ) {            dir_list.push_back(lib_info.m_LibPath);        }    }    dir_list.sort();    dir_list.unique();    return NStr::Join(dir_list, ", ");}void CMsvcPrjProjectContext::CreateLibsList(list<string>* libs_list) const{    libs_list->clear();    // We'll build libs list.    *libs_list = m_Requires;

⌨️ 快捷键说明

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