Bring back ext2 code from branch
[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
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #ifndef __RBUILD_H
19 #define __RBUILD_H
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 "7.10"
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 If;
87 class CompilerFlag;
88 class LinkerFlag;
89 class LinkerScript;
90 class Property;
91 class TestSupportCode;
92 class AutomaticDependency;
93 class Bootstrap;
94 class CDFile;
95 class InstallFile;
96 class PchFile;
97 class StubbedComponent;
98 class StubbedSymbol;
99 class CompilationUnit;
100 class FileLocation;
101 class AutoRegister;
102
103 class SourceFileTest;
104 class Metadata;
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 void Add ( const char* subdir );
138 void GenerateTree ( DirectoryLocation root,
139 bool verbose );
140 void CreateRule ( FILE* f,
141 const std::string& parent );
142 private:
143 bool mkdir_p ( const char* path );
144 bool CreateDirectory ( const std::string& path );
145 std::string EscapeSpaces ( const std::string& path );
146 void GenerateTree ( const std::string& parent,
147 bool verbose );
148 };
149
150
151 class Configuration
152 {
153 public:
154 Configuration ();
155 ~Configuration ();
156 bool Verbose;
157 bool CleanAsYouGo;
158 bool AutomaticDependencies;
159 bool CheckDependenciesForModuleOnly;
160 bool CompilationUnitsEnabled;
161 std::string CheckDependenciesForModuleOnlyModule;
162 std::string VSProjectVersion;
163 std::string VSConfigurationType;
164 bool UseVSVersionInPath;
165 bool UseConfigurationInPath;
166 bool MakeHandlesInstallDirectories;
167 bool GenerateProxyMakefilesInSourceTree;
168 bool InstallFiles;
169 };
170
171 class Environment
172 {
173 public:
174 static std::string GetVariable ( const std::string& name );
175 static std::string GetArch ();
176 static std::string GetIntermediatePath ();
177 static std::string GetOutputPath ();
178 static std::string GetCdOutputPath ();
179 static std::string GetInstallPath ();
180 static std::string GetAutomakeFile ( const std::string& defaultFile );
181 static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
182 const std::string& defaultValue );
183 };
184
185
186 class FileSupportCode
187 {
188 public:
189 static void WriteIfChanged ( char* outbuf,
190 const std::string& filename,
191 bool ignoreError = false );
192 };
193
194
195 class ParseContext
196 {
197 public:
198 If* ifData;
199 CompilationUnit* compilationUnit;
200 ParseContext ();
201 };
202
203
204 class IfableData
205 {
206 public:
207 std::vector<CompilationUnit*> compilationUnits;
208 std::vector<File*> files;
209 std::vector<Include*> includes;
210 std::vector<Define*> defines;
211 std::vector<Library*> libraries;
212 std::vector<Property*> properties;
213 std::vector<Module*> modules;
214 std::vector<CompilerFlag*> compilerFlags;
215 std::vector<If*> ifs;
216 int asmFiles; // number of .asm files in compilationUnits
217
218 IfableData();
219 ~IfableData();
220 void ProcessXML();
221 void ExtractModules( std::vector<Module*> &modules );
222 };
223
224 class Project
225 {
226 std::string xmlfile;
227 XMLElement *node, *head;
228 Backend* _backend;
229 public:
230 const Configuration& configuration;
231 std::string name;
232 std::string makefile;
233 XMLIncludes xmlbuildfiles;
234 std::vector<LinkerFlag*> linkerFlags;
235 std::vector<CDFile*> cdfiles;
236 std::vector<InstallFile*> installfiles;
237 std::vector<Module*> modules;
238 IfableData non_if_data;
239
240 Project ( const Configuration& configuration,
241 const std::string& filename,
242 const std::map<std::string, std::string>* properties = NULL );
243 ~Project ();
244 void SetBackend ( Backend* backend ) { _backend = backend; }
245 Backend& GetBackend() { return *_backend; }
246 void WriteConfigurationFile ();
247 void ExecuteInvocations ();
248
249 void ProcessXML ( const std::string& path );
250 Module* LocateModule ( const std::string& name );
251 const Module* LocateModule ( const std::string& name ) const;
252 const std::string& GetProjectFilename () const;
253 std::string ResolveProperties ( const std::string& s ) const;
254 private:
255 std::string ResolveNextProperty ( const std::string& s ) const;
256 const Property* LookupProperty ( const std::string& name ) const;
257 void SetConfigurationOption ( char* s,
258 std::string name,
259 std::string* alternativeName );
260 void SetConfigurationOption ( char* s,
261 std::string name );
262 void ReadXml ();
263 void ProcessXMLSubElement ( const XMLElement& e,
264 const std::string& path,
265 ParseContext& parseContext );
266
267 // disable copy semantics
268 Project ( const Project& );
269 Project& operator = ( const Project& );
270 };
271
272
273 enum ModuleType
274 {
275 BuildTool = 0,
276 StaticLibrary = 1,
277 ObjectLibrary = 2,
278 Kernel = 3,
279 KernelModeDLL = 4,
280 KernelModeDriver = 5,
281 NativeDLL = 6,
282 NativeCUI = 7,
283 Win32DLL = 8,
284 Win32OCX = 9,
285 Win32CUI = 10,
286 Win32GUI = 11,
287 BootLoader = 12,
288 BootSector = 13,
289 Iso = 14,
290 LiveIso = 15,
291 Test = 16,
292 RpcServer = 17,
293 RpcClient = 18,
294 Alias = 19,
295 BootProgram = 20,
296 Win32SCR = 21,
297 IdlHeader = 23,
298 IsoRegTest = 24,
299 LiveIsoRegTest = 25,
300 EmbeddedTypeLib = 26,
301 ElfExecutable = 27,
302 RpcProxy,
303 TypeDontCare,
304 };
305
306 enum HostType
307 {
308 HostFalse,
309 HostDefault,
310 HostTrue,
311 HostDontCare,
312 };
313
314 enum CompilerType
315 {
316 CompilerTypeDontCare,
317 CompilerTypeCC,
318 CompilerTypeCPP,
319 };
320
321 class FileLocation
322 {
323 public:
324 DirectoryLocation directory;
325 std::string relative_path;
326 std::string name;
327
328 FileLocation ( const DirectoryLocation directory,
329 const std::string& relative_path,
330 const std::string& name,
331 const XMLElement *node = NULL );
332
333 FileLocation ( const FileLocation& other );
334 };
335
336 class Module
337 {
338 public:
339 const Project& project;
340 const XMLElement& node;
341 std::string xmlbuildFile;
342 std::string name;
343 std::string guid;
344 std::string extension;
345 std::string baseaddress;
346 std::string payload;
347 std::string buildtype;
348 ModuleType type;
349 ImportLibrary* importLibrary;
350 Metadata* metadata;
351 bool mangledSymbols;
352 bool underscoreSymbols;
353 bool isUnicode;
354 bool isDefaultEntryPoint;
355 Bootstrap* bootstrap;
356 AutoRegister* autoRegister; // <autoregister> node
357 IfableData non_if_data;
358 std::vector<Invoke*> invocations;
359 std::vector<Dependency*> dependencies;
360 std::vector<CompilerFlag*> compilerFlags;
361 std::vector<LinkerFlag*> linkerFlags;
362 std::vector<StubbedComponent*> stubbedComponents;
363 LinkerScript* linkerScript;
364 PchFile* pch;
365 bool cplusplus;
366 std::string prefix;
367 HostType host;
368 std::string aliasedModuleName;
369 bool allowWarnings;
370 bool enabled;
371 bool isStartupLib;
372 FileLocation *output; // "path/foo.exe"
373 FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
374 FileLocation *install;
375
376 Module ( const Project& project,
377 const XMLElement& moduleNode,
378 const std::string& modulePath );
379 ~Module ();
380 ModuleType GetModuleType ( const std::string& location,
381 const XMLAttribute& attribute );
382 bool HasImportLibrary () const;
383 bool IsDLL () const;
384 std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
385 std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
386 std::string GetEntryPoint(bool leadingUnderscore) const;
387 void GetTargets ( string_list& ) const;
388 std::string GetInvocationTarget ( const int index ) const;
389 bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
390 void InvokeModule () const;
391 void ProcessXML ();
392 private:
393 void SetImportLibrary ( ImportLibrary* importLibrary );
394 DirectoryLocation GetTargetDirectoryTree () const;
395 std::string GetDefaultModuleExtension () const;
396 std::string GetDefaultModuleEntrypoint () const;
397 std::string GetDefaultModuleBaseaddress () const;
398 std::string entrypoint;
399 void ProcessXMLSubElement ( const XMLElement& e,
400 DirectoryLocation directory,
401 const std::string& relative_path,
402 ParseContext& parseContext );
403 };
404
405
406 class Include
407 {
408 public:
409 FileLocation *directory;
410
411 Include ( const Project& project,
412 const XMLElement* includeNode );
413 Include ( const Project& project,
414 const XMLElement* includeNode,
415 const Module* module );
416 Include ( const Project& project,
417 DirectoryLocation directory,
418 const std::string& relative_path );
419 ~Include ();
420 void ProcessXML ();
421 private:
422 const Project& project;
423 const XMLElement* node;
424 const Module* module;
425 DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
426 };
427
428
429 class Define
430 {
431 public:
432 const Project& project;
433 const Module* module;
434 const XMLElement* node;
435 std::string name;
436 std::string value;
437 std::string backend;
438 bool overridable;
439
440 Define ( const Project& project,
441 const XMLElement& defineNode );
442 Define ( const Project& project,
443 const Module* module,
444 const XMLElement& defineNode );
445 Define ( const Project& project,
446 const Module* module,
447 const std::string& name_,
448 const std::string& backend_ = "" );
449 ~Define();
450 void ProcessXML();
451 private:
452 void Initialize();
453 };
454
455
456 class File
457 {
458 public:
459 FileLocation file;
460 bool first;
461 std::string switches;
462 bool isPreCompiledHeader;
463
464 File ( DirectoryLocation directory,
465 const std::string& relative_path,
466 const std::string& name,
467 bool _first,
468 const std::string& _switches,
469 bool _isPreCompiledHeader );
470
471 void ProcessXML();
472 std::string GetFullPath () const;
473 };
474
475
476 class Library
477 {
478 const XMLElement *node;
479 public:
480 const Module& module;
481 std::string name;
482 const Module* importedModule;
483
484 Library ( const XMLElement& _node,
485 const Module& _module,
486 const std::string& _name );
487 Library ( const Module& _module,
488 const std::string& _name );
489
490 void ProcessXML();
491 };
492
493
494 class Invoke
495 {
496 public:
497 const XMLElement& node;
498 const Module& module;
499 const Module* invokeModule;
500 std::vector<InvokeFile*> input;
501 std::vector<InvokeFile*> output;
502
503 Invoke ( const XMLElement& _node,
504 const Module& _module );
505
506 void ProcessXML();
507 void GetTargets ( string_list& targets ) const;
508 std::string GetParameters () const;
509 private:
510 void ProcessXMLSubElement ( const XMLElement& e );
511 void ProcessXMLSubElementInput ( const XMLElement& e );
512 void ProcessXMLSubElementOutput ( const XMLElement& e );
513 };
514
515
516 class InvokeFile
517 {
518 public:
519 const XMLElement& node;
520 std::string name;
521 std::string switches;
522
523 InvokeFile ( const XMLElement& _node,
524 const std::string& _name );
525
526 void ProcessXML ();
527 };
528
529
530 class Dependency
531 {
532 public:
533 const XMLElement& node;
534 const Module& module;
535 const Module* dependencyModule;
536
537 Dependency ( const XMLElement& _node,
538 const Module& _module );
539
540 void ProcessXML();
541 };
542
543 class Metadata
544 {
545 public:
546 const XMLElement& node;
547 const Module& module;
548 std::string name;
549 std::string description;
550 std::string version;
551 std::string copyright;
552 std::string url;
553 std::string date;
554 std::string owner;
555
556 Metadata ( const XMLElement& _node,
557 const Module& _module );
558
559 void ProcessXML();
560 };
561
562 class ImportLibrary : public XmlNode
563 {
564 public:
565 const Module& module;
566 std::string dllname;
567 FileLocation *source;
568
569 ImportLibrary ( const Project& project,
570 const XMLElement& node,
571 const Module& module );
572 };
573
574
575 class If
576 {
577 public:
578 const XMLElement& node;
579 const Project& project;
580 const Module* module;
581 const bool negated;
582 std::string property, value;
583 IfableData data;
584
585 If ( const XMLElement& node_,
586 const Project& project_,
587 const Module* module_,
588 const bool negated_ = false );
589 ~If();
590
591 void ProcessXML();
592 };
593
594
595 class CompilerFlag
596 {
597 public:
598 const Project& project;
599 const Module* module;
600 const XMLElement& node;
601 std::string flag;
602 CompilerType compiler;
603
604 CompilerFlag ( const Project& project,
605 const XMLElement& compilerFlagNode );
606 CompilerFlag ( const Project& project,
607 const Module* module,
608 const XMLElement& compilerFlagNode );
609 ~CompilerFlag ();
610 void ProcessXML();
611 private:
612 void Initialize();
613 };
614
615
616 class LinkerFlag
617 {
618 public:
619 const Project& project;
620 const Module* module;
621 const XMLElement& node;
622 std::string flag;
623
624 LinkerFlag ( const Project& project,
625 const XMLElement& linkerFlagNode );
626 LinkerFlag ( const Project& project,
627 const Module* module,
628 const XMLElement& linkerFlagNode );
629 ~LinkerFlag ();
630 void ProcessXML();
631 private:
632 void Initialize();
633 };
634
635
636 class LinkerScript
637 {
638 public:
639 const XMLElement& node;
640 const Module& module;
641 FileLocation file;
642
643 LinkerScript ( const XMLElement& node,
644 const Module& module,
645 const FileLocation& file );
646 ~LinkerScript ();
647 void ProcessXML();
648 };
649
650
651 class Property
652 {
653 public:
654 const Project& project;
655 const Module* module;
656 std::string name, value;
657
658 Property ( const XMLElement& node_,
659 const Project& project_,
660 const Module* module_ );
661
662 Property ( const Project& project_,
663 const Module* module_,
664 const std::string& name_,
665 const std::string& value_ );
666
667 void ProcessXML();
668 };
669
670
671 class TestSupportCode
672 {
673 public:
674 const Project& project;
675
676 TestSupportCode ( const Project& project );
677 ~TestSupportCode ();
678 void GenerateTestSupportCode ( bool verbose );
679 private:
680 bool IsTestModule ( const Module& module );
681 void GenerateTestSupportCodeForModule ( Module& module,
682 bool verbose );
683 std::string GetHooksFilename ( Module& module );
684 char* WriteStubbedSymbolToHooksFile ( char* buffer,
685 const StubbedComponent& component,
686 const StubbedSymbol& symbol );
687 char* WriteStubbedComponentToHooksFile ( char* buffer,
688 const StubbedComponent& component );
689 void WriteHooksFile ( Module& module );
690 std::string GetStubsFilename ( Module& module );
691 char* WriteStubbedSymbolToStubsFile ( char* buffer,
692 const StubbedComponent& component,
693 const StubbedSymbol& symbol,
694 int stubIndex );
695 char* WriteStubbedComponentToStubsFile ( char* buffer,
696 const StubbedComponent& component,
697 int* stubIndex );
698 void WriteStubsFile ( Module& module );
699 std::string GetStartupFilename ( Module& module );
700 bool IsUnknownCharacter ( char ch );
701 std::string GetTestDispatcherName ( std::string filename );
702 bool IsTestFile ( std::string& filename ) const;
703 void GetSourceFilenames ( string_list& list,
704 Module& module ) const;
705 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
706 Module& module );
707 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
708 Module& module );
709 void WriteStartupFile ( Module& module );
710 };
711
712
713 class SourceFile
714 {
715 public:
716 SourceFile ( AutomaticDependency* automaticDependency,
717 const Module& module,
718 const File& file,
719 SourceFile* parent );
720 void Parse ();
721 std::vector<SourceFile*> files; /* List of files included in this file */
722 const File& file;
723 AutomaticDependency* automaticDependency;
724 const Module& module;
725 std::vector<SourceFile*> parents; /* List of files, this file is included from */
726 time_t lastWriteTime;
727 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
728 SourceFile* youngestFile;
729 private:
730 void Close ();
731 void Open ();
732 void SkipWhitespace ();
733 bool ReadInclude ( std::string& filename,
734 bool& searchCurrentDirectory,
735 bool& includeNext );
736 bool IsIncludedFrom ( const File& file );
737 SourceFile* ParseFile(const File& file);
738 bool CanProcessFile ( const File& file );
739 bool IsParentOf ( const SourceFile* parent,
740 const SourceFile* child );
741 std::string buf;
742 const char *p;
743 const char *end;
744 };
745
746
747 class AutomaticDependency
748 {
749 friend class SourceFileTest;
750 public:
751 const Project& project;
752
753 AutomaticDependency ( const Project& project );
754 ~AutomaticDependency ();
755 bool LocateIncludedFile ( const FileLocation& directory,
756 const std::string& includedFilename );
757 bool LocateIncludedFile ( SourceFile* sourceFile,
758 const Module& module,
759 const std::string& includedFilename,
760 bool searchCurrentDirectory,
761 bool includeNext,
762 File& resolvedFile );
763 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
764 const File& file,
765 SourceFile* parentSourceFile );
766 SourceFile* RetrieveFromCache ( const File& file );
767 void CheckAutomaticDependencies ( bool verbose );
768 void CheckAutomaticDependenciesForModule ( Module& module,
769 bool verbose );
770 private:
771 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
772 void CheckAutomaticDependencies ( const Module& module,
773 bool verbose );
774 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
775 void GetIncludeDirectories ( std::vector<Include*>& includes,
776 const Module& module );
777 void GetModuleFiles ( const Module& module,
778 std::vector<File*>& files ) const;
779 void ParseFiles ();
780 void ParseFiles ( const Module& module );
781 void ParseFile ( const Module& module,
782 const File& file );
783 std::map<std::string, SourceFile*> sourcefile_map;
784 };
785
786
787 class Bootstrap
788 {
789 public:
790 const Project& project;
791 const Module* module;
792 const XMLElement& node;
793 std::string base;
794 std::string nameoncd;
795
796 Bootstrap ( const Project& project,
797 const Module* module,
798 const XMLElement& bootstrapNode );
799 ~Bootstrap ();
800 void ProcessXML();
801 private:
802 bool IsSupportedModuleType ( ModuleType type );
803 void Initialize();
804 static std::string ReplaceVariable ( const std::string& name,
805 const std::string& value,
806 std::string path );
807 };
808
809
810 class CDFile : public XmlNode
811 {
812 public:
813 FileLocation *source;
814 FileLocation *target;
815
816 CDFile ( const Project& project,
817 const XMLElement& bootstrapNode,
818 const std::string& path );
819 private:
820 static std::string ReplaceVariable ( const std::string& name,
821 const std::string& value,
822 std::string path );
823 };
824
825
826 class InstallFile : public XmlNode
827 {
828 public:
829 FileLocation *source;
830 FileLocation *target;
831
832 InstallFile ( const Project& project,
833 const XMLElement& bootstrapNode,
834 const std::string& path );
835 };
836
837
838 class PchFile
839 {
840 public:
841 const XMLElement& node;
842 const Module& module;
843 FileLocation file;
844
845 PchFile (
846 const XMLElement& node,
847 const Module& module,
848 const FileLocation& file );
849 void ProcessXML();
850 };
851
852
853 class StubbedComponent
854 {
855 public:
856 const Module* module;
857 const XMLElement& node;
858 std::string name;
859 std::vector<StubbedSymbol*> symbols;
860
861 StubbedComponent ( const Module* module_,
862 const XMLElement& stubbedComponentNode );
863 ~StubbedComponent ();
864 void ProcessXML ();
865 void ProcessXMLSubElement ( const XMLElement& e );
866 };
867
868
869 class StubbedSymbol
870 {
871 public:
872 const XMLElement& node;
873 std::string symbol;
874 std::string newname;
875 std::string strippedName;
876
877 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
878 ~StubbedSymbol ();
879 void ProcessXML();
880 private:
881 std::string StripSymbol ( std::string symbol );
882 };
883
884
885 class CompilationUnit
886 {
887 public:
888 std::string name;
889
890 CompilationUnit ( const File* file );
891 CompilationUnit ( const Project* project,
892 const Module* module,
893 const XMLElement* node );
894 ~CompilationUnit ();
895 void ProcessXML();
896 bool IsGeneratedFile () const;
897 bool HasFileWithExtension ( const std::string& extension ) const;
898 bool IsFirstFile () const;
899 const FileLocation& GetFilename () const;
900 const std::string& GetSwitches () const;
901 void AddFile ( const File * file );
902 const std::vector<const File*> GetFiles () const;
903 private:
904 const Project* project;
905 const Module* module;
906 const XMLElement* node;
907 std::vector<const File*> files;
908 FileLocation *default_name;
909 };
910
911
912 class CompilationUnitSupportCode
913 {
914 public:
915 const Project& project;
916
917 CompilationUnitSupportCode ( const Project& project );
918 ~CompilationUnitSupportCode ();
919 void Generate ( bool verbose );
920 private:
921 void GenerateForModule ( Module& module,
922 bool verbose );
923 std::string GetCompilationUnitFilename ( Module& module,
924 CompilationUnit& compilationUnit );
925 void WriteCompilationUnitFile ( Module& module,
926 CompilationUnit& compilationUnit );
927 };
928
929
930 enum AutoRegisterType
931 {
932 DllRegisterServer,
933 DllInstall,
934 Both
935 };
936
937 class AutoRegister : public XmlNode
938 {
939 public:
940 const Module* module;
941 std::string infSection;
942 AutoRegisterType type;
943 AutoRegister ( const Project& project_,
944 const Module* module_,
945 const XMLElement& node_ );
946 private:
947 bool IsSupportedModuleType ( ModuleType type );
948 AutoRegisterType GetAutoRegisterType( const std::string& type );
949 void Initialize ();
950 };
951
952
953 class SysSetupGenerator
954 {
955 public:
956 const Project& project;
957 SysSetupGenerator ( const Project& project );
958 ~SysSetupGenerator ();
959 void Generate ();
960 private:
961 std::string GetDirectoryId ( const Module& module );
962 std::string GetFlags ( const Module& module );
963 void Generate ( HINF inf,
964 const Module& module );
965 };
966
967
968 extern void
969 InitializeEnvironment ();
970
971 extern std::string
972 Right ( const std::string& s, size_t n );
973
974 extern std::string
975 Replace ( const std::string& s, const std::string& find, const std::string& with );
976
977 extern std::string
978 ChangeSeparator ( const std::string& s,
979 const char fromSeparator,
980 const char toSeparator );
981
982 extern std::string
983 FixSeparator ( const std::string& s );
984
985 extern std::string
986 FixSeparatorForSystemCommand ( const std::string& s );
987
988 extern std::string
989 DosSeparator ( const std::string& s );
990
991 extern std::string
992 ReplaceExtension (
993 const std::string& filename,
994 const std::string& newExtension );
995
996 extern std::string
997 GetSubPath (
998 const Project& project,
999 const std::string& location,
1000 const std::string& path,
1001 const std::string& att_value );
1002
1003 extern std::string
1004 GetExtension ( const FileLocation& file );
1005
1006 extern std::string
1007 NormalizeFilename ( const std::string& filename );
1008
1009 extern std::string
1010 ToLower ( std::string filename );
1011
1012 #endif /* __RBUILD_H */