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