Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-03-10 04:58:40 UTC (rev 13907)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp 2005-03-10 14:05:41 UTC (rev 13908)
@@ -50,6 +50,7 @@
if ( !fMakefile )
throw AccessDeniedException ( ProjectNode.makefile );
MingwModuleHandler::SetMakefile ( fMakefile );
+ MingwModuleHandler::SetUsePch ( use_pch );
}
void
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-03-10 04:58:40 UTC (rev 13907)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-03-10 14:05:41 UTC (rev 13908)
@@ -23,6 +23,8 @@
FILE*
MingwModuleHandler::fMakefile = NULL;
+bool
+MingwModuleHandler::use_pch = false;
string
ReplaceExtension ( const string& filename,
@@ -67,6 +69,12 @@
fMakefile = f;
}
+void
+MingwModuleHandler::SetUsePch ( bool b )
+{
+ use_pch = b;
+}
+
MingwModuleHandler*
MingwModuleHandler::LookupHandler ( const string& location,
ModuleType moduletype )
@@ -710,11 +718,14 @@
const string& cc,
const string& cflagsMacro ) const
{
+ string deps = sourceFilename;
+ if ( module.pch && use_pch )
+ deps += " " + module.pch->header + ".gch";
string objectFilename = PassThruCacheDirectory ( MingwModuleHandler::GetObjectFilename ( sourceFilename ) );
fprintf ( fMakefile,
"%s: %s\n",
objectFilename.c_str (),
- sourceFilename.c_str () );
+ deps.c_str () );
fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [CC] $<\n" );
fprintf ( fMakefile,
"\t%s -c %s -o %s %s\n",
@@ -1045,6 +1056,26 @@
const string& windresflagsMacro,
string_list& clean_files ) const
{
+ if ( module.pch && use_pch )
+ {
+ const string& pch_file = module.pch->header;
+ string gch_file = pch_file + ".gch";
+ CLEAN_FILE(gch_file);
+ fprintf (
+ fMakefile,
+ "%s: %s\n",
+ gch_file.c_str(),
+ pch_file.c_str() );
+ fprintf ( fMakefile, "\t$(HALFVERBOSEECHO) [PCH] $@\n" );
+ fprintf (
+ fMakefile,
+ "\t%s -c %s -o %s %s\n\n",
+ cc.c_str(),
+ pch_file.c_str(),
+ gch_file.c_str(),
+ cflagsMacro.c_str() );
+ }
+
GenerateObjectFileTargets ( module,
module.non_if_data,
cc,
@@ -1425,6 +1456,8 @@
return dependencies;
}
+// TODO FIXME - check for C++ extensions when parsing XML, and set a
+// bool in the Module class
bool
MingwModuleHandler::IsCPlusPlusModule ( const Module& module ) const
{
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-03-10 04:58:40 UTC (rev 13907)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h 2005-03-10 14:05:41 UTC (rev 13908)
@@ -5,7 +5,7 @@
extern std::string
ReplaceExtension ( const std::string& filename,
- const std::string& newExtension );
+ const std::string& newExtension );
class MingwModuleHandler
@@ -20,6 +20,7 @@
virtual ~MingwModuleHandler();
static void SetMakefile ( FILE* f );
+ static void SetUsePch ( bool use_pch );
static MingwModuleHandler* LookupHandler ( const std::string& location,
ModuleType moduletype_ );
virtual void Process ( const Module& module, string_list& clean_files ) = 0;
@@ -73,6 +74,7 @@
std::string GetLinkingDependencies ( const Module& module ) const;
bool IsCPlusPlusModule ( const Module& module ) const;
static FILE* fMakefile;
+ static bool use_pch;
static std::set<std::string> directory_set;
private:
std::string ConcatenatePaths ( const std::string& path1,
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-03-10 04:58:40 UTC (rev 13907)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp 2005-03-10 14:05:41 UTC (rev 13908)
@@ -90,7 +90,8 @@
: project (project),
node (moduleNode),
importLibrary (NULL),
- bootstrap (NULL)
+ bootstrap (NULL),
+ pch (NULL)
{
if ( node.name != "module" )
throw Exception ( "internal tool error: Module created with non-<module> node" );
@@ -141,6 +142,8 @@
delete compilerFlags[i];
for ( i = 0; i < linkerFlags.size(); i++ )
delete linkerFlags[i];
+ if ( pch )
+ delete pch;
}
void
@@ -158,6 +161,8 @@
for ( i = 0; i < linkerFlags.size(); i++ )
linkerFlags[i]->ProcessXML();
non_if_data.ProcessXML();
+ if ( pch )
+ pch->ProcessXML();
}
void
@@ -282,6 +287,20 @@
bootstrap = new Bootstrap ( project, this, e );
subs_invalid = true;
}
+ else if ( e.name == "pch" )
+ {
+ if ( pIf )
+ throw InvalidBuildFileException (
+ e.location,
+ "<pch> is not a valid sub-element of <if>" );
+ if ( pch )
+ throw InvalidBuildFileException (
+ e.location,
+ "Only one <pch> is valid per module" );
+ pch = new PchFile (
+ e, *this, FixSeparator ( path + CSEP + e.value ) );
+ subs_invalid = true;
+ }
if ( subs_invalid && e.subElements.size() > 0 )
throw InvalidBuildFileException (
e.location,
@@ -806,3 +825,17 @@
Property::ProcessXML()
{
}
+
+
+PchFile::PchFile (
+ const XMLElement& node_,
+ const Module& module_,
+ const string& header_ )
+ : node(node_), module(module_), header(header_)
+{
+}
+
+void
+PchFile::ProcessXML()
+{
+}
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-03-10 04:58:40 UTC (rev 13907)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h 2005-03-10 14:05:41 UTC (rev 13908)
@@ -54,6 +54,7 @@
class AutomaticDependency;
class Bootstrap;
class CDFile;
+class PchFile;
class SourceFileTest;
@@ -150,6 +151,7 @@
std::vector<Dependency*> dependencies;
std::vector<CompilerFlag*> compilerFlags;
std::vector<LinkerFlag*> linkerFlags;
+ PchFile* pch;
Module ( const Project& project,
const XMLElement& moduleNode,
@@ -499,6 +501,21 @@
};
+class PchFile
+{
+public:
+ const XMLElement& node;
+ const Module& module;
+ std::string header;
+
+ PchFile (
+ const XMLElement& node,
+ const Module& module,
+ const std::string& header );
+ void ProcessXML();
+};
+
+
extern std::string
FixSeparator ( const std::string& s );