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