1 #ifndef PROJECT_TREE_BUILDER__TOOLS_IMPLEMENT__HPP
2 #define PROJECT_TREE_BUILDER__TOOLS_IMPLEMENT__HPP
3 
4 /* $Id: msvc_tools_implement.hpp 585862 2019-05-06 15:07:51Z gouriano $
5  * ===========================================================================
6  *
7  *                            PUBLIC DOMAIN NOTICE
8  *               National Center for Biotechnology Information
9  *
10  *  This software/database is a "United States Government Work" under the
11  *  terms of the United States Copyright Act.  It was written as part of
12  *  the author's official duties as a United States Government employee and
13  *  thus cannot be copyrighted.  This software/database is freely available
14  *  to the public for use. The National Library of Medicine and the U.S.
15  *  Government have not placed any restriction on its use or reproduction.
16  *
17  *  Although all reasonable efforts have been taken to ensure the accuracy
18  *  and reliability of the software and data, the NLM and the U.S.
19  *  Government do not and cannot warrant the performance or results that
20  *  may be obtained by using this software or data. The NLM and the U.S.
21  *  Government disclaim all warranties, express or implied, including
22  *  warranties of performance, merchantability or fitness for any particular
23  *  purpose.
24  *
25  *  Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Author:  Viatcheslav Gorelenkov
30  *
31  */
32 
33 
34 #include <string>
35 
36 #include "msvc_project_context.hpp"
37 #include "msvc_traits.hpp"
38 #include "msvc_prj_utils.hpp"
39 
40 #include <corelib/ncbienv.hpp>
41 
42 BEGIN_NCBI_SCOPE
43 
44 /////////////////////////////////////////////////////////////////////////////
45 ///
46 /// CConfigurationImpl --
47 ///
48 /// Implementation of IConfiguration interface.
49 ///
50 /// Accepts trait class as a template parameter.
51 
52 template <class ConfTrait>
53 class CConfigurationImpl : public IConfiguration
54 {
55 public:
CConfigurationImpl(const string & output_directory,const string & configuration_name,const IMsvcMetaMakefile & project_makefile,const IMsvcMetaMakefile & meta_makefile,const SConfigInfo & config)56     CConfigurationImpl(	const string& output_directory,
57                         const string& configuration_name,
58                         const IMsvcMetaMakefile& project_makefile,
59                         const IMsvcMetaMakefile& meta_makefile,
60                         const SConfigInfo&       config )
61                         :m_OutputDirectory  (output_directory),
62                          m_ConfigurationName(configuration_name),
63                          m_MsvcProjectMakefile         (project_makefile),
64                          m_MsvcMetaMakefile            (meta_makefile),
65                          m_Config                      (config)
66     {
67     }
68 
69 #define SUPPORT_CONFIGURATION_OPTION(opt) \
70     virtual string opt(void) const \
71     { \
72         return GetConfigurationOpt(m_MsvcMetaMakefile, \
73                               m_MsvcProjectMakefile, \
74                               #opt, \
75                               m_Config ); \
76     }
77 
Name(void) const78     virtual string Name(void) const
79     {
80 	    return ConfigName(m_ConfigurationName);
81     }
OutputDirectory(void) const82     virtual string OutputDirectory(void) const
83     {
84 	    return m_OutputDirectory;
85     }
IntermediateDirectory(void) const86     virtual string IntermediateDirectory(void) const
87     {
88         if (CMsvc7RegSettings::GetMsvcPlatform() < CMsvc7RegSettings::eUnix) {
89 	        return CDirEntry::AddTrailingPathSeparator(
90                 CDirEntry::ConcatPath(
91                     CMsvc7RegSettings::GetConfigNameKeyword(),"$(TargetName)"));
92         }
93 	    return CDirEntry::AddTrailingPathSeparator(
94                 CMsvc7RegSettings::GetConfigNameKeyword());
95     }
ConfigurationType(void) const96     virtual string ConfigurationType(void) const
97     {
98 	    return CMsvcMetaMakefile::TranslateOpt(
99 	        ConfTrait::ConfigurationType(),"Configuration","ConfigurationType");
100     }
101 #if 1
CharacterSet(void) const102     virtual string CharacterSet(void) const
103     {
104         if (m_Config.m_Unicode) {
105             return CMsvcMetaMakefile::TranslateOpt("1","Configuration","CharacterSet");
106         }
107         string val = GetConfigurationOpt(
108             m_MsvcMetaMakefile, m_MsvcProjectMakefile,
109             "CharacterSet",m_Config );
110         if (val.empty()) {
111             val = CMsvcMetaMakefile::TranslateOpt("2","Configuration","CharacterSet");
112         }
113         return val;
114     }
115 #else
116     SUPPORT_CONFIGURATION_OPTION(CharacterSet)
117 #endif
SUPPORT_CONFIGURATION_OPTION(PlatformToolset)118     SUPPORT_CONFIGURATION_OPTION(PlatformToolset)
119     virtual string BuildLogFile(void) const
120     {
121 	    return "$(IntDir)BuildLog_$(TargetName).htm";
122     }
123 
124 
125 private:
126     string m_OutputDirectory;
127     string m_ConfigurationName;
128     const IMsvcMetaMakefile& m_MsvcProjectMakefile;
129     const IMsvcMetaMakefile& m_MsvcMetaMakefile;
130     SConfigInfo              m_Config;
131 
132     CConfigurationImpl(void);
133     CConfigurationImpl(const CConfigurationImpl&);
134     CConfigurationImpl& operator= (const CConfigurationImpl&);
135 };
136 
137 
s_GetDefaultPreprocessorDefinitions(const SConfigInfo & config,CMsvcPrjGeneralContext::TTargetType target_type)138 static string s_GetDefaultPreprocessorDefinitions
139                             (const SConfigInfo&                   config,
140                              CMsvcPrjGeneralContext::TTargetType  target_type)
141 {
142     string defines = config.m_Debug ? "_DEBUG;" : "NDEBUG;" ;
143     switch (target_type) {
144     case CMsvcPrjGeneralContext::eLib:
145         defines +=  "WIN32;_LIB;";
146         break;
147     case CMsvcPrjGeneralContext::eExe:
148         defines += "WIN32;_CONSOLE;NCBI_APP_BUILT_AS=$(TargetName);";
149         break;
150     case CMsvcPrjGeneralContext::eDll:
151         defines += "WIN32;_WINDOWS;_USRDLL;";
152         break;
153     default:
154         break;
155     }
156     return defines;
157 }
158 
159 
160 /////////////////////////////////////////////////////////////////////////////
161 ///
162 /// CCompilerToolImpl --
163 ///
164 /// Implementation of ICompilerTool interface.
165 ///
166 /// Uses msvc makefiles information
167 class CCompilerToolImpl : public ICompilerTool
168 {
169 public:
170     typedef CMsvcPrjGeneralContext::TTargetType TTargetType;
171 
CCompilerToolImpl(const string & additional_include_dirs,const IMsvcMetaMakefile & project_makefile,const string & runtimeLibraryOption,const IMsvcMetaMakefile & meta_makefile,const SConfigInfo & config,TTargetType target_type,const list<string> & defines,const string & project_id)172     CCompilerToolImpl(const string&            additional_include_dirs,
173                       const IMsvcMetaMakefile& project_makefile,
174                       const string&            runtimeLibraryOption,
175                       const IMsvcMetaMakefile& meta_makefile,
176                       const SConfigInfo&       config,
177                       TTargetType              target_type,
178                       const list<string>&      defines,
179                       const string&            project_id)
180 	    :m_AdditionalIncludeDirectories(additional_include_dirs),
181          m_MsvcProjectMakefile         (project_makefile),
182          m_RuntimeLibraryOption        (runtimeLibraryOption),
183          m_MsvcMetaMakefile            (meta_makefile),
184          m_Config                      (config),
185          m_Defines                     (defines),
186          m_TargetType                  (target_type),
187 		 m_ProjectId                   (project_id)
188     {
189     }
190 
Name(void) const191     virtual string Name(void) const
192     {
193 	    return "VCCLCompilerTool";
194     }
195 
196 #define SUPPORT_COMPILER_OPTION(opt) \
197     virtual string opt(void) const \
198     { \
199         return GetCompilerOpt(m_MsvcMetaMakefile, \
200                               m_MsvcProjectMakefile, \
201                               #opt, \
202                               m_Config ); \
203     }
204 
SUPPORT_COMPILER_OPTION(Optimization)205     SUPPORT_COMPILER_OPTION(Optimization)
206 
207     virtual string AdditionalIncludeDirectories(void) const
208     {
209 	    return m_AdditionalIncludeDirectories;
210     }
211 
212     //SUPPORT_COMPILER_OPTION(PreprocessorDefinitions)
PreprocessorDefinitions(void) const213     virtual string PreprocessorDefinitions(void) const
214     {
215         string defines =
216             s_GetDefaultPreprocessorDefinitions(m_Config, m_TargetType);
217 
218         ITERATE(list<string>, p, m_Defines) {
219             const string& define = *p;
220             defines += define;
221             defines += ';';
222         }
223 
224         string opt("PreprocessorDefinitions");
225         string val;
226         val = m_MsvcProjectMakefile.GetCompilerOpt(opt, m_Config);
227         if (!val.empty()) {
228             defines += val;
229             defines += ';';
230         }
231 
232         if ( CMsvc7RegSettings::GetMsvcVersion() < CMsvc7RegSettings::eMsvc1000 ) {
233             val = m_MsvcMetaMakefile.GetCompilerOpt(opt, m_Config);
234             if (!val.empty()) {
235                 defines += val;
236             }
237         } else {
238             defines += "%(PreprocessorDefinitions)";
239         }
240         return defines;
241     }
242 
243     SUPPORT_COMPILER_OPTION(MinimalRebuild)
SUPPORT_COMPILER_OPTION(BasicRuntimeChecks)244     SUPPORT_COMPILER_OPTION(BasicRuntimeChecks)
245     SUPPORT_COMPILER_OPTION(RuntimeLibrary)
246     SUPPORT_COMPILER_OPTION(RuntimeTypeInfo)
247     SUPPORT_COMPILER_OPTION(UsePrecompiledHeader)
248     SUPPORT_COMPILER_OPTION(WarningLevel)
249     SUPPORT_COMPILER_OPTION(Detect64BitPortabilityProblems)
250     virtual string DebugInformationFormat(void) const
251     {
252         if (m_Config.m_VTuneAddon) {
253             return CMsvcMetaMakefile::TranslateOpt("3", "Compiler", "DebugInformationFormat");
254         }
255         return GetCompilerOpt(m_MsvcMetaMakefile,
256                               m_MsvcProjectMakefile,
257                               "DebugInformationFormat",
258                               m_Config );
259     }
260     SUPPORT_COMPILER_OPTION(CompileAs)
261     SUPPORT_COMPILER_OPTION(InlineFunctionExpansion)
262     SUPPORT_COMPILER_OPTION(OmitFramePointers)
263     SUPPORT_COMPILER_OPTION(StringPooling)
264     SUPPORT_COMPILER_OPTION(EnableFunctionLevelLinking)
265 
266     SUPPORT_COMPILER_OPTION(OptimizeForProcessor)
267     SUPPORT_COMPILER_OPTION(StructMemberAlignment)
268     SUPPORT_COMPILER_OPTION(CallingConvention)
269     SUPPORT_COMPILER_OPTION(IgnoreStandardIncludePath)
270     SUPPORT_COMPILER_OPTION(ExceptionHandling)
271     SUPPORT_COMPILER_OPTION(BufferSecurityCheck)
272     SUPPORT_COMPILER_OPTION(DisableSpecificWarnings)
273     SUPPORT_COMPILER_OPTION(UndefinePreprocessorDefinitions)
274     SUPPORT_COMPILER_OPTION(AdditionalOptions)
275     SUPPORT_COMPILER_OPTION(GlobalOptimizations)
276     SUPPORT_COMPILER_OPTION(FavorSizeOrSpeed)
277     SUPPORT_COMPILER_OPTION(BrowseInformation)
278     SUPPORT_COMPILER_OPTION(ProgramDataBaseFileName)
279 
280 private:
281     string                   m_AdditionalIncludeDirectories;
282     const IMsvcMetaMakefile& m_MsvcProjectMakefile;
283     string                   m_RuntimeLibraryOption;
284     const IMsvcMetaMakefile& m_MsvcMetaMakefile;
285     SConfigInfo              m_Config;
286     list<string>             m_Defines;
287 
288     TTargetType              m_TargetType;
289     string      m_ProjectId;
290 
291     // No value-type semantics
292     CCompilerToolImpl(void);
293     CCompilerToolImpl(const CCompilerToolImpl&);
294     CCompilerToolImpl& operator= (const CCompilerToolImpl&);
295 };
296 
297 
298 /////////////////////////////////////////////////////////////////////////////
299 ///
300 /// CLinkerToolImpl --
301 ///
302 /// Implementation of ILinkerTool interface.
303 ///
304 /// Accepts trait classes as a template parameters.
305 
306 template <class ConfTrait >
307 class CLinkerToolImpl : public ILinkerTool
308 {
309 public:
CLinkerToolImpl(const string & additional_options,const string & additional_library_directories,const string & project_id,const IMsvcMetaMakefile & project_makefile,const IMsvcMetaMakefile & meta_makefile,const SConfigInfo & config)310     CLinkerToolImpl(const string&            additional_options,
311                     const string&            additional_library_directories,
312                     const string&            project_id,
313                     const IMsvcMetaMakefile& project_makefile,
314                     const IMsvcMetaMakefile& meta_makefile,
315                     const SConfigInfo&       config)
316 	    :m_AdditionalOptions    (additional_options),
317          m_AdditionalLibraryDirectories(additional_library_directories),
318 		 m_ProjectId            (project_id),
319          m_Config               (config),
320          m_MsvcProjectMakefile  (project_makefile),
321          m_MsvcMetaMakefile     (meta_makefile)
322     {
323     }
Name(void) const324     virtual string Name(void) const
325     {
326 	    return "VCLinkerTool";
327     }
AdditionalOptions(void) const328     virtual string AdditionalOptions(void) const
329     {
330         string options(m_AdditionalOptions);
331         string add;
332         if ( CMsvc7RegSettings::GetMsvcVersion() < CMsvc7RegSettings::eMsvc1000 ) {
333             add = m_MsvcMetaMakefile.GetLinkerOpt("AdditionalOptions", m_Config);
334             if (!add.empty()) {
335                 options += " " + add;
336             }
337         }
338         add = m_MsvcProjectMakefile.GetLinkerOpt("AdditionalOptions", m_Config);
339         if (!add.empty()) {
340             options += " " + add;
341         }
342         return options;
343     }
344 
345 #define SUPPORT_LINKER_OPTION(opt) \
346     virtual string opt(void) const \
347     { \
348         return GetLinkerOpt(m_MsvcMetaMakefile, \
349                             m_MsvcProjectMakefile, \
350                             #opt, \
351                             m_Config ); \
352     }
353 
354     SUPPORT_LINKER_OPTION(OutputFile)
SUPPORT_LINKER_OPTION(LinkIncremental)355     SUPPORT_LINKER_OPTION(LinkIncremental)
356     SUPPORT_LINKER_OPTION(LargeAddressAware)
357     virtual string GenerateDebugInformation(void) const
358     {
359         if (m_Config.m_VTuneAddon) {
360             return "true";
361         }
362         return GetLinkerOpt(m_MsvcMetaMakefile,
363                             m_MsvcProjectMakefile,
364                             "GenerateDebugInformation",
365                             m_Config );
366     }
367 
368     SUPPORT_LINKER_OPTION(ProgramDatabaseFile)
SUPPORT_LINKER_OPTION(SubSystem)369     SUPPORT_LINKER_OPTION(SubSystem)
370     SUPPORT_LINKER_OPTION(ImportLibrary)
371     SUPPORT_LINKER_OPTION(TargetMachine)
372     SUPPORT_LINKER_OPTION(ImageHasSafeExceptionHandlers)
373     SUPPORT_LINKER_OPTION(OptimizeReferences)
374     SUPPORT_LINKER_OPTION(EnableCOMDATFolding)
375     SUPPORT_LINKER_OPTION(IgnoreAllDefaultLibraries)
376     SUPPORT_LINKER_OPTION(IgnoreDefaultLibraryNames)
377     SUPPORT_LINKER_OPTION(AdditionalDependencies)
378 
379     virtual string AdditionalLibraryDirectories(void) const
380     {
381         string add =
382             GetLinkerOpt(m_MsvcMetaMakefile,
383                          m_MsvcProjectMakefile,
384                          "AdditionalLibraryDirectories",
385                          m_Config );
386         if (!add.empty() && !m_AdditionalLibraryDirectories.empty()) {
387             add += ", ";
388         }
389 	    return add + m_AdditionalLibraryDirectories;
390     }
391 
392     SUPPORT_LINKER_OPTION(FixedBaseAddress)
393     SUPPORT_LINKER_OPTION(GenerateManifest)
394     SUPPORT_LINKER_OPTION(EmbedManifest)
395 
396 private:
397     string      m_AdditionalOptions;
398     string      m_AdditionalLibraryDirectories;
399     string      m_ProjectId;
400     SConfigInfo m_Config;
401 
402     const IMsvcMetaMakefile& m_MsvcProjectMakefile;
403     const IMsvcMetaMakefile&            m_MsvcMetaMakefile;
404 
405     CLinkerToolImpl(void);
406     CLinkerToolImpl(const CLinkerToolImpl&);
407     CLinkerToolImpl& operator= (const CLinkerToolImpl&);
408 };
409 
410 
411 #define SUPPORT_DUMMY_OPTION(opt) \
412     virtual string opt(void) const \
413     { \
414         return ""; \
415     }
416 
417 
418 /////////////////////////////////////////////////////////////////////////////
419 ///
420 /// CLinkerToolDummyImpl --
421 ///
422 /// Implementation of ILinkerTool interface.
423 ///
424 /// Dummy (name-only) implementation.
425 class CLinkerToolDummyImpl : public ILinkerTool // for LIB targets:
426 {
427 public:
CLinkerToolDummyImpl()428     CLinkerToolDummyImpl()
429     {
430     }
Name(void) const431     virtual string Name(void) const
432     {
433 	    return "VCLinkerTool";
434     }
435     SUPPORT_DUMMY_OPTION(AdditionalDependencies)
436     SUPPORT_DUMMY_OPTION(AdditionalOptions)
437     SUPPORT_DUMMY_OPTION(OutputFile)
438     SUPPORT_DUMMY_OPTION(LinkIncremental)
439     SUPPORT_DUMMY_OPTION(LargeAddressAware)
440     SUPPORT_DUMMY_OPTION(GenerateDebugInformation)
441     SUPPORT_DUMMY_OPTION(ProgramDatabaseFile)
442     SUPPORT_DUMMY_OPTION(SubSystem)
443     SUPPORT_DUMMY_OPTION(ImportLibrary)
444     SUPPORT_DUMMY_OPTION(TargetMachine)
445     SUPPORT_DUMMY_OPTION(ImageHasSafeExceptionHandlers)
446     SUPPORT_DUMMY_OPTION(OptimizeReferences)
447     SUPPORT_DUMMY_OPTION(EnableCOMDATFolding)
448     SUPPORT_DUMMY_OPTION(IgnoreAllDefaultLibraries)
449     SUPPORT_DUMMY_OPTION(IgnoreDefaultLibraryNames)
450     SUPPORT_DUMMY_OPTION(AdditionalLibraryDirectories)
451     SUPPORT_DUMMY_OPTION(FixedBaseAddress)
452     SUPPORT_DUMMY_OPTION(GenerateManifest)
453     SUPPORT_DUMMY_OPTION(EmbedManifest)
454 
455 private:
456     CLinkerToolDummyImpl(const CLinkerToolDummyImpl&);
457     CLinkerToolDummyImpl& operator= (const CLinkerToolDummyImpl&);
458 };
459 
460 /////////////////////////////////////////////////////////////////////////////
461 ///
462 /// CLibrarianToolImpl --
463 ///
464 /// Implementation of ILibrarianTool interface.
465 ///
466 /// Implementation for LIB targets.
467 class CLibrarianToolImpl : public ILibrarianTool
468 {
469 public:
CLibrarianToolImpl(const string & project_id,const IMsvcMetaMakefile & project_makefile,const IMsvcMetaMakefile & meta_makefile,const SConfigInfo & config)470     CLibrarianToolImpl( const string&            project_id,
471                         const IMsvcMetaMakefile& project_makefile,
472                         const IMsvcMetaMakefile& meta_makefile,
473                         const SConfigInfo&       config)
474         :m_ProjectId            (project_id),
475          m_Config               (config),
476          m_MsvcProjectMakefile  (project_makefile),
477          m_MsvcMetaMakefile     (meta_makefile)
478     {
479     }
Name(void) const480     virtual string Name(void) const
481     {
482 	    return "VCLibrarianTool";
483     }
484 
485 #define SUPPORT_LIBRARIAN_OPTION(opt) \
486     virtual string opt(void) const \
487     { \
488         return GetLibrarianOpt(m_MsvcMetaMakefile, \
489                             m_MsvcProjectMakefile, \
490                             #opt, \
491                             m_Config ); \
492     }
493     SUPPORT_LIBRARIAN_OPTION(AdditionalOptions)
494     SUPPORT_LIBRARIAN_OPTION(AdditionalLibraryDirectories)
495     SUPPORT_LIBRARIAN_OPTION(IgnoreAllDefaultLibraries)
496     SUPPORT_LIBRARIAN_OPTION(IgnoreDefaultLibraryNames)
497     SUPPORT_LIBRARIAN_OPTION(OutputFile)
498     SUPPORT_LIBRARIAN_OPTION(TargetMachine)
499 
500 private:
501     string      m_ProjectId;
502     SConfigInfo m_Config;
503 
504     const IMsvcMetaMakefile& m_MsvcProjectMakefile;
505     const IMsvcMetaMakefile& m_MsvcMetaMakefile;
506 
507     CLibrarianToolImpl(void);
508     CLibrarianToolImpl(const CLibrarianToolImpl&);
509     CLibrarianToolImpl& operator= (const CLibrarianToolImpl&);
510 };
511 
512 
513 /////////////////////////////////////////////////////////////////////////////
514 ///
515 /// CLibrarianToolDummyImpl --
516 ///
517 /// Implementation of ILibrarianTool interface.
518 ///
519 /// Dummy (name-only) implementation for APP and DLL targets.
520 
521 class CLibrarianToolDummyImpl : public ILibrarianTool // for APP and DLL
522 {
523 public:
CLibrarianToolDummyImpl(void)524     CLibrarianToolDummyImpl(void)
525     {
526     }
527 
Name(void) const528     virtual string Name(void) const
529     {
530 	    return "VCLibrarianTool";
531     }
532 
533     SUPPORT_DUMMY_OPTION(AdditionalOptions)
534     SUPPORT_DUMMY_OPTION(OutputFile)
535     SUPPORT_DUMMY_OPTION(IgnoreAllDefaultLibraries)
536     SUPPORT_DUMMY_OPTION(IgnoreDefaultLibraryNames)
537     SUPPORT_DUMMY_OPTION(AdditionalLibraryDirectories)
538     SUPPORT_DUMMY_OPTION(TargetMachine)
539 
540 private:
541 	CLibrarianToolDummyImpl(const CLibrarianToolDummyImpl&);
542 	CLibrarianToolDummyImpl& operator= (const CLibrarianToolDummyImpl&);
543 };
544 
545 
546 class CPreBuildEventToolDummyImpl : public IPreBuildEventTool // for APP and DLL
547 {
548 public:
CPreBuildEventToolDummyImpl(void)549     CPreBuildEventToolDummyImpl(void)
550     {
551     }
552 
Name(void) const553     virtual string Name(void) const
554     {
555 	    return "VCPreBuildEventTool";
556     }
557 
558     SUPPORT_DUMMY_OPTION(CommandLine)
559 
560 private:
561 	CPreBuildEventToolDummyImpl(const CPreBuildEventToolDummyImpl&);
562 	CPreBuildEventToolDummyImpl& operator= (const CPreBuildEventToolDummyImpl&);
563 };
564 
565 class CPreBuildEventTool : public IPreBuildEventTool
566 {
567 public:
CPreBuildEventTool(const list<CProjKey> & lib_depends,EMakeFileType maketype)568     CPreBuildEventTool(const list<CProjKey>& lib_depends, EMakeFileType maketype)
569         : m_LibDepends(lib_depends), m_MakeType(maketype)
570     {
571     }
Name(void) const572     virtual string Name(void) const
573     {
574 	    return "VCPreBuildEventTool";
575     }
CommandLine(void) const576     virtual string CommandLine(void) const
577     {
578         string command_line;
579         if (m_MakeType != eMakeType_Undefined) {
580             string echo = MakeFileTypeAsString(m_MakeType);
581             if (!echo.empty()) {
582                 command_line += "@echo " + echo + " project\n";
583             }
584         }
585         if ( !m_LibDepends.empty() ) {
586             const CProjectItemsTree* tree = GetApp().GetCurrentBuildTree();
587             ITERATE(list<CProjKey>, p, m_LibDepends) {
588                 if (tree->m_Projects.find(*p) == tree->m_Projects.end()) {
589                     command_line += "@echo ERROR: This project depends on missing " + CreateProjectName(*p) + "\n";
590                     command_line += "exit 1\n";
591                     break;
592                 }
593             }
594         }
595         return command_line;
596     }
597 protected:
598     list<CProjKey> m_LibDepends;
599 
600 private:
601     EMakeFileType m_MakeType;
602 
603 	CPreBuildEventTool(const CPreBuildEventTool&);
604 	CPreBuildEventTool& operator= (const CPreBuildEventTool&);
605 };
606 
607 class CPreBuildEventToolLibImpl : public CPreBuildEventTool // for LIB
608 {
609 public:
CPreBuildEventToolLibImpl(const list<CProjKey> & lib_depends,EMakeFileType maketype)610     CPreBuildEventToolLibImpl(const list<CProjKey>& lib_depends, EMakeFileType maketype)
611         : CPreBuildEventTool(lib_depends, maketype)
612     {
613     }
614 
CommandLine(void) const615     virtual string CommandLine(void) const
616     {
617         string command_line = CPreBuildEventTool::CommandLine();
618         if (CMsvc7RegSettings::GetMsvcVersion() > CMsvc7RegSettings::eMsvc710) {
619             return command_line;
620         }
621         string cmd;
622         if ( !m_LibDepends.empty() ) {
623             cmd = "\"";
624             cmd += GetApp().GetProjectTreeRoot();
625             cmd += "asn_prebuild.bat\"";
626             cmd += " \"$(OutDir)\" \"$(ConfigurationName)\" \"$(SolutionPath)\"";
627         }
628         ITERATE(list<CProjKey>, p, m_LibDepends)
629         {
630             const string& lib = CreateProjectName(*p);
631             cmd += " ";
632             cmd += lib;
633         }
634         if (!cmd.empty()) {
635             command_line += "@echo " + cmd + "\n" + cmd;
636         }
637         return command_line;
638     }
639 
640 private:
641 	CPreBuildEventToolLibImpl(const CPreBuildEventToolLibImpl&);
642 	CPreBuildEventToolLibImpl& operator= (const CPreBuildEventToolLibImpl&);
643 };
644 
645 
646 /// Dummy (name-only) tool implementations.
647 
648 #define DEFINE_NAME_ONLY_DUMMY_TOOL(C,I,N)\
649 class C : public I\
650 {\
651 public:\
652     C()\
653     {\
654     }\
655     virtual string Name(void) const\
656     {\
657 	    return N;\
658     }\
659 private:\
660     C(const C&);\
661     C& operator= (const C&);\
662 }
663 
664 DEFINE_NAME_ONLY_DUMMY_TOOL(CCustomBuildToolDummyImpl,
665                             ICustomBuildTool,
666                             "VCCustomBuildTool");
667 
668 DEFINE_NAME_ONLY_DUMMY_TOOL(CMIDLToolDummyImpl,
669                             IMIDLTool,
670                             "VCMIDLTool");
671 
672 DEFINE_NAME_ONLY_DUMMY_TOOL(CPostBuildEventToolDummyImpl,
673                             IPostBuildEventTool,
674                             "VCPostBuildEventTool");
675 #if 0
676 DEFINE_NAME_ONLY_DUMMY_TOOL(CPreBuildEventToolDummyImpl,
677                             IPreBuildEventTool,
678                             "VCPreBuildEventTool");
679 #endif
680 
681 DEFINE_NAME_ONLY_DUMMY_TOOL(CPreLinkEventToolDummyImpl,
682                             IPreLinkEventTool,
683                             "VCPreLinkEventTool");
684 
685 
686 /////////////////////////////////////////////////////////////////////////////
687 ///
688 /// CResourceCompilerToolImpl --
689 ///
690 /// Implementation of IResourceCompilerTool interface.
691 ///
692 /// Accepts traits as a template parameter.
693 
694 template <class DebugReleaseTrait>
695 class CResourceCompilerToolImpl : public IResourceCompilerTool
696 {
697 public:
CResourceCompilerToolImpl(const string & additional_include_dirs,const IMsvcMetaMakefile & project_makefile,const IMsvcMetaMakefile & meta_makefile,const SConfigInfo & config)698     CResourceCompilerToolImpl(const string&            additional_include_dirs,
699                               const IMsvcMetaMakefile& project_makefile,
700                               const IMsvcMetaMakefile& meta_makefile,
701                               const SConfigInfo&       config)
702       :m_AdditionalIncludeDirectories(additional_include_dirs),
703        m_MsvcProjectMakefile(project_makefile),
704        m_MsvcMetaMakefile   (meta_makefile),
705        m_Config             (config)
706     {
707     }
Name(void) const708     virtual string Name(void) const
709     {
710 	    return "VCResourceCompilerTool";
711     }
712 
AdditionalIncludeDirectories(void) const713     virtual string AdditionalIncludeDirectories(void) const
714     {
715 	    return m_AdditionalIncludeDirectories;
716     }
717 
718 #define SUPPORT_RESOURCE_COMPILER_OPTION(opt) \
719     virtual string opt(void) const \
720     { \
721         return GetResourceCompilerOpt(m_MsvcMetaMakefile, \
722                                       m_MsvcProjectMakefile, \
723                                       #opt, \
724                                       m_Config ); \
725     }
726 
727     SUPPORT_RESOURCE_COMPILER_OPTION(AdditionalOptions)
SUPPORT_RESOURCE_COMPILER_OPTION(Culture)728     SUPPORT_RESOURCE_COMPILER_OPTION(Culture)
729 
730 
731     virtual string PreprocessorDefinitions(void) const
732     {
733 	    return DebugReleaseTrait::PreprocessorDefinitions();
734     }
735 
736 private:
737     string                   m_AdditionalIncludeDirectories;
738     const IMsvcMetaMakefile& m_MsvcProjectMakefile;
739     const IMsvcMetaMakefile& m_MsvcMetaMakefile;
740     const SConfigInfo&       m_Config;
741 
742     CResourceCompilerToolImpl(const CResourceCompilerToolImpl&);
743     CResourceCompilerToolImpl& operator= (const CResourceCompilerToolImpl&);
744 
745 };
746 
747 
748 /////////////////////////////////////////////////////////////////////////////
749 ///
750 /// CResourceCompilerToolImpl --
751 ///
752 /// Implementation of IResourceCompilerTool interface.
753 ///
754 /// Dummy (name-only) implementation.
755 
756 class CResourceCompilerToolDummyImpl : public IResourceCompilerTool //no resources
757 {
758 public:
CResourceCompilerToolDummyImpl()759     CResourceCompilerToolDummyImpl()
760     {
761     }
Name(void) const762     virtual string Name(void) const
763     {
764         return "VCResourceCompilerTool";
765     }
766 
767     SUPPORT_DUMMY_OPTION(AdditionalIncludeDirectories)
768     SUPPORT_DUMMY_OPTION(AdditionalOptions)
769     SUPPORT_DUMMY_OPTION(Culture)
770     SUPPORT_DUMMY_OPTION(PreprocessorDefinitions)
771 
772 private:
773     CResourceCompilerToolDummyImpl
774         (const CResourceCompilerToolDummyImpl&);
775     CResourceCompilerToolDummyImpl& operator=
776         (const CResourceCompilerToolDummyImpl&);
777 };
778 
779 
780 /// Dummy (name-only) tool implementations.
781 
782 DEFINE_NAME_ONLY_DUMMY_TOOL(CWebServiceProxyGeneratorToolDummyImpl,
783                             IWebServiceProxyGeneratorTool,
784                             "VCWebServiceProxyGeneratorTool");
785 
786 DEFINE_NAME_ONLY_DUMMY_TOOL(CXMLDataGeneratorToolDummyImpl,
787                             IXMLDataGeneratorTool,
788                             "VCXMLDataGeneratorTool");
789 
790 DEFINE_NAME_ONLY_DUMMY_TOOL(CManagedWrapperGeneratorToolDummyImpl,
791                             IManagedWrapperGeneratorTool,
792                             "VCManagedWrapperGeneratorTool");
793 
794 DEFINE_NAME_ONLY_DUMMY_TOOL(CAuxiliaryManagedWrapperGeneratorToolDummyImpl,
795                             IAuxiliaryManagedWrapperGeneratorTool,
796                             "VCAuxiliaryManagedWrapperGeneratorTool");
797 
798 
799 
800 END_NCBI_SCOPE
801 
802 #endif //PROJECT_TREE_BUILDER__TOOLS_IMPLEMENT__HPP
803