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
" -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
rIf.includes,\r
rIf.defines,\r
rIf.ifs );\r
- fprintf ( \r
+ fprintf (\r
fMakefile,\r
"endif\n\n" );\r
}\r
void\r
MingwBackend::GenerateGlobalVariables () const\r
{\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, "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, "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
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
fprintf ( fMakefile, "\n\t\n\n" );\r
}\r
\r
+string\r
+MingwBackend::GetBuildToolDependencies () const\r
+{\r
+ string dependencies;\r
+ for ( size_t i = 0; i < ProjectNode.modules.size (); i++ )\r
+ {\r
+ Module& module = *ProjectNode.modules[i];\r
+ if ( module.type == BuildTool )\r
+ {\r
+ if ( dependencies.length () > 0 )\r
+ dependencies += " ";\r
+ dependencies += module.GetDependencyPath ();\r
+ }\r
+ }\r
+ return dependencies;\r
+}\r
+\r
+void\r
+MingwBackend::GenerateInitTarget () const\r
+{\r
+ fprintf ( fMakefile,\r
+ "init:");\r
+ fprintf ( fMakefile,\r
+ " $(ROS_INTERMEDIATE)." SSEP "tools" );\r
+ fprintf ( fMakefile,\r
+ " %s",\r
+ GetBuildToolDependencies ().c_str () );\r
+ fprintf ( fMakefile,\r
+ " %s",\r
+ "include" SSEP "reactos" SSEP "buildno.h" );\r
+ fprintf ( fMakefile,\r
+ "\n\t\n\n" );\r
+\r
+ fprintf ( fMakefile,\r
+ "$(ROS_INTERMEDIATE)." SSEP "tools:\n" );\r
+ fprintf ( fMakefile,\r
+ "ifneq ($(ROS_INTERMEDIATE),)\n" );\r
+ fprintf ( fMakefile,\r
+ "\t${nmkdir} $(ROS_INTERMEDIATE)\n" );\r
+ fprintf ( fMakefile,\r
+ "endif\n" );\r
+ fprintf ( fMakefile,\r
+ "\t${nmkdir} $(ROS_INTERMEDIATE)." SSEP "tools\n" );\r
+ fprintf ( fMakefile,\r
+ "\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
{\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