e7a5b28735d4f4e20786f0fd48458f36bfdb3545
[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 bool isInternal;
662
663 Property ( const XMLElement& node_,
664 const Project& project_,
665 const Module* module_ );
666
667 Property ( const Project& project_,
668 const Module* module_,
669 const std::string& name_,
670 const std::string& value_ );
671
672 void ProcessXML();
673 };
674
675
676 class TestSupportCode
677 {
678 public:
679 const Project& project;
680
681 TestSupportCode ( const Project& project );
682 ~TestSupportCode ();
683 void GenerateTestSupportCode ( bool verbose );
684 private:
685 bool IsTestModule ( const Module& module );
686 void GenerateTestSupportCodeForModule ( Module& module,
687 bool verbose );
688 std::string GetHooksFilename ( Module& module );
689 char* WriteStubbedSymbolToHooksFile ( char* buffer,
690 const StubbedComponent& component,
691 const StubbedSymbol& symbol );
692 char* WriteStubbedComponentToHooksFile ( char* buffer,
693 const StubbedComponent& component );
694 void WriteHooksFile ( Module& module );
695 std::string GetStubsFilename ( Module& module );
696 char* WriteStubbedSymbolToStubsFile ( char* buffer,
697 const StubbedComponent& component,
698 const StubbedSymbol& symbol,
699 int stubIndex );
700 char* WriteStubbedComponentToStubsFile ( char* buffer,
701 const StubbedComponent& component,
702 int* stubIndex );
703 void WriteStubsFile ( Module& module );
704 std::string GetStartupFilename ( Module& module );
705 bool IsUnknownCharacter ( char ch );
706 std::string GetTestDispatcherName ( std::string filename );
707 bool IsTestFile ( std::string& filename ) const;
708 void GetSourceFilenames ( string_list& list,
709 Module& module ) const;
710 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
711 Module& module );
712 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
713 Module& module );
714 void WriteStartupFile ( Module& module );
715 };
716
717
718 class SourceFile
719 {
720 public:
721 SourceFile ( AutomaticDependency* automaticDependency,
722 const Module& module,
723 const File& file,
724 SourceFile* parent );
725 void Parse ();
726 std::vector<SourceFile*> files; /* List of files included in this file */
727 const File& file;
728 AutomaticDependency* automaticDependency;
729 const Module& module;
730 std::vector<SourceFile*> parents; /* List of files, this file is included from */
731 time_t lastWriteTime;
732 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
733 SourceFile* youngestFile;
734 private:
735 void Close ();
736 void Open ();
737 void SkipWhitespace ();
738 bool ReadInclude ( std::string& filename,
739 bool& searchCurrentDirectory,
740 bool& includeNext );
741 bool IsIncludedFrom ( const File& file );
742 SourceFile* ParseFile(const File& file);
743 bool CanProcessFile ( const File& file );
744 bool IsParentOf ( const SourceFile* parent,
745 const SourceFile* child );
746 std::string buf;
747 const char *p;
748 const char *end;
749 };
750
751
752 class AutomaticDependency
753 {
754 friend class SourceFileTest;
755 public:
756 const Project& project;
757
758 AutomaticDependency ( const Project& project );
759 ~AutomaticDependency ();
760 bool LocateIncludedFile ( const FileLocation& directory,
761 const std::string& includedFilename );
762 bool LocateIncludedFile ( SourceFile* sourceFile,
763 const Module& module,
764 const std::string& includedFilename,
765 bool searchCurrentDirectory,
766 bool includeNext,
767 File& resolvedFile );
768 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
769 const File& file,
770 SourceFile* parentSourceFile );
771 SourceFile* RetrieveFromCache ( const File& file );
772 void CheckAutomaticDependencies ( bool verbose );
773 void CheckAutomaticDependenciesForModule ( Module& module,
774 bool verbose );
775 private:
776 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
777 void CheckAutomaticDependencies ( const Module& module,
778 bool verbose );
779 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
780 void GetIncludeDirectories ( std::vector<Include*>& includes,
781 const Module& module );
782 void GetModuleFiles ( const Module& module,
783 std::vector<File*>& files ) const;
784 void ParseFiles ();
785 void ParseFiles ( const Module& module );
786 void ParseFile ( const Module& module,
787 const File& file );
788 std::map<std::string, SourceFile*> sourcefile_map;
789 };
790
791
792 class Bootstrap
793 {
794 public:
795 const Project& project;
796 const Module* module;
797 const XMLElement& node;
798 std::string base;
799 std::string nameoncd;
800
801 Bootstrap ( const Project& project,
802 const Module* module,
803 const XMLElement& bootstrapNode );
804 ~Bootstrap ();
805 void ProcessXML();
806 private:
807 bool IsSupportedModuleType ( ModuleType type );
808 void Initialize();
809 static std::string ReplaceVariable ( const std::string& name,
810 const std::string& value,
811 std::string path );
812 };
813
814
815 class CDFile : public XmlNode
816 {
817 public:
818 FileLocation *source;
819 FileLocation *target;
820
821 CDFile ( const Project& project,
822 const XMLElement& bootstrapNode,
823 const std::string& path );
824 ~CDFile ();
825 private:
826 static std::string ReplaceVariable ( const std::string& name,
827 const std::string& value,
828 std::string path );
829 };
830
831
832 class InstallFile : public XmlNode
833 {
834 public:
835 FileLocation *source;
836 FileLocation *target;
837
838 InstallFile ( const Project& project,
839 const XMLElement& bootstrapNode,
840 const std::string& path );
841 ~InstallFile ();
842 };
843
844
845 class PchFile
846 {
847 public:
848 const XMLElement& node;
849 const Module& module;
850 const FileLocation *file;
851
852 PchFile (
853 const XMLElement& node,
854 const Module& module,
855 const FileLocation *file );
856 ~PchFile();
857 void ProcessXML();
858 };
859
860
861 class StubbedComponent
862 {
863 public:
864 const Module* module;
865 const XMLElement& node;
866 std::string name;
867 std::vector<StubbedSymbol*> symbols;
868
869 StubbedComponent ( const Module* module_,
870 const XMLElement& stubbedComponentNode );
871 ~StubbedComponent ();
872 void ProcessXML ();
873 void ProcessXMLSubElement ( const XMLElement& e );
874 };
875
876
877 class StubbedSymbol
878 {
879 public:
880 const XMLElement& node;
881 std::string symbol;
882 std::string newname;
883 std::string strippedName;
884
885 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
886 ~StubbedSymbol ();
887 void ProcessXML();
888 private:
889 std::string StripSymbol ( std::string symbol );
890 };
891
892
893 class CompilationUnit
894 {
895 public:
896 std::string name;
897
898 CompilationUnit ( const File* file );
899 CompilationUnit ( const Project* project,
900 const Module* module,
901 const XMLElement* node );
902 ~CompilationUnit ();
903 void ProcessXML();
904 bool IsGeneratedFile () const;
905 bool HasFileWithExtension ( const std::string& extension ) const;
906 bool IsFirstFile () const;
907 const FileLocation& GetFilename () const;
908 const std::string& GetSwitches () const;
909 void AddFile ( const File * file );
910 const std::vector<const File*> GetFiles () const;
911 private:
912 const Project* project;
913 const Module* module;
914 const XMLElement* node;
915 std::vector<const File*> files;
916 FileLocation *default_name;
917 };
918
919
920 class CompilationUnitSupportCode
921 {
922 public:
923 const Project& project;
924
925 CompilationUnitSupportCode ( const Project& project );
926 ~CompilationUnitSupportCode ();
927 void Generate ( bool verbose );
928 private:
929 void GenerateForModule ( Module& module,
930 bool verbose );
931 std::string GetCompilationUnitFilename ( Module& module,
932 CompilationUnit& compilationUnit );
933 void WriteCompilationUnitFile ( Module& module,
934 CompilationUnit& compilationUnit );
935 };
936
937
938 enum AutoRegisterType
939 {
940 DllRegisterServer,
941 DllInstall,
942 Both
943 };
944
945 class AutoRegister : public XmlNode
946 {
947 public:
948 const Module* module;
949 std::string infSection;
950 AutoRegisterType type;
951 AutoRegister ( const Project& project_,
952 const Module* module_,
953 const XMLElement& node_ );
954 private:
955 bool IsSupportedModuleType ( ModuleType type );
956 AutoRegisterType GetAutoRegisterType( const std::string& type );
957 void Initialize ();
958 };
959
960
961 class SysSetupGenerator
962 {
963 public:
964 const Project& project;
965 SysSetupGenerator ( const Project& project );
966 ~SysSetupGenerator ();
967 void Generate ();
968 private:
969 std::string GetDirectoryId ( const Module& module );
970 std::string GetFlags ( const Module& module );
971 void Generate ( HINF inf,
972 const Module& module );
973 };
974
975
976 extern void
977 InitializeEnvironment ();
978
979 extern std::string
980 Right ( const std::string& s, size_t n );
981
982 extern std::string
983 Replace ( const std::string& s, const std::string& find, const std::string& with );
984
985 extern std::string
986 ChangeSeparator ( const std::string& s,
987 const char fromSeparator,
988 const char toSeparator );
989
990 extern std::string
991 FixSeparator ( const std::string& s );
992
993 extern std::string
994 FixSeparatorForSystemCommand ( const std::string& s );
995
996 extern std::string
997 DosSeparator ( const std::string& s );
998
999 extern std::string
1000 ReplaceExtension (
1001 const std::string& filename,
1002 const std::string& newExtension );
1003
1004 extern std::string
1005 GetSubPath (
1006 const Project& project,
1007 const std::string& location,
1008 const std::string& path,
1009 const std::string& att_value );
1010
1011 extern std::string
1012 GetExtension ( const FileLocation& file );
1013
1014 extern std::string
1015 NormalizeFilename ( const std::string& filename );
1016
1017 extern std::string
1018 ToLower ( std::string filename );
1019
1020 #endif /* __RBUILD_H */