📄 msvc_dlls_info.cpp
字号:
/* * =========================================================================== * PRODUCTION $Log: msvc_dlls_info.cpp,v $ * PRODUCTION Revision 1000.4 2004/06/16 17:02:26 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.19 * PRODUCTION * =========================================================================== *//* $Id: msvc_dlls_info.cpp,v 1000.4 2004/06/16 17:02:26 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/msvc_dlls_info.hpp>#include <app/project_tree_builder/proj_builder_app.hpp>#include <app/project_tree_builder/msvc_prj_defines.hpp>#include <app/project_tree_builder/proj_projects.hpp>#include <app/project_tree_builder/proj_tree_builder.hpp>#include <app/project_tree_builder/msvc_project_context.hpp>#include <app/project_tree_builder/msvc_prj_files_collector.hpp>#include <app/project_tree_builder/msvc_dlls_info_utils.hpp>#include <corelib/ncbistre.hpp>#include <algorithm>BEGIN_NCBI_SCOPECMsvcDllsInfo::CMsvcDllsInfo(const string& file_path){ CNcbiIfstream ifs(file_path.c_str(), IOS_BASE::in | IOS_BASE::binary); if (ifs) { //read registry m_Registry.Read(ifs); }}CMsvcDllsInfo::~CMsvcDllsInfo(void){}void CMsvcDllsInfo::GetDllsList(list<string>* dlls_ids) const{ ncbi::GetDllsList(m_Registry, dlls_ids);}void CMsvcDllsInfo::GetBuildConfigs(list<SConfigInfo>* config) const{ config->clear(); string configs_str = m_Registry.GetString("DllBuild", "Configurations", ""); list<string> config_names; NStr::Split(configs_str, LIST_SEPARATOR, config_names); LoadConfigInfoByNames(GetApp().GetConfig(), config_names, config);}string CMsvcDllsInfo::GetBuildDefine(void) const{ return m_Registry.GetString("DllBuild", "BuildDefine", "");}bool CMsvcDllsInfo::SDllInfo::IsEmpty(void) const{ return m_Hosting.empty() && m_Depends.empty() && m_DllDefine.empty();} void CMsvcDllsInfo::SDllInfo::Clear(void){ m_Hosting.clear(); m_Depends.clear(); m_DllDefine.erase();}void CMsvcDllsInfo::GetDllInfo(const string& dll_id, SDllInfo* dll_info) const{ dll_info->Clear(); GetHostedLibs(m_Registry, dll_id, &(dll_info->m_Hosting) ); string depends_str = m_Registry.GetString(dll_id, "Dependencies", ""); NStr::Split(depends_str, LIST_SEPARATOR, dll_info->m_Depends); dll_info->m_DllDefine = m_Registry.GetString(dll_id, "DllDefine", "");}bool CMsvcDllsInfo::IsDllHosted(const string& lib_id) const{ return !GetDllHost(lib_id).empty();}string CMsvcDllsInfo::GetDllHost(const string& lib_id) const{ list<string> dll_list; GetDllsList(&dll_list); ITERATE(list<string>, p, dll_list) { const string& dll_id = *p; SDllInfo dll_info; GetDllInfo(dll_id, &dll_info); if (find(dll_info.m_Hosting.begin(), dll_info.m_Hosting.end(), lib_id) != dll_info.m_Hosting.end()) { return dll_id; } } return "";}//-----------------------------------------------------------------------------void FilterOutDllHostedProjects(const CProjectItemsTree& tree_src, CProjectItemsTree* tree_dst){ tree_dst->m_RootSrc = tree_src.m_RootSrc; tree_dst->m_Projects.clear(); ITERATE(CProjectItemsTree::TProjects, p, tree_src.m_Projects) { const CProjKey& proj_id = p->first; const CProjItem& project = p->second; bool dll_hosted = (proj_id.Type() == CProjKey::eLib) && GetApp().GetDllsInfo().IsDllHosted(proj_id.Id()); if ( !dll_hosted ) { tree_dst->m_Projects[proj_id] = project; } } }static bool s_IsInTree(CProjKey::TProjType proj_type, const string& proj_id, const CProjectItemsTree& tree){ return tree.m_Projects.find (CProjKey(proj_type, proj_id)) != tree.m_Projects.end();}static bool s_IsDllProject(const string& project_id){ CMsvcDllsInfo::SDllInfo dll_info; GetApp().GetDllsInfo().GetDllInfo(project_id, &dll_info); return !dll_info.IsEmpty();}static void s_InitalizeDllProj(const string& dll_id, const CMsvcDllsInfo::SDllInfo& dll_info, CProjItem* dll, CProjectItemsTree* tree_dst){ dll->m_Name = dll_id; dll->m_ID = dll_id; dll->m_ProjType = CProjKey::eDll; ITERATE(list<string>, p, dll_info.m_Depends) { const string& depend_id = *p; // Is this a dll? if ( s_IsDllProject(depend_id) ) { dll->m_Depends.push_back(CProjKey(CProjKey::eDll, depend_id)); } else { if ( s_IsInTree(CProjKey::eApp, depend_id, GetApp().GetWholeTree()) ) { CProjKey depend_key(CProjKey::eApp, depend_id); dll->m_Depends.push_back(depend_key); tree_dst->m_Projects[depend_key] = (GetApp().GetWholeTree().m_Projects.find(depend_key))->second; } else if ( s_IsInTree(CProjKey::eLib, depend_id, GetApp().GetWholeTree()) ) { CProjKey depend_key(CProjKey::eLib, depend_id); dll->m_Depends.push_back(depend_key); tree_dst->m_Projects[depend_key] = (GetApp().GetWholeTree().m_Projects.find(depend_key))->second; } else { LOG_POST(Error << "Can not find project : " + depend_id); } } } string dll_project_dir = GetApp().GetProjectTreeInfo().m_Compilers; dll_project_dir = CDirEntry::ConcatPath(dll_project_dir, GetApp().GetRegSettings().m_CompilersSubdir); dll_project_dir = CDirEntry::ConcatPath(dll_project_dir, GetApp().GetBuildType().GetTypeStr()); dll_project_dir = CDirEntry::ConcatPath(dll_project_dir, GetApp().GetRegSettings().m_ProjectsSubdir); dll_project_dir = CDirEntry::ConcatPath(dll_project_dir, dll_id); dll_project_dir = CDirEntry::AddTrailingPathSeparator(dll_project_dir); dll->m_SourcesBaseDir = dll_project_dir; dll->m_Sources.clear(); dll->m_Sources.push_back("..\\..\\dll_main");}static void s_AddProjItemToDll(const CProjItem& lib, CProjItem* dll){ // If this library is available as a third-party, // then we'll require it if (GetApp().GetSite().GetChoiceForLib(lib.m_ID) == CMsvcSite::e3PartyLib ) { CMsvcSite::SLibChoice choice = GetApp().GetSite().GetLibChoiceForLib(lib.m_ID); dll->m_Requires.push_back(choice.m_3PartyLib); dll->m_Requires.sort(); dll->m_Requires.unique(); return; } CMsvcPrjProjectContext lib_context(lib); CMsvcPrjFilesCollector collector(lib_context, lib); // Sources - all pathes are relative to one dll->m_SourcesBaseDir ITERATE(list<string>, p, collector.SourceFiles()) { const string& rel_path = *p; string abs_path = CDirEntry::ConcatPath(lib_context.ProjectDir(), rel_path); abs_path = CDirEntry::NormalizePath(abs_path); // Register DLL source files as belongs to lib // With .ext GetApp().GetDllFilesDistr().RegisterSource (abs_path, CProjKey(CProjKey::eDll, dll->m_ID), CProjKey(CProjKey::eLib, lib.m_ID) ); string dir; string base; CDirEntry::SplitPath(abs_path, &dir, &base); string abs_source_path = dir + base; string new_rel_path = CDirEntry::CreateRelativePath(dll->m_SourcesBaseDir, abs_source_path); dll->m_Sources.push_back(new_rel_path); } dll->m_Sources.sort(); dll->m_Sources.unique(); // Header files - also register them ITERATE(list<string>, p, collector.HeaderFiles()) { const string& rel_path = *p; string abs_path = CDirEntry::ConcatPath(lib_context.ProjectDir(), rel_path); abs_path = CDirEntry::NormalizePath(abs_path); GetApp().GetDllFilesDistr().RegisterHeader (abs_path, CProjKey(CProjKey::eDll, dll->m_ID), CProjKey(CProjKey::eLib, lib.m_ID) ); } // Inline files - also register them ITERATE(list<string>, p, collector.InlineFiles()) { const string& rel_path = *p;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -