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