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