if ( !fMakefile )\r
throw AccessDeniedException ( ProjectNode.makefile );\r
MingwModuleHandler::SetMakefile ( fMakefile );\r
+ MingwModuleHandler::SetUsePch ( use_pch );\r
}\r
\r
void\r
\r
FILE*\r
MingwModuleHandler::fMakefile = NULL;\r
+bool\r
+MingwModuleHandler::use_pch = false;\r
\r
string\r
ReplaceExtension ( const string& filename,\r
fMakefile = f;\r
}\r
\r
+void\r
+MingwModuleHandler::SetUsePch ( bool b )\r
+{\r
+ use_pch = b;\r
+}\r
+\r
MingwModuleHandler*\r
MingwModuleHandler::LookupHandler ( const string& location,\r
ModuleType moduletype )\r
const string& cc,\r
const string& cflagsMacro ) const\r
{\r
+ string deps = sourceFilename;\r
+ if ( module.pch && use_pch )\r
+ deps += " " + module.pch->header + ".gch";\r
string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );\r
fprintf ( fMakefile,\r
"%s: %s\n",\r
objectFilename.c_str (),\r
- sourceFilename.c_str () );\r
+ deps.c_str () );\r
fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CC] $<\n" );\r
fprintf ( fMakefile,\r
"\t%s -c %s -o %s %s\n",\r
const string& windresflagsMacro,\r
string_list& clean_files ) const\r
{\r
+ if ( module.pch && use_pch )\r
+ {\r
+ const string& pch_file = module.pch->header;\r
+ string gch_file = pch_file + ".gch";\r
+ CLEAN_FILE(gch_file);\r
+ fprintf (\r
+ fMakefile,\r
+ "%s: %s\n",\r
+ gch_file.c_str(),\r
+ pch_file.c_str() );\r
+ fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [PCH] $@\n" );\r
+ fprintf (\r
+ fMakefile,\r
+ "\t%s -c %s -o %s %s\n\n",\r
+ cc.c_str(),\r
+ pch_file.c_str(),\r
+ gch_file.c_str(),\r
+ cflagsMacro.c_str() );\r
+ }\r
+\r
GenerateObjectFileTargets ( module,\r
module.non_if_data,\r
cc,\r
return dependencies;\r
}\r
\r
+// TODO FIXME - check for C++ extensions when parsing XML, and set a\r
+// bool in the Module class\r
bool\r
MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const\r
{\r
\r
extern std::string\r
ReplaceExtension ( const std::string& filename,\r
- const std::string& newExtension );\r
+ const std::string& newExtension );\r
\r
\r
class MingwModuleHandler\r
virtual ~MingwModuleHandler();\r
\r
static void SetMakefile ( FILE* f );\r
+ static void SetUsePch ( bool use_pch );\r
static MingwModuleHandler* LookupHandler ( const std::string& location,\r
ModuleType moduletype_ );\r
virtual void Process ( const Module& module, string_list& clean_files ) = 0;\r
std::string GetLinkingDependencies ( const Module& module ) const;\r
bool IsCPlusPlusModule ( const Module& module ) const;\r
static FILE* fMakefile;\r
+ static bool use_pch;\r
static std::set<std::string> directory_set;\r
private:\r
std::string ConcatenatePaths ( const std::string& path1,\r
: project (project),\r
node (moduleNode),\r
importLibrary (NULL),\r
- bootstrap (NULL)\r
+ bootstrap (NULL),\r
+ pch (NULL)\r
{\r
if ( node.name != "module" )\r
throw Exception ( "internal tool error: Module created with non-<module> node" );\r
delete compilerFlags[i];\r
for ( i = 0; i < linkerFlags.size(); i++ )\r
delete linkerFlags[i];\r
+ if ( pch )\r
+ delete pch;\r
}\r
\r
void\r
for ( i = 0; i < linkerFlags.size(); i++ )\r
linkerFlags[i]->ProcessXML();\r
non_if_data.ProcessXML();\r
+ if ( pch )\r
+ pch->ProcessXML();\r
}\r
\r
void\r
bootstrap = new Bootstrap ( project, this, e );\r
subs_invalid = true;\r
}\r
+ else if ( e.name == "pch" )\r
+ {\r
+ if ( pIf )\r
+ throw InvalidBuildFileException (\r
+ e.location,\r
+ "<pch> is not a valid sub-element of <if>" );\r
+ if ( pch )\r
+ throw InvalidBuildFileException (\r
+ e.location,\r
+ "Only one <pch> is valid per module" );\r
+ pch = new PchFile (\r
+ e, *this, FixSeparator ( path + CSEP + e.value ) );\r
+ subs_invalid = true;\r
+ }\r
if ( subs_invalid && e.subElements.size() > 0 )\r
throw InvalidBuildFileException (\r
e.location,\r
Property::ProcessXML()\r
{\r
}\r
+\r
+\r
+PchFile::PchFile (\r
+ const XMLElement& node_,\r
+ const Module& module_,\r
+ const string& header_ )\r
+ : node(node_), module(module_), header(header_)\r
+{\r
+}\r
+\r
+void\r
+PchFile::ProcessXML()\r
+{\r
+}\r
class AutomaticDependency;\r
class Bootstrap;\r
class CDFile;\r
+class PchFile;\r
\r
class SourceFileTest;\r
\r
std::vector<Dependency*> dependencies;\r
std::vector<CompilerFlag*> compilerFlags;\r
std::vector<LinkerFlag*> linkerFlags;\r
+ PchFile* pch;\r
\r
Module ( const Project& project,\r
const XMLElement& moduleNode,\r
};\r
\r
\r
+class PchFile\r
+{\r
+public:\r
+ const XMLElement& node;\r
+ const Module& module;\r
+ std::string header;\r
+\r
+ PchFile (\r
+ const XMLElement& node,\r
+ const Module& module,\r
+ const std::string& header );\r
+ void ProcessXML();\r
+};\r
+\r
+\r
extern std::string\r
FixSeparator ( const std::string& s );\r
\r