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