e9f7f2051253747dd518cfa1872eaf4855a7ccc6
[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 };
307
308 enum HostType
309 {
310 HostFalse,
311 HostDefault,
312 HostTrue,
313 HostDontCare,
314 };
315
316 enum CompilerType
317 {
318 CompilerTypeDontCare,
319 CompilerTypeCC,
320 CompilerTypeCPP,
321 };
322
323 class FileLocation
324 {
325 public:
326 DirectoryLocation directory;
327 std::string relative_path;
328 std::string name;
329
330 FileLocation ( const DirectoryLocation directory,
331 const std::string& relative_path,
332 const std::string& name,
333 const XMLElement *node = NULL );
334
335 FileLocation ( const FileLocation& other );
336 };
337
338 class Module
339 {
340 public:
341 const Project& project;
342 const XMLElement& node;
343 std::string xmlbuildFile;
344 std::string name;
345 std::string guid;
346 std::string extension;
347 std::string baseaddress;
348 std::string payload;
349 std::string buildtype;
350 ModuleType type;
351 ImportLibrary* importLibrary;
352 Metadata* metadata;
353 bool mangledSymbols;
354 bool underscoreSymbols;
355 bool isUnicode;
356 bool isDefaultEntryPoint;
357 Bootstrap* bootstrap;
358 AutoRegister* autoRegister; // <autoregister> node
359 IfableData non_if_data;
360 std::vector<Invoke*> invocations;
361 std::vector<Dependency*> dependencies;
362 std::vector<CompilerFlag*> compilerFlags;
363 std::vector<LinkerFlag*> linkerFlags;
364 std::vector<StubbedComponent*> stubbedComponents;
365 LinkerScript* linkerScript;
366 PchFile* pch;
367 bool cplusplus;
368 std::string prefix;
369 HostType host;
370 std::string aliasedModuleName;
371 bool allowWarnings;
372 bool enabled;
373 bool isStartupLib;
374 FileLocation *output; // "path/foo.exe"
375 FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
376 FileLocation *install;
377
378 Module ( const Project& project,
379 const XMLElement& moduleNode,
380 const std::string& modulePath );
381 ~Module ();
382 ModuleType GetModuleType ( const std::string& location,
383 const XMLAttribute& attribute );
384 bool HasImportLibrary () const;
385 bool IsDLL () const;
386 std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
387 std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
388 std::string GetEntryPoint(bool leadingUnderscore) const;
389 void GetTargets ( string_list& ) const;
390 std::string GetInvocationTarget ( const int index ) const;
391 bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
392 void InvokeModule () const;
393 void ProcessXML ();
394 private:
395 void SetImportLibrary ( ImportLibrary* importLibrary );
396 DirectoryLocation GetTargetDirectoryTree () const;
397 std::string GetDefaultModuleExtension () const;
398 std::string GetDefaultModuleEntrypoint () const;
399 std::string GetDefaultModuleBaseaddress () const;
400 std::string entrypoint;
401 void ProcessXMLSubElement ( const XMLElement& e,
402 DirectoryLocation directory,
403 const std::string& relative_path,
404 ParseContext& parseContext );
405 };
406
407
408 class Include
409 {
410 public:
411 FileLocation *directory;
412
413 Include ( const Project& project,
414 const XMLElement* includeNode );
415 Include ( const Project& project,
416 const XMLElement* includeNode,
417 const Module* module );
418 Include ( const Project& project,
419 DirectoryLocation directory,
420 const std::string& relative_path );
421 ~Include ();
422 void ProcessXML ();
423 private:
424 const Project& project;
425 const XMLElement* node;
426 const Module* module;
427 DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
428 };
429
430
431 class Define
432 {
433 public:
434 const Project& project;
435 const Module* module;
436 const XMLElement* node;
437 std::string name;
438 std::string value;
439 std::string backend;
440 bool overridable;
441
442 Define ( const Project& project,
443 const XMLElement& defineNode );
444 Define ( const Project& project,
445 const Module* module,
446 const XMLElement& defineNode );
447 Define ( const Project& project,
448 const Module* module,
449 const std::string& name_,
450 const std::string& backend_ = "" );
451 ~Define();
452 void ProcessXML();
453 private:
454 void Initialize();
455 };
456
457
458 class File
459 {
460 public:
461 FileLocation file;
462 bool first;
463 std::string switches;
464 bool isPreCompiledHeader;
465
466 File ( DirectoryLocation directory,
467 const std::string& relative_path,
468 const std::string& name,
469 bool _first,
470 const std::string& _switches,
471 bool _isPreCompiledHeader );
472
473 void ProcessXML();
474 std::string GetFullPath () const;
475 };
476
477
478 class Library
479 {
480 const XMLElement *node;
481 public:
482 const Module& module;
483 std::string name;
484 const Module* importedModule;
485
486 Library ( const XMLElement& _node,
487 const Module& _module,
488 const std::string& _name );
489 Library ( const Module& _module,
490 const std::string& _name );
491
492 void ProcessXML();
493 };
494
495
496 class Invoke
497 {
498 public:
499 const XMLElement& node;
500 const Module& module;
501 const Module* invokeModule;
502 std::vector<InvokeFile*> input;
503 std::vector<InvokeFile*> output;
504
505 Invoke ( const XMLElement& _node,
506 const Module& _module );
507
508 void ProcessXML();
509 void GetTargets ( string_list& targets ) const;
510 std::string GetParameters () const;
511 private:
512 void ProcessXMLSubElement ( const XMLElement& e );
513 void ProcessXMLSubElementInput ( const XMLElement& e );
514 void ProcessXMLSubElementOutput ( const XMLElement& e );
515 };
516
517
518 class InvokeFile
519 {
520 public:
521 const XMLElement& node;
522 std::string name;
523 std::string switches;
524
525 InvokeFile ( const XMLElement& _node,
526 const std::string& _name );
527
528 void ProcessXML ();
529 };
530
531
532 class Dependency
533 {
534 public:
535 const XMLElement& node;
536 const Module& module;
537 const Module* dependencyModule;
538
539 Dependency ( const XMLElement& _node,
540 const Module& _module );
541
542 void ProcessXML();
543 };
544
545 class Metadata
546 {
547 public:
548 const XMLElement& node;
549 const Module& module;
550 std::string name;
551 std::string description;
552 std::string version;
553 std::string copyright;
554 std::string url;
555 std::string date;
556 std::string owner;
557
558 Metadata ( const XMLElement& _node,
559 const Module& _module );
560
561 void ProcessXML();
562 };
563
564 class ImportLibrary : public XmlNode
565 {
566 public:
567 const Module& module;
568 std::string dllname;
569 FileLocation *source;
570
571 ImportLibrary ( const Project& project,
572 const XMLElement& node,
573 const Module& module );
574 ~ImportLibrary ();
575 };
576
577
578 class If
579 {
580 public:
581 const XMLElement& node;
582 const Project& project;
583 const Module* module;
584 const bool negated;
585 std::string property, value;
586 IfableData data;
587
588 If ( const XMLElement& node_,
589 const Project& project_,
590 const Module* module_,
591 const bool negated_ = false );
592 ~If();
593
594 void ProcessXML();
595 };
596
597
598 class CompilerFlag
599 {
600 public:
601 const Project& project;
602 const Module* module;
603 const XMLElement& node;
604 std::string flag;
605 CompilerType compiler;
606
607 CompilerFlag ( const Project& project,
608 const XMLElement& compilerFlagNode );
609 CompilerFlag ( const Project& project,
610 const Module* module,
611 const XMLElement& compilerFlagNode );
612 ~CompilerFlag ();
613 void ProcessXML();
614 private:
615 void Initialize();
616 };
617
618
619 class LinkerFlag
620 {
621 public:
622 const Project& project;
623 const Module* module;
624 const XMLElement& node;
625 std::string flag;
626
627 LinkerFlag ( const Project& project,
628 const XMLElement& linkerFlagNode );
629 LinkerFlag ( const Project& project,
630 const Module* module,
631 const XMLElement& linkerFlagNode );
632 ~LinkerFlag ();
633 void ProcessXML();
634 private:
635 void Initialize();
636 };
637
638
639 class LinkerScript
640 {
641 public:
642 const XMLElement& node;
643 const Module& module;
644 const FileLocation *file;
645
646 LinkerScript ( const XMLElement& node,
647 const Module& module,
648 const FileLocation *file );
649 ~LinkerScript ();
650 void ProcessXML();
651 };
652
653
654 class Property
655 {
656 public:
657 const Project& project;
658 const Module* module;
659 std::string name, value;
660
661 Property ( const XMLElement& node_,
662 const Project& project_,
663 const Module* module_ );
664
665 Property ( const Project& project_,
666 const Module* module_,
667 const std::string& name_,
668 const std::string& value_ );
669
670 void ProcessXML();
671 };
672
673
674 class TestSupportCode
675 {
676 public:
677 const Project& project;
678
679 TestSupportCode ( const Project& project );
680 ~TestSupportCode ();
681 void GenerateTestSupportCode ( bool verbose );
682 private:
683 bool IsTestModule ( const Module& module );
684 void GenerateTestSupportCodeForModule ( Module& module,
685 bool verbose );
686 std::string GetHooksFilename ( Module& module );
687 char* WriteStubbedSymbolToHooksFile ( char* buffer,
688 const StubbedComponent& component,
689 const StubbedSymbol& symbol );
690 char* WriteStubbedComponentToHooksFile ( char* buffer,
691 const StubbedComponent& component );
692 void WriteHooksFile ( Module& module );
693 std::string GetStubsFilename ( Module& module );
694 char* WriteStubbedSymbolToStubsFile ( char* buffer,
695 const StubbedComponent& component,
696 const StubbedSymbol& symbol,
697 int stubIndex );
698 char* WriteStubbedComponentToStubsFile ( char* buffer,
699 const StubbedComponent& component,
700 int* stubIndex );
701 void WriteStubsFile ( Module& module );
702 std::string GetStartupFilename ( Module& module );
703 bool IsUnknownCharacter ( char ch );
704 std::string GetTestDispatcherName ( std::string filename );
705 bool IsTestFile ( std::string& filename ) const;
706 void GetSourceFilenames ( string_list& list,
707 Module& module ) const;
708 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
709 Module& module );
710 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
711 Module& module );
712 void WriteStartupFile ( Module& module );
713 };
714
715
716 class SourceFile
717 {
718 public:
719 SourceFile ( AutomaticDependency* automaticDependency,
720 const Module& module,
721 const File& file,
722 SourceFile* parent );
723 void Parse ();
724 std::vector<SourceFile*> files; /* List of files included in this file */
725 const File& file;
726 AutomaticDependency* automaticDependency;
727 const Module& module;
728 std::vector<SourceFile*> parents; /* List of files, this file is included from */
729 time_t lastWriteTime;
730 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
731 SourceFile* youngestFile;
732 private:
733 void Close ();
734 void Open ();
735 void SkipWhitespace ();
736 bool ReadInclude ( std::string& filename,
737 bool& searchCurrentDirectory,
738 bool& includeNext );
739 bool IsIncludedFrom ( const File& file );
740 SourceFile* ParseFile(const File& file);
741 bool CanProcessFile ( const File& file );
742 bool IsParentOf ( const SourceFile* parent,
743 const SourceFile* child );
744 std::string buf;
745 const char *p;
746 const char *end;
747 };
748
749
750 class AutomaticDependency
751 {
752 friend class SourceFileTest;
753 public:
754 const Project& project;
755
756 AutomaticDependency ( const Project& project );
757 ~AutomaticDependency ();
758 bool LocateIncludedFile ( const FileLocation& directory,
759 const std::string& includedFilename );
760 bool LocateIncludedFile ( SourceFile* sourceFile,
761 const Module& module,
762 const std::string& includedFilename,
763 bool searchCurrentDirectory,
764 bool includeNext,
765 File& resolvedFile );
766 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
767 const File& file,
768 SourceFile* parentSourceFile );
769 SourceFile* RetrieveFromCache ( const File& file );
770 void CheckAutomaticDependencies ( bool verbose );
771 void CheckAutomaticDependenciesForModule ( Module& module,
772 bool verbose );
773 private:
774 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
775 void CheckAutomaticDependencies ( const Module& module,
776 bool verbose );
777 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
778 void GetIncludeDirectories ( std::vector<Include*>& includes,
779 const Module& module );
780 void GetModuleFiles ( const Module& module,
781 std::vector<File*>& files ) const;
782 void ParseFiles ();
783 void ParseFiles ( const Module& module );
784 void ParseFile ( const Module& module,
785 const File& file );
786 std::map<std::string, SourceFile*> sourcefile_map;
787 };
788
789
790 class Bootstrap
791 {
792 public:
793 const Project& project;
794 const Module* module;
795 const XMLElement& node;
796 std::string base;
797 std::string nameoncd;
798
799 Bootstrap ( const Project& project,
800 const Module* module,
801 const XMLElement& bootstrapNode );
802 ~Bootstrap ();
803 void ProcessXML();
804 private:
805 bool IsSupportedModuleType ( ModuleType type );
806 void Initialize();
807 static std::string ReplaceVariable ( const std::string& name,
808 const std::string& value,
809 std::string path );
810 };
811
812
813 class CDFile : public XmlNode
814 {
815 public:
816 FileLocation *source;
817 FileLocation *target;
818
819 CDFile ( const Project& project,
820 const XMLElement& bootstrapNode,
821 const std::string& path );
822 ~CDFile ();
823 private:
824 static std::string ReplaceVariable ( const std::string& name,
825 const std::string& value,
826 std::string path );
827 };
828
829
830 class InstallFile : public XmlNode
831 {
832 public:
833 FileLocation *source;
834 FileLocation *target;
835
836 InstallFile ( const Project& project,
837 const XMLElement& bootstrapNode,
838 const std::string& path );
839 ~InstallFile ();
840 };
841
842
843 class PchFile
844 {
845 public:
846 const XMLElement& node;
847 const Module& module;
848 const FileLocation *file;
849
850 PchFile (
851 const XMLElement& node,
852 const Module& module,
853 const FileLocation *file );
854 ~PchFile();
855 void ProcessXML();
856 };
857
858
859 class StubbedComponent
860 {
861 public:
862 const Module* module;
863 const XMLElement& node;
864 std::string name;
865 std::vector<StubbedSymbol*> symbols;
866
867 StubbedComponent ( const Module* module_,
868 const XMLElement& stubbedComponentNode );
869 ~StubbedComponent ();
870 void ProcessXML ();
871 void ProcessXMLSubElement ( const XMLElement& e );
872 };
873
874
875 class StubbedSymbol
876 {
877 public:
878 const XMLElement& node;
879 std::string symbol;
880 std::string newname;
881 std::string strippedName;
882
883 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
884 ~StubbedSymbol ();
885 void ProcessXML();
886 private:
887 std::string StripSymbol ( std::string symbol );
888 };
889
890
891 class CompilationUnit
892 {
893 public:
894 std::string name;
895
896 CompilationUnit ( const File* file );
897 CompilationUnit ( const Project* project,
898 const Module* module,
899 const XMLElement* node );
900 ~CompilationUnit ();
901 void ProcessXML();
902 bool IsGeneratedFile () const;
903 bool HasFileWithExtension ( const std::string& extension ) const;
904 bool IsFirstFile () const;
905 const FileLocation& GetFilename () const;
906 const std::string& GetSwitches () const;
907 void AddFile ( const File * file );
908 const std::vector<const File*> GetFiles () const;
909 private:
910 const Project* project;
911 const Module* module;
912 const XMLElement* node;
913 std::vector<const File*> files;
914 FileLocation *default_name;
915 };
916
917
918 class CompilationUnitSupportCode
919 {
920 public:
921 const Project& project;
922
923 CompilationUnitSupportCode ( const Project& project );
924 ~CompilationUnitSupportCode ();
925 void Generate ( bool verbose );
926 private:
927 void GenerateForModule ( Module& module,
928 bool verbose );
929 std::string GetCompilationUnitFilename ( Module& module,
930 CompilationUnit& compilationUnit );
931 void WriteCompilationUnitFile ( Module& module,
932 CompilationUnit& compilationUnit );
933 };
934
935
936 enum AutoRegisterType
937 {
938 DllRegisterServer,
939 DllInstall,
940 Both
941 };
942
943 class AutoRegister : public XmlNode
944 {
945 public:
946 const Module* module;
947 std::string infSection;
948 AutoRegisterType type;
949 AutoRegister ( const Project& project_,
950 const Module* module_,
951 const XMLElement& node_ );
952 private:
953 bool IsSupportedModuleType ( ModuleType type );
954 AutoRegisterType GetAutoRegisterType( const std::string& type );
955 void Initialize ();
956 };
957
958
959 class SysSetupGenerator
960 {
961 public:
962 const Project& project;
963 SysSetupGenerator ( const Project& project );
964 ~SysSetupGenerator ();
965 void Generate ();
966 private:
967 std::string GetDirectoryId ( const Module& module );
968 std::string GetFlags ( const Module& module );
969 void Generate ( HINF inf,
970 const Module& module );
971 };
972
973
974 extern void
975 InitializeEnvironment ();
976
977 extern std::string
978 Right ( const std::string& s, size_t n );
979
980 extern std::string
981 Replace ( const std::string& s, const std::string& find, const std::string& with );
982
983 extern std::string
984 ChangeSeparator ( const std::string& s,
985 const char fromSeparator,
986 const char toSeparator );
987
988 extern std::string
989 FixSeparator ( const std::string& s );
990
991 extern std::string
992 FixSeparatorForSystemCommand ( const std::string& s );
993
994 extern std::string
995 DosSeparator ( const std::string& s );
996
997 extern std::string
998 ReplaceExtension (
999 const std::string& filename,
1000 const std::string& newExtension );
1001
1002 extern std::string
1003 GetSubPath (
1004 const Project& project,
1005 const std::string& location,
1006 const std::string& path,
1007 const std::string& att_value );
1008
1009 extern std::string
1010 GetExtension ( const FileLocation& file );
1011
1012 extern std::string
1013 NormalizeFilename ( const std::string& filename );
1014
1015 extern std::string
1016 ToLower ( std::string filename );
1017
1018 #endif /* __RBUILD_H */