msvc_project_context.cpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:33k
源码类别:

生物技术

开发平台:

C/C++

  1. /*
  2.  * ===========================================================================
  3.  * PRODUCTION $Log: msvc_project_context.cpp,v $
  4.  * PRODUCTION Revision 1000.4  2004/06/16 17:02:34  gouriano
  5.  * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.33
  6.  * PRODUCTION
  7.  * ===========================================================================
  8.  */
  9. /* $Id: msvc_project_context.cpp,v 1000.4 2004/06/16 17:02:34 gouriano Exp $
  10.  * ===========================================================================
  11.  *
  12.  *                            PUBLIC DOMAIN NOTICE
  13.  *               National Center for Biotechnology Information
  14.  *
  15.  *  This software/database is a "United States Government Work" under the
  16.  *  terms of the United States Copyright Act.  It was written as part of
  17.  *  the author's official duties as a United States Government employee and
  18.  *  thus cannot be copyrighted.  This software/database is freely available
  19.  *  to the public for use. The National Library of Medicine and the U.S.
  20.  *  Government have not placed any restriction on its use or reproduction.
  21.  *
  22.  *  Although all reasonable efforts have been taken to ensure the accuracy
  23.  *  and reliability of the software and data, the NLM and the U.S.
  24.  *  Government do not and cannot warrant the performance or results that
  25.  *  may be obtained by using this software or data. The NLM and the U.S.
  26.  *  Government disclaim all warranties, express or implied, including
  27.  *  warranties of performance, merchantability or fitness for any particular
  28.  *  purpose.
  29.  *
  30.  *  Please cite the author in any work or product based on this material.
  31.  *
  32.  * ===========================================================================
  33.  *
  34.  * Author:  Viatcheslav Gorelenkov
  35.  *
  36.  */
  37. #include <ncbi_pch.hpp>
  38. #include <app/project_tree_builder/stl_msvc_usage.hpp>
  39. #include <app/project_tree_builder/msvc_project_context.hpp>
  40. #include <app/project_tree_builder/msvc_tools_implement.hpp>
  41. #include <app/project_tree_builder/proj_builder_app.hpp>
  42. #include <app/project_tree_builder/msvc_site.hpp>
  43. #include <app/project_tree_builder/msvc_prj_defines.hpp>
  44. #include <set>
  45. BEGIN_NCBI_SCOPE
  46. //-----------------------------------------------------------------------------
  47. CMsvcPrjProjectContext::CMsvcPrjProjectContext(const CProjItem& project)
  48. {
  49.     //MSVC project name created from project type and project ID
  50.     m_ProjectName  = CreateProjectName(CProjKey(project.m_ProjType, 
  51.                                                 project.m_ID));
  52.     m_ProjectId    = project.m_ID;
  53.     m_ProjType     = project.m_ProjType;
  54.     m_SourcesBaseDir = project.m_SourcesBaseDir;
  55.     m_Requires       = project.m_Requires;
  56.     
  57.     // Get msvc project makefile
  58.     m_MsvcProjectMakefile.reset
  59.         (new CMsvcProjectMakefile
  60.                     (CDirEntry::ConcatPath
  61.                             (m_SourcesBaseDir, 
  62.                              CreateMsvcProjectMakefileName(project))));
  63.     // Done if this is ready MSVC project
  64.     if ( project.m_ProjType == CProjKey::eMsvc)
  65.         return;
  66.     // Collect all dirs of source files into m_SourcesDirsAbs:
  67.     set<string> sources_dirs;
  68.     sources_dirs.insert(m_SourcesBaseDir);
  69.     ITERATE(list<string>, p, project.m_Sources) {
  70.         const string& src_rel = *p;
  71.         string src_path = CDirEntry::ConcatPath(m_SourcesBaseDir, src_rel);
  72.         src_path = CDirEntry::NormalizePath(src_path);
  73.         string dir;
  74.         CDirEntry::SplitPath(src_path, &dir);
  75.         sources_dirs.insert(dir);
  76.     }
  77.     copy(sources_dirs.begin(), 
  78.          sources_dirs.end(), 
  79.          back_inserter(m_SourcesDirsAbs));
  80.     // Creating project dir:
  81.     if (project.m_ProjType == CProjKey::eDll) {
  82.         //For dll - it is so
  83.         m_ProjectDir = project.m_SourcesBaseDir;
  84.     } else {
  85.         m_ProjectDir = GetApp().GetProjectTreeInfo().m_Compilers;
  86.         m_ProjectDir = 
  87.             CDirEntry::ConcatPath(m_ProjectDir, 
  88.                                   GetApp().GetRegSettings().m_CompilersSubdir);
  89.         m_ProjectDir = 
  90.             CDirEntry::ConcatPath(m_ProjectDir, 
  91.                                   GetApp().GetBuildType().GetTypeStr());
  92.         m_ProjectDir =
  93.             CDirEntry::ConcatPath(m_ProjectDir,
  94.                                   GetApp().GetRegSettings().m_ProjectsSubdir);
  95.         m_ProjectDir = 
  96.             CDirEntry::ConcatPath(m_ProjectDir, 
  97.                                   CDirEntry::CreateRelativePath
  98.                                       (GetApp().GetProjectTreeInfo().m_Src, 
  99.                                       m_SourcesBaseDir));
  100.         m_ProjectDir = CDirEntry::AddTrailingPathSeparator(m_ProjectDir);
  101.     }
  102.     
  103.     // Generate include dirs:
  104.     // Include dirs for appropriate src dirs
  105.     set<string> include_dirs;
  106.     ITERATE(list<string>, p, project.m_Sources) {
  107.         //create full path for src file
  108.         const string& src_rel = *p;
  109.         string src_abs  = CDirEntry::ConcatPath(m_SourcesBaseDir, src_rel);
  110.         src_abs = CDirEntry::NormalizePath(src_abs);
  111.         //part of path (from <src> dir)
  112.         string rel_path  = 
  113.             CDirEntry::CreateRelativePath(GetApp().GetProjectTreeInfo().m_Src, 
  114.                                           src_abs);
  115.         //add this part to <include> dir
  116.         string incl_path = 
  117.             CDirEntry::ConcatPath(GetApp().GetProjectTreeInfo().m_Include, 
  118.                                   rel_path);
  119.         string incl_dir;
  120.         CDirEntry::SplitPath(incl_path, &incl_dir);
  121.         include_dirs.insert(incl_dir);
  122.         //impl include sub-dir
  123.         string impl_dir = 
  124.             CDirEntry::ConcatPath(incl_dir, 
  125.                                   GetApp().GetProjectTreeInfo().m_Impl);
  126.         impl_dir = CDirEntry::AddTrailingPathSeparator(impl_dir);
  127.         include_dirs.insert(impl_dir);
  128.     }
  129.     copy(include_dirs.begin(), 
  130.          include_dirs.end(), 
  131.          back_inserter(m_IncludeDirsAbs));
  132.     // Get custom build files and adjust pathes 
  133.     GetMsvcProjectMakefile().GetCustomBuildInfo(&m_CustomBuildInfo);
  134.     NON_CONST_ITERATE(list<SCustomBuildInfo>, p, m_CustomBuildInfo) {
  135.        SCustomBuildInfo& build_info = *p;
  136.        string file_path_abs = 
  137.            CDirEntry::ConcatPath(m_SourcesBaseDir, build_info.m_SourceFile);
  138.        build_info.m_SourceFile = 
  139.            CDirEntry::CreateRelativePath(m_ProjectDir, file_path_abs);           
  140.     }
  141.     // Collect include dirs, specified in project Makefiles
  142.     m_ProjectIncludeDirs = project.m_IncludeDirs;
  143.     // LIBS from Makefiles
  144.     // m_ProjectLibs = project.m_Libs3Party;
  145.     ITERATE(list<string>, p, project.m_Libs3Party) {
  146.         const string& lib_id = *p;
  147.         if ( GetApp().GetSite().IsLibWithChoice(lib_id) ) {
  148.             if ( GetApp().GetSite().GetChoiceForLib(lib_id) == CMsvcSite::eLib )
  149.                 m_ProjectLibs.push_back(lib_id);
  150.         } else {
  151.             m_ProjectLibs.push_back(lib_id);
  152.         }
  153.     }
  154.     // Proprocessor definitions from makefiles:
  155.     m_Defines = project.m_Defines;
  156.     if (GetApp().GetBuildType().GetType() == CBuildType::eDll) {
  157.         m_Defines.push_back(GetApp().GetDllsInfo().GetBuildDefine());
  158.         if (project.m_ProjType == CProjKey::eDll) {
  159.             CMsvcDllsInfo::SDllInfo dll_info;
  160.             GetApp().GetDllsInfo().GetDllInfo(project.m_ID, &dll_info);
  161.             m_Defines.push_back(dll_info.m_DllDefine);
  162.         }
  163.     }
  164.     // Pre-Builds for LIB projects:
  165.     if (m_ProjType == CProjKey::eLib) {
  166.         ITERATE(list<CProjKey>, p, project.m_Depends) {
  167.             const CProjKey& proj_key = *p;
  168.             if (proj_key.Type() == CProjKey::eLib) {
  169.                 m_PreBuilds.push_back(CreateProjectName(proj_key));
  170.             }
  171.         }
  172.     }
  173.     // Libraries from NCBI C Toolkit
  174.     m_NcbiCLibs = project.m_NcbiCLibs;
  175. }
  176. string CMsvcPrjProjectContext::AdditionalIncludeDirectories
  177.                                             (const SConfigInfo& cfg_info) const
  178. {
  179.     list<string> add_include_dirs_list;
  180.     add_include_dirs_list.push_back 
  181.         (CDirEntry::CreateRelativePath(m_ProjectDir, 
  182.                                       GetApp().GetProjectTreeInfo().m_Include));
  183.     
  184.     //take into account project include dirs
  185.     ITERATE(list<string>, p, m_ProjectIncludeDirs) {
  186.         const string& dir_abs = *p;
  187.         add_include_dirs_list.push_back(SameRootDirs(m_ProjectDir,dir_abs) ?
  188.                 CDirEntry::CreateRelativePath(m_ProjectDir, dir_abs) :
  189.                 dir_abs);
  190.     }
  191.     //MSVC Makefile additional include dirs
  192.     list<string> makefile_add_incl_dirs;
  193.     GetMsvcProjectMakefile().GetAdditionalIncludeDirs(cfg_info, 
  194.                                                     &makefile_add_incl_dirs);
  195.     ITERATE(list<string>, p, makefile_add_incl_dirs) {
  196.         const string& dir = *p;
  197.         string dir_abs = 
  198.             CDirEntry::AddTrailingPathSeparator
  199.                 (CDirEntry::ConcatPath(m_SourcesBaseDir, dir));
  200.         dir_abs = CDirEntry::NormalizePath(dir_abs);
  201.         dir_abs = 
  202.             CDirEntry::CreateRelativePath
  203.                         (m_ProjectDir, dir_abs);
  204.         add_include_dirs_list.push_back(dir_abs);
  205.     }
  206.     // Additional include dirs for 3-party libs
  207.     list<string> libs_list;
  208.     CreateLibsList(&libs_list);
  209.     ITERATE(list<string>, p, libs_list) {
  210.         const string& requires = *p;
  211.         SLibInfo lib_info;
  212.         GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);
  213.         if ( !lib_info.m_IncludeDir.empty() ) {
  214.             const string& dir_abs = lib_info.m_IncludeDir;
  215.             add_include_dirs_list.push_back(SameRootDirs(m_ProjectDir,dir_abs)?
  216.                                 CDirEntry::CreateRelativePath(m_ProjectDir, 
  217.                                                               dir_abs) :
  218.                                 dir_abs);
  219.         }
  220.     }
  221.     //Leave only unique dirs and join them to string
  222.     add_include_dirs_list.sort();
  223.     add_include_dirs_list.unique();
  224.     return NStr::Join(add_include_dirs_list, ", ");
  225. }
  226. string CMsvcPrjProjectContext::AdditionalLinkerOptions
  227.                                             (const SConfigInfo& cfg_info) const
  228. {
  229.     list<string> additional_libs;
  230.     // Take into account requires, default and makefiles libs
  231.     list<string> libs_list;
  232.     CreateLibsList(&libs_list);
  233.     ITERATE(list<string>, p, libs_list) {
  234.         const string& requires = *p;
  235.         SLibInfo lib_info;
  236.         GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);
  237.         if ( !lib_info.m_Libs.empty() ) {
  238.             copy(lib_info.m_Libs.begin(), 
  239.                  lib_info.m_Libs.end(), 
  240.                  back_inserter(additional_libs));
  241.         }
  242.     }
  243.     // NCBI C Toolkit libs
  244.     ITERATE(list<string>, p, m_NcbiCLibs) {
  245.         string ncbi_lib = *p + ".lib";
  246.         additional_libs.push_back(ncbi_lib);        
  247.     }
  248.     additional_libs.sort();
  249.     additional_libs.unique();
  250.     return NStr::Join(additional_libs, " ");
  251. }
  252. #if 0
  253. string CMsvcPrjProjectContext::AdditionalLibrarianOptions
  254.                                             (const SConfigInfo& cfg_info) const
  255. {
  256.     return AdditionalLinkerOptions(cfg_info);
  257. }
  258. #endif
  259. string CMsvcPrjProjectContext::AdditionalLibraryDirectories
  260.                                             (const SConfigInfo& cfg_info) const
  261. {
  262.     // Take into account requires, default and makefiles libs
  263.     list<string> libs_list;
  264.     CreateLibsList(&libs_list);
  265.     list<string> dir_list;
  266.     ITERATE(list<string>, p, libs_list) {
  267.         const string& requires = *p;
  268.         SLibInfo lib_info;
  269.         GetApp().GetSite().GetLibInfo(requires, cfg_info, &lib_info);
  270.         if ( !lib_info.m_LibPath.empty() ) {
  271.             dir_list.push_back(lib_info.m_LibPath);
  272.         }
  273.     }
  274.     dir_list.sort();
  275.     dir_list.unique();
  276.     return NStr::Join(dir_list, ", ");
  277. }
  278. void CMsvcPrjProjectContext::CreateLibsList(list<string>* libs_list) const
  279. {
  280.     libs_list->clear();
  281.     // We'll build libs list.
  282.     *libs_list = m_Requires;
  283.     //take into account default libs from site:
  284.     libs_list->push_back(MSVC_DEFAULT_LIBS_TAG);
  285.     //and LIBS from Makefiles:
  286.     ITERATE(list<string>, p, m_ProjectLibs) {
  287.         const string& lib = *p;
  288.         list<string> components;
  289.         GetApp().GetSite().GetComponents(lib, &components);
  290.         copy(components.begin(), 
  291.              components.end(), back_inserter(*libs_list));
  292.     }
  293.     libs_list->sort();
  294.     libs_list->unique();
  295. }
  296. const CMsvcCombinedProjectMakefile& 
  297. CMsvcPrjProjectContext::GetMsvcProjectMakefile(void) const
  298. {
  299.     if ( m_MsvcCombinedProjectMakefile.get() )
  300.         return *m_MsvcCombinedProjectMakefile;
  301.     string rules_dir = GetApp().GetProjectTreeInfo().m_Compilers;
  302.     rules_dir = 
  303.             CDirEntry::ConcatPath(rules_dir, 
  304.                                   GetApp().GetRegSettings().m_CompilersSubdir);
  305.     // temporary fix with const_cast
  306.     (const_cast<auto_ptr<CMsvcCombinedProjectMakefile>&>
  307.         (m_MsvcCombinedProjectMakefile)).reset(new CMsvcCombinedProjectMakefile
  308.                                                   (m_ProjType,
  309.                                                    m_MsvcProjectMakefile.get(),
  310.                                                    rules_dir,
  311.                                                    m_Requires));
  312.     return *m_MsvcCombinedProjectMakefile;
  313. }
  314. bool CMsvcPrjProjectContext::IsRequiresOk(const CProjItem& prj)
  315. {
  316.     ITERATE(list<string>, p, prj.m_Requires) {
  317.         const string& requires = *p;
  318.         if ( !GetApp().GetSite().IsProvided(requires) )
  319.             return false;
  320.     }
  321.     return true;
  322. }
  323. bool CMsvcPrjProjectContext::IsConfigEnabled(const SConfigInfo& config) const
  324. {
  325.     list<string> libs_3party;
  326.     ITERATE(list<string>, p, m_ProjectLibs) {
  327.         const string& lib = *p;
  328.         list<string> components;
  329.         GetApp().GetSite().GetComponents(lib, &components);
  330.         copy(components.begin(), 
  331.              components.end(), back_inserter(libs_3party));
  332.     }
  333.     // Add requires to test : If there is such library and configuration for 
  334.     // this library is disabled then we'll disable this config
  335.     copy(m_Requires.begin(), m_Requires.end(), back_inserter(libs_3party));
  336.     libs_3party.sort();
  337.     libs_3party.unique();
  338.     // Test third-party libs and requires:
  339.     ITERATE(list<string>, p, libs_3party) {
  340.         const string& requires = *p;
  341.         SLibInfo lib_info;
  342.         GetApp().GetSite().GetLibInfo(requires, config, &lib_info);
  343.         
  344.         if ( lib_info.IsEmpty() ) 
  345.             continue;
  346.         if ( !GetApp().GetSite().IsLibEnabledInConfig(requires, config) )
  347.             return false;
  348.     }
  349.     return true;
  350. }
  351. const list<string> CMsvcPrjProjectContext::Defines(const SConfigInfo& cfg_info) const
  352. {
  353.     list<string> defines(m_Defines);
  354.     list<string> libs_list;
  355.     CreateLibsList(&libs_list);
  356.     ITERATE(list<string>, p, libs_list) {
  357.         const string& lib_id = *p;
  358.         SLibInfo lib_info;
  359.         GetApp().GetSite().GetLibInfo(lib_id, cfg_info, &lib_info);
  360.         if ( !lib_info.m_LibDefines.empty() ) {
  361.             copy(lib_info.m_LibDefines.begin(),
  362.                  lib_info.m_LibDefines.end(),
  363.                  back_inserter(defines));
  364.         }
  365.     }
  366.     defines.sort();
  367.     defines.unique();
  368.     return defines;
  369. }
  370. //-----------------------------------------------------------------------------
  371. CMsvcPrjGeneralContext::CMsvcPrjGeneralContext
  372.     (const SConfigInfo&            config, 
  373.      const CMsvcPrjProjectContext& prj_context)
  374.      :m_Config          (config),
  375.       m_MsvcMetaMakefile(GetApp().GetMetaMakefile())
  376. {
  377.     //m_Type
  378.     switch ( prj_context.ProjectType() ) {
  379.     case CProjKey::eLib:
  380.         m_Type = eLib;
  381.         break;
  382.     case CProjKey::eApp:
  383.         m_Type = eExe;
  384.         break;
  385.     case CProjKey::eDll:
  386.         m_Type = eDll;
  387.         break;
  388.     default:
  389.         //TODO - handle Dll(s)
  390.         NCBI_THROW(CProjBulderAppException, eProjectType, 
  391.                         NStr::IntToString(prj_context.ProjectType()));
  392.     }
  393.     
  394.     //m_OutputDirectory;
  395.     // /compilers/msvc7_prj/
  396.     string output_dir_abs = GetApp().GetProjectTreeInfo().m_Compilers;
  397.     output_dir_abs = 
  398.             CDirEntry::ConcatPath(output_dir_abs, 
  399.                                   GetApp().GetRegSettings().m_CompilersSubdir);
  400.     output_dir_abs = 
  401.             CDirEntry::ConcatPath(output_dir_abs, 
  402.                                   GetApp().GetBuildType().GetTypeStr());
  403.     if (m_Type == eLib)
  404.         output_dir_abs = CDirEntry::ConcatPath(output_dir_abs, "lib");
  405.     else if (m_Type == eExe)
  406.         output_dir_abs = CDirEntry::ConcatPath(output_dir_abs, "bin");
  407.     else if (m_Type == eDll) // same dir as exe 
  408.         output_dir_abs = CDirEntry::ConcatPath(output_dir_abs, "bin"); 
  409.     else {
  410.         //TODO - handle Dll(s)
  411.         NCBI_THROW(CProjBulderAppException, 
  412.                    eProjectType, NStr::IntToString(m_Type));
  413.     }
  414.     output_dir_abs = 
  415.         CDirEntry::ConcatPath(output_dir_abs, config.m_Name);
  416.     m_OutputDirectory = 
  417.         CDirEntry::CreateRelativePath(prj_context.ProjectDir(), 
  418.                                       output_dir_abs);
  419. #if 0
  420.     const string project_tag(string(1,CDirEntry::GetPathSeparator()) + 
  421.                              "compilers" +
  422.                              CDirEntry::GetPathSeparator() + 
  423.                              GetApp().GetRegSettings().m_CompilersSubdir +
  424.                              CDirEntry::GetPathSeparator());
  425.     
  426.     string project_dir = prj_context.ProjectDir();
  427.     string output_dir_prefix = 
  428.         string (project_dir, 
  429.                 0, 
  430.                 project_dir.find(project_tag) + project_tag.length());
  431.     
  432.     output_dir_prefix = 
  433.         CDirEntry::ConcatPath(output_dir_prefix, 
  434.                               GetApp().GetBuildType().GetTypeStr());
  435.     if (m_Type == eLib)
  436.         output_dir_prefix = CDirEntry::ConcatPath(output_dir_prefix, "lib");
  437.     else if (m_Type == eExe)
  438.         output_dir_prefix = CDirEntry::ConcatPath(output_dir_prefix, "bin");
  439.     else if (m_Type == eDll) // same dir as exe 
  440.         output_dir_prefix = CDirEntry::ConcatPath(output_dir_prefix, "bin"); 
  441.     else {
  442.         //TODO - handle Dll(s)
  443.         NCBI_THROW(CProjBulderAppException, 
  444.                    eProjectType, NStr::IntToString(m_Type));
  445.     }
  446.     //output to ..staticDebugDLL or ..dllDebugDLL
  447.     string output_dir_abs = 
  448.         CDirEntry::ConcatPath(output_dir_prefix, config.m_Name);
  449.     m_OutputDirectory = 
  450.         CDirEntry::CreateRelativePath(project_dir, output_dir_abs);
  451. #endif
  452. }
  453. //------------------------------------------------------------------------------
  454. static IConfiguration* s_CreateConfiguration
  455.     (const CMsvcPrjGeneralContext& general_context,
  456.      const CMsvcPrjProjectContext& project_context);
  457. static ICompilerTool* s_CreateCompilerTool
  458.     (const CMsvcPrjGeneralContext& general_context,
  459.      const CMsvcPrjProjectContext& project_context);
  460. static ILinkerTool* s_CreateLinkerTool
  461.     (const CMsvcPrjGeneralContext& general_context,
  462.      const CMsvcPrjProjectContext& project_context);
  463. static ILibrarianTool* s_CreateLibrarianTool
  464.     (const CMsvcPrjGeneralContext& general_context,
  465.      const CMsvcPrjProjectContext& project_context);
  466. static IResourceCompilerTool* s_CreateResourceCompilerTool
  467.     (const CMsvcPrjGeneralContext& general_context,
  468.      const CMsvcPrjProjectContext& project_context);
  469. //-----------------------------------------------------------------------------
  470. CMsvcTools::CMsvcTools(const CMsvcPrjGeneralContext& general_context,
  471.                        const CMsvcPrjProjectContext& project_context)
  472. {
  473.     //configuration
  474.     m_Configuration.reset
  475.         (s_CreateConfiguration(general_context, project_context));
  476.     //compiler
  477.     m_Compiler.reset
  478.         (s_CreateCompilerTool(general_context, project_context));
  479.     //Linker:
  480.     m_Linker.reset(s_CreateLinkerTool(general_context, project_context));
  481.     //Librarian
  482.     m_Librarian.reset(s_CreateLibrarianTool
  483.                                      (general_context, project_context));
  484.     //Dummies
  485.     m_CustomBuid.reset    (new CCustomBuildToolDummyImpl());
  486.     m_MIDL.reset          (new CMIDLToolDummyImpl());
  487.     m_PostBuildEvent.reset(new CPostBuildEventToolDummyImpl());
  488.     //Pre-build event - special case for LIB projects
  489.     if (project_context.ProjectType() == CProjKey::eLib) {
  490.         m_PreBuildEvent.reset(new CPreBuildEventToolLibImpl
  491.                                                 (project_context.PreBuilds()));
  492.     } else {
  493.         m_PreBuildEvent.reset(new CPreBuildEventToolDummyImpl());
  494.     }
  495.     m_PreLinkEvent.reset(new CPreLinkEventToolDummyImpl());
  496.     //Resource Compiler
  497.     m_ResourceCompiler.reset(s_CreateResourceCompilerTool
  498.                                      (general_context,project_context));
  499.     //Dummies
  500.     m_WebServiceProxyGenerator.reset
  501.         (new CWebServiceProxyGeneratorToolDummyImpl());
  502.     m_XMLDataGenerator.reset
  503.         (new CXMLDataGeneratorToolDummyImpl());
  504.     m_ManagedWrapperGenerator.reset
  505.         (new CManagedWrapperGeneratorToolDummyImpl());
  506.     m_AuxiliaryManagedWrapperGenerator.reset
  507.         (new CAuxiliaryManagedWrapperGeneratorToolDummyImpl());
  508. }
  509. IConfiguration* CMsvcTools::Configuration(void) const
  510. {
  511.     return m_Configuration.get();
  512. }
  513. ICompilerTool* CMsvcTools::Compiler(void) const
  514. {
  515.     return m_Compiler.get();
  516. }
  517. ILinkerTool* CMsvcTools::Linker(void) const
  518. {
  519.     return m_Linker.get();
  520. }
  521. ILibrarianTool* CMsvcTools::Librarian(void) const
  522. {
  523.     return m_Librarian.get();
  524. }
  525. ICustomBuildTool* CMsvcTools::CustomBuid(void) const
  526. {
  527.     return m_CustomBuid.get();
  528. }
  529. IMIDLTool* CMsvcTools::MIDL(void) const
  530. {
  531.     return m_MIDL.get();
  532. }
  533. IPostBuildEventTool* CMsvcTools::PostBuildEvent(void) const
  534. {
  535.     return m_PostBuildEvent.get();
  536. }
  537. IPreBuildEventTool* CMsvcTools::PreBuildEvent(void) const
  538. {
  539.     return m_PreBuildEvent.get();
  540. }
  541. IPreLinkEventTool* CMsvcTools::PreLinkEvent(void) const
  542. {
  543.     return m_PreLinkEvent.get();
  544. }
  545. IResourceCompilerTool* CMsvcTools::ResourceCompiler(void) const
  546. {
  547.     return m_ResourceCompiler.get();
  548. }
  549. IWebServiceProxyGeneratorTool* CMsvcTools::WebServiceProxyGenerator(void) const
  550. {
  551.     return m_WebServiceProxyGenerator.get();
  552. }
  553. IXMLDataGeneratorTool* CMsvcTools::XMLDataGenerator(void) const
  554. {
  555.     return m_XMLDataGenerator.get();
  556. }
  557. IManagedWrapperGeneratorTool* CMsvcTools::ManagedWrapperGenerator(void) const
  558. {
  559.     return m_ManagedWrapperGenerator.get();
  560. }
  561. IAuxiliaryManagedWrapperGeneratorTool* 
  562.                        CMsvcTools::AuxiliaryManagedWrapperGenerator(void) const
  563. {
  564.     return m_AuxiliaryManagedWrapperGenerator.get();
  565. }
  566. CMsvcTools::~CMsvcTools()
  567. {
  568. }
  569. static bool s_IsExe(const CMsvcPrjGeneralContext& general_context,
  570.                     const CMsvcPrjProjectContext& project_context)
  571. {
  572.     return general_context.m_Type == CMsvcPrjGeneralContext::eExe;
  573. }
  574. static bool s_IsLib(const CMsvcPrjGeneralContext& general_context,
  575.                     const CMsvcPrjProjectContext& project_context)
  576. {
  577.     return general_context.m_Type == CMsvcPrjGeneralContext::eLib;
  578. }
  579. static bool s_IsDll(const CMsvcPrjGeneralContext& general_context,
  580.                     const CMsvcPrjProjectContext& project_context)
  581. {
  582.     return general_context.m_Type == CMsvcPrjGeneralContext::eDll;
  583. }
  584. static bool s_IsDebug(const CMsvcPrjGeneralContext& general_context,
  585.                       const CMsvcPrjProjectContext& project_context)
  586. {
  587.     return general_context.m_Config.m_Debug;
  588. }
  589. static bool s_IsRelease(const CMsvcPrjGeneralContext& general_context,
  590.                         const CMsvcPrjProjectContext& project_context)
  591. {
  592.     return !(general_context.m_Config.m_Debug);
  593. }
  594. //-----------------------------------------------------------------------------
  595. // Creators:
  596. static IConfiguration* 
  597. s_CreateConfiguration(const CMsvcPrjGeneralContext& general_context,
  598.                       const CMsvcPrjProjectContext& project_context)
  599. {
  600.     if ( s_IsExe(general_context, project_context) )
  601.     return new CConfigurationImpl<SApp>
  602.                        (general_context.OutputDirectory(), 
  603.                         general_context.ConfigurationName());
  604.     if ( s_IsLib(general_context, project_context) )
  605.     return new CConfigurationImpl<SLib>
  606.                         (general_context.OutputDirectory(), 
  607.                          general_context.ConfigurationName());
  608.     if ( s_IsDll(general_context, project_context) )
  609.     return new CConfigurationImpl<SDll>
  610.                         (general_context.OutputDirectory(), 
  611.                          general_context.ConfigurationName());
  612.     return NULL;
  613. }
  614. static ICompilerTool* 
  615. s_CreateCompilerTool(const CMsvcPrjGeneralContext& general_context,
  616.  const CMsvcPrjProjectContext& project_context)
  617. {
  618.     return new CCompilerToolImpl
  619.        (project_context.AdditionalIncludeDirectories(general_context.m_Config),
  620.         project_context.GetMsvcProjectMakefile(),
  621.         general_context.m_Config.m_RuntimeLibrary,
  622.         general_context.GetMsvcMetaMakefile(),
  623.         general_context.m_Config,
  624.         general_context.m_Type,
  625.         project_context.Defines(general_context.m_Config));
  626. }
  627. static ILinkerTool* 
  628. s_CreateLinkerTool(const CMsvcPrjGeneralContext& general_context,
  629.                    const CMsvcPrjProjectContext& project_context)
  630. {
  631.     //---- EXE ----
  632.     if ( s_IsExe  (general_context, project_context) )
  633.         return new CLinkerToolImpl<SApp>
  634.                        (project_context.AdditionalLinkerOptions
  635.                                             (general_context.m_Config),
  636.                         project_context.AdditionalLibraryDirectories
  637.                                             (general_context.m_Config),
  638.                         project_context.ProjectId(),
  639.                         project_context.GetMsvcProjectMakefile(),
  640.                         general_context.GetMsvcMetaMakefile(),
  641.                         general_context.m_Config);
  642.     //---- LIB ----
  643.     if ( s_IsLib(general_context, project_context) )
  644.         return new CLinkerToolDummyImpl();
  645.     //---- DLL ----
  646.     if ( s_IsDll  (general_context, project_context) )
  647.         return new CLinkerToolImpl<SDll>
  648.                        (project_context.AdditionalLinkerOptions
  649.                                             (general_context.m_Config),
  650.                         project_context.AdditionalLibraryDirectories
  651.                                             (general_context.m_Config),
  652.                         project_context.ProjectId(),
  653.                         project_context.GetMsvcProjectMakefile(),
  654.                         general_context.GetMsvcMetaMakefile(),
  655.                         general_context.m_Config);
  656.     // unsupported tool
  657.     return NULL;
  658. }
  659. static ILibrarianTool* 
  660. s_CreateLibrarianTool(const CMsvcPrjGeneralContext& general_context,
  661.                       const CMsvcPrjProjectContext& project_context)
  662. {
  663.     if ( s_IsLib  (general_context, project_context) )
  664.     return new CLibrarianToolImpl
  665.                                 (project_context.ProjectId(),
  666.                                  project_context.GetMsvcProjectMakefile(),
  667.                                  general_context.GetMsvcMetaMakefile(),
  668.                                  general_context.m_Config);
  669.     // dummy tool
  670.     return new CLibrarianToolDummyImpl();
  671. }
  672. static IResourceCompilerTool* s_CreateResourceCompilerTool
  673.                                 (const CMsvcPrjGeneralContext& general_context,
  674.                                  const CMsvcPrjProjectContext& project_context)
  675. {
  676.     if ( s_IsDll  (general_context, project_context)  &&
  677.          s_IsDebug(general_context, project_context) )
  678.         return new CResourceCompilerToolImpl<SDebug>
  679.        (project_context.AdditionalIncludeDirectories(general_context.m_Config),
  680.         project_context.GetMsvcProjectMakefile(),
  681.         general_context.GetMsvcMetaMakefile(),
  682.         general_context.m_Config);
  683.     if ( s_IsDll    (general_context, project_context)  &&
  684.          s_IsRelease(general_context, project_context) )
  685.         return new CResourceCompilerToolImpl<SRelease>
  686.        (project_context.AdditionalIncludeDirectories(general_context.m_Config),
  687.         project_context.GetMsvcProjectMakefile(),
  688.         general_context.GetMsvcMetaMakefile(),
  689.         general_context.m_Config);
  690.     if ( s_IsExe  (general_context, project_context)  &&
  691.          s_IsDebug(general_context, project_context) )
  692.         return new CResourceCompilerToolImpl<SDebug>
  693.        (project_context.AdditionalIncludeDirectories(general_context.m_Config),
  694.         project_context.GetMsvcProjectMakefile(),
  695.         general_context.GetMsvcMetaMakefile(),
  696.         general_context.m_Config);
  697.     if ( s_IsExe    (general_context, project_context)  &&
  698.          s_IsRelease(general_context, project_context) )
  699.         return new CResourceCompilerToolImpl<SRelease>
  700.        (project_context.AdditionalIncludeDirectories(general_context.m_Config),
  701.         project_context.GetMsvcProjectMakefile(),
  702.         general_context.GetMsvcMetaMakefile(),
  703.         general_context.m_Config);
  704.     // dummy tool
  705.     return new CResourceCompilerToolDummyImpl();
  706. }
  707. END_NCBI_SCOPE
  708. /*
  709.  * ===========================================================================
  710.  * $Log: msvc_project_context.cpp,v $
  711.  * Revision 1000.4  2004/06/16 17:02:34  gouriano
  712.  * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.33
  713.  *
  714.  * Revision 1.33  2004/06/15 19:01:40  gorelenk
  715.  * Fixed compilation errors on GCC 2.95 .
  716.  *
  717.  * Revision 1.32  2004/06/10 15:16:46  gorelenk
  718.  * Changed macrodefines to be comply with GCC 3.4.0 .
  719.  *
  720.  * Revision 1.31  2004/06/07 19:16:07  gorelenk
  721.  * + Taking into account 'impl' in creation of header dir list.
  722.  *
  723.  * Revision 1.30  2004/06/07 13:56:17  gorelenk
  724.  * Changed CMsvcPrjProjectContext::GetMsvcProjectMakefile to accomodate
  725.  * project creation rules.
  726.  *
  727.  * Revision 1.29  2004/05/21 21:41:41  gorelenk
  728.  * Added PCH ncbi_pch.hpp
  729.  *
  730.  * Revision 1.28  2004/05/11 15:55:03  gorelenk
  731.  * Changed CMsvcPrjProjectContext::IsConfigEnabled - added test REQUIRES.
  732.  *
  733.  * Revision 1.27  2004/05/10 19:52:04  gorelenk
  734.  * Changed CMsvcPrjProjectContext class constructor .
  735.  *
  736.  * Revision 1.26  2004/04/19 15:44:50  gorelenk
  737.  * Changed implementation of class CMsvcPrjProjectContext constructor:
  738.  * added lib choice test while creating list of dependencies (m_ProjectLibs).
  739.  *
  740.  * Revision 1.25  2004/04/13 17:08:55  gorelenk
  741.  * Changed implementation of class CMsvcPrjProjectContext constructor.
  742.  *
  743.  * Revision 1.24  2004/03/22 14:50:50  gorelenk
  744.  * Removed implementation of
  745.  * CMsvcPrjProjectContext::AdditionalLibrarianOptions .
  746.  * Added implemetation of CMsvcPrjProjectContext::Defines .
  747.  *
  748.  * Revision 1.23  2004/03/16 21:46:17  gorelenk
  749.  * Changed implementation of
  750.  * CMsvcPrjProjectContext::AdditionalIncludeDirectories : implemented
  751.  * uniqueness of include dirs from 3-party libraries.
  752.  *
  753.  * Revision 1.22  2004/03/16 16:37:33  gorelenk
  754.  * Changed msvc7_prj subdirs structure: Separated "static" and "dll" branches.
  755.  *
  756.  * Revision 1.21  2004/03/10 21:28:42  gorelenk
  757.  * Changed implementation of class CMsvcPrjProjectContext constructor.
  758.  *
  759.  * Revision 1.20  2004/03/10 16:44:21  gorelenk
  760.  * Changed implementation of class CMsvcPrjProjectContext.
  761.  *
  762.  * Revision 1.19  2004/03/08 23:36:11  gorelenk
  763.  * Changed implementation of class CMsvcPrjProjectContext constructor.
  764.  *
  765.  * Revision 1.18  2004/03/02 23:33:55  gorelenk
  766.  * Changed implementation of class CMsvcPrjGeneralContext constructor.
  767.  *
  768.  * Revision 1.17  2004/02/26 15:15:38  gorelenk
  769.  * Changed implementation of CMsvcPrjProjectContext::IsConfigEnabled.
  770.  *
  771.  * Revision 1.16  2004/02/24 20:54:26  gorelenk
  772.  * Added implementation of member-function bool IsConfigEnabled
  773.  * of class CMsvcPrjProjectContext.
  774.  *
  775.  * Revision 1.15  2004/02/24 18:13:26  gorelenk
  776.  * Changed implementation of class CMsvcPrjProjectContext constructor.
  777.  * Changed implementation of member-function AdditionalLinkerOptions of
  778.  * class CMsvcPrjProjectContext.
  779.  *
  780.  * Revision 1.14  2004/02/23 20:58:41  gorelenk
  781.  * Fixed double properties apperience in generated MSVC projects.
  782.  *
  783.  * Revision 1.13  2004/02/23 20:42:57  gorelenk
  784.  * Added support of MSVC ResourceCompiler tool.
  785.  *
  786.  * Revision 1.12  2004/02/20 22:53:26  gorelenk
  787.  * Added analysis of ASN projects depends.
  788.  *
  789.  * Revision 1.11  2004/02/06 23:14:59  gorelenk
  790.  * Implemented support of ASN projects, semi-auto configure,
  791.  * CPPFLAGS support. Second working version.
  792.  *
  793.  * Revision 1.10  2004/02/05 16:28:47  gorelenk
  794.  * GetComponents was moved to class CMsvcSite.
  795.  *
  796.  * Revision 1.9  2004/02/05 00:02:08  gorelenk
  797.  * Added support of user site and  Makefile defines.
  798.  *
  799.  * Revision 1.8  2004/02/03 17:17:38  gorelenk
  800.  * Changed implementation of class CMsvcPrjProjectContext constructor.
  801.  *
  802.  * Revision 1.7  2004/01/29 15:46:44  gorelenk
  803.  * Added support of default libs, defined in user site
  804.  *
  805.  * Revision 1.6  2004/01/28 17:55:49  gorelenk
  806.  * += For msvc makefile support of :
  807.  *                 Requires tag, ExcludeProject tag,
  808.  *                 AddToProject section (SourceFiles and IncludeDirs),
  809.  *                 CustomBuild section.
  810.  * += For support of user local site.
  811.  *
  812.  * Revision 1.5  2004/01/26 19:27:29  gorelenk
  813.  * += MSVC meta makefile support
  814.  * += MSVC project makefile support
  815.  *
  816.  * Revision 1.4  2004/01/22 17:57:54  gorelenk
  817.  * first version
  818.  *
  819.  * ===========================================================================
  820.  */