Merge trunk HEAD (r46369)
[reactos.git] / reactos / tools / rbuild / rbuild.h
1 /*
2 * Copyright (C) 2005 Casper S. Hornstrup
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #pragma once
20
21 #include "pch.h"
22
23 #ifdef WIN32
24 #include <direct.h>
25 #include <io.h>
26 #endif/*WIN32*/
27 #include <sys/stat.h>
28 #include <time.h>
29 #ifdef _MSC_VER
30 #include <sys/utime.h>
31 #else/*_MSC_VER*/
32 #include <utime.h>
33 #ifdef WIN32
34 #include <process.h>
35 #endif/*WIN32*/
36 #endif/*_MSC_VER*/
37
38 #include <infhost.h>
39
40 #include "ssprintf.h"
41 #include "exception.h"
42 #include "xml.h"
43
44 class Backend; // forward declaration
45
46 typedef std::vector<std::string> string_list;
47
48 extern std::string ExePrefix;
49 extern std::string ExePostfix;
50 extern std::string sSep;
51 extern std::string sBadSep;
52 extern char cSep;
53 extern char cBadSep;
54
55 #ifdef WIN32
56 #define DEF_EXEPREFIX ""
57 #define DEF_EXEPOSTFIX ".exe"
58 #define DEF_CSEP '\\'
59 #define DEF_CBAD_SEP '/'
60 #define DEF_SSEP "\\"
61 #define DEF_SBAD_SEP "/"
62 #else
63 #define DEF_EXEPREFIX "./"
64 #define DEF_EXEPOSTFIX ""
65 #define DEF_CSEP '/'
66 #define DEF_CBAD_SEP '\\'
67 #define DEF_SSEP "/"
68 #define DEF_SBAD_SEP "\\"
69 #endif
70
71 #define MS_VS_DEF_VERSION "9.00"
72
73 class XmlNode;
74 class Directory;
75 class Project;
76 class IfableData;
77 class Module;
78 class Include;
79 class Define;
80 class File;
81 class Library;
82 class Invoke;
83 class InvokeFile;
84 class Dependency;
85 class ImportLibrary;
86 class CompilerFlag;
87 class LinkerFlag;
88 class LinkerScript;
89 class Property;
90 class TestSupportCode;
91 class AutomaticDependency;
92 class Bootstrap;
93 class CDFile;
94 class InstallFile;
95 class PchFile;
96 class StubbedComponent;
97 class StubbedSymbol;
98 class CompilationUnit;
99 class FileLocation;
100 class AutoRegister;
101
102 class SourceFileTest;
103 class Metadata;
104 class Bootsector;
105
106 typedef std::map<std::string,Directory*> directory_map;
107
108 class XmlNode
109 {
110 protected:
111 const Project& project;
112 const XMLElement& node;
113
114 XmlNode ( const Project& project_,
115 const XMLElement& node_ );
116 virtual ~XmlNode();
117
118 public:
119 virtual void ProcessXML();
120 };
121
122 enum DirectoryLocation
123 {
124 SourceDirectory,
125 IntermediateDirectory,
126 OutputDirectory,
127 InstallDirectory,
128 TemporaryDirectory,
129 };
130
131 class Directory
132 {
133 public:
134 std::string name;
135 directory_map subdirs;
136 Directory ( const std::string& name );
137 ~Directory();
138 void Add ( const char* subdir );
139 void GenerateTree ( DirectoryLocation root,
140 bool verbose );
141 void CreateRule ( FILE* f,
142 const std::string& parent );
143 private:
144 bool mkdir_p ( const char* path );
145 bool CreateDirectory ( const std::string& path );
146 std::string EscapeSpaces ( const std::string& path );
147 void GenerateTree ( const std::string& parent,
148 bool verbose );
149 };
150
151 enum DependenciesType
152 {
153 NoDependencies,
154 AutomaticDependencies,
155 FullDependencies
156 };
157
158 enum CompilerSet
159 {
160 GnuGcc,
161 MicrosoftC
162 };
163
164 enum LinkerSet
165 {
166 GnuLd,
167 MicrosoftLink
168 };
169
170 enum SpecFileType
171 {
172 None,
173 Spec = 1,
174 PSpec = 2
175 };
176
177 class Configuration
178 {
179 public:
180 Configuration ();
181 ~Configuration ();
182 bool Verbose;
183 bool CleanAsYouGo;
184 DependenciesType Dependencies;
185 bool CheckDependenciesForModuleOnly;
186 bool CompilationUnitsEnabled;
187 bool PrecompiledHeadersEnabled;
188 std::string CheckDependenciesForModuleOnlyModule;
189 std::string VSProjectVersion;
190 std::string VSConfigurationType;
191 bool UseVSVersionInPath;
192 bool UseConfigurationInPath;
193 bool MakeHandlesInstallDirectories;
194 bool GenerateProxyMakefilesInSourceTree;
195 bool InstallFiles;
196 CompilerSet Compiler;
197 LinkerSet Linker;
198 };
199
200 class Environment
201 {
202 public:
203 static std::string GetVariable ( const std::string& name );
204 static std::string GetArch ();
205 static std::string GetIntermediatePath ();
206 static std::string GetOutputPath ();
207 static std::string GetSourcePath ();
208 static std::string GetCdOutputPath ();
209 static std::string GetInstallPath ();
210 static std::string GetAutomakeFile ( const std::string& defaultFile );
211 static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
212 const std::string& defaultValue );
213 };
214
215
216 class FileSupportCode
217 {
218 public:
219 static void WriteIfChanged ( char* outbuf,
220 const std::string& filename,
221 bool ignoreError = false );
222 };
223
224
225 class ParseContext
226 {
227 public:
228 CompilationUnit* compilationUnit;
229 ParseContext ();
230 };
231
232
233 class IfableData
234 {
235 public:
236 std::vector<CompilationUnit*> compilationUnits;
237 std::vector<File*> files;
238 std::vector<Include*> includes;
239 std::vector<Define*> defines;
240 std::vector<Library*> libraries;
241 std::map<std::string, Property*> properties;
242 std::vector<Module*> modules;
243 std::vector<CompilerFlag*> compilerFlags;
244 int asmFiles; // number of .asm files in compilationUnits
245
246 IfableData();
247 ~IfableData();
248 void ProcessXML();
249 void ExtractModules( std::map<std::string, Module*> &modules );
250 };
251
252 class Project
253 {
254 std::string xmlfile;
255 XMLElement *node, *head;
256 Backend* _backend;
257 public:
258 const Configuration& configuration;
259 std::string name;
260 std::string makefile;
261 XMLIncludes xmlbuildfiles;
262 std::vector<LinkerFlag*> linkerFlags;
263 std::vector<CDFile*> cdfiles;
264 std::vector<InstallFile*> installfiles;
265 std::map<std::string, Module*> modules;
266 IfableData non_if_data;
267 IfableData host_non_if_data;
268 bool allowWarnings;
269 bool allowWarningsSet;
270
271 Project ( const Configuration& configuration,
272 const std::string& filename,
273 const std::map<std::string, std::string>* properties = NULL );
274 ~Project ();
275 void SetBackend ( Backend* backend ) { _backend = backend; }
276 Backend& GetBackend() { return *_backend; }
277 void ExecuteInvocations ();
278
279 void ProcessXML ( const std::string& path );
280 Module* LocateModule ( const std::string& name );
281 const Module* LocateModule ( const std::string& name ) const;
282 const std::string& GetProjectFilename () const;
283 std::string ResolveProperties ( const std::string& s ) const;
284 const Property* LookupProperty ( const std::string& name ) const;
285 std::string GetCompilerSet () const;
286 std::string GetLinkerSet () const;
287 void GenerateInstallerFileList();
288 private:
289 std::string ResolveNextProperty ( const std::string& s ) const;
290 void ReadXml ();
291 void ProcessXMLSubElement ( const XMLElement& e,
292 const std::string& path,
293 ParseContext& parseContext );
294
295 // disable copy semantics
296 Project ( const Project& );
297 Project& operator = ( const Project& );
298 };
299
300
301 enum ModuleType
302 {
303 BuildTool,
304 StaticLibrary,
305 ObjectLibrary,
306 Kernel,
307 KernelModeDLL,
308 KernelModeDriver,
309 NativeDLL,
310 NativeCUI,
311 Win32DLL,
312 Win32OCX,
313 Win32CUI,
314 Win32GUI,
315 BootLoader,
316 BootSector,
317 Iso,
318 LiveIso,
319 Test,
320 RpcServer,
321 RpcClient,
322 Alias,
323 BootProgram,
324 Win32SCR,
325 IdlHeader,
326 IdlInterface,
327 EmbeddedTypeLib,
328 ElfExecutable,
329 RpcProxy,
330 HostStaticLibrary,
331 Cabinet,
332 KeyboardLayout,
333 MessageHeader,
334 TypeDontCare, // always at the end
335 };
336
337 enum HostType
338 {
339 HostFalse,
340 HostDefault,
341 HostTrue,
342 HostDontCare,
343 };
344
345 enum CompilerType
346 {
347 CompilerTypeCC,
348 CompilerTypeCXX,
349 CompilerTypeCPP,
350 CompilerTypeAS,
351 CompilerTypeMIDL,
352 CompilerTypeRC,
353 CompilerTypeNASM,
354
355 CompilerTypesCount
356 };
357
358 class FileLocation
359 {
360 public:
361 DirectoryLocation directory;
362 std::string relative_path;
363 std::string name;
364
365 FileLocation ( const DirectoryLocation directory,
366 const std::string& relative_path,
367 const std::string& name,
368 const XMLElement *node = NULL );
369
370 FileLocation ( const FileLocation& other );
371 };
372
373 class Module
374 {
375 public:
376 const Project& project;
377 const XMLElement& node;
378 std::string xmlbuildFile;
379 std::string name;
380 std::string guid;
381 std::string extension;
382 std::string baseaddress;
383 std::string payload;
384 std::string buildtype;
385 ModuleType type;
386 ImportLibrary* importLibrary;
387 ImportLibrary* delayImportLibrary;
388 Metadata* metadata;
389 Bootsector* bootSector;
390 bool isUnicode;
391 bool isDefaultEntryPoint;
392 Bootstrap* bootstrap;
393 AutoRegister* autoRegister; // <autoregister> node
394 IfableData non_if_data;
395 std::vector<Invoke*> invocations;
396 std::vector<Dependency*> dependencies;
397 std::vector<CompilerFlag*> compilerFlags;
398 std::vector<LinkerFlag*> linkerFlags;
399 std::vector<StubbedComponent*> stubbedComponents;
400 std::vector<CDFile*> cdfiles;
401 LinkerScript* linkerScript;
402 PchFile* pch;
403 bool cplusplus;
404 std::string prefix;
405 std::string aliasedModuleName;
406 bool allowWarnings;
407 bool enabled;
408 bool isStartupLib;
409 bool isCRT;
410 std::string CRT;
411 bool dynamicCRT;
412 std::string installbase;
413 FileLocation *output; // "path/foo.exe"
414 FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
415 FileLocation *install;
416 std::string description;
417 std::string lcid;
418 std::string layoutId;
419 std::string layoutNameResId;
420
421 Module ( const Project& project,
422 const XMLElement& moduleNode,
423 const std::string& modulePath );
424 ~Module ();
425 ModuleType GetModuleType ( const std::string& location,
426 const XMLAttribute& attribute );
427 bool HasImportLibrary () const;
428 bool IsDLL () const;
429 std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
430 std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
431 std::string GetEntryPoint() const;
432 void GetTargets ( string_list& ) const;
433 std::string GetInvocationTarget ( const int index ) const;
434 bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
435 void InvokeModule () const;
436 void ProcessXML ();
437 std::string GetDllName() const;
438 SpecFileType IsSpecDefinitionFile () const;
439 private:
440 void SetImportLibrary ( ImportLibrary* importLibrary );
441 void SetDelayImportLibrary ( ImportLibrary* importLibrary );
442 DirectoryLocation GetTargetDirectoryTree () const;
443 std::string GetDefaultModuleExtension () const;
444 std::string GetDefaultModuleEntrypoint () const;
445 std::string GetDefaultModuleBaseaddress () const;
446 std::string GetDefaultModuleCRT () const;
447 bool GetDefaultModuleIsCRT () const;
448 std::string entrypoint;
449 void ProcessXMLSubElement ( const XMLElement& e,
450 DirectoryLocation directory,
451 const std::string& relative_path,
452 ParseContext& parseContext );
453 bool GetBooleanAttribute ( const XMLElement& moduleNode,
454 const char * name,
455 bool default_value = false );
456 };
457
458 class ToolsetDirective
459 {
460 private:
461 bool enabled;
462
463 protected:
464 void ParseToolsets ( const Project& project, const XMLElement& node );
465
466 public:
467 virtual ~ToolsetDirective() { }
468 bool IsEnabled () const;
469 };
470
471 class CompilerDirective
472 {
473 private:
474 std::bitset<CompilerTypesCount> compilersSet;
475 bool enabled;
476
477 protected:
478 void ParseCompilers ( const XMLElement& node, const std::string& defaultValue );
479
480 public:
481 CompilerDirective (): enabled ( true ) { }
482 virtual ~CompilerDirective() { }
483 void SetCompiler ( CompilerType compiler );
484 void UnsetCompiler ( CompilerType compiler );
485 void SetAllCompilers ();
486 void UnsetAllCompilers ();
487 bool IsCompilerSet ( CompilerType compiler ) const;
488 };
489
490 class Include: public CompilerDirective, public ToolsetDirective
491 {
492 public:
493 FileLocation *directory;
494
495 Include ( const Project& project,
496 const XMLElement* includeNode );
497 Include ( const Project& project,
498 const XMLElement* includeNode,
499 const Module* module );
500 Include ( const Project& project,
501 DirectoryLocation directory,
502 const std::string& relative_path );
503 ~Include ();
504 void ProcessXML ();
505 private:
506 const Project& project;
507 const XMLElement* node;
508 const Module* module;
509 DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
510 void Initialize ();
511 };
512
513
514 class Define: public CompilerDirective, public ToolsetDirective
515 {
516 public:
517 const Project& project;
518 const Module* module;
519 const XMLElement* node;
520 std::string name;
521 std::string arguments;
522 std::string value;
523 std::string backend;
524 bool redefine;
525
526 Define ( const Project& project,
527 const XMLElement& defineNode );
528 Define ( const Project& project,
529 const Module* module,
530 const XMLElement& defineNode );
531 Define ( const Project& project,
532 const Module* module,
533 const std::string& name_,
534 const std::string& backend_ = "",
535 bool redefine_ = false );
536 ~Define();
537 void ProcessXML();
538 private:
539 void Initialize();
540 };
541
542
543 class File
544 {
545 public:
546 FileLocation file;
547 bool first;
548 std::string switches;
549 bool isPreCompiledHeader;
550
551 File ( DirectoryLocation directory,
552 const std::string& relative_path,
553 const std::string& name,
554 bool _first,
555 const std::string& _switches,
556 bool _isPreCompiledHeader );
557
558 void ProcessXML();
559 std::string GetFullPath () const;
560 };
561
562
563 class Library
564 {
565 const XMLElement *node;
566 public:
567 const Module& module;
568 std::string name;
569 const Module* importedModule;
570 bool delayimp;
571
572 Library ( const XMLElement& _node,
573 const Module& _module,
574 const std::string& _name );
575 Library ( const Module& _module,
576 const std::string& _name );
577
578 void ProcessXML();
579 };
580
581
582 class Invoke
583 {
584 public:
585 const XMLElement& node;
586 const Module& module;
587 const Module* invokeModule;
588 std::vector<InvokeFile*> input;
589 std::vector<InvokeFile*> output;
590
591 Invoke ( const XMLElement& _node,
592 const Module& _module );
593
594 void ProcessXML();
595 void GetTargets ( string_list& targets ) const;
596 std::string GetParameters () const;
597 private:
598 void ProcessXMLSubElement ( const XMLElement& e );
599 void ProcessXMLSubElementInput ( const XMLElement& e );
600 void ProcessXMLSubElementOutput ( const XMLElement& e );
601 };
602
603
604 class InvokeFile
605 {
606 public:
607 const XMLElement& node;
608 std::string name;
609 std::string switches;
610
611 InvokeFile ( const XMLElement& _node,
612 const std::string& _name );
613
614 void ProcessXML ();
615 };
616
617
618 class Dependency
619 {
620 public:
621 const XMLElement& node;
622 const Module& module;
623 const Module* dependencyModule;
624
625 Dependency ( const XMLElement& _node,
626 const Module& _module );
627
628 void ProcessXML();
629 };
630
631 class Bootsector
632 {
633 public:
634 const XMLElement& node;
635 const Module* module;
636 const Module* bootSectorModule;
637
638 Bootsector ( const XMLElement& _node,
639 const Module* _module );
640
641 void ProcessXML();
642 private:
643 bool IsSupportedModuleType ( ModuleType type );
644 };
645
646 class Metadata
647 {
648 public:
649 const XMLElement& node;
650 const Module& module;
651 std::string name;
652 std::string description;
653 std::string version;
654 std::string copyright;
655 std::string url;
656 std::string date;
657 std::string owner;
658
659 Metadata ( const XMLElement& _node,
660 const Module& _module );
661
662 void ProcessXML();
663 };
664
665 class ImportLibrary : public XmlNode
666 {
667 public:
668 const Module* module;
669 std::string dllname;
670 FileLocation *source;
671 FileLocation *target;
672
673 ImportLibrary ( const Project& project,
674 const XMLElement& node,
675 const Module* module,
676 bool delayimp );
677 ~ImportLibrary ();
678 };
679
680
681 class CompilerFlag: public CompilerDirective, public ToolsetDirective
682 {
683 public:
684 const Project& project;
685 const Module* module;
686 const XMLElement& node;
687 std::string flag;
688
689 CompilerFlag ( const Project& project,
690 const XMLElement& compilerFlagNode );
691 CompilerFlag ( const Project& project,
692 const Module* module,
693 const XMLElement& compilerFlagNode );
694 ~CompilerFlag ();
695 void ProcessXML();
696 private:
697 void Initialize();
698 };
699
700
701 class LinkerFlag: public ToolsetDirective
702 {
703 public:
704 const Project& project;
705 const Module* module;
706 const XMLElement& node;
707 std::string flag;
708
709 LinkerFlag ( const Project& project,
710 const XMLElement& linkerFlagNode );
711 LinkerFlag ( const Project& project,
712 const Module* module,
713 const XMLElement& linkerFlagNode );
714 ~LinkerFlag ();
715 void ProcessXML();
716 private:
717 void Initialize();
718 };
719
720
721 class LinkerScript
722 {
723 public:
724 const XMLElement& node;
725 const Module& module;
726 const FileLocation *file;
727
728 LinkerScript ( const XMLElement& node,
729 const Module& module,
730 const FileLocation *file );
731 ~LinkerScript ();
732 void ProcessXML();
733 };
734
735
736 class Property
737 {
738 public:
739 const Project& project;
740 const Module* module;
741 std::string name, value;
742 bool isInternal;
743
744 Property ( const XMLElement& node_,
745 const Project& project_,
746 const Module* module_ );
747
748 Property ( const Project& project_,
749 const Module* module_,
750 const std::string& name_,
751 const std::string& value_ );
752
753 void ProcessXML();
754 };
755
756
757 class TestSupportCode
758 {
759 public:
760 const Project& project;
761
762 TestSupportCode ( const Project& project );
763 ~TestSupportCode ();
764 void GenerateTestSupportCode ( bool verbose );
765 private:
766 bool IsTestModule ( const Module& module );
767 void GenerateTestSupportCodeForModule ( Module& module,
768 bool verbose );
769 std::string GetHooksFilename ( Module& module );
770 char* WriteStubbedSymbolToHooksFile ( char* buffer,
771 const StubbedComponent& component,
772 const StubbedSymbol& symbol );
773 char* WriteStubbedComponentToHooksFile ( char* buffer,
774 const StubbedComponent& component );
775 void WriteHooksFile ( Module& module );
776 std::string GetStubsFilename ( Module& module );
777 char* WriteStubbedSymbolToStubsFile ( char* buffer,
778 const StubbedComponent& component,
779 const StubbedSymbol& symbol,
780 int stubIndex );
781 char* WriteStubbedComponentToStubsFile ( char* buffer,
782 const StubbedComponent& component,
783 int* stubIndex );
784 void WriteStubsFile ( Module& module );
785 std::string GetStartupFilename ( Module& module );
786 bool IsUnknownCharacter ( char ch );
787 std::string GetTestDispatcherName ( std::string filename );
788 bool IsTestFile ( std::string& filename ) const;
789 void GetSourceFilenames ( string_list& list,
790 Module& module ) const;
791 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
792 Module& module );
793 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
794 Module& module );
795 void WriteStartupFile ( Module& module );
796 };
797
798
799 class SourceFile
800 {
801 public:
802 SourceFile ( AutomaticDependency* automaticDependency,
803 const Module& module,
804 const File& file,
805 SourceFile* parent );
806 void Parse ();
807 std::vector<SourceFile*> files; /* List of files included in this file */
808 const File& file;
809 AutomaticDependency* automaticDependency;
810 const Module& module;
811 std::vector<SourceFile*> parents; /* List of files, this file is included from */
812 time_t lastWriteTime;
813 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
814 SourceFile* youngestFile;
815 private:
816 void Close ();
817 void Open ();
818 void SkipWhitespace ();
819 bool ReadInclude ( std::string& filename,
820 bool& searchCurrentDirectory,
821 bool& includeNext );
822 bool IsIncludedFrom ( const File& file );
823 SourceFile* ParseFile(const File& file);
824 bool CanProcessFile ( const File& file );
825 bool IsParentOf ( const SourceFile* parent,
826 const SourceFile* child );
827 std::string buf;
828 const char *p;
829 const char *end;
830 };
831
832
833 class AutomaticDependency
834 {
835 friend class SourceFileTest;
836 public:
837 const Project& project;
838
839 AutomaticDependency ( const Project& project );
840 ~AutomaticDependency ();
841 bool LocateIncludedFile ( const FileLocation& directory,
842 const std::string& includedFilename );
843 bool LocateIncludedFile ( SourceFile* sourceFile,
844 const Module& module,
845 const std::string& includedFilename,
846 bool searchCurrentDirectory,
847 bool includeNext,
848 File& resolvedFile );
849 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
850 const File& file,
851 SourceFile* parentSourceFile );
852 SourceFile* RetrieveFromCache ( const File& file );
853 void CheckAutomaticDependencies ( bool verbose );
854 void CheckAutomaticDependenciesForModule ( Module& module,
855 bool verbose );
856 private:
857 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
858 void CheckAutomaticDependencies ( const Module& module,
859 bool verbose );
860 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
861 void GetIncludeDirectories ( std::vector<Include*>& includes,
862 const Module& module );
863 void GetModuleFiles ( const Module& module,
864 std::vector<File*>& files ) const;
865 void ParseFiles ();
866 void ParseFiles ( const Module& module );
867 void ParseFile ( const Module& module,
868 const File& file );
869 std::map<std::string, SourceFile*> sourcefile_map;
870 };
871
872
873 class Bootstrap
874 {
875 public:
876 const Project& project;
877 const Module* module;
878 const XMLElement& node;
879 std::string base;
880 std::string nameoncd;
881
882 Bootstrap ( const Project& project,
883 const Module* module,
884 const XMLElement& bootstrapNode );
885 ~Bootstrap ();
886 void ProcessXML();
887 private:
888 bool IsSupportedModuleType ( ModuleType type );
889 void Initialize();
890 static std::string ReplaceVariable ( const std::string& name,
891 const std::string& value,
892 std::string path );
893 };
894
895
896 class CDFile : public XmlNode
897 {
898 public:
899 FileLocation *source;
900 FileLocation *target;
901
902 CDFile ( const Project& project,
903 const XMLElement& bootstrapNode,
904 const std::string& path );
905 ~CDFile ();
906 private:
907 static std::string ReplaceVariable ( const std::string& name,
908 const std::string& value,
909 std::string path );
910 };
911
912
913 class InstallFile : public XmlNode
914 {
915 public:
916 FileLocation *source;
917 FileLocation *target;
918 std::string installbase;
919
920 InstallFile ( const Project& project,
921 const XMLElement& bootstrapNode,
922 const std::string& path );
923 ~InstallFile ();
924 };
925
926
927 class PchFile
928 {
929 public:
930 const XMLElement& node;
931 const Module& module;
932 const FileLocation *file;
933
934 PchFile (
935 const XMLElement& node,
936 const Module& module,
937 const FileLocation *file );
938 ~PchFile();
939 void ProcessXML();
940 };
941
942
943 class StubbedComponent
944 {
945 public:
946 const Module* module;
947 const XMLElement& node;
948 std::string name;
949 std::vector<StubbedSymbol*> symbols;
950
951 StubbedComponent ( const Module* module_,
952 const XMLElement& stubbedComponentNode );
953 ~StubbedComponent ();
954 void ProcessXML ();
955 void ProcessXMLSubElement ( const XMLElement& e );
956 };
957
958
959 class StubbedSymbol
960 {
961 public:
962 const XMLElement& node;
963 std::string symbol;
964 std::string newname;
965 std::string strippedName;
966
967 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
968 ~StubbedSymbol ();
969 void ProcessXML();
970 private:
971 std::string StripSymbol ( std::string symbol );
972 };
973
974
975 class CompilationUnit
976 {
977 public:
978 std::string name;
979
980 CompilationUnit ( const File* file );
981 CompilationUnit ( const Project* project,
982 const Module* module,
983 const XMLElement* node );
984 ~CompilationUnit ();
985 void ProcessXML();
986 bool IsGeneratedFile () const;
987 bool HasFileWithExtension ( const std::string& extension ) const;
988 bool IsFirstFile () const;
989 const FileLocation& GetFilename () const;
990 const std::string& GetSwitches () const;
991 void AddFile ( const File * file );
992 const std::vector<const File*> GetFiles () const;
993 private:
994 const Project* project;
995 const Module* module;
996 const XMLElement* node;
997 std::vector<const File*> files;
998 FileLocation *default_name;
999 };
1000
1001
1002 class CompilationUnitSupportCode
1003 {
1004 public:
1005 const Project& project;
1006
1007 CompilationUnitSupportCode ( const Project& project );
1008 ~CompilationUnitSupportCode ();
1009 void Generate ( bool verbose );
1010 private:
1011 void GenerateForModule ( Module& module,
1012 bool verbose );
1013 std::string GetCompilationUnitFilename ( Module& module,
1014 CompilationUnit& compilationUnit );
1015 void WriteCompilationUnitFile ( Module& module,
1016 CompilationUnit& compilationUnit );
1017 };
1018
1019
1020 enum AutoRegisterType
1021 {
1022 DllRegisterServer,
1023 DllInstall,
1024 Both
1025 };
1026
1027 class AutoRegister : public XmlNode
1028 {
1029 public:
1030 const Module* module;
1031 std::string infSection;
1032 AutoRegisterType type;
1033 AutoRegister ( const Project& project_,
1034 const Module* module_,
1035 const XMLElement& node_ );
1036 private:
1037 bool IsSupportedModuleType ( ModuleType type );
1038 AutoRegisterType GetAutoRegisterType( const std::string& type );
1039 void Initialize ();
1040 };
1041
1042
1043 class SysSetupGenerator
1044 {
1045 public:
1046 const Project& project;
1047 SysSetupGenerator ( const Project& project );
1048 ~SysSetupGenerator ();
1049 void Generate ();
1050 private:
1051 std::string GetDirectoryId ( const Module& module );
1052 std::string GetFlags ( const Module& module );
1053 void Generate ( HINF inf,
1054 const Module& module );
1055 };
1056
1057
1058 extern void
1059 InitializeEnvironment ();
1060
1061 extern std::string
1062 Right ( const std::string& s, size_t n );
1063
1064 extern std::string
1065 Replace ( const std::string& s, const std::string& find, const std::string& with );
1066
1067 extern std::string
1068 ChangeSeparator ( const std::string& s,
1069 const char fromSeparator,
1070 const char toSeparator );
1071
1072 extern std::string
1073 FixSeparator ( const std::string& s );
1074
1075 extern std::string
1076 FixSeparatorForSystemCommand ( const std::string& s );
1077
1078 extern std::string
1079 DosSeparator ( const std::string& s );
1080
1081 extern std::string
1082 ReplaceExtension (
1083 const std::string& filename,
1084 const std::string& newExtension );
1085
1086 extern std::string
1087 GetSubPath (
1088 const Project& project,
1089 const std::string& location,
1090 const std::string& path,
1091 const std::string& att_value );
1092
1093 extern std::string
1094 GetExtension ( const FileLocation& file );
1095
1096 extern std::string
1097 NormalizeFilename ( const std::string& filename );
1098
1099 extern std::string
1100 ToLower ( std::string filename );