mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 12:23:25 +00:00
PCH support
svn path=/branches/xmlbuildsystem/; revision=13908
This commit is contained in:
@@ -50,6 +50,7 @@ MingwBackend::CreateMakefile ()
|
||||
if ( !fMakefile )
|
||||
throw AccessDeniedException ( ProjectNode.makefile );
|
||||
MingwModuleHandler::SetMakefile ( fMakefile );
|
||||
MingwModuleHandler::SetUsePch ( use_pch );
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -23,6 +23,8 @@ MingwModuleHandler::ref = 0;
|
||||
|
||||
FILE*
|
||||
MingwModuleHandler::fMakefile = NULL;
|
||||
bool
|
||||
MingwModuleHandler::use_pch = false;
|
||||
|
||||
string
|
||||
ReplaceExtension ( const string& filename,
|
||||
@@ -67,6 +69,12 @@ MingwModuleHandler::SetMakefile ( FILE* f )
|
||||
fMakefile = f;
|
||||
}
|
||||
|
||||
void
|
||||
MingwModuleHandler::SetUsePch ( bool b )
|
||||
{
|
||||
use_pch = b;
|
||||
}
|
||||
|
||||
MingwModuleHandler*
|
||||
MingwModuleHandler::LookupHandler ( const string& location,
|
||||
ModuleType moduletype )
|
||||
@@ -710,11 +718,14 @@ MingwModuleHandler::GenerateGccCommand ( const Module& module,
|
||||
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 @@ MingwModuleHandler::GenerateObjectFileTargets (
|
||||
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 @@ MingwModuleHandler::GetDefinitionDependencies ( const Module& module ) const
|
||||
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
|
||||
{
|
||||
|
||||
@@ -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 @@ public:
|
||||
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 @@ protected:
|
||||
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,
|
||||
|
||||
@@ -90,7 +90,8 @@ Module::Module ( const Project& project,
|
||||
: 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 @@ Module::~Module ()
|
||||
delete compilerFlags[i];
|
||||
for ( i = 0; i < linkerFlags.size(); i++ )
|
||||
delete linkerFlags[i];
|
||||
if ( pch )
|
||||
delete pch;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -158,6 +161,8 @@ Module::ProcessXML()
|
||||
for ( i = 0; i < linkerFlags.size(); i++ )
|
||||
linkerFlags[i]->ProcessXML();
|
||||
non_if_data.ProcessXML();
|
||||
if ( pch )
|
||||
pch->ProcessXML();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -282,6 +287,20 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||
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 @@ void
|
||||
Property::ProcessXML()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
PchFile::PchFile (
|
||||
const XMLElement& node_,
|
||||
const Module& module_,
|
||||
const string& header_ )
|
||||
: node(node_), module(module_), header(header_)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
PchFile::ProcessXML()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ class Property;
|
||||
class AutomaticDependency;
|
||||
class Bootstrap;
|
||||
class CDFile;
|
||||
class PchFile;
|
||||
|
||||
class SourceFileTest;
|
||||
|
||||
@@ -150,6 +151,7 @@ public:
|
||||
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 @@ public:
|
||||
};
|
||||
|
||||
|
||||
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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user