Disable pre-compiled headers when using compilation units

svn path=/trunk/; revision=19486
This commit is contained in:
Casper Hornstrup 2005-11-23 15:05:53 +00:00
parent 8f440cb624
commit f4e5a5a581
5 changed files with 45 additions and 10 deletions

View file

@ -89,6 +89,42 @@ MingwBackend::AddDirectoryTarget ( const string& directory,
return directoryTree->name;
}
bool
MingwBackend::CanEnablePreCompiledHeaderSupportForModule ( const Module& module )
{
if ( !configuration.CompilationUnitsEnabled )
return true;
const vector<CompilationUnit*>& compilationUnits = module.non_if_data.compilationUnits;
size_t i;
for ( i = 0; i < compilationUnits.size (); i++ )
{
CompilationUnit& compilationUnit = *compilationUnits[i];
if ( compilationUnit.files.size () != 1 )
return false;
}
// intentionally make a copy so that we can append more work in
// the middle of processing without having to go recursive
vector<If*> v = module.non_if_data.ifs;
for ( i = 0; i < v.size (); i++ )
{
size_t j;
If& rIf = *v[i];
// check for sub-ifs to add to list
const vector<If*>& ifs = rIf.data.ifs;
for ( j = 0; j < ifs.size (); j++ )
v.push_back ( ifs[j] );
const vector<CompilationUnit*>& compilationUnits = rIf.data.compilationUnits;
for ( j = 0; j < compilationUnits.size (); j++ )
{
CompilationUnit& compilationUnit = *compilationUnits[j];
if ( compilationUnit.files.size () != 1 )
return false;
}
}
return true;
}
void
MingwBackend::ProcessModules ()
{
@ -104,6 +140,8 @@ MingwBackend::ProcessModules ()
MingwModuleHandler* h = MingwModuleHandler::InstanciateHandler (
module,
this );
if ( use_pch && CanEnablePreCompiledHeaderSupportForModule ( module ) )
h->EnablePreCompiledHeaderSupport ();
if ( module.host == HostDefault )
{
module.host = h->DefaultHost();
@ -207,7 +245,6 @@ MingwBackend::CreateMakefile ()
throw AccessDeniedException ( ProjectNode.makefile );
MingwModuleHandler::SetBackend ( this );
MingwModuleHandler::SetMakefile ( fMakefile );
MingwModuleHandler::SetUsePch ( use_pch );
}
void

View file

@ -92,6 +92,7 @@ private:
void DetectNetwideAssembler ();
void DetectPipeSupport ();
void DetectPCHSupport ();
bool CanEnablePreCompiledHeaderSupportForModule ( const Module& module );
void ProcessModules ();
void CheckAutomaticDependenciesForModuleOnly ();
void ProcessNormal ();

View file

@ -32,8 +32,6 @@ MingwBackend*
MingwModuleHandler::backend = NULL;
FILE*
MingwModuleHandler::fMakefile = NULL;
bool
MingwModuleHandler::use_pch = false;
string
PrefixFilename (
@ -73,6 +71,7 @@ MingwModuleHandler::MingwModuleHandler (
: module(module_)
{
use_pch = false;
}
MingwModuleHandler::~MingwModuleHandler()
@ -91,10 +90,10 @@ MingwModuleHandler::SetMakefile ( FILE* f )
fMakefile = f;
}
/*static*/ void
MingwModuleHandler::SetUsePch ( bool b )
void
MingwModuleHandler::EnablePreCompiledHeaderSupport ()
{
use_pch = b;
use_pch = true;
}
/* static*/ string

View file

@ -39,7 +39,7 @@ public:
static void SetBackend ( MingwBackend* backend_ );
static void SetMakefile ( FILE* f );
static void SetUsePch ( bool use_pch );
void EnablePreCompiledHeaderSupport ();
static std::string PassThruCacheDirectory (
const std::string &f,
@ -125,7 +125,7 @@ protected:
std::string GetLinkingDependencies () const;
static MingwBackend* backend;
static FILE* fMakefile;
static bool use_pch;
bool use_pch;
private:
std::string ConcatenatePaths ( const std::string& path1,
const std::string& path2 ) const;

View file

@ -82,8 +82,6 @@ CompilationUnitSupportCode::WriteCompilationUnitFile ( Module& module,
s = buf;
s = s + sprintf ( s, "/* This file is automatically generated. */\n" );
s = s + sprintf ( s, "#define ONE_COMPILATION_UNIT\n" );
if ( module.pch )
s = s + sprintf ( s, "#include <%s>\n", ChangeSeparator ( module.pch->file.name, '\\', '/' ).c_str () );
for ( size_t i = 0; i < compilationUnit.files.size () ; i++ )
{