adjust newlines around rsym command
[reactos.git] / reactos / tools / rbuild / backend / mingw / mingw.cpp
index 80eeefb..27d0245 100644 (file)
@@ -26,11 +26,14 @@ MingwBackend::MingwBackend ( Project& project )
 void\r
 MingwBackend::Process ()\r
 {\r
+       DetectPCHSupport();\r
+\r
        CreateMakefile ();\r
        GenerateHeader ();\r
        GenerateGlobalVariables ();\r
        GenerateAllTarget ();\r
        GenerateInitTarget ();\r
+       GenerateXmlBuildFilesMacro();\r
        for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )\r
        {\r
                Module& module = *ProjectNode.modules[i];\r
@@ -80,7 +83,7 @@ MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation,
                        " -I%s",\r
                        includes[i]->directory.c_str() );\r
        }\r
-       \r
+\r
        for ( i = 0; i < defines.size(); i++ )\r
        {\r
                Define& d = *defines[i];\r
@@ -138,7 +141,7 @@ MingwBackend::GenerateGlobalCFlagsAndProperties (
                                rIf.includes,\r
                                rIf.defines,\r
                                rIf.ifs );\r
-                       fprintf ( \r
+                       fprintf (\r
                                fMakefile,\r
                                "endif\n\n" );\r
                }\r
@@ -162,41 +165,13 @@ MingwBackend::GenerateProjectLFLAGS () const
 void\r
 MingwBackend::GenerateGlobalVariables () const\r
 {\r
-       fprintf ( fMakefile, "EXEPREFIX = " EXEPREFIX "\n" );\r
-       fprintf ( fMakefile, "EXEPOSTFIX = " EXEPOSTFIX "\n" );\r
-       fprintf ( fMakefile, "SEP = " SSEP "$(EMPTY_VAR)\n" );\r
-       fprintf ( fMakefile, "host_gcc = gcc\n" );\r
-       fprintf ( fMakefile, "host_gpp = g++\n" );\r
-       fprintf ( fMakefile, "host_ld = ld\n" );\r
-       fprintf ( fMakefile, "host_ar = ar\n" );\r
-       fprintf ( fMakefile, "host_objcopy = objcopy\n" );\r
-#ifdef WIN32\r
-       fprintf ( fMakefile, "nmkdir = mkdir\n" );\r
-       fprintf ( fMakefile, "rm = del /f /q\n" );\r
-       fprintf ( fMakefile, "gcc = gcc\n" );\r
-       fprintf ( fMakefile, "gpp = g++\n" );\r
-       fprintf ( fMakefile, "ld = ld\n" );\r
-       fprintf ( fMakefile, "ar = ar\n" );\r
-       fprintf ( fMakefile, "objcopy = objcopy\n" );\r
-       fprintf ( fMakefile, "dlltool = dlltool\n" );\r
-       fprintf ( fMakefile, "windres = windres\n" );\r
-#else\r
-       fprintf ( fMakefile, "nmkdir = mkdir -p\n" );\r
-       fprintf ( fMakefile, "rm = rm -f\n" );\r
-       fprintf ( fMakefile, "gcc = mingw32-gcc\n" );\r
-       fprintf ( fMakefile, "gpp = mingw32-g++\n" );\r
-       fprintf ( fMakefile, "ld = mingw32-ld\n" );\r
-       fprintf ( fMakefile, "ar = mingw32-ar\n" );\r
-       fprintf ( fMakefile, "objcopy = mingw32-objcopy\n" );\r
-       fprintf ( fMakefile, "dlltool = mingw32-dlltool\n" );\r
-       fprintf ( fMakefile, "windres = mingw32-windres\n" );\r
-#endif\r
        fprintf ( fMakefile, "mkdir = tools" SSEP "rmkdir" EXEPOSTFIX "\n" );\r
-       fprintf ( fMakefile, "NUL=NUL\n" );\r
        fprintf ( fMakefile, "winebuild = tools" SSEP "winebuild" SSEP "winebuild" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "bin2res = tools" SSEP "bin2res" SSEP "bin2res" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "cabman = tools" SSEP "cabman" SSEP "cabman" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "cdmake = tools" SSEP "cdmake" SSEP "cdmake" EXEPOSTFIX "\n" );\r
+       fprintf ( fMakefile, "rsym = tools" SSEP "rsym" EXEPOSTFIX "\n" );\r
+       fprintf ( fMakefile, "wrc = tools" SSEP "wrc" SSEP "wrc" EXEPOSTFIX "\n" );\r
        fprintf ( fMakefile, "\n" );\r
        GenerateGlobalCFlagsAndProperties (\r
                "=",\r
@@ -208,8 +183,6 @@ MingwBackend::GenerateGlobalVariables () const
        fprintf ( fMakefile, "PROJECT_LFLAGS = %s\n",\r
                  GenerateProjectLFLAGS ().c_str () );\r
        fprintf ( fMakefile, "\n" );\r
-\r
-       fprintf ( fMakefile, ".PHONY: clean\n\n" );\r
 }\r
 \r
 bool\r
@@ -257,7 +230,7 @@ MingwBackend::GetBuildToolDependencies () const
        }\r
        return dependencies;\r
 }\r
-       \r
+\r
 void\r
 MingwBackend::GenerateInitTarget () const\r
 {\r
@@ -288,6 +261,47 @@ MingwBackend::GenerateInitTarget () const
                  "\n" );\r
 }\r
 \r
+void\r
+MingwBackend::GenerateXmlBuildFilesMacro() const\r
+{\r
+       fprintf ( fMakefile,\r
+                 "XMLBUILDFILES = %s \\\n",\r
+                 ProjectNode.GetProjectFilename ().c_str () );\r
+       string xmlbuildFilenames;\r
+       int numberOfExistingFiles = 0;\r
+       for ( size_t i = 0; i < ProjectNode.xmlbuildfiles.size (); i++ )\r
+       {\r
+               XMLInclude& xmlbuildfile = *ProjectNode.xmlbuildfiles[i];\r
+               if ( !xmlbuildfile.fileExists )\r
+                       continue;\r
+               numberOfExistingFiles++;\r
+               if ( xmlbuildFilenames.length () > 0 )\r
+                       xmlbuildFilenames += " ";\r
+               xmlbuildFilenames += NormalizeFilename ( xmlbuildfile.topIncludeFilename );\r
+               if ( numberOfExistingFiles % 5 == 4 || i == ProjectNode.xmlbuildfiles.size () - 1 )\r
+               {\r
+                       fprintf ( fMakefile,\r
+                                 "\t%s",\r
+                                 xmlbuildFilenames.c_str ());\r
+                       if ( i == ProjectNode.xmlbuildfiles.size () - 1 )\r
+                       {\r
+                               fprintf ( fMakefile,\r
+                                         "\n" );\r
+                       }\r
+                       else\r
+                       {\r
+                               fprintf ( fMakefile,\r
+                                         " \\\n",\r
+                                         xmlbuildFilenames.c_str () );\r
+                       }\r
+                       xmlbuildFilenames.resize ( 0 );\r
+               }\r
+               numberOfExistingFiles++;\r
+       }\r
+       fprintf ( fMakefile,\r
+                 "\n" );\r
+}\r
+\r
 void\r
 MingwBackend::CheckAutomaticDependencies ()\r
 {\r
@@ -311,3 +325,24 @@ FixupTargetFilename ( const string& targetFilename )
 {\r
        return string("$(ROS_INTERMEDIATE)") + NormalizeFilename ( targetFilename );\r
 }\r
+\r
+void\r
+MingwBackend::DetectPCHSupport()\r
+{\r
+       string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h";\r
+       system ( ssprintf("gcc -c %s", path.c_str()).c_str() );\r
+       path += ".gch";\r
+\r
+       FILE* f = fopen ( path.c_str(), "rb" );\r
+       if ( f )\r
+       {\r
+               use_pch = true;\r
+               fclose(f);\r
+               unlink ( path.c_str() );\r
+       }\r
+       else\r
+               use_pch = false;\r
+\r
+       // TODO FIXME - eventually check for ROS_USE_PCH env var and\r
+       // allow that to override use_pch if true\r
+}\r