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