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