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