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