sync trunk head (37032)
[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 CompilerFlag;
87 class LinkerFlag;
88 class LinkerScript;
89 class Property;
90 class TestSupportCode;
91 class AutomaticDependency;
92 class Bootstrap;
93 class CDFile;
94 class InstallFile;
95 class PchFile;
96 class StubbedComponent;
97 class StubbedSymbol;
98 class CompilationUnit;
99 class FileLocation;
100 class AutoRegister;
101
102 class SourceFileTest;
103 class Metadata;
104 class Bootsector;
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 bool PrecompiledHeadersEnabled;
163 std::string CheckDependenciesForModuleOnlyModule;
164 std::string VSProjectVersion;
165 std::string VSConfigurationType;
166 bool UseVSVersionInPath;
167 bool UseConfigurationInPath;
168 bool MakeHandlesInstallDirectories;
169 bool GenerateProxyMakefilesInSourceTree;
170 bool InstallFiles;
171 };
172
173 class Environment
174 {
175 public:
176 static std::string GetVariable ( const std::string& name );
177 static std::string GetArch ();
178 static std::string GetIntermediatePath ();
179 static std::string GetOutputPath ();
180 static std::string GetCdOutputPath ();
181 static std::string GetInstallPath ();
182 static std::string GetAutomakeFile ( const std::string& defaultFile );
183 static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
184 const std::string& defaultValue );
185 };
186
187
188 class FileSupportCode
189 {
190 public:
191 static void WriteIfChanged ( char* outbuf,
192 const std::string& filename,
193 bool ignoreError = false );
194 };
195
196
197 class ParseContext
198 {
199 public:
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::map<std::string, Property*> properties;
214 std::vector<Module*> modules;
215 std::vector<CompilerFlag*> compilerFlags;
216 int asmFiles; // number of .asm files in compilationUnits
217
218 IfableData();
219 ~IfableData();
220 void ProcessXML();
221 void ExtractModules( std::map<std::string, 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::map<std::string, Module*> modules;
238 IfableData non_if_data;
239 IfableData host_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 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 const Property* LookupProperty ( const std::string& name ) const;
255 private:
256 std::string ResolveNextProperty ( const std::string& s ) const;
257 void ReadXml ();
258 void ProcessXMLSubElement ( const XMLElement& e,
259 const std::string& path,
260 ParseContext& parseContext );
261
262 // disable copy semantics
263 Project ( const Project& );
264 Project& operator = ( const Project& );
265 };
266
267
268 enum ModuleType
269 {
270 BuildTool,
271 StaticLibrary,
272 ObjectLibrary,
273 Kernel,
274 KernelModeDLL,
275 KernelModeDriver,
276 NativeDLL,
277 NativeCUI,
278 Win32DLL,
279 Win32OCX,
280 Win32CUI,
281 Win32GUI,
282 BootLoader,
283 BootSector,
284 Iso,
285 LiveIso,
286 Test,
287 RpcServer,
288 RpcClient,
289 Alias,
290 BootProgram,
291 Win32SCR,
292 IdlHeader,
293 IsoRegTest,
294 LiveIsoRegTest,
295 EmbeddedTypeLib,
296 ElfExecutable,
297 RpcProxy,
298 HostStaticLibrary,
299 Cabinet,
300 KeyboardLayout,
301 MessageHeader,
302 TypeDontCare, // always at the end
303 };
304
305 enum HostType
306 {
307 HostFalse,
308 HostDefault,
309 HostTrue,
310 HostDontCare,
311 };
312
313 enum CompilerType
314 {
315 CompilerTypeDontCare,
316 CompilerTypeCC,
317 CompilerTypeCPP,
318 };
319
320 class FileLocation
321 {
322 public:
323 DirectoryLocation directory;
324 std::string relative_path;
325 std::string name;
326
327 FileLocation ( const DirectoryLocation directory,
328 const std::string& relative_path,
329 const std::string& name,
330 const XMLElement *node = NULL );
331
332 FileLocation ( const FileLocation& other );
333 };
334
335 class Module
336 {
337 public:
338 const Project& project;
339 const XMLElement& node;
340 std::string xmlbuildFile;
341 std::string name;
342 std::string guid;
343 std::string extension;
344 std::string baseaddress;
345 std::string payload;
346 std::string buildtype;
347 ModuleType type;
348 ImportLibrary* importLibrary;
349 Metadata* metadata;
350 Bootsector* bootSector;
351 bool mangledSymbols;
352 bool underscoreSymbols;
353 bool isUnicode;
354 bool isDefaultEntryPoint;
355 Bootstrap* bootstrap;
356 AutoRegister* autoRegister; // <autoregister> node
357 IfableData non_if_data;
358 std::vector<Invoke*> invocations;
359 std::vector<Dependency*> dependencies;
360 std::vector<CompilerFlag*> compilerFlags;
361 std::vector<LinkerFlag*> linkerFlags;
362 std::vector<StubbedComponent*> stubbedComponents;
363 LinkerScript* linkerScript;
364 PchFile* pch;
365 bool cplusplus;
366 std::string prefix;
367 std::string aliasedModuleName;
368 bool allowWarnings;
369 bool enabled;
370 bool isStartupLib;
371 FileLocation *output; // "path/foo.exe"
372 FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
373 FileLocation *install;
374 std::string description;
375 std::string lcid;
376 std::string layoutId;
377 std::string layoutNameResId;
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 Bootsector
547 {
548 public:
549 const XMLElement& node;
550 const Module* module;
551 const Module* bootSectorModule;
552
553 Bootsector ( const XMLElement& _node,
554 const Module* _module );
555
556 void ProcessXML();
557 private:
558 bool IsSupportedModuleType ( ModuleType type );
559 };
560
561 class Metadata
562 {
563 public:
564 const XMLElement& node;
565 const Module& module;
566 std::string name;
567 std::string description;
568 std::string version;
569 std::string copyright;
570 std::string url;
571 std::string date;
572 std::string owner;
573
574 Metadata ( const XMLElement& _node,
575 const Module& _module );
576
577 void ProcessXML();
578 };
579
580 class ImportLibrary : public XmlNode
581 {
582 public:
583 const Module* module;
584 std::string dllname;
585 FileLocation *source;
586
587 ImportLibrary ( const Project& project,
588 const XMLElement& node,
589 const Module* module );
590 ~ImportLibrary ();
591 };
592
593
594 class CompilerFlag
595 {
596 public:
597 const Project& project;
598 const Module* module;
599 const XMLElement& node;
600 std::string flag;
601 CompilerType compiler;
602
603 CompilerFlag ( const Project& project,
604 const XMLElement& compilerFlagNode );
605 CompilerFlag ( const Project& project,
606 const Module* module,
607 const XMLElement& compilerFlagNode );
608 ~CompilerFlag ();
609 void ProcessXML();
610 private:
611 void Initialize();
612 };
613
614
615 class LinkerFlag
616 {
617 public:
618 const Project& project;
619 const Module* module;
620 const XMLElement& node;
621 std::string flag;
622
623 LinkerFlag ( const Project& project,
624 const XMLElement& linkerFlagNode );
625 LinkerFlag ( const Project& project,
626 const Module* module,
627 const XMLElement& linkerFlagNode );
628 ~LinkerFlag ();
629 void ProcessXML();
630 private:
631 void Initialize();
632 };
633
634
635 class LinkerScript
636 {
637 public:
638 const XMLElement& node;
639 const Module& module;
640 const FileLocation *file;
641
642 LinkerScript ( const XMLElement& node,
643 const Module& module,
644 const FileLocation *file );
645 ~LinkerScript ();
646 void ProcessXML();
647 };
648
649
650 class Property
651 {
652 public:
653 const Project& project;
654 const Module* module;
655 std::string name, value;
656 bool isInternal;
657
658 Property ( const XMLElement& node_,
659 const Project& project_,
660 const Module* module_ );
661
662 Property ( const Project& project_,
663 const Module* module_,
664 const std::string& name_,
665 const std::string& value_ );
666
667 void ProcessXML();
668 };
669
670
671 class TestSupportCode
672 {
673 public:
674 const Project& project;
675
676 TestSupportCode ( const Project& project );
677 ~TestSupportCode ();
678 void GenerateTestSupportCode ( bool verbose );
679 private:
680 bool IsTestModule ( const Module& module );
681 void GenerateTestSupportCodeForModule ( Module& module,
682 bool verbose );
683 std::string GetHooksFilename ( Module& module );
684 char* WriteStubbedSymbolToHooksFile ( char* buffer,
685 const StubbedComponent& component,
686 const StubbedSymbol& symbol );
687 char* WriteStubbedComponentToHooksFile ( char* buffer,
688 const StubbedComponent& component );
689 void WriteHooksFile ( Module& module );
690 std::string GetStubsFilename ( Module& module );
691 char* WriteStubbedSymbolToStubsFile ( char* buffer,
692 const StubbedComponent& component,
693 const StubbedSymbol& symbol,
694 int stubIndex );
695 char* WriteStubbedComponentToStubsFile ( char* buffer,
696 const StubbedComponent& component,
697 int* stubIndex );
698 void WriteStubsFile ( Module& module );
699 std::string GetStartupFilename ( Module& module );
700 bool IsUnknownCharacter ( char ch );
701 std::string GetTestDispatcherName ( std::string filename );
702 bool IsTestFile ( std::string& filename ) const;
703 void GetSourceFilenames ( string_list& list,
704 Module& module ) const;
705 char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
706 Module& module );
707 char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
708 Module& module );
709 void WriteStartupFile ( Module& module );
710 };
711
712
713 class SourceFile
714 {
715 public:
716 SourceFile ( AutomaticDependency* automaticDependency,
717 const Module& module,
718 const File& file,
719 SourceFile* parent );
720 void Parse ();
721 std::vector<SourceFile*> files; /* List of files included in this file */
722 const File& file;
723 AutomaticDependency* automaticDependency;
724 const Module& module;
725 std::vector<SourceFile*> parents; /* List of files, this file is included from */
726 time_t lastWriteTime;
727 time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
728 SourceFile* youngestFile;
729 private:
730 void Close ();
731 void Open ();
732 void SkipWhitespace ();
733 bool ReadInclude ( std::string& filename,
734 bool& searchCurrentDirectory,
735 bool& includeNext );
736 bool IsIncludedFrom ( const File& file );
737 SourceFile* ParseFile(const File& file);
738 bool CanProcessFile ( const File& file );
739 bool IsParentOf ( const SourceFile* parent,
740 const SourceFile* child );
741 std::string buf;
742 const char *p;
743 const char *end;
744 };
745
746
747 class AutomaticDependency
748 {
749 friend class SourceFileTest;
750 public:
751 const Project& project;
752
753 AutomaticDependency ( const Project& project );
754 ~AutomaticDependency ();
755 bool LocateIncludedFile ( const FileLocation& directory,
756 const std::string& includedFilename );
757 bool LocateIncludedFile ( SourceFile* sourceFile,
758 const Module& module,
759 const std::string& includedFilename,
760 bool searchCurrentDirectory,
761 bool includeNext,
762 File& resolvedFile );
763 SourceFile* RetrieveFromCacheOrParse ( const Module& module,
764 const File& file,
765 SourceFile* parentSourceFile );
766 SourceFile* RetrieveFromCache ( const File& file );
767 void CheckAutomaticDependencies ( bool verbose );
768 void CheckAutomaticDependenciesForModule ( Module& module,
769 bool verbose );
770 private:
771 void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
772 void CheckAutomaticDependencies ( const Module& module,
773 bool verbose );
774 void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
775 void GetIncludeDirectories ( std::vector<Include*>& includes,
776 const Module& module );
777 void GetModuleFiles ( const Module& module,
778 std::vector<File*>& files ) const;
779 void ParseFiles ();
780 void ParseFiles ( const Module& module );
781 void ParseFile ( const Module& module,
782 const File& file );
783 std::map<std::string, SourceFile*> sourcefile_map;
784 };
785
786
787 class Bootstrap
788 {
789 public:
790 const Project& project;
791 const Module* module;
792 const XMLElement& node;
793 std::string base;
794 std::string nameoncd;
795
796 Bootstrap ( const Project& project,
797 const Module* module,
798 const XMLElement& bootstrapNode );
799 ~Bootstrap ();
800 void ProcessXML();
801 private:
802 bool IsSupportedModuleType ( ModuleType type );
803 void Initialize();
804 static std::string ReplaceVariable ( const std::string& name,
805 const std::string& value,
806 std::string path );
807 };
808
809
810 class CDFile : public XmlNode
811 {
812 public:
813 FileLocation *source;
814 FileLocation *target;
815
816 CDFile ( const Project& project,
817 const XMLElement& bootstrapNode,
818 const std::string& path );
819 ~CDFile ();
820 private:
821 static std::string ReplaceVariable ( const std::string& name,
822 const std::string& value,
823 std::string path );
824 };
825
826
827 class InstallFile : public XmlNode
828 {
829 public:
830 FileLocation *source;
831 FileLocation *target;
832
833 InstallFile ( const Project& project,
834 const XMLElement& bootstrapNode,
835 const std::string& path );
836 ~InstallFile ();
837 };
838
839
840 class PchFile
841 {
842 public:
843 const XMLElement& node;
844 const Module& module;
845 const FileLocation *file;
846
847 PchFile (
848 const XMLElement& node,
849 const Module& module,
850 const FileLocation *file );
851 ~PchFile();
852 void ProcessXML();
853 };
854
855
856 class StubbedComponent
857 {
858 public:
859 const Module* module;
860 const XMLElement& node;
861 std::string name;
862 std::vector<StubbedSymbol*> symbols;
863
864 StubbedComponent ( const Module* module_,
865 const XMLElement& stubbedComponentNode );
866 ~StubbedComponent ();
867 void ProcessXML ();
868 void ProcessXMLSubElement ( const XMLElement& e );
869 };
870
871
872 class StubbedSymbol
873 {
874 public:
875 const XMLElement& node;
876 std::string symbol;
877 std::string newname;
878 std::string strippedName;
879
880 StubbedSymbol ( const XMLElement& stubbedSymbolNode );
881 ~StubbedSymbol ();
882 void ProcessXML();
883 private:
884 std::string StripSymbol ( std::string symbol );
885 };
886
887
888 class CompilationUnit
889 {
890 public:
891 std::string name;
892
893 CompilationUnit ( const File* file );
894 CompilationUnit ( const Project* project,
895 const Module* module,
896 const XMLElement* node );
897 ~CompilationUnit ();
898 void ProcessXML();
899 bool IsGeneratedFile () const;
900 bool HasFileWithExtension ( const std::string& extension ) const;
901 bool IsFirstFile () const;
902 const FileLocation& GetFilename () const;
903 const std::string& GetSwitches () const;
904 void AddFile ( const File * file );
905 const std::vector<const File*> GetFiles () const;
906 private:
907 const Project* project;
908 const Module* module;
909 const XMLElement* node;
910 std::vector<const File*> files;
911 FileLocation *default_name;
912 };
913
914
915 class CompilationUnitSupportCode
916 {
917 public:
918 const Project& project;
919
920 CompilationUnitSupportCode ( const Project& project );
921 ~CompilationUnitSupportCode ();
922 void Generate ( bool verbose );
923 private:
924 void GenerateForModule ( Module& module,
925 bool verbose );
926 std::string GetCompilationUnitFilename ( Module& module,
927 CompilationUnit& compilationUnit );
928 void WriteCompilationUnitFile ( Module& module,
929 CompilationUnit& compilationUnit );
930 };
931
932
933 enum AutoRegisterType
934 {
935 DllRegisterServer,
936 DllInstall,
937 Both
938 };
939
940 class AutoRegister : public XmlNode
941 {
942 public:
943 const Module* module;
944 std::string infSection;
945 AutoRegisterType type;
946 AutoRegister ( const Project& project_,
947 const Module* module_,
948 const XMLElement& node_ );
949 private:
950 bool IsSupportedModuleType ( ModuleType type );
951 AutoRegisterType GetAutoRegisterType( const std::string& type );
952 void Initialize ();
953 };
954
955
956 class SysSetupGenerator
957 {
958 public:
959 const Project& project;
960 SysSetupGenerator ( const Project& project );
961 ~SysSetupGenerator ();
962 void Generate ();
963 private:
964 std::string GetDirectoryId ( const Module& module );
965 std::string GetFlags ( const Module& module );
966 void Generate ( HINF inf,
967 const Module& module );
968 };
969
970
971 extern void
972 InitializeEnvironment ();
973
974 extern std::string
975 Right ( const std::string& s, size_t n );
976
977 extern std::string
978 Replace ( const std::string& s, const std::string& find, const std::string& with );
979
980 extern std::string
981 ChangeSeparator ( const std::string& s,
982 const char fromSeparator,
983 const char toSeparator );
984
985 extern std::string
986 FixSeparator ( const std::string& s );
987
988 extern std::string
989 FixSeparatorForSystemCommand ( const std::string& s );
990
991 extern std::string
992 DosSeparator ( const std::string& s );
993
994 extern std::string
995 ReplaceExtension (
996 const std::string& filename,
997 const std::string& newExtension );
998
999 extern std::string
1000 GetSubPath (
1001 const Project& project,
1002 const std::string& location,
1003 const std::string& path,
1004 const std::string& att_value );
1005
1006 extern std::string
1007 GetExtension ( const FileLocation& file );
1008
1009 extern std::string
1010 NormalizeFilename ( const std::string& filename );
1011
1012 extern std::string
1013 ToLower ( std::string filename );
1014
1015 #endif /* __RBUILD_H */