-Add a new module type 'cabinet' to handle .cab files generation
[reactos.git] / reactos / tools / rbuild / rbuild.h
index 6e2d5a6..1b6adba 100644 (file)
@@ -89,7 +89,6 @@ class LinkerFlag;
 class LinkerScript;
 class Property;
 class TestSupportCode;
-class WineResource;
 class AutomaticDependency;
 class Bootstrap;
 class CDFile;
@@ -120,27 +119,33 @@ public:
        virtual void ProcessXML();
 };
 
+enum DirectoryLocation
+{
+       SourceDirectory,
+       IntermediateDirectory,
+       OutputDirectory,
+       InstallDirectory,
+       TemporaryDirectory,
+};
+
 class Directory
 {
 public:
        std::string name;
        directory_map subdirs;
        Directory ( const std::string& name );
+       ~Directory();
        void Add ( const char* subdir );
-       void GenerateTree ( const std::string& parent,
+       void GenerateTree ( DirectoryLocation root,
                            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 ( const std::string& name,
-                                     const std::string& value,
-                                     std::string path );
-       std::string GetEnvironmentVariable ( const std::string& name );
-       void ResolveVariablesInPath ( char* buf,
-                                     const std::string& path );
-       bool CreateDirectory ( std::string path );
+       bool CreateDirectory ( const std::string& path );
+       std::string EscapeSpaces ( const std::string& path );
+       void GenerateTree ( const std::string& parent,
+                           bool verbose );
 };
 
 
@@ -209,7 +214,9 @@ public:
        std::vector<Module*> modules;
        std::vector<CompilerFlag*> compilerFlags;
        std::vector<If*> ifs;
+       int asmFiles; // number of .asm files in compilationUnits
 
+       IfableData();
        ~IfableData();
        void ProcessXML();
        void ExtractModules( std::vector<Module*> &modules );
@@ -246,11 +253,11 @@ public:
        const std::string& GetProjectFilename () const;
        std::string ResolveProperties ( const std::string& s ) const;
 private:
-       std::string ResolveNextProperty ( std::string& s ) const;
+       std::string ResolveNextProperty ( const std::string& s ) const;
        const Property* LookupProperty ( const std::string& name ) const;
        void SetConfigurationOption ( char* s,
                                      std::string name,
-                                     std::string* alternativeName );
+                                     std::string alternativeName );
        void SetConfigurationOption ( char* s,
                                      std::string name );
        void ReadXml ();
@@ -292,14 +299,41 @@ enum ModuleType
        IsoRegTest = 24,
        LiveIsoRegTest = 25,
        EmbeddedTypeLib = 26,
-       ElfExecutable = 27
+       ElfExecutable = 27,
+       RpcProxy,
+       HostStaticLibrary,
+       TypeDontCare,
+       Cabinet
 };
 
 enum HostType
 {
        HostFalse,
        HostDefault,
-       HostTrue
+       HostTrue,
+       HostDontCare,
+};
+
+enum CompilerType
+{
+       CompilerTypeDontCare,
+       CompilerTypeCC,
+       CompilerTypeCPP,
+};
+
+class FileLocation
+{
+public:
+       DirectoryLocation directory;
+       std::string relative_path;
+       std::string name;
+
+       FileLocation ( const DirectoryLocation directory,
+                      const std::string& relative_path,
+                      const std::string& name,
+                      const XMLElement *node = NULL );
+
+       FileLocation ( const FileLocation& other );
 };
 
 class Module
@@ -314,7 +348,6 @@ public:
        std::string baseaddress;
        std::string payload;
        std::string buildtype;
-       std::string path;
        ModuleType type;
        ImportLibrary* importLibrary;
        Metadata* metadata;
@@ -335,14 +368,13 @@ public:
        bool cplusplus;
        std::string prefix;
        HostType host;
-       std::string installBase;
-       std::string installName;
        std::string aliasedModuleName;
-       bool useWRC;
        bool allowWarnings;
        bool enabled;
-       bool useHostStdlib;
        bool isStartupLib;
+       FileLocation *output; // "path/foo.exe"
+       FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
+       FileLocation *install;
 
        Module ( const Project& project,
                 const XMLElement& moduleNode,
@@ -352,12 +384,6 @@ public:
                                   const XMLAttribute& attribute );
        bool HasImportLibrary () const;
        bool IsDLL () const;
-       bool GenerateInOutputTree () const;
-       std::string GetTargetName () const; // "foo.exe"
-       std::string GetDependencyPath () const; // "path/foo.exe" or "path/libfoo.a"
-       std::string GetDependencyTargetName () const; // "foo.exe" or "libfoo.a"
-       std::string GetBasePath () const; // "path"
-       std::string GetPath () const; // "path/foo.exe"
        std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
        std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
        std::string GetEntryPoint(bool leadingUnderscore) const;
@@ -366,16 +392,16 @@ public:
        bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
        void InvokeModule () const;
        void ProcessXML ();
-       void GetSourceFilenames ( string_list& list,
-                                 bool includeGeneratedFiles ) const;
 private:
+       void SetImportLibrary ( ImportLibrary* importLibrary );
+       DirectoryLocation GetTargetDirectoryTree () const;
        std::string GetDefaultModuleExtension () const;
        std::string GetDefaultModuleEntrypoint () const;
        std::string GetDefaultModuleBaseaddress () const;
        std::string entrypoint;
        void ProcessXMLSubElement ( const XMLElement& e,
-                                   const std::string& path,
-                                   const std::string& path_prefix,
+                                   DirectoryLocation directory,
+                                   const std::string& relative_path,
                                    ParseContext& parseContext );
 };
 
@@ -383,25 +409,23 @@ private:
 class Include
 {
 public:
-       const Project& project;
-       const Module* module;
-       const XMLElement* node;
-       const Module* baseModule;
-       std::string directory;
-       std::string basePath;
-       std::string root;
+       FileLocation *directory;
 
        Include ( const Project& project,
                  const XMLElement* includeNode );
        Include ( const Project& project,
-                 const Module* module,
-                 const XMLElement* includeNode );
+                 const XMLElement* includeNode,
+                 const Module* module );
        Include ( const Project& project,
-                 std::string directory,
-                 std::string basePath );
+                 DirectoryLocation directory,
+                 const std::string& relative_path );
        ~Include ();
-       void ProcessXML();
+       void ProcessXML ();
 private:
+       const Project& project;
+       const XMLElement* node;
+       const Module* module;
+       DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
 };
 
 
@@ -414,6 +438,7 @@ public:
        std::string name;
        std::string value;
        std::string backend;
+       bool overridable;
 
        Define ( const Project& project,
                 const XMLElement& defineNode );
@@ -422,8 +447,8 @@ public:
                 const XMLElement& defineNode );
        Define ( const Project& project,
                 const Module* module,
-                const std::string name_,
-                const std::string backend_ = "" );
+                const std::string& name_,
+                const std::string& backend_ = "" );
        ~Define();
        void ProcessXML();
 private:
@@ -434,21 +459,16 @@ private:
 class File
 {
 public:
-       std::string name;
-       std::string path_prefix;
+       FileLocation file;
        bool first;
        std::string switches;
        bool isPreCompiledHeader;
 
-       File ( const std::string& _name,
-              bool _first,
-              std::string _switches,
-              bool _isPreCompiledHeader );
-
-       File ( const std::string& _name,
-              const std::string& _path_prefix,
+       File ( DirectoryLocation directory,
+              const std::string& relative_path,
+              const std::string& name,
               bool _first,
-              std::string _switches,
+              const std::string& _switches,
               bool _isPreCompiledHeader );
 
        void ProcessXML();
@@ -542,19 +562,17 @@ public:
        void ProcessXML();
 };
 
-class ImportLibrary
+class ImportLibrary : public XmlNode
 {
 public:
-       const XMLElement& node;
        const Module& module;
-       std::string basename;
-       std::string definition;
        std::string dllname;
+       FileLocation *source;
 
-       ImportLibrary ( const XMLElement& _node,
+       ImportLibrary ( const Project& project,
+                       const XMLElement& node,
                        const Module& module );
-
-       void ProcessXML ();
+       ~ImportLibrary ();
 };
 
 
@@ -585,6 +603,7 @@ public:
        const Module* module;
        const XMLElement& node;
        std::string flag;
+       CompilerType compiler;
 
        CompilerFlag ( const Project& project,
                       const XMLElement& compilerFlagNode );
@@ -621,16 +640,13 @@ private:
 class LinkerScript
 {
 public:
-       const Project& project;
-       const Module* module;
        const XMLElement& node;
-       const Module* baseModule;
-       std::string directory;
-       std::string basePath;
+       const Module& module;
+       const FileLocation *file;
 
-       LinkerScript ( const Project& project,
-                      const Module* module,
-                      const XMLElement& node );
+       LinkerScript ( const XMLElement& node,
+                      const Module& module,
+                      const FileLocation *file );
        ~LinkerScript ();
        void ProcessXML();
 };
@@ -698,60 +714,32 @@ private:
 };
 
 
-class WineResource
-{
-public:
-       const Project& project;
-       std::string bin2res;
-
-       WineResource ( const Project& project,
-                      std::string bin2res );
-       ~WineResource ();
-       void UnpackResources ( bool verbose );
-private:
-       bool IsSpecFile ( const File& file );
-       bool IsWineModule ( const Module& module );
-       bool IsResourceFile ( const File& file );
-       std::string GetResourceFilename ( const Module& module );
-       void UnpackResourcesInModule ( Module& module,
-                                      bool verbose );
-};
-
-
 class SourceFile
 {
 public:
        SourceFile ( AutomaticDependency* automaticDependency,
                     const Module& module,
-                    const std::string& filename,
-                    SourceFile* parent,
-                    bool isNonAutomaticDependency );
-       SourceFile* ParseFile ( const std::string& normalizedFilename );
+                    const File& file,
+                    SourceFile* parent );
        void Parse ();
-       std::string Location () const;
-       std::vector<SourceFile*> files;
+       std::vector<SourceFile*> files; /* List of files included in this file */
+       const File& file;
        AutomaticDependency* automaticDependency;
        const Module& module;
-       std::string filename;
-       std::string filenamePart;
-       std::string directoryPart;
        std::vector<SourceFile*> parents; /* List of files, this file is included from */
-       bool isNonAutomaticDependency;
-       std::string cachedDependencies;
        time_t lastWriteTime;
        time_t youngestLastWriteTime; /* Youngest last write time of this file and all children */
        SourceFile* youngestFile;
 private:
-       void GetDirectoryAndFilenameParts ();
        void Close ();
        void Open ();
        void SkipWhitespace ();
        bool ReadInclude ( std::string& filename,
                           bool& searchCurrentDirectory,
                           bool& includeNext );
-       bool IsIncludedFrom ( const std::string& normalizedFilename );
-       SourceFile* GetParentSourceFile ();
-       bool CanProcessFile ( const std::string& extension );
+       bool IsIncludedFrom ( const File& file );
+       SourceFile* ParseFile(const File& file);
+       bool CanProcessFile ( const File& file );
        bool IsParentOf ( const SourceFile* parent,
                          const SourceFile* child );
        std::string buf;
@@ -768,20 +756,18 @@ public:
 
        AutomaticDependency ( const Project& project );
        ~AutomaticDependency ();
-       std::string GetFilename ( const std::string& filename );
-       bool LocateIncludedFile ( const std::string& directory,
-                                 const std::string& includedFilename,
-                                 std::string& resolvedFilename );
+       bool LocateIncludedFile ( const FileLocation& directory,
+                                 const std::string& includedFilename );
        bool LocateIncludedFile ( SourceFile* sourceFile,
                                  const Module& module,
                                  const std::string& includedFilename,
                                  bool searchCurrentDirectory,
                                  bool includeNext,
-                                 std::string& resolvedFilename );
+                                 File& resolvedFile );
        SourceFile* RetrieveFromCacheOrParse ( const Module& module,
-                                              const std::string& filename,
+                                              const File& file,
                                               SourceFile* parentSourceFile );
-       SourceFile* RetrieveFromCache ( const std::string& filename );
+       SourceFile* RetrieveFromCache ( const File& file );
        void CheckAutomaticDependencies ( bool verbose );
        void CheckAutomaticDependenciesForModule ( Module& module,
                                                   bool verbose );
@@ -791,19 +777,13 @@ private:
                                          bool verbose );
        void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
        void GetIncludeDirectories ( std::vector<Include*>& includes,
-                                    const Module& module,
-                                    Include& currentDirectory,
-                                    bool searchCurrentDirectory );
+                                    const Module& module );
        void GetModuleFiles ( const Module& module,
                                  std::vector<File*>& files ) const;
        void ParseFiles ();
        void ParseFiles ( const Module& module );
        void ParseFile ( const Module& module,
                         const File& file );
-       std::string ReplaceVariable ( const std::string& name,
-                                     const std::string& value,
-                                     std::string path );
-       std::string ResolveVariablesInPath ( const std::string& path );
        std::map<std::string, SourceFile*> sourcefile_map;
 };
 
@@ -831,31 +811,6 @@ private:
 };
 
 
-enum DirectoryLocation
-{
-       SourceDirectory,
-       IntermediateDirectory,
-       OutputDirectory,
-       InstallDirectory,
-       TemporaryDirectory,
-};
-
-
-class FileLocation
-{
-public:
-       DirectoryLocation directory;
-       std::string relative_path;
-       std::string name;
-
-       FileLocation ( const DirectoryLocation directory,
-                      const std::string& relative_path,
-                      const std::string& name );
-
-       FileLocation ( const FileLocation& other );
-};
-
-
 class CDFile : public XmlNode
 {
 public:
@@ -865,6 +820,7 @@ public:
        CDFile ( const Project& project,
                 const XMLElement& bootstrapNode,
                 const std::string& path );
+       ~CDFile ();
 private:
        static std::string ReplaceVariable ( const std::string& name,
                                             const std::string& value,
@@ -881,6 +837,7 @@ public:
        InstallFile ( const Project& project,
                      const XMLElement& bootstrapNode,
                      const std::string& path );
+       ~InstallFile ();
 };
 
 
@@ -889,12 +846,13 @@ class PchFile
 public:
        const XMLElement& node;
        const Module& module;
-       FileLocation file;
+       const FileLocation *file;
 
        PchFile (
                const XMLElement& node,
                const Module& module,
-               const FileLocation& file );
+               const FileLocation *file );
+       ~PchFile();
        void ProcessXML();
 };
 
@@ -934,13 +892,9 @@ private:
 class CompilationUnit
 {
 public:
-       const Project* project;
-       const Module* module;
-       const XMLElement* node;
        std::string name;
-       std::vector<File*> files;
 
-       CompilationUnit ( File* file );
+       CompilationUnit ( const File* file );
        CompilationUnit ( const Project* project,
                          const Module* module,
                          const XMLElement* node );
@@ -949,10 +903,16 @@ public:
        bool IsGeneratedFile () const;
        bool HasFileWithExtension ( const std::string& extension ) const;
        bool IsFirstFile () const;
-       const FileLocation* GetFilename () const;
-       std::string GetSwitches () const;
+       const FileLocation& GetFilename () const;
+       const std::string& GetSwitches () const;
+       void AddFile ( const File * file );
+       const std::vector<const File*> GetFiles () const;
 private:
-       std::string local_name;
+       const Project* project;
+       const Module* module;
+       const XMLElement* node;
+       std::vector<const File*> files;
+       FileLocation *default_name;
 };
 
 
@@ -1048,13 +1008,7 @@ GetSubPath (
        const std::string& att_value );
 
 extern std::string
-GetExtension ( const std::string& filename );
-
-extern std::string
-GetDirectory ( const std::string& filename );
-
-extern std::string
-GetFilename ( const std::string& filename );
+GetExtension ( const FileLocation& file );
 
 extern std::string
 NormalizeFilename ( const std::string& filename );