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