Fix separators for .rbuild files in the generated makefile
[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 class FileLocation
315 {
316 public:
317 DirectoryLocation directory;
318 std::string relative_path;
319 std::string name;
320
321 FileLocation ( const DirectoryLocation directory,
322 const std::string& relative_path,
323 const std::string& name,
324 const XMLElement *node = NULL );
325
326 FileLocation ( const FileLocation& other );
327 };
328
329 class Module
330 {
331 public:
332 const Project& project;
333 const XMLElement& node;
334 std::string xmlbuildFile;
335 std::string name;
336 std::string guid;
337 std::string extension;
338 std::string baseaddress;
339 std::string payload;
340 std::string buildtype;
341 ModuleType type;
342 ImportLibrary* importLibrary;
343 Metadata* metadata;
344 bool mangledSymbols;
345 bool underscoreSymbols;
346 bool isUnicode;
347 bool isDefaultEntryPoint;
348 Bootstrap* bootstrap;
349 AutoRegister* autoRegister; // <autoregister> node
350 IfableData non_if_data;
351 std::vector<Invoke*> invocations;
352 std::vector<Dependency*> dependencies;
353 std::vector<CompilerFlag*> compilerFlags;
354 std::vector<LinkerFlag*> linkerFlags;
355 std::vector<StubbedComponent*> stubbedComponents;
356 LinkerScript* linkerScript;
357 PchFile* pch;
358 bool cplusplus;
359 std::string prefix;
360 HostType host;
361 std::string aliasedModuleName;
362 bool allowWarnings;
363 bool enabled;
364 bool isStartupLib;
365 FileLocation *output; // "path/foo.exe"
366 FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
367 FileLocation *install;
368
369 Module ( const Project& project,
370 const XMLElement& moduleNode,
371 const std::string& modulePath );
372 ~Module ();
373 ModuleType GetModuleType ( const std::string& location,
374 const XMLAttribute& attribute );
375 bool HasImportLibrary () const;
376 bool IsDLL () const;
377 std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
378 std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
379 std::string GetEntryPoint(bool leadingUnderscore) const;
380 void GetTargets ( string_list& ) const;
381 std::string GetInvocationTarget ( const int index ) const;
382 bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
383 void InvokeModule () const;
384 void ProcessXML ();
385 private:
386 void SetImportLibrary ( ImportLibrary* importLibrary );
387 DirectoryLocation GetTargetDirectoryTree () const;
388 std::string GetDefaultModuleExtension () const;
389 std::string GetDefaultModuleEntrypoint () const;
390 std::string GetDefaultModuleBaseaddress () const;
391 std::string entrypoint;
392 void ProcessXMLSubElement ( const XMLElement& e,
393 DirectoryLocation directory,
394 const std::string& relative_path,
395 ParseContext& parseContext );
396 };
397
398
399 class Include
400 {
401 public:
402 FileLocation *directory;
403
404 Include ( const Project& project,
405 const XMLElement* includeNode );
406 Include ( const Project& project,
407 const XMLElement* includeNode,
408 const Module* module );
409 Include ( const Project& project,
410 DirectoryLocation directory,
411 const std::string& relative_path );
412 ~Include ();
413 void ProcessXML ();
414 private:
415 const Project& project;
416 const XMLElement* node;
417 const Module* module;
418 DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
419 };
420
421
422 class Define
423 {
424 public:
425 const Project& project;
426 const Module* module;
427 const XMLElement* node;
428 std::string name;
429 std::string value;
430 std::string backend;
431 bool overridable;
432
433 Define ( const Project& project,
434 const XMLElement& defineNode );
435 Define ( const Project& project,
436 const Module* module,
437 const XMLElement& defineNode );
438 Define ( const Project& project,
439 const Module* module,
440 const std::string& name_,
441 const std::string& backend_ = "" );
442 ~Define();
443 void ProcessXML();
444 private:
445 void Initialize();
446 };
447
448
449 class File
450 {
451 public:
452 FileLocation file;
453 bool first;
454 std::string switches;
455 bool isPreCompiledHeader;
456
457 File ( DirectoryLocation directory,
458 const std::string& relative_path,
459 const std::string& name,
460 bool _first,
461 const std::string& _switches,
462 bool _isPreCompiledHeader );
463
464 void ProcessXML();
465 std::string GetFullPath () const;
466 };
467
468
469 class Library
470 {
471 const XMLElement *node;
472 public:
473 const Module& module;
474 std::string name;
475 const Module* importedModule;
476
477 Library ( const XMLElement& _node,
478 const Module& _module,
479 const std::string& _name );
480 Library ( const Module& _module,
481 const std::string& _name );
482
483 void ProcessXML();
484 };
485
486
487 class Invoke
488 {
489 public:
490 const XMLElement& node;
491 const Module& module;
492 const Module* invokeModule;
493 std::vector<InvokeFile*> input;
494 std::vector<InvokeFile*> output;
495
496 Invoke ( const XMLElement& _node,
497 const Module& _module );
498
499 void ProcessXML();
500 void GetTargets ( string_list& targets ) const;
501 std::string GetParameters () const;
502 private:
503 void ProcessXMLSubElement ( const XMLElement& e );
504 void ProcessXMLSubElementInput ( const XMLElement& e );
505 void ProcessXMLSubElementOutput ( const XMLElement& e );
506 };
507
508
509 class InvokeFile
510 {
511 public:
512 const XMLElement& node;
513 std::string name;
514 std::string switches;
515
516 InvokeFile ( const XMLElement& _node,
517 const std::string& _name );
518
519 void ProcessXML ();
520 };
521
522
523 class Dependency
524 {
525 public:
526 const XMLElement& node;
527 const Module& module;
528 const Module* dependencyModule;
529
530 Dependency ( const XMLElement& _node,
531 const Module& _module );
532
533 void ProcessXML();
534 };
535
536 class Metadata
537 {
538 public:
539 const XMLElement& node;
540 const Module& module;
541 std::string name;
542 std::string description;
543 std::string version;
544 std::string copyright;
545 std::string url;
546 std::string date;
547 std::string owner;
548
549 Metadata ( const XMLElement& _node,
550 const Module& _module );
551
552 void ProcessXML();
553 };
554
555 class ImportLibrary : public XmlNode
556 {
557 public:
558 const Module& module;
559 std::string dllname;
560 FileLocation *source;
561
562 ImportLibrary ( const Project& project,
563 const XMLElement& node,
564 const Module& module );
565 };
566
567
568 class If
569 {
570 public:
571 const XMLElement& node;
572 const Project& project;
573 const Module* module;
574 const bool negated;
575 std::string property, value;
576 IfableData data;
577
578 If ( const XMLElement& node_,
579 const Project& project_,
580 const Module* module_,
581 const bool negated_ = false );
582 ~If();
583
584 void ProcessXML();
585 };
586
587
588 class CompilerFlag
589 {
590 public:
591 const Project& project;
592 const Module* module;
593 const XMLElement& node;
594 std::string flag;
595
596 CompilerFlag ( const Project& project,
597 const XMLElement& compilerFlagNode );
598 CompilerFlag ( const Project& project,
599 const Module* module,
600 const XMLElement& compilerFlagNode );
601 ~CompilerFlag ();
602 void ProcessXML();
603 private:
604 void Initialize();
605 };
606
607
608 class LinkerFlag
609 {
610 public:
611 const Project& project;
612 const Module* module;
613 const XMLElement& node;
614 std::string flag;
615
616 LinkerFlag ( const Project& project,
617 const XMLElement& linkerFlagNode );
618 LinkerFlag ( const Project& project,
619 const Module* module,
620 const XMLElement& linkerFlagNode );
621 ~LinkerFlag ();
622 void ProcessXML();
623 private:
624 void Initialize();
625 };
626
627
628 class LinkerScript
629 {
630 public:
631 const XMLElement& node;
632 const Module& module;
633 FileLocation file;
634
635 LinkerScript ( const XMLElement& node,
636 const Module& module,
637 const FileLocation& file );
638 ~LinkerScript ();
639 void ProcessXML();
640 };
641
642
643 class Property
644 {
645 public:
646 const Project& project;
647 const Module* module;
648 std::string name, value;
649
650 Property ( const XMLElement& node_,
651 const Project& project_,
652 const Module* module_ );
653
654 Property ( const Project& project_,
655 const Module* module_,
656 const std::string& name_,
657 const std::string& value_ );
658
659 void ProcessXML();
660 };
661
662
663 class TestSupportCode
664 {
665 public:
666 const Project& project;
667
668 TestSupportCode ( const Project& project );
669 ~TestSupportCode ();
670 void GenerateTestSupportCode ( bool verbose );
671 private:
672 bool IsTestModule ( const Module& module );
673 void GenerateTestSupportCodeForModule ( Module& module,
674 bool verbose );
675 std::string GetHooksFilename ( Module& module );
676 char* WriteStubbedSymbolToHooksFile ( char* buffer,
677 const StubbedComponent& component,
678 const StubbedSymbol& symbol );
679 char* WriteStubbedComponentToHooksFile ( char* buffer,
680 const StubbedComponent& component );
681 void WriteHooksFile ( Module& module );
682 std::string GetStubsFilename ( Module& module );
683 char* WriteStubbedSymbolToStubsFile ( char* buffer,
684 const StubbedComponent& component,
685 const StubbedSymbol& symbol,
686 int stubIndex );
687 char* WriteStubbedComponentToStubsFile ( char* buffer,
688 const StubbedComponent& component,
689 int* stubIndex );
690 void WriteStubsFile ( Module& module );
691 std::string GetStartupFilename ( Module& module );
692 bool IsUnknownCharacter ( char ch );
693 std::string GetTestDispatcherName ( std::string filename );
694 bool IsTestFile ( std::string& filename ) const;
695 void GetSourceFilenames ( string_list& list,
696 Module& module ) const;
697 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
698 Module& module );
699 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
700 Module& module );
701 void WriteStartupFile ( Module& module );
702 };
703
704
705 class SourceFile
706 {
707 public:
708 SourceFile ( AutomaticDependency* automaticDependency,
709 const Module& module,
710 const File& file,
711 SourceFile* parent );
712 void Parse ();
713 std::vector<SourceFile*> files; /* List of files included in this file */
714 const File& file;
715 AutomaticDependency* automaticDependency;
716 const Module& module;
717 std::vector<SourceFile*> parents; /* List of files, this file is included from */
718 time_t lastWriteTime;
719 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
720 SourceFile* youngestFile;
721 private:
722 void Close ();
723 void Open ();
724 void SkipWhitespace ();
725 bool ReadInclude ( std::string& filename,
726 bool& searchCurrentDirectory,
727 bool& includeNext );
728 bool IsIncludedFrom ( const File& file );
729 SourceFile* ParseFile(const File& file);
730 bool CanProcessFile ( const File& file );
731 bool IsParentOf ( const SourceFile* parent,
732 const SourceFile* child );
733 std::string buf;
734 const char *p;
735 const char *end;
736 };
737
738
739 class AutomaticDependency
740 {
741 friend class SourceFileTest;
742 public:
743 const Project& project;
744
745 AutomaticDependency ( const Project& project );
746 ~AutomaticDependency ();
747 bool LocateIncludedFile ( const FileLocation& directory,
748 const std::string& includedFilename );
749 bool LocateIncludedFile ( SourceFile* sourceFile,
750 const Module& module,
751 const std::string& includedFilename,
752 bool searchCurrentDirectory,
753 bool includeNext,
754 File& resolvedFile );
755 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
756 const File& file,
757 SourceFile* parentSourceFile );
758 SourceFile* RetrieveFromCache ( const File& file );
759 void CheckAutomaticDependencies ( bool verbose );
760 void CheckAutomaticDependenciesForModule ( Module& module,
761 bool verbose );
762 private:
763 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
764 void CheckAutomaticDependencies ( const Module& module,
765 bool verbose );
766 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
767 void GetIncludeDirectories ( std::vector<Include*>& includes,
768 const Module& module );
769 void GetModuleFiles ( const Module& module,
770 std::vector<File*>& files ) const;
771 void ParseFiles ();
772 void ParseFiles ( const Module& module );
773 void ParseFile ( const Module& module,
774 const File& file );
775 std::map<std::string, SourceFile*> sourcefile_map;
776 };
777
778
779 class Bootstrap
780 {
781 public:
782 const Project& project;
783 const Module* module;
784 const XMLElement& node;
785 std::string base;
786 std::string nameoncd;
787
788 Bootstrap ( const Project& project,
789 const Module* module,
790 const XMLElement& bootstrapNode );
791 ~Bootstrap ();
792 void ProcessXML();
793 private:
794 bool IsSupportedModuleType ( ModuleType type );
795 void Initialize();
796 static std::string ReplaceVariable ( const std::string& name,
797 const std::string& value,
798 std::string path );
799 };
800
801
802 class CDFile : public XmlNode
803 {
804 public:
805 FileLocation *source;
806 FileLocation *target;
807
808 CDFile ( const Project& project,
809 const XMLElement& bootstrapNode,
810 const std::string& path );
811 private:
812 static std::string ReplaceVariable ( const std::string& name,
813 const std::string& value,
814 std::string path );
815 };
816
817
818 class InstallFile : public XmlNode
819 {
820 public:
821 FileLocation *source;
822 FileLocation *target;
823
824 InstallFile ( const Project& project,
825 const XMLElement& bootstrapNode,
826 const std::string& path );
827 };
828
829
830 class PchFile
831 {
832 public:
833 const XMLElement& node;
834 const Module& module;
835 FileLocation file;
836
837 PchFile (
838 const XMLElement& node,
839 const Module& module,
840 const FileLocation& file );
841 void ProcessXML();
842 };
843
844
845 class StubbedComponent
846 {
847 public:
848 const Module* module;
849 const XMLElement& node;
850 std::string name;
851 std::vector<StubbedSymbol*> symbols;
852
853 StubbedComponent ( const Module* module_,
854 const XMLElement& stubbedComponentNode );
855 ~StubbedComponent ();
856 void ProcessXML ();
857 void ProcessXMLSubElement ( const XMLElement& e );
858 };
859
860
861 class StubbedSymbol
862 {
863 public:
864 const XMLElement& node;
865 std::string symbol;
866 std::string newname;
867 std::string strippedName;
868
869 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
870 ~StubbedSymbol ();
871 void ProcessXML();
872 private:
873 std::string StripSymbol ( std::string symbol );
874 };
875
876
877 class CompilationUnit
878 {
879 public:
880 std::string name;
881
882 CompilationUnit ( const File* file );
883 CompilationUnit ( const Project* project,
884 const Module* module,
885 const XMLElement* node );
886 ~CompilationUnit ();
887 void ProcessXML();
888 bool IsGeneratedFile () const;
889 bool HasFileWithExtension ( const std::string& extension ) const;
890 bool IsFirstFile () const;
891 const FileLocation& GetFilename () const;
892 const std::string& GetSwitches () const;
893 void AddFile ( const File * file );
894 const std::vector<const File*> GetFiles () const;
895 private:
896 const Project* project;
897 const Module* module;
898 const XMLElement* node;
899 std::vector<const File*> files;
900 FileLocation *default_name;
901 };
902
903
904 class CompilationUnitSupportCode
905 {
906 public:
907 const Project& project;
908
909 CompilationUnitSupportCode ( const Project& project );
910 ~CompilationUnitSupportCode ();
911 void Generate ( bool verbose );
912 private:
913 void GenerateForModule ( Module& module,
914 bool verbose );
915 std::string GetCompilationUnitFilename ( Module& module,
916 CompilationUnit& compilationUnit );
917 void WriteCompilationUnitFile ( Module& module,
918 CompilationUnit& compilationUnit );
919 };
920
921
922 enum AutoRegisterType
923 {
924 DllRegisterServer,
925 DllInstall,
926 Both
927 };
928
929 class AutoRegister : public XmlNode
930 {
931 public:
932 const Module* module;
933 std::string infSection;
934 AutoRegisterType type;
935 AutoRegister ( const Project& project_,
936 const Module* module_,
937 const XMLElement& node_ );
938 private:
939 bool IsSupportedModuleType ( ModuleType type );
940 AutoRegisterType GetAutoRegisterType( const std::string& type );
941 void Initialize ();
942 };
943
944
945 class SysSetupGenerator
946 {
947 public:
948 const Project& project;
949 SysSetupGenerator ( const Project& project );
950 ~SysSetupGenerator ();
951 void Generate ();
952 private:
953 std::string GetDirectoryId ( const Module& module );
954 std::string GetFlags ( const Module& module );
955 void Generate ( HINF inf,
956 const Module& module );
957 };
958
959
960 extern void
961 InitializeEnvironment ();
962
963 extern std::string
964 Right ( const std::string& s, size_t n );
965
966 extern std::string
967 Replace ( const std::string& s, const std::string& find, const std::string& with );
968
969 extern std::string
970 ChangeSeparator ( const std::string& s,
971 const char fromSeparator,
972 const char toSeparator );
973
974 extern std::string
975 FixSeparator ( const std::string& s );
976
977 extern std::string
978 FixSeparatorForSystemCommand ( const std::string& s );
979
980 extern std::string
981 DosSeparator ( const std::string& s );
982
983 extern std::string
984 ReplaceExtension (
985 const std::string& filename,
986 const std::string& newExtension );
987
988 extern std::string
989 GetSubPath (
990 const Project& project,
991 const std::string& location,
992 const std::string& path,
993 const std::string& att_value );
994
995 extern std::string
996 GetExtension ( const FileLocation& file );
997
998 extern std::string
999 NormalizeFilename ( const std::string& filename );
1000
1001 extern std::string
1002 ToLower ( std::string filename );
1003
1004 #endif /* __RBUILD_H */