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