📄 proj_builder_app.cpp
字号:
}}#else {{ // Implicit/Exclicit exclude by msvc Makefiles.in.msvc PIsExcludedByProjectMakefile p_project_makefile; EraseIf(projects_tree.m_Projects, p_project_makefile); }}#endif {{ // Project requires are not provided EraseIf(projects_tree.m_Projects, PIsExcludedByRequires()); }} if (GetBuildType().GetType() == CBuildType::eStatic) { // Static build // Projects CMsvcProjectGenerator prj_gen(GetRegSettings().m_ConfigInfo); ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) { prj_gen.Generate(p->second); } //Utility projects dir string utility_projects_dir = CDirEntry(m_Solution).GetDir(); utility_projects_dir = CDirEntry::ConcatPath(utility_projects_dir, "UtilityProjects"); utility_projects_dir = CDirEntry::AddTrailingPathSeparator(utility_projects_dir); // MasterProject CMsvcMasterProjectGenerator master_prj_gen(projects_tree, GetRegSettings().m_ConfigInfo, utility_projects_dir); master_prj_gen.SaveProject(); // ConfigureProject string output_dir = GetProjectTreeInfo().m_Compilers; output_dir = CDirEntry::ConcatPath(output_dir, GetRegSettings().m_CompilersSubdir); output_dir = CDirEntry::ConcatPath(output_dir, GetBuildType().GetTypeStr()); output_dir = CDirEntry::ConcatPath(output_dir, "bin"); output_dir = CDirEntry::AddTrailingPathSeparator(output_dir); CMsvcConfigureProjectGenerator configure_generator (output_dir, GetRegSettings().m_ConfigInfo, false, utility_projects_dir, GetProjectTreeInfo().m_Root, GetArgs()["subtree"].AsString(), m_Solution); configure_generator.SaveProject(); // INDEX dummy project CVisualStudioProject index_xmlprj; CreateUtilityProject(" INDEX, see here: ", GetRegSettings().m_ConfigInfo, &index_xmlprj); string index_prj_path = CDirEntry::ConcatPath(utility_projects_dir, "_INDEX_"); index_prj_path += MSVC_PROJECT_FILE_EXT; SaveIfNewer(index_prj_path, index_xmlprj); // // BuildAll utility project CVisualStudioProject build_all_xmlprj; CreateUtilityProject("-BUILD-ALL-", GetRegSettings().m_ConfigInfo, &build_all_xmlprj); string build_all_prj_path = CDirEntry::ConcatPath(utility_projects_dir, "_BUILD_ALL_"); build_all_prj_path += MSVC_PROJECT_FILE_EXT; SaveIfNewer(build_all_prj_path, build_all_xmlprj); // // Solution CMsvcSolutionGenerator sln_gen(GetRegSettings().m_ConfigInfo); ITERATE(CProjectItemsTree::TProjects, p, projects_tree.m_Projects) { sln_gen.AddProject(p->second); } sln_gen.AddUtilityProject (master_prj_gen.GetPath()); sln_gen.AddUtilityProject (configure_generator.GetPath()); sln_gen.AddUtilityProject (index_prj_path); sln_gen.AddBuildAllProject(build_all_prj_path); sln_gen.SaveSolution(m_Solution); } if (GetBuildType().GetType() == CBuildType::eDll) { //Dll build list<SConfigInfo> dll_configs; GetDllsInfo().GetBuildConfigs(&dll_configs); CProjectItemsTree dll_projects_tree; CreateDllBuildTree(projects_tree, &dll_projects_tree); // Projects CMsvcProjectGenerator prj_gen(dll_configs); ITERATE(CProjectItemsTree::TProjects, p, dll_projects_tree.m_Projects) { prj_gen.Generate(p->second); } //Utility projects dir string utility_projects_dir = CDirEntry(m_Solution).GetDir(); utility_projects_dir = CDirEntry::ConcatPath(utility_projects_dir, "UtilityProjects"); utility_projects_dir = CDirEntry::AddTrailingPathSeparator(utility_projects_dir); // MasterProject CMsvcMasterProjectGenerator master_prj_gen(dll_projects_tree, dll_configs, utility_projects_dir); master_prj_gen.SaveProject(); // ConfigureProject string output_dir = GetProjectTreeInfo().m_Compilers; output_dir = CDirEntry::ConcatPath(output_dir, GetRegSettings().m_CompilersSubdir); output_dir = CDirEntry::ConcatPath(output_dir, "static"); output_dir = CDirEntry::ConcatPath(output_dir, "bin"); output_dir = CDirEntry::AddTrailingPathSeparator(output_dir); CMsvcConfigureProjectGenerator configure_generator (output_dir, dll_configs, true, utility_projects_dir, GetProjectTreeInfo().m_Root, GetArgs()["subtree"].AsString(), m_Solution); configure_generator.SaveProject(); // INDEX dummy project CVisualStudioProject index_xmlprj; CreateUtilityProject(" INDEX, see here: ", dll_configs, &index_xmlprj); string index_prj_path = CDirEntry::ConcatPath(utility_projects_dir, "_INDEX_"); index_prj_path += MSVC_PROJECT_FILE_EXT; SaveIfNewer(index_prj_path, index_xmlprj); // // BuildAll utility project CVisualStudioProject build_all_xmlprj; CreateUtilityProject("-BUILD-ALL-", dll_configs, &build_all_xmlprj); string build_all_prj_path = CDirEntry::ConcatPath(utility_projects_dir, "_BUILD_ALL_"); build_all_prj_path += MSVC_PROJECT_FILE_EXT; SaveIfNewer(build_all_prj_path, build_all_xmlprj); // // Solution CMsvcSolutionGenerator sln_gen(dll_configs); ITERATE(CProjectItemsTree::TProjects, p, dll_projects_tree.m_Projects) { sln_gen.AddProject(p->second); } sln_gen.AddUtilityProject (master_prj_gen.GetPath()); sln_gen.AddUtilityProject (configure_generator.GetPath()); sln_gen.AddUtilityProject (index_prj_path); sln_gen.AddBuildAllProject(build_all_prj_path); sln_gen.SaveSolution(m_Solution); } // LOG_POST(Info << "Finished at "+ CTime(CTime::eCurrent).AsString()); return 0;}void CProjBulderApp::Exit(void){ //TODO}void CProjBulderApp::ParseArguments(void){ CArgs args = GetArgs(); /// Root dir of building tree, /// src child dir of Root, /// Subtree to buil (default is m_RootSrc) /// are provided by SProjectTreeInfo (see GetProjectTreeInfo(void) below) // Solution m_Solution = CDirEntry::NormalizePath(args["solution"].AsString());}int CProjBulderApp::EnumOpt(const string& enum_name, const string& enum_val) const{ int opt = GetConfig().GetInt(enum_name, enum_val, -1); if (opt == -1) { NCBI_THROW(CProjBulderAppException, eEnumValue, enum_name + "::" + enum_val); } return opt;}void CProjBulderApp::DumpFiles(const TFiles& files, const string& filename) const{ CNcbiOfstream ofs(filename.c_str(), IOS_BASE::out | IOS_BASE::trunc); if ( !ofs ) { NCBI_THROW(CProjBulderAppException, eFileCreation, filename); } ITERATE(TFiles, p, files) { ofs << "+++++++++++++++++++++++++\n"; ofs << p->first << endl; p->second.Dump(ofs); ofs << "-------------------------\n"; }}void CProjBulderApp::GetMetaDataFiles(list<string>* files) const{ files->clear(); string files_str = GetConfig().GetString("ProjectTree", "MetaData", ""); NStr::Split(files_str, LIST_SEPARATOR, *files);}void CProjBulderApp::GetBuildConfigs(list<SConfigInfo>* configs) const{ configs->clear(); string config_str = GetConfig().GetString("msvc7", "Configurations", ""); list<string> configs_list; NStr::Split(config_str, LIST_SEPARATOR, configs_list); LoadConfigInfoByNames(GetConfig(), configs_list, configs);}const CMsvc7RegSettings& CProjBulderApp::GetRegSettings(void){ if ( !m_MsvcRegSettings.get() ) { m_MsvcRegSettings.reset(new CMsvc7RegSettings()); m_MsvcRegSettings->m_Version = GetConfig().GetString("msvc7", "Version", "7.10"); GetBuildConfigs(&m_MsvcRegSettings->m_ConfigInfo); m_MsvcRegSettings->m_CompilersSubdir = GetConfig().GetString("msvc7", "compilers", "msvc710_prj"); m_MsvcRegSettings->m_ProjectsSubdir = GetConfig().GetString("msvc7", "Projects", "build"); m_MsvcRegSettings->m_MakefilesExt = GetConfig().GetString("msvc7", "MakefilesExt", "msvc"); m_MsvcRegSettings->m_MetaMakefile = GetConfig().GetString("msvc7", "MetaMakefile", ""); m_MsvcRegSettings->m_DllInfo = GetConfig().GetString("msvc7", "DllInfo", ""); } return *m_MsvcRegSettings;}const CMsvcSite& CProjBulderApp::GetSite(void){ if ( !m_MsvcSite.get() ) m_MsvcSite.reset(new CMsvcSite(GetConfig())); return *m_MsvcSite;}const CMsvcMetaMakefile& CProjBulderApp::GetMetaMakefile(void){ if ( !m_MsvcMetaMakefile.get() ) { //Metamakefile must be in RootSrc directory m_MsvcMetaMakefile.reset(new CMsvcMetaMakefile (CDirEntry::ConcatPath(GetProjectTreeInfo().m_Src, GetRegSettings().m_MetaMakefile))); //Metamakefile must present and must not be empty if ( m_MsvcMetaMakefile->IsEmpty() ) NCBI_THROW(CProjBulderAppException, eMetaMakefile, GetRegSettings().m_MetaMakefile); } return *m_MsvcMetaMakefile;}const SProjectTreeInfo& CProjBulderApp::GetProjectTreeInfo(void){ if ( m_ProjectTreeInfo.get() ) return *m_ProjectTreeInfo; m_ProjectTreeInfo.reset(new SProjectTreeInfo); CArgs args = GetArgs(); // Root, etc. string root = args["root"].AsString(); root = CDirEntry::AddTrailingPathSeparator(root); root = CDirEntry::NormalizePath(root); root = CDirEntry::AddTrailingPathSeparator(root); m_ProjectTreeInfo->m_Root = root; /// <include> branch of tree string include = GetConfig().GetString("ProjectTree", "include", ""); m_ProjectTreeInfo->m_Include = CDirEntry::ConcatPath(m_ProjectTreeInfo->m_Root, include); m_ProjectTreeInfo->m_Include =
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -