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