Merge trunk HEAD (r46369)
[reactos.git] / reactos / tools / rbuild / backend / mingw / mingw.h
index 0de4197..e73973f 100644 (file)
@@ -1,5 +1,22 @@
-#ifndef MINGW_H
-#define MINGW_H
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#pragma once
 
 #include "../backend.h"
 
 class Directory;
 class MingwModuleHandler;
 
+extern std::string
+v2s ( const Backend* backend, const std::vector<FileLocation>& files, int wrap_at );
 extern std::string
 v2s ( const string_list& v, int wrap_at );
 
-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 MingwBackend : public Backend
 {
@@ -51,58 +44,68 @@ public:
        virtual void Process ();
        std::string AddDirectoryTarget ( const std::string& directory,
                                         Directory* directoryTree );
+       const Module& GetAliasedModuleOrModule ( const Module& module ) const;
+       bool compilerNeedsHelper;
        std::string compilerPrefix;
        std::string compilerCommand;
        std::string nasmCommand;
-       bool usePipe;
+       std::string binutilsPrefix;
+       bool binutilsNeedsHelper;
+       std::string binutilsCommand;
+       bool usePipe, manualBinutilsSetting;
        Directory* intermediateDirectory;
        Directory* outputDirectory;
        Directory* installDirectory;
+
+       std::string GetFullName ( const FileLocation& file ) const;
+       std::string GetFullPath ( const FileLocation& file ) const;
+
 private:
        void CreateMakefile ();
        void CloseMakefile () const;
        void GenerateHeader () const;
-       std::string GenerateIncludesAndDefines ( IfableData& data ) const;
-       void GenerateProjectCFlagsMacro ( const char* assignmentOperation,
-                                         IfableData& data ) const;
-       void GenerateGlobalCFlagsAndProperties ( const char* op,
-                                                IfableData& data ) const;
-       void GenerateProjectGccOptionsMacro ( const char* assignmentOperation,
-                                              IfableData& data ) const;
-       void GenerateProjectGccOptions ( const char* assignmentOperation,
-                                        IfableData& data ) const;
-       std::string GenerateProjectLFLAGS () const;
+       void GenerateGlobalProperties ( const char* assignmentOperation,
+                                                                         const IfableData& data ) const;
+       std::string GenerateProjectLDFLAGS () const;
        void GenerateDirectories ();
        void GenerateGlobalVariables () const;
        bool IncludeInAllTarget ( const Module& module ) const;
        void GenerateAllTarget ( const std::vector<MingwModuleHandler*>& handlers ) const;
-       std::string GetBuildToolDependencies () const;
-       void GenerateInitTarget () const;
        void GenerateRegTestsRunTarget () const;
        void GenerateXmlBuildFilesMacro() const;
-       std::string GetBin2ResExecutable ();
-       void UnpackWineResources ();
        void GenerateTestSupportCode ();
+       void GenerateCompilationUnitSupportCode ();
+       void GenerateSysSetup ();
+       std::string GetProxyMakefileTree () const;
        void GenerateProxyMakefiles ();
        void CheckAutomaticDependencies ();
-       bool IncludeDirectoryTarget ( const std::string& directory ) const;
        bool TryToDetectThisCompiler ( const std::string& compiler );
        void DetectCompiler ();
+       std::string GetCompilerVersion ( const std::string& compilerCommand );
+       bool IsSupportedCompilerVersion ( const std::string& compilerVersion );
        bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
+       bool TryToDetectThisBinutils ( const std::string& binutils );
+       std::string GetBinutilsVersion ( const std::string& binutilsCommand );
+       std::string GetBinutilsVersionDate ( const std::string& binutilsCommand );
+       bool IsSupportedBinutilsVersion ( const std::string& binutilsVersion );
+       std::string GetVersionString ( const std::string& versionCommand );
+       std::string GetNetwideAssemblerVersion ( const std::string& nasmCommand );
+       void DetectBinutils ();
        void DetectNetwideAssembler ();
        void DetectPipeSupport ();
        void DetectPCHSupport ();
+       bool CanEnablePreCompiledHeaderSupportForModule ( const Module& module );
        void ProcessModules ();
+       void CheckAutomaticDependenciesForModuleOnly ();
+       void ProcessNormal ();
        std::string GetNonModuleInstallDirectories ( const std::string& installDirectory );
        std::string GetInstallDirectories ( const std::string& installDirectory );
        void GetNonModuleInstallFiles ( std::vector<std::string>& out ) const;
        void GetInstallFiles ( std::vector<std::string>& out ) const;
-       void GetNonModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
-       void GetModuleInstallTargetFiles ( std::vector<std::string>& out ) const;
-       void GetInstallTargetFiles ( std::vector<std::string>& out ) const;
-       void OutputInstallTarget ( const std::string& sourceFilename,
-                                  const std::string& targetFilename,
-                                  const std::string& targetDirectory );
+       void GetNonModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
+       void GetModuleInstallTargetFiles ( std::vector<FileLocation>& out ) const;
+       void GetInstallTargetFiles ( std::vector<FileLocation>& out ) const;
+       void OutputInstallTarget ( const FileLocation& source, const FileLocation& target );
        void OutputNonModuleInstallTargets ();
        void OutputModuleInstallTargets ();
        std::string GetRegistrySourceFiles ();
@@ -114,6 +117,9 @@ private:
        void GenerateDirectoryTargets ();
        FILE* fMakefile;
        bool use_pch;
+       bool DetectMicrosoftCompiler ( std::string& version, std::string& path );
+       bool DetectMicrosoftLinker ( std::string& version, std::string& path );
+       void GenerateInstallerFileList();
 };
 
 
@@ -122,13 +128,25 @@ class ProxyMakefile
 public:
        ProxyMakefile ( const Project& project );
        ~ProxyMakefile ();
-       void GenerateProxyMakefiles ( bool verbose );
+       void GenerateProxyMakefiles ( bool verbose,
+                                      std::string outputTree );
+       static bool GenerateProxyMakefile ( const Module& module );
+
 private:
        std::string GeneratePathToParentDirectory ( int numberOfParentDirectories );
        std::string GetPathToTopDirectory ( Module& module );
        void GenerateProxyMakefileForModule ( Module& module,
-                                              bool verbose );
+                                              bool verbose,
+                                              std::string outputTree );
        const Project& project;
 };
 
-#endif /* MINGW_H */
+struct ModuleHandlerInformations
+{
+       HostType DefaultHost;
+       const char* cflags;
+       const char* nasmflags;
+       const char* linkerflags;
+};
+
+extern const struct ModuleHandlerInformations ModuleHandlerInformations[];