Merge trunk HEAD (r46369)
[reactos.git] / reactos / tools / rbuild / rbuild.h
index 3375fbc..e5be60c 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-#ifndef __RBUILD_H
-#define __RBUILD_H
+
+#pragma once
 
 #include "pch.h"
 
@@ -68,7 +68,7 @@ extern char cBadSep;
 #define DEF_SBAD_SEP "\\"
 #endif
 
-#define MS_VS_DEF_VERSION "7.10"
+#define MS_VS_DEF_VERSION "9.00"
 
 class XmlNode;
 class Directory;
@@ -83,7 +83,6 @@ class Invoke;
 class InvokeFile;
 class Dependency;
 class ImportLibrary;
-class If;
 class CompilerFlag;
 class LinkerFlag;
 class LinkerScript;
@@ -102,6 +101,7 @@ class AutoRegister;
 
 class SourceFileTest;
 class Metadata;
+class Bootsector;
 
 typedef std::map<std::string,Directory*> directory_map;
 
@@ -148,6 +148,31 @@ private:
                            bool verbose );
 };
 
+enum DependenciesType
+{
+       NoDependencies,
+       AutomaticDependencies,
+       FullDependencies
+};
+
+enum CompilerSet
+{
+       GnuGcc,
+       MicrosoftC
+};
+
+enum LinkerSet
+{
+       GnuLd,
+       MicrosoftLink
+};
+
+enum SpecFileType
+{
+    None,
+    Spec = 1,
+    PSpec = 2
+};
 
 class Configuration
 {
@@ -156,9 +181,10 @@ public:
        ~Configuration ();
        bool Verbose;
        bool CleanAsYouGo;
-       bool AutomaticDependencies;
+       DependenciesType Dependencies;
        bool CheckDependenciesForModuleOnly;
        bool CompilationUnitsEnabled;
+       bool PrecompiledHeadersEnabled;
        std::string CheckDependenciesForModuleOnlyModule;
        std::string VSProjectVersion;
        std::string VSConfigurationType;
@@ -167,6 +193,8 @@ public:
        bool MakeHandlesInstallDirectories;
        bool GenerateProxyMakefilesInSourceTree;
        bool InstallFiles;
+       CompilerSet Compiler;
+       LinkerSet Linker;
 };
 
 class Environment
@@ -176,6 +204,7 @@ public:
        static std::string GetArch ();
        static std::string GetIntermediatePath ();
        static std::string GetOutputPath ();
+       static std::string GetSourcePath ();
        static std::string GetCdOutputPath ();
        static std::string GetInstallPath ();
        static std::string GetAutomakeFile ( const std::string& defaultFile );
@@ -196,7 +225,6 @@ public:
 class ParseContext
 {
 public:
-       If* ifData;
        CompilationUnit* compilationUnit;
        ParseContext ();
 };
@@ -210,16 +238,15 @@ public:
        std::vector<Include*> includes;
        std::vector<Define*> defines;
        std::vector<Library*> libraries;
-       std::vector<Property*> properties;
+       std::map<std::string, Property*> properties;
        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 );
+       void ExtractModules( std::map<std::string, Module*> &modules );
 };
 
 class Project
@@ -235,8 +262,11 @@ public:
        std::vector<LinkerFlag*> linkerFlags;
        std::vector<CDFile*> cdfiles;
        std::vector<InstallFile*> installfiles;
-       std::vector<Module*> modules;
+       std::map<std::string, Module*> modules;
        IfableData non_if_data;
+       IfableData host_non_if_data;
+       bool allowWarnings;
+       bool allowWarningsSet;
 
        Project ( const Configuration& configuration,
                  const std::string& filename,
@@ -244,7 +274,6 @@ public:
        ~Project ();
        void SetBackend ( Backend* backend ) { _backend = backend; }
        Backend& GetBackend() { return *_backend; }
-       void WriteConfigurationFile ();
        void ExecuteInvocations ();
 
        void ProcessXML ( const std::string& path );
@@ -252,14 +281,12 @@ public:
        const Module* LocateModule ( const std::string& name ) const;
        const std::string& GetProjectFilename () const;
        std::string ResolveProperties ( const std::string& s ) const;
+       const Property* LookupProperty ( const std::string& name ) const;
+       std::string GetCompilerSet () const;
+       std::string GetLinkerSet () const;
+       void GenerateInstallerFileList();
 private:
        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 );
-       void SetConfigurationOption ( char* s,
-                                     std::string name );
        void ReadXml ();
        void ProcessXMLSubElement ( const XMLElement& e,
                                    const std::string& path,
@@ -273,38 +300,38 @@ private:
 
 enum ModuleType
 {
-       BuildTool = 0,
-       StaticLibrary = 1,
-       ObjectLibrary = 2,
-       Kernel = 3,
-       KernelModeDLL = 4,
-       KernelModeDriver = 5,
-       NativeDLL = 6,
-       NativeCUI = 7,
-       Win32DLL = 8,
-       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,
+       BuildTool,
+       StaticLibrary,
+       ObjectLibrary,
+       Kernel,
+       KernelModeDLL,
+       KernelModeDriver,
+       NativeDLL,
+       NativeCUI,
+       Win32DLL,
+       Win32OCX,
+       Win32CUI,
+       Win32GUI,
+       BootLoader,
+       BootSector,
+       Iso,
+       LiveIso,
+       Test,
+       RpcServer,
+       RpcClient,
+       Alias,
+       BootProgram,
+       Win32SCR,
+       IdlHeader,
+       IdlInterface,
+       EmbeddedTypeLib,
+       ElfExecutable,
        RpcProxy,
        HostStaticLibrary,
-       TypeDontCare,
        Cabinet,
-       KeyboardLayout
+       KeyboardLayout,
+       MessageHeader,
+       TypeDontCare, // always at the end
 };
 
 enum HostType
@@ -317,9 +344,15 @@ enum HostType
 
 enum CompilerType
 {
-       CompilerTypeDontCare,
        CompilerTypeCC,
+       CompilerTypeCXX,
        CompilerTypeCPP,
+       CompilerTypeAS,
+       CompilerTypeMIDL,
+       CompilerTypeRC,
+       CompilerTypeNASM,
+
+       CompilerTypesCount
 };
 
 class FileLocation
@@ -351,9 +384,9 @@ public:
        std::string buildtype;
        ModuleType type;
        ImportLibrary* importLibrary;
+       ImportLibrary* delayImportLibrary;
        Metadata* metadata;
-       bool mangledSymbols;
-       bool underscoreSymbols;
+       Bootsector* bootSector;
        bool isUnicode;
        bool isDefaultEntryPoint;
        Bootstrap* bootstrap;
@@ -364,20 +397,26 @@ public:
        std::vector<CompilerFlag*> compilerFlags;
        std::vector<LinkerFlag*> linkerFlags;
        std::vector<StubbedComponent*> stubbedComponents;
+       std::vector<CDFile*> cdfiles;
        LinkerScript* linkerScript;
        PchFile* pch;
        bool cplusplus;
        std::string prefix;
-       HostType host;
        std::string aliasedModuleName;
        bool allowWarnings;
        bool enabled;
        bool isStartupLib;
+       bool isCRT;
+       std::string CRT;
+       bool dynamicCRT;
+       std::string installbase;
        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,
@@ -389,27 +428,66 @@ public:
        bool IsDLL () const;
        std::string GetPathWithPrefix ( const std::string& prefix ) const; // "path/prefixfoo.exe"
        std::string GetPathToBaseDir() const; // "../" offset to rootdirectory
-       std::string GetEntryPoint(bool leadingUnderscore) const;
+       std::string GetEntryPoint() const;
        void GetTargets ( string_list& ) const;
        std::string GetInvocationTarget ( const int index ) const;
        bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
        void InvokeModule () const;
        void ProcessXML ();
+       std::string GetDllName() const;
+       SpecFileType IsSpecDefinitionFile () const;
 private:
        void SetImportLibrary ( ImportLibrary* importLibrary );
+       void SetDelayImportLibrary ( ImportLibrary* importLibrary );
        DirectoryLocation GetTargetDirectoryTree () const;
        std::string GetDefaultModuleExtension () const;
        std::string GetDefaultModuleEntrypoint () const;
        std::string GetDefaultModuleBaseaddress () const;
+       std::string GetDefaultModuleCRT () const;
+       bool GetDefaultModuleIsCRT () const;
        std::string entrypoint;
        void ProcessXMLSubElement ( const XMLElement& e,
                                    DirectoryLocation directory,
                                    const std::string& relative_path,
                                    ParseContext& parseContext );
+       bool GetBooleanAttribute ( const XMLElement& moduleNode,
+                                  const char * name,
+                                  bool default_value = false );
 };
 
+class ToolsetDirective
+{
+private:
+       bool enabled;
+
+protected:
+       void ParseToolsets ( const Project& project, const XMLElement& node );
+
+public:
+       virtual ~ToolsetDirective() { }
+       bool IsEnabled () const;
+};
 
-class Include
+class CompilerDirective
+{
+private:
+       std::bitset<CompilerTypesCount> compilersSet;
+       bool enabled;
+
+protected:
+       void ParseCompilers ( const XMLElement& node, const std::string& defaultValue );
+
+public:
+       CompilerDirective (): enabled ( true ) { }
+       virtual ~CompilerDirective() { }
+       void SetCompiler ( CompilerType compiler );
+       void UnsetCompiler ( CompilerType compiler );
+       void SetAllCompilers ();
+       void UnsetAllCompilers ();
+       bool IsCompilerSet ( CompilerType compiler ) const;
+};
+
+class Include: public CompilerDirective, public ToolsetDirective
 {
 public:
        FileLocation *directory;
@@ -429,19 +507,21 @@ private:
        const XMLElement* node;
        const Module* module;
        DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
+       void Initialize ();
 };
 
 
-class Define
+class Define: public CompilerDirective, public ToolsetDirective
 {
 public:
        const Project& project;
        const Module* module;
        const XMLElement* node;
        std::string name;
+       std::string arguments;
        std::string value;
        std::string backend;
-       bool overridable;
+       bool redefine;
 
        Define ( const Project& project,
                 const XMLElement& defineNode );
@@ -451,7 +531,8 @@ public:
        Define ( const Project& project,
                 const Module* module,
                 const std::string& name_,
-                const std::string& backend_ = "" );
+                const std::string& backend_ = "",
+                bool redefine_ = false );
        ~Define();
        void ProcessXML();
 private:
@@ -486,6 +567,7 @@ public:
        const Module& module;
        std::string name;
        const Module* importedModule;
+       bool delayimp;
 
        Library ( const XMLElement& _node,
                  const Module& _module,
@@ -546,6 +628,21 @@ public:
        void ProcessXML();
 };
 
+class Bootsector
+{
+public:
+       const XMLElement& node;
+       const Module* module;
+       const Module* bootSectorModule;
+
+       Bootsector ( const XMLElement& _node,
+                    const Module* _module );
+
+       void ProcessXML();
+private:
+       bool IsSupportedModuleType ( ModuleType type );
+};
+
 class Metadata
 {
 public:
@@ -568,45 +665,26 @@ public:
 class ImportLibrary : public XmlNode
 {
 public:
-       const Module& module;
+       const Module* module;
        std::string dllname;
        FileLocation *source;
+       FileLocation *target;
 
        ImportLibrary ( const Project& project,
                        const XMLElement& node,
-                       const Module& module );
+                       const Module* module,
+                       bool delayimp );
        ~ImportLibrary ();
 };
 
 
-class If
-{
-public:
-       const XMLElement& node;
-       const Project& project;
-       const Module* module;
-       const bool negated;
-       std::string property, value;
-       IfableData data;
-
-       If ( const XMLElement& node_,
-            const Project& project_,
-            const Module* module_,
-            const bool negated_ = false );
-       ~If();
-
-       void ProcessXML();
-};
-
-
-class CompilerFlag
+class CompilerFlag: public CompilerDirective, public ToolsetDirective
 {
 public:
        const Project& project;
        const Module* module;
        const XMLElement& node;
        std::string flag;
-       CompilerType compiler;
 
        CompilerFlag ( const Project& project,
                       const XMLElement& compilerFlagNode );
@@ -620,7 +698,7 @@ private:
 };
 
 
-class LinkerFlag
+class LinkerFlag: public ToolsetDirective
 {
 public:
        const Project& project;
@@ -837,6 +915,7 @@ class InstallFile : public XmlNode
 public:
        FileLocation *source;
        FileLocation *target;
+       std::string installbase;
 
        InstallFile ( const Project& project,
                      const XMLElement& bootstrapNode,
@@ -1019,5 +1098,3 @@ NormalizeFilename ( const std::string& filename );
 
 extern std::string
 ToLower ( std::string filename );
-
-#endif /* __RBUILD_H */