[rbuild] Remove distinction between Iso/IsoRegTest, and LiveIso/LiveIsoRegTest module...
[reactos.git] / reactos / tools / rbuild / backend / mingw / modulehandler.h
index c20fe57..6b8e9b5 100644 (file)
@@ -32,6 +32,13 @@ PrefixFilename (
        const std::string& filename,
        const std::string& prefix );
 
+enum SpecFileType
+{
+    None,
+    Spec = 1,
+    PSpec = 2
+};
+
 class MingwModuleHandler
 {
 public:
@@ -50,10 +57,17 @@ public:
 
        static const FileLocation* GetImportLibraryFilename (
                const Module& module,
-               string_list* pclean_files );
+               string_list* pclean_files,
+               bool delayimp );
 
        static std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines, std::set<std::string> &used_defs );
-       static std::string GenerateGccIncludeParametersFromVector ( const std::vector<Include*>& includes );
+       static std::string GenerateDefineParametersFromVector ( const std::vector<Define*>& defines, CompilerType compiler );
+       static std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags, const CompilerType type );
+       static std::string GenerateIncludeParametersFromVector ( const std::vector<Include*>& includes, CompilerType compiler );
+
+       static void GenerateParameters ( const char* prefix,
+                                                                        const char* assignmentOperation,
+                                                                        const IfableData& data );
 
        std::string GetModuleTargets ( const Module& module );
        void GetObjectsVector ( const IfableData& data,
@@ -65,12 +79,8 @@ public:
 
        static MingwModuleHandler* InstanciateHandler ( const Module& module_,
                                                        MingwBackend* backend_ );
-       virtual HostType DefaultHost() = 0;
        void GeneratePreconditionDependencies ();
-       virtual void Process () = 0;
-       virtual std::string TypeSpecificCFlags() { return ""; }
-       virtual std::string TypeSpecificNasmFlags() { return ""; }
-       virtual std::string TypeSpecificLinkerFlags() { return ""; }
+       virtual void Process () { GenerateRules (); }
        void GenerateInvocations () const;
        void GenerateCleanTarget () const;
        void GenerateInstallTarget () const;
@@ -80,34 +90,28 @@ public:
 
        void OutputCopyCommand ( const FileLocation& source,
                                 const FileLocation& destination );
+       void OutputCopyCommandSingle ( const FileLocation& source,
+                                      const FileLocation& destination );
 protected:
        virtual void GetModuleSpecificCompilationUnits ( std::vector<CompilationUnit*>& compilationUnits );
        std::string GetWorkingDirectory () const;
        std::string GetBasename ( const std::string& filename ) const;
-       const FileLocation* GetActualSourceFilename ( const FileLocation* file ) const;
-       std::string GetExtraDependencies ( const FileLocation *file ) const;
        std::string GetCompilationUnitDependencies ( const CompilationUnit& compilationUnit ) const;
        const FileLocation* GetModuleArchiveFilename () const;
-       bool IsGeneratedFile ( const File& file ) const;
-       std::string GetImportLibraryDependency ( const Module& importedModule );
+       std::string GetImportLibraryDependency ( const Module& importedModule, bool delayimp );
        void GetTargets ( const Module& dependencyModule,
                          string_list& targets );
        void GetModuleDependencies ( string_list& dependencies );
        std::string GetAllDependencies () const;
-       void GetSourceFilenames ( std::vector<FileLocation>& list,
-                                 bool includeGeneratedFiles ) const;
-       void GetSourceFilenamesWithoutGeneratedFiles ( std::vector<FileLocation>& list ) const;
        const FileLocation* GetObjectFilename ( const FileLocation* sourceFile,
                                                const Module& module ) const;
 
-       std::string GetObjectFilenames ();
-
        std::string GetPreconditionDependenciesName () const;
-       std::string GetCFlagsMacro () const;
        static std::string GetObjectsMacro ( const Module& );
        std::string GetLinkingDependenciesMacro () const;
        std::string GetLibsMacro () const;
        std::string GetLinkerMacro () const;
+       static std::string GetDebugFormat ();
        void GenerateCleanObjectsAsYouGoCode () const;
        void GenerateRunRsymCode () const;
        void GenerateRunStripCode () const;
@@ -117,6 +121,7 @@ protected:
        void GeneratePhonyTarget() const;
        void GenerateBuildMapCode ( const FileLocation *mapTarget = NULL );
        void GenerateRules ();
+       void GenerateImportLibraryTarget (const FileLocation *defFilename, const FileLocation *library_target, bool delayimp);
        void GenerateImportLibraryTargetIfNeeded ();
        void GetDefinitionDependencies ( std::vector<FileLocation>& dependencies ) const;
        std::string GetLinkingDependencies () const;
@@ -126,28 +131,18 @@ protected:
 private:
        std::string ConcatenatePaths ( const std::string& path1,
                                       const std::string& path2 ) const;
-       std::string GenerateGccDefineParameters () const;
-       std::string GenerateCompilerParametersFromVector ( const std::vector<CompilerFlag*>& compilerFlags, const CompilerType type ) const;
        std::string GenerateLinkerParametersFromVector ( const std::vector<LinkerFlag*>& linkerFlags ) const;
        std::string GenerateImportLibraryDependenciesFromVector ( const std::vector<Library*>& libraries );
        std::string GenerateLinkerParameters () const;
-       void GenerateMacro ( const char* assignmentOperation,
-                            const std::string& macro,
-                            const IfableData& data,
-                            std::set<const Define *>* used_defs,
-                            bool generatingCompilerMacro );
        void GenerateMacros ( const char* op,
                              const IfableData& data,
                              const std::vector<LinkerFlag*>* linkerFlags,
                              std::set<const Define *>& used_defs );
-       void GenerateSourceMacros ( const char* assignmentOperation,
-                                   const IfableData& data );
-       void GenerateObjectMacros ( const char* assignmentOperation,
-                                   const IfableData& data );
-       std::string GenerateGccIncludeParameters () const;
-       std::string GenerateGccParameters () const;
-       std::string GenerateNasmParameters () const;
+       void GenerateSourceMacros ( const IfableData& data );
+       void GenerateObjectMacros ( const IfableData& data );
        const FileLocation* GetPrecompiledHeaderFilename () const;
+       const FileLocation* GetPrecompiledHeaderPath () const;
+       const FileLocation* GetDlldataFilename () const;
        void GenerateGccCommand ( const FileLocation* sourceFile,
                                  const Rule *rule,
                                  const std::string& extraDependencies );
@@ -160,11 +155,13 @@ private:
                                         const FileLocation *file ) const;
        void GetSpecObjectDependencies ( std::vector<FileLocation>& dependencies,
                                         const FileLocation *file ) const;
+       void GetSpecImplibDependencies ( std::vector<FileLocation>& dependencies,
+                                        const FileLocation *file ) const;
        void GetWidlObjectDependencies ( std::vector<FileLocation>& dependencies,
                                         const FileLocation *file ) const;
        void GetDefaultDependencies ( string_list& dependencies ) const;
        void GetInvocationDependencies ( const Module& module, string_list& dependencies );
-       bool IsWineModule () const;
+       SpecFileType IsSpecDefinitionFile () const;
        const FileLocation* GetDefinitionFilename () const;
        void GenerateBuildNonSymbolStrippedCode ();
        void CleanupCompilationUnitVector ( std::vector<CompilationUnit*>& compilationUnits );
@@ -181,7 +178,9 @@ private:
 public:
        const Module& module;
        string_list clean_files;
+       std::string commonflagsMacro;
        std::string cflagsMacro;
+       std::string cxxflagsMacro;
        std::string nasmflagsMacro;
        std::string windresflagsMacro;
        std::string widlflagsMacro;
@@ -197,7 +196,6 @@ class MingwBuildToolModuleHandler : public MingwModuleHandler
 {
 public:
        MingwBuildToolModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostTrue; }
        virtual void Process ();
 private:
        void GenerateBuildToolModuleTarget ();
@@ -208,80 +206,28 @@ class MingwKernelModuleHandler : public MingwModuleHandler
 {
 public:
        MingwKernelModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 private:
        void GenerateKernelModuleTarget ();
 };
 
 
-class MingwStaticLibraryModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwStaticLibraryModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-private:
-       void GenerateStaticLibraryModuleTarget ();
-};
-
-
-class MingwHostStaticLibraryModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwHostStaticLibraryModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostTrue; }
-       virtual void Process ();
-private:
-       void GenerateHostStaticLibraryModuleTarget ();
-};
-
-
-class MingwObjectLibraryModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwObjectLibraryModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-private:
-       void GenerateObjectLibraryModuleTarget ();
-};
-
-
 class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
 {
 public:
        MingwKernelModeDLLModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateKernelModeDLLModuleTarget ();
 };
 
 
-class MingwKernelModeDriverModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwKernelModeDriverModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-       std::string TypeSpecificCFlags() { return "-D__NTDRIVER__"; }
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
-       void AddImplicitLibraries ( Module& module );
-private:
-       void GenerateKernelModeDriverModuleTarget ();
-};
-
-
 class MingwNativeDLLModuleHandler : public MingwModuleHandler
 {
 public:
        MingwNativeDLLModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateNativeDLLModuleTarget ();
@@ -292,10 +238,7 @@ class MingwNativeCUIModuleHandler : public MingwModuleHandler
 {
 public:
        MingwNativeCUIModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificCFlags() { return "-D__NTAPP__"; }
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateNativeCUIModuleTarget ();
@@ -306,9 +249,7 @@ class MingwWin32DLLModuleHandler : public MingwModuleHandler
 {
 public:
        MingwWin32DLLModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return module.cplusplus ? "-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateWin32DLLModuleTarget ();
@@ -319,9 +260,7 @@ class MingwWin32OCXModuleHandler : public MingwModuleHandler
 {
 public:
        MingwWin32OCXModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return module.cplusplus ? "-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateWin32OCXModuleTarget ();
@@ -332,9 +271,7 @@ class MingwWin32CUIModuleHandler : public MingwModuleHandler
 {
 public:
        MingwWin32CUIModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return module.cplusplus ? "-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateWin32CUIModuleTarget ();
@@ -345,9 +282,7 @@ class MingwWin32GUIModuleHandler : public MingwModuleHandler
 {
 public:
        MingwWin32GUIModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return module.cplusplus ? "-nostartfiles -lgcc" : "-nostartfiles -nostdlib -lgcc"; }
        void AddImplicitLibraries ( Module& module );
 private:
        void GenerateWin32GUIModuleTarget ();
@@ -358,34 +293,18 @@ class MingwBootLoaderModuleHandler : public MingwModuleHandler
 {
 public:
        MingwBootLoaderModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
 private:
        void GenerateBootLoaderModuleTarget ();
 };
 
 
-class MingwBootSectorModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwBootSectorModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-       std::string TypeSpecificNasmFlags() { return "-f bin"; }
-private:
-       void GenerateBootSectorModuleTarget ();
-};
-
-
 class MingwBootProgramModuleHandler : public MingwModuleHandler
 {
 public:
        MingwBootProgramModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
        std::string GetProgTextAddrMacro ();
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
 private:
        void GenerateBootProgramModuleTarget ();
 };
@@ -395,7 +314,6 @@ class MingwIsoModuleHandler : public MingwModuleHandler
 {
 public:
        MingwIsoModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 private:
        void GenerateIsoModuleTarget ();
@@ -405,8 +323,10 @@ private:
        void GetBootstrapCdFiles ( std::vector<FileLocation>& out ) const;
        void GetNonModuleCdFiles ( std::vector<FileLocation>& out ) const;
        void GetCdFiles ( std::vector<FileLocation>& out ) const;
-       void OutputBootstrapfileCopyCommands ( const std::string& bootcdDirectory );
-       void OutputCdfileCopyCommands ( const std::string& bootcdDirectory );
+       void OutputBootstrapfileCopyCommands ( const std::string& bootcdDirectory,
+                                              std::vector<FileLocation>& destinations );
+       void OutputCdfileCopyCommands ( const std::string& bootcdDirectory,
+                                       std::vector<FileLocation>& destinations );
 };
 
 
@@ -414,17 +334,20 @@ class MingwLiveIsoModuleHandler : public MingwModuleHandler
 {
 public:
        MingwLiveIsoModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 private:
        void GenerateLiveIsoModuleTarget ();
        void CreateDirectory ( const std::string& directory );
        void OutputModuleCopyCommands ( std::string& livecdDirectory,
-                                       std::string& livecdReactos );
+                                       std::string& livecdReactos,
+                                       std::vector<FileLocation>& destinations );
        void OutputNonModuleCopyCommands ( std::string& livecdDirectory,
-                                          std::string& livecdReactos );
-       void OutputProfilesDirectoryCommands ( std::string& livecdDirectory );
-       void OutputLoaderCommands ( std::string& livecdDirectory );
+                                          std::string& livecdReactos,
+                                          std::vector<FileLocation>& destinations );
+       void OutputProfilesDirectoryCommands ( std::string& livecdDirectory,
+                                              std::vector<FileLocation>& destinations );
+       void OutputLoaderCommands ( std::string& livecdDirectory,
+                                   std::vector<FileLocation>& destinations );
        void OutputRegistryCommands ( std::string& livecdDirectory );
 };
 
@@ -433,63 +356,17 @@ class MingwTestModuleHandler : public MingwModuleHandler
 {
 public:
        MingwTestModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
-       std::string TypeSpecificLinkerFlags() { return "-nostartfiles -nostdlib"; }
 protected:
        virtual void GetModuleSpecificCompilationUnits ( std::vector<CompilationUnit*>& compilationUnits );
 private:
        void GenerateTestModuleTarget ();
 };
 
-
-class MingwRpcServerModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwRpcServerModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
-
-class MingwRpcClientModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwRpcClientModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
-
-class MingwRpcProxyModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwRpcProxyModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
-class MingwMessageHeaderModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwMessageHeaderModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
 class MingwAliasModuleHandler : public MingwModuleHandler
 {
 public:
        MingwAliasModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
-class MingwIdlHeaderModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwIdlHeaderModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 };
 
@@ -497,15 +374,6 @@ class MingwCabinetModuleHandler : public MingwModuleHandler
 {
 public:
        MingwCabinetModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
-       virtual void Process ();
-};
-
-class MingwEmbeddedTypeLibModuleHandler : public MingwModuleHandler
-{
-public:
-       MingwEmbeddedTypeLibModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 };
 
@@ -513,7 +381,6 @@ class MingwElfExecutableModuleHandler : public MingwModuleHandler
 {
 public:
        MingwElfExecutableModuleHandler ( const Module& module );
-       virtual HostType DefaultHost() { return HostFalse; }
        virtual void Process ();
 };