- Add specific properties to the keyboardlayout module type. They will assist us...
[reactos.git] / reactos / tools / rbuild / rbuild.h
index f45b53f..cac006b 100644 (file)
@@ -70,6 +70,7 @@ extern char cBadSep;
 
 #define MS_VS_DEF_VERSION "7.10"
 
+class XmlNode;
 class Directory;
 class Project;
 class IfableData;
@@ -88,7 +89,6 @@ class LinkerFlag;
 class LinkerScript;
 class Property;
 class TestSupportCode;
-class WineResource;
 class AutomaticDependency;
 class Bootstrap;
 class CDFile;
@@ -101,31 +101,51 @@ class FileLocation;
 class AutoRegister;
 
 class SourceFileTest;
-
+class Metadata;
 
 typedef std::map<std::string,Directory*> directory_map;
 
+class XmlNode
+{
+protected:
+       const Project& project;
+       const XMLElement& node;
+
+       XmlNode ( const Project& project_,
+                 const XMLElement& node_ );
+       virtual ~XmlNode();
+
+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 ( 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 );
+       bool CreateDirectory ( const std::string& path );
+       std::string EscapeSpaces ( const std::string& path );
+       void GenerateTree ( const std::string& parent,
+                           bool verbose );
 };
 
 
@@ -143,7 +163,7 @@ public:
        std::string VSProjectVersion;
        std::string VSConfigurationType;
        bool UseVSVersionInPath;
-       bool UseVSConfigurationInPath;
+       bool UseConfigurationInPath;
        bool MakeHandlesInstallDirectories;
        bool GenerateProxyMakefilesInSourceTree;
        bool InstallFiles;
@@ -153,9 +173,12 @@ class Environment
 {
 public:
        static std::string GetVariable ( const std::string& name );
+       static std::string GetArch ();
        static std::string GetIntermediatePath ();
        static std::string GetOutputPath ();
+       static std::string GetCdOutputPath ();
        static std::string GetInstallPath ();
+       static std::string GetAutomakeFile ( const std::string& defaultFile );
        static std::string GetEnvironmentVariablePathOrDefault ( const std::string& name,
                                                                 const std::string& defaultValue );
 };
@@ -165,7 +188,8 @@ class FileSupportCode
 {
 public:
        static void WriteIfChanged ( char* outbuf,
-                                    std::string filename );
+                                    const std::string& filename,
+                                    bool ignoreError = false );
 };
 
 
@@ -190,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 );
@@ -213,7 +239,8 @@ public:
        IfableData non_if_data;
 
        Project ( const Configuration& configuration,
-                 const std::string& filename );
+                 const std::string& filename,
+                 const std::map<std::string, std::string>* properties = NULL );
        ~Project ();
        void SetBackend ( Backend* backend ) { _backend = backend; }
        Backend& GetBackend() { return *_backend; }
@@ -223,14 +250,14 @@ public:
        void ProcessXML ( const std::string& path );
        Module* LocateModule ( const std::string& name );
        const Module* LocateModule ( const std::string& name ) const;
-       std::string GetProjectFilename () const;
+       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 ();
@@ -255,29 +282,59 @@ enum ModuleType
        NativeDLL = 6,
        NativeCUI = 7,
        Win32DLL = 8,
-       Win32CUI = 9,
-       Win32GUI = 10,
-       BootLoader = 11,
-       BootSector = 12,
-       Iso = 13,
-       LiveIso = 14,
-       Test = 15,
-       RpcServer = 16,
-       RpcClient = 17,
-       Alias = 18,
-       BootProgram = 19,
-       Win32SCR = 20,
-    ExportDriver = 21,
-    IdlHeader = 22,
-       IsoRegTest = 23,
-       LiveIsoRegTest = 24
+       Win32OCX = 9,
+       Win32CUI = 10,
+       Win32GUI = 11,
+       BootLoader = 12,
+       BootSector = 13,
+       Iso = 14,
+       LiveIso = 15,
+       Test = 16,
+       RpcServer = 17,
+       RpcClient = 18,
+       Alias = 19,
+       BootProgram = 20,
+       Win32SCR = 21,
+       IdlHeader = 23,
+       IsoRegTest = 24,
+       LiveIsoRegTest = 25,
+       EmbeddedTypeLib = 26,
+       ElfExecutable = 27,
+       RpcProxy,
+       HostStaticLibrary,
+       TypeDontCare,
+       Cabinet,
+       KeyboardLayout
 };
 
 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
@@ -291,14 +348,16 @@ public:
        std::string extension;
        std::string baseaddress;
        std::string payload;
-       std::string path;
+       std::string buildtype;
        ModuleType type;
        ImportLibrary* importLibrary;
+       Metadata* metadata;
        bool mangledSymbols;
+       bool underscoreSymbols;
        bool isUnicode;
-    bool isDefaultEntryPoint;
+       bool isDefaultEntryPoint;
        Bootstrap* bootstrap;
-       AutoRegister* autoRegister;
+       AutoRegister* autoRegister; // <autoregister> node
        IfableData non_if_data;
        std::vector<Invoke*> invocations;
        std::vector<Dependency*> dependencies;
@@ -310,14 +369,17 @@ 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;
+       bool isStartupLib;
+       FileLocation *output; // "path/foo.exe"
+       FileLocation *dependency; // "path/foo.exe" or "path/libfoo.a"
+       FileLocation *install;
+       std::string description;
+       std::string lcid;
+       std::string layoutId;
+       std::string layoutNameResId;
 
        Module ( const Project& project,
                 const XMLElement& moduleNode,
@@ -327,11 +389,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 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;
@@ -340,15 +397,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,
+                                   DirectoryLocation directory,
+                                   const std::string& relative_path,
                                    ParseContext& parseContext );
 };
 
@@ -356,24 +414,23 @@ private:
 class Include
 {
 public:
-       const Project& project;
-       const Module* module;
-       const XMLElement* node;
-       const Module* baseModule;
-       std::string directory;
-       std::string basePath;
+       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;
 };
 
 
@@ -382,9 +439,11 @@ class Define
 public:
        const Project& project;
        const Module* module;
-    const XMLElement* node;
+       const XMLElement* node;
        std::string name;
        std::string value;
+       std::string backend;
+       bool overridable;
 
        Define ( const Project& project,
                 const XMLElement& defineNode );
@@ -393,7 +452,8 @@ public:
                 const XMLElement& defineNode );
        Define ( const Project& project,
                 const Module* module,
-                const std::string name_ );
+                const std::string& name_,
+                const std::string& backend_ = "" );
        ~Define();
        void ProcessXML();
 private:
@@ -404,17 +464,20 @@ private:
 class File
 {
 public:
-       std::string name;
+       FileLocation file;
        bool first;
        std::string switches;
        bool isPreCompiledHeader;
 
-       File ( const std::string& _name,
+       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();
+       std::string GetFullPath () const;
 };
 
 
@@ -485,20 +548,36 @@ public:
        void ProcessXML();
 };
 
-
-class ImportLibrary
+class Metadata
 {
 public:
        const XMLElement& node;
        const Module& module;
-       std::string basename;
-       std::string definition;
+       std::string name;
+       std::string description;
+       std::string version;
+       std::string copyright;
+       std::string url;
+       std::string date;
+       std::string owner;
+
+       Metadata ( const XMLElement& _node,
+                 const Module& _module );
+
+       void ProcessXML();
+};
+
+class ImportLibrary : public XmlNode
+{
+public:
+       const Module& module;
        std::string dllname;
+       FileLocation *source;
 
-       ImportLibrary ( const XMLElement& _node,
+       ImportLibrary ( const Project& project,
+                       const XMLElement& node,
                        const Module& module );
-
-       void ProcessXML ();
+       ~ImportLibrary ();
 };
 
 
@@ -529,6 +608,7 @@ public:
        const Module* module;
        const XMLElement& node;
        std::string flag;
+       CompilerType compiler;
 
        CompilerFlag ( const Project& project,
                       const XMLElement& compilerFlagNode );
@@ -565,16 +645,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();
 };
@@ -583,15 +660,20 @@ public:
 class Property
 {
 public:
-       const XMLElement& node;
        const Project& project;
        const Module* module;
        std::string name, value;
+       bool isInternal;
 
        Property ( const XMLElement& node_,
                   const Project& project_,
                   const Module* module_ );
 
+       Property ( const Project& project_,
+                  const Module* module_,
+                  const std::string& name_,
+                  const std::string& value_ );
+
        void ProcessXML();
 };
 
@@ -617,11 +699,11 @@ private:
        void WriteHooksFile ( Module& module );
        std::string GetStubsFilename ( Module& module );
        char* WriteStubbedSymbolToStubsFile ( char* buffer,
-                                              const StubbedComponent& component,
+                                             const StubbedComponent& component,
                                              const StubbedSymbol& symbol,
                                              int stubIndex );
        char* WriteStubbedComponentToStubsFile ( char* buffer,
-                                                 const StubbedComponent& component,
+                                                const StubbedComponent& component,
                                                 int* stubIndex );
        void WriteStubsFile ( Module& module );
        std::string GetStartupFilename ( Module& module );
@@ -629,69 +711,41 @@ private:
        std::string GetTestDispatcherName ( std::string filename );
        bool IsTestFile ( std::string& filename ) const;
        void GetSourceFilenames ( string_list& list,
-                                  Module& module ) const;
+                                 Module& module ) const;
        char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
-                                                           Module& module );
+                                                          Module& module );
        char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
                                                        Module& module );
        void WriteStartupFile ( Module& module );
 };
 
 
-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;
@@ -708,34 +762,30 @@ 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 );
 private:
        void GetModulesToCheck ( Module& module, std::vector<const Module*>& modules );
        void CheckAutomaticDependencies ( const Module& module,
-                                          bool verbose );
+                                         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;
+                                 std::vector<File*>& files ) const;
        void ParseFiles ();
        void ParseFiles ( const Module& module );
        void ParseFile ( const Module& module,
@@ -761,44 +811,39 @@ public:
 private:
        bool IsSupportedModuleType ( ModuleType type );
        void Initialize();
+       static std::string ReplaceVariable ( const std::string& name,
+                                            const std::string& value,
+                                            std::string path );
 };
 
 
-class CDFile
+class CDFile : public XmlNode
 {
 public:
-       const Project& project;
-       const XMLElement& node;
-       std::string name;
-       std::string base;
-       std::string nameoncd;
-       std::string path;
+       FileLocation *source;
+       FileLocation *target;
 
        CDFile ( const Project& project,
                 const XMLElement& bootstrapNode,
                 const std::string& path );
        ~CDFile ();
-       void ProcessXML();
-       std::string GetPath () const;
+private:
+       static std::string ReplaceVariable ( const std::string& name,
+                                            const std::string& value,
+                                            std::string path );
 };
 
 
-class InstallFile
+class InstallFile : public XmlNode
 {
 public:
-       const Project& project;
-       const XMLElement& node;
-       std::string name;
-       std::string base;
-       std::string newname;
-       std::string path;
+       FileLocation *source;
+       FileLocation *target;
 
        InstallFile ( const Project& project,
                      const XMLElement& bootstrapNode,
                      const std::string& path );
        ~InstallFile ();
-       void ProcessXML ();
-       std::string GetPath () const;
 };
 
 
@@ -807,12 +852,13 @@ class PchFile
 public:
        const XMLElement& node;
        const Module& module;
-       File file;
+       const FileLocation *file;
 
        PchFile (
                const XMLElement& node,
                const Module& module,
-               const File file );
+               const FileLocation *file );
+       ~PchFile();
        void ProcessXML();
 };
 
@@ -852,13 +898,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 );
@@ -867,8 +909,16 @@ public:
        bool IsGeneratedFile () const;
        bool HasFileWithExtension ( const std::string& extension ) const;
        bool IsFirstFile () const;
-       FileLocation* GetFilename ( Directory* intermediateDirectory ) 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:
+       const Project* project;
+       const Module* module;
+       const XMLElement* node;
+       std::vector<const File*> files;
+       FileLocation *default_name;
 };
 
 
@@ -890,16 +940,6 @@ private:
 };
 
 
-class FileLocation
-{
-public:
-       Directory* directory;
-       std::string filename;
-       FileLocation ( Directory* directory,
-                      std::string filename );
-};
-
-
 enum AutoRegisterType
 {
        DllRegisterServer,
@@ -907,22 +947,18 @@ enum AutoRegisterType
        Both
 };
 
-class AutoRegister
+class AutoRegister : public XmlNode
 {
 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 );
+       AutoRegisterType GetAutoRegisterType( const std::string& type );
        void Initialize ();
 };
 
@@ -972,18 +1008,13 @@ ReplaceExtension (
 
 extern std::string
 GetSubPath (
+       const Project& project,
        const std::string& location,
        const std::string& path,
        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 );