store pointer to Backend in the Project class so properties of the Backend object...
[reactos.git] / reactos / tools / rbuild / rbuild.h
index c7fb4b8..4cdb08d 100644 (file)
 #endif/*WIN32*/
 #endif/*_MSC_VER*/
 
+#include <infhost.h>
+
 #include "ssprintf.h"
 #include "exception.h"
-#include "XML.h"
+#include "xml.h"
+
+class Backend; // forward declaration
 
 typedef std::vector<std::string> string_list;
 
@@ -66,6 +70,7 @@ extern char cBadSep;
 
 #define MS_VS_DEF_VERSION "7.10"
 
+class Directory;
 class Project;
 class IfableData;
 class Module;
@@ -92,10 +97,38 @@ class PchFile;
 class StubbedComponent;
 class StubbedSymbol;
 class CompilationUnit;
+class FileLocation;
+class AutoRegister;
 
 class SourceFileTest;
 
 
+typedef std::map<std::string,Directory*> directory_map;
+
+class Directory
+{
+public:
+       std::string name;
+       directory_map subdirs;
+       Directory ( const std::string& name );
+       void Add ( const char* subdir );
+       void GenerateTree ( const std::string& parent,
+                           bool verbose );
+       std::string EscapeSpaces ( std::string path );
+       void CreateRule ( FILE* f,
+                         const std::string& parent );
+private:
+       bool mkdir_p ( const char* path );
+       std::string ReplaceVariable ( std::string name,
+                                     std::string value,
+                                     std::string path );
+       std::string GetEnvironmentVariable ( const std::string& name );
+       void ResolveVariablesInPath ( char* buf,
+                                     std::string path );
+       bool CreateDirectory ( std::string path );
+};
+
+
 class Configuration
 {
 public:
@@ -105,6 +138,7 @@ public:
        bool CleanAsYouGo;
        bool AutomaticDependencies;
        bool CheckDependenciesForModuleOnly;
+       bool CompilationUnitsEnabled;
        std::string CheckDependenciesForModuleOnlyModule;
        std::string VSProjectVersion;
        bool MakeHandlesInstallDirectories;
@@ -160,7 +194,9 @@ class Project
 {
        std::string xmlfile;
        XMLElement *node, *head;
+       Backend* _backend;
 public:
+       const Configuration& configuration;
        std::string name;
        std::string makefile;
        XMLIncludes xmlbuildfiles;
@@ -170,10 +206,14 @@ public:
        std::vector<InstallFile*> installfiles;
        IfableData non_if_data;
 
-       Project ( const std::string& filename );
+       Project ( const Configuration& configuration,
+                 const std::string& filename );
        ~Project ();
+       void SetBackend ( Backend* backend ) { _backend = backend; }
+       Backend& GetBackend() { return *_backend; }
        void WriteConfigurationFile ();
        void ExecuteInvocations ();
+
        void ProcessXML ( const std::string& path );
        Module* LocateModule ( const std::string& name );
        const Module* LocateModule ( const std::string& name ) const;
@@ -245,6 +285,7 @@ public:
        bool mangledSymbols;
        bool isUnicode;
        Bootstrap* bootstrap;
+       AutoRegister* autoRegister;
        IfableData non_if_data;
        std::vector<Invoke*> invocations;
        std::vector<Dependency*> dependencies;
@@ -353,7 +394,6 @@ public:
               bool _isPreCompiledHeader );
 
        void ProcessXML();
-       bool IsGeneratedFile () const;
 };
 
 
@@ -788,20 +828,97 @@ private:
 class CompilationUnit
 {
 public:
-       const Project& project;
+       const Project* project;
        const Module* module;
-       const XMLElement& node;
+       const XMLElement* node;
+       std::string name;
        std::vector<File*> files;
 
-       CompilationUnit ( const Project& project,
+       CompilationUnit ( File* file );
+       CompilationUnit ( const Project* project,
                          const Module* module,
-                         const XMLElement& node );
+                         const XMLElement* node );
        ~CompilationUnit ();
        void ProcessXML();
+       bool IsGeneratedFile () const;
+       bool HasFileWithExtension ( const std::string& extension ) const;
+       bool IsFirstFile () const;
+       FileLocation* GetFilename ( Directory* intermediateDirectory ) const;
+       std::string GetSwitches () const;
+};
+
+
+class CompilationUnitSupportCode
+{
+public:
+       const Project& project;
+
+       CompilationUnitSupportCode ( const Project& project );
+       ~CompilationUnitSupportCode ();
+       void Generate ( bool verbose );
+private:
+       void GenerateForModule ( Module& module,
+                                bool verbose );
+       std::string GetCompilationUnitFilename ( Module& module,
+                                                CompilationUnit& compilationUnit );
+       void WriteCompilationUnitFile ( Module& module,
+                                       CompilationUnit& compilationUnit );
 };
 
 
-extern VOID
+class FileLocation
+{
+public:
+       Directory* directory;
+       std::string filename;
+       FileLocation ( Directory* directory,
+                      std::string filename );
+};
+
+
+enum AutoRegisterType
+{
+       DllRegisterServer,
+       DllInstall,
+       Both
+};
+
+class AutoRegister
+{
+public:
+       const Project& project;
+       const Module* module;
+       const XMLElement& node;
+       std::string infSection;
+       AutoRegisterType type;
+       AutoRegister ( const Project& project_,
+                      const Module* module_,
+                      const XMLElement& node_ );
+       ~AutoRegister ();
+       void ProcessXML();
+private:
+       bool IsSupportedModuleType ( ModuleType type );
+       AutoRegisterType GetAutoRegisterType( std::string type );
+       void Initialize ();
+};
+
+
+class SysSetupGenerator
+{
+public:
+       const Project& project;
+       SysSetupGenerator ( const Project& project );
+       ~SysSetupGenerator ();
+       void Generate ();
+private:
+       std::string GetDirectoryId ( const Module& module );
+       std::string GetFlags ( const Module& module );
+       void Generate ( HINF inf,
+                       const Module& module );
+};
+
+
+extern void
 InitializeEnvironment ();
 
 extern std::string
@@ -810,6 +927,11 @@ Right ( const std::string& s, size_t n );
 extern std::string
 Replace ( const std::string& s, const std::string& find, const std::string& with );
 
+extern std::string
+ChangeSeparator ( const std::string& s,
+                  const char fromSeparator,
+                  const char toSeparator );
+
 extern std::string
 FixSeparator ( const std::string& s );
 
@@ -842,4 +964,7 @@ GetFilename ( const std::string& filename );
 extern std::string
 NormalizeFilename ( const std::string& filename );
 
+extern std::string
+ToLower ( std::string filename );
+
 #endif /* __RBUILD_H */