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