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