msvc_prj_utils.hpp

来自「ncbi源码」· HPP 代码 · 共 558 行 · 第 1/2 页

HPP
558
字号
/* * =========================================================================== * PRODUCTION $Log: msvc_prj_utils.hpp,v $ * PRODUCTION Revision 1000.3  2004/06/16 17:05:02  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.24 * PRODUCTION * =========================================================================== */#ifndef PROJECT_TREE_BUILDER__MSVC_PRJ_UTILS__HPP#define PROJECT_TREE_BUILDER__MSVC_PRJ_UTILS__HPP/* $Id: msvc_prj_utils.hpp,v 1000.3 2004/06/16 17:05:02 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 <corelib/ncbireg.hpp>#include <app/project_tree_builder/msvc71_project__.hpp>#include <app/project_tree_builder/proj_item.hpp>#include <set>#include <corelib/ncbienv.hpp>BEGIN_NCBI_SCOPEUSING_SCOPE(objects);/// Creates CVisualStudioProject class instance from file.////// @param file_path///   Path to file load from./// @return///   Created on heap CVisualStudioProject instance or NULL///   if failed.CVisualStudioProject * LoadFromXmlFile(const string& file_path);/// Save CVisualStudioProject class instance to file.////// @param file_path///   Path to file project will be saved to./// @param project///   Project to save.void SaveToXmlFile  (const string&               file_path,                      const CVisualStudioProject& project);/// Save CVisualStudioProject class instance to file only if no such file //  or contents of this file will be different from already present file.////// @param file_path///   Path to file project will be saved to./// @param project///   Project to save.void SaveIfNewer    (const string&               file_path,                      const CVisualStudioProject& project);/// Consider promotion candidate to present void PromoteIfDifferent(const string& present_path,                         const string& candidate_path);/// Generate pseudo-GUID.string GenerateSlnGUID(void);/// Get extension for source file without extension.////// @param file_path///   Source file full path withour extension./// @return///   Extension of source file (".cpp" or ".c") ///   if such file exist. Empty string string if there is no///   such file.string SourceFileExt(const string& file_path);/////////////////////////////////////////////////////////////////////////////////// SConfigInfo --////// Abstraction of configuration informaion.////// Configuration name, debug/release flag, runtime library /// struct SConfigInfo{    SConfigInfo(void);    SConfigInfo(const string& name,                 bool          debug,                 const string& runtime_library);    string m_Name;    bool   m_Debug;    string m_RuntimeLibrary;};// Helper to load configs from ini filesvoid LoadConfigInfoByNames(const CNcbiRegistry& registry,                            const list<string>&  config_names,                            list<SConfigInfo>*   configs);/////////////////////////////////////////////////////////////////////////////////// SCustomBuildInfo --////// Abstraction of custom build source file.////// Information for custom buil source file /// (not *.c, *.cpp, *.midl, *.rc, etc.)/// MSVC does not know how to buil this file and/// we provide information how to do it./// struct SCustomBuildInfo{    string m_SourceFile; // absolut path!    string m_CommandLine;    string m_Description;    string m_Outputs;    string m_AdditionalDependencies;    bool IsEmpty(void) const    {        return m_SourceFile.empty() || m_CommandLine.empty();    }    void Clear(void)    {        m_SourceFile.erase();        m_CommandLine.erase();        m_Description.erase();        m_Outputs.erase();        m_AdditionalDependencies.erase();    }};/////////////////////////////////////////////////////////////////////////////////// CMsvc7RegSettings --////// Abstraction of [msvc7] section in app registry.////// Settings for generation of msvc 7.10 projects/// class CMsvc7RegSettings{public:    CMsvc7RegSettings(void);    string            m_Version;    list<SConfigInfo> m_ConfigInfo;    string            m_CompilersSubdir;    string            m_ProjectsSubdir;    string            m_MakefilesExt;    string            m_MetaMakefile;    string            m_DllInfo;private:    CMsvc7RegSettings(const CMsvc7RegSettings&);    CMsvc7RegSettings& operator= (const CMsvc7RegSettings&);};/// Is abs_dir a parent of abs_parent_dir.bool IsSubdir(const string& abs_parent_dir, const string& abs_dir);/// Erase if predicate is truetemplate <class C, class P> void EraseIf(C& cont, const P& pred){    for (typename C::iterator p = cont.begin(); p != cont.end(); )    {        if ( pred(*p) ) {            typename C::iterator p_next = p;	    ++p_next;            cont.erase(p);	    p = p_next;        }        else            ++p;    }}/// Get option fron registry from  ///     [<section>.debug.<ConfigName>] section for debug configuratios///  or [<section>.release.<ConfigName>] for release configurations////// if no such option then try      ///     [<section>.debug]/// or  [<section>.release]////// if no such option then finally try///     [<section>]///string GetOpt(const CNcbiRegistry& registry,               const string&        section,               const string&        opt,               const SConfigInfo&   config);/// return <config>|Win32 as needed by MSVC compilerstring ConfigName(const string& config);//-----------------------------------------------------------------------------// Base interface class for all insertorsclass IFilesToProjectInserter{public:    virtual ~IFilesToProjectInserter(void)    {    }    virtual void AddSourceFile (const string& rel_file_path) = 0;    virtual void AddHeaderFile (const string& rel_file_path) = 0;    virtual void AddInlineFile (const string& rel_file_path) = 0;    virtual void Finalize      (void)                        = 0;};// Insert .cpp and .c files to filter and set PCH usage if necessaryclass CSrcToFilterInserterWithPch{public:    CSrcToFilterInserterWithPch(const string&            project_id,                                const list<SConfigInfo>& configs,                                const string&            project_dir);    ~CSrcToFilterInserterWithPch(void);    void operator() (CRef<CFilter>& filter,                      const string&  rel_source_file);private:    string            m_ProjectId;    list<SConfigInfo> m_Configs;    string            m_ProjectDir;    typedef set<string> TPchHeaders;    TPchHeaders m_PchHeaders;    enum EUsePch {        eNotUse = 0,        eCreate = 1,        eUse    = 3    };    typedef pair<EUsePch, string> TPch;    TPch DefinePchUsage(const string&     project_dir,                        const string&     rel_source_file);    // Prohibited to:

⌨️ 快捷键说明

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