mirror of
https://github.com/reactos/reactos.git
synced 2025-07-05 06:41:21 +00:00
Search current directory first for #include "".
svn path=/trunk/; revision=16260
This commit is contained in:
parent
5444c47450
commit
59605ac1e7
5 changed files with 84 additions and 59 deletions
|
@ -85,6 +85,7 @@ SourceFile::SkipWhitespace ()
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SourceFile::ReadInclude ( string& filename,
|
SourceFile::ReadInclude ( string& filename,
|
||||||
|
bool& searchCurrentDirectory,
|
||||||
bool& includeNext)
|
bool& includeNext)
|
||||||
{
|
{
|
||||||
while ( p < end )
|
while ( p < end )
|
||||||
|
@ -117,6 +118,7 @@ SourceFile::ReadInclude ( string& filename,
|
||||||
register char ch = *p;
|
register char ch = *p;
|
||||||
if ( ch == '<' || ch == '"' )
|
if ( ch == '<' || ch == '"' )
|
||||||
{
|
{
|
||||||
|
searchCurrentDirectory = (ch == '"');
|
||||||
p++;
|
p++;
|
||||||
filename.resize ( MAX_PATH );
|
filename.resize ( MAX_PATH );
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -138,6 +140,7 @@ SourceFile::ReadInclude ( string& filename,
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
filename = "";
|
filename = "";
|
||||||
|
searchCurrentDirectory = false;
|
||||||
includeNext = false;
|
includeNext = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -230,14 +233,17 @@ SourceFile::Parse ()
|
||||||
{
|
{
|
||||||
string includedFilename ( "" );
|
string includedFilename ( "" );
|
||||||
|
|
||||||
|
bool searchCurrentDirectory;
|
||||||
bool includeNext;
|
bool includeNext;
|
||||||
while ( ReadInclude ( includedFilename,
|
while ( ReadInclude ( includedFilename,
|
||||||
|
searchCurrentDirectory,
|
||||||
includeNext ) )
|
includeNext ) )
|
||||||
{
|
{
|
||||||
string resolvedFilename ( "" );
|
string resolvedFilename ( "" );
|
||||||
bool locatedFile = automaticDependency->LocateIncludedFile ( this,
|
bool locatedFile = automaticDependency->LocateIncludedFile ( this,
|
||||||
module,
|
module,
|
||||||
includedFilename,
|
includedFilename,
|
||||||
|
searchCurrentDirectory,
|
||||||
includeNext,
|
includeNext,
|
||||||
resolvedFilename );
|
resolvedFilename );
|
||||||
if ( locatedFile )
|
if ( locatedFile )
|
||||||
|
@ -347,23 +353,32 @@ AutomaticDependency::GetFilename ( const string& filename )
|
||||||
filename.length () - index - 1);
|
filename.length () - index - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AutomaticDependency::GetIncludeDirectories ( vector<Include*>& includes,
|
||||||
|
Module& module,
|
||||||
|
Include& currentDirectory,
|
||||||
|
bool searchCurrentDirectory )
|
||||||
|
{
|
||||||
|
if ( searchCurrentDirectory )
|
||||||
|
includes.push_back( ¤tDirectory );
|
||||||
|
for ( size_t i = 0; i < module.non_if_data.includes.size (); i++ )
|
||||||
|
includes.push_back( module.non_if_data.includes[i] );
|
||||||
|
for ( size_t i = 0; i < module.project.non_if_data.includes.size (); i++ )
|
||||||
|
includes.push_back( module.project.non_if_data.includes[i] );
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
||||||
Module& module,
|
Module& module,
|
||||||
const string& includedFilename,
|
const string& includedFilename,
|
||||||
|
bool searchCurrentDirectory,
|
||||||
bool includeNext,
|
bool includeNext,
|
||||||
string& resolvedFilename )
|
string& resolvedFilename )
|
||||||
{
|
{
|
||||||
size_t i, j;
|
vector<Include*> includes;
|
||||||
const vector<Include*>* pincludes;
|
Include currentDirectory ( module.project, ".", sourceFile->directoryPart );
|
||||||
for ( i = 0; i < 2; i++ )
|
GetIncludeDirectories ( includes, module, currentDirectory, searchCurrentDirectory );
|
||||||
{
|
for ( size_t j = 0; j < includes.size (); j++ )
|
||||||
if ( !i )
|
|
||||||
pincludes = &module.non_if_data.includes;
|
|
||||||
else
|
|
||||||
pincludes = &module.project.non_if_data.includes;
|
|
||||||
const vector<Include*>& includes = *pincludes;
|
|
||||||
for ( j = 0; j < includes.size (); j++ )
|
|
||||||
{
|
{
|
||||||
Include& include = *includes[j];
|
Include& include = *includes[j];
|
||||||
if ( LocateIncludedFile ( include.directory,
|
if ( LocateIncludedFile ( include.directory,
|
||||||
|
@ -376,8 +391,6 @@ AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
resolvedFilename = "";
|
resolvedFilename = "";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,45 +6,49 @@
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
Include::Include ( const Project& project_,
|
Include::Include ( const Project& project,
|
||||||
const XMLElement& includeNode )
|
const XMLElement* includeNode )
|
||||||
: project (project_),
|
: project ( project ),
|
||||||
module ( NULL ),
|
module ( NULL ),
|
||||||
node ( includeNode )
|
node ( includeNode )
|
||||||
{
|
{
|
||||||
Initialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Include::Include ( const Project& project_,
|
Include::Include ( const Project& project,
|
||||||
const Module* module_,
|
const Module* module,
|
||||||
const XMLElement& includeNode )
|
const XMLElement* includeNode )
|
||||||
: project (project_),
|
: project ( project ),
|
||||||
module (module_),
|
module ( module ),
|
||||||
node ( includeNode )
|
node ( includeNode )
|
||||||
{
|
{
|
||||||
Initialize();
|
}
|
||||||
|
|
||||||
|
Include::Include ( const Project& project,
|
||||||
|
string directory,
|
||||||
|
string basePath )
|
||||||
|
: project ( project ),
|
||||||
|
module ( NULL ),
|
||||||
|
node ( NULL )
|
||||||
|
{
|
||||||
|
this->directory = NormalizeFilename ( basePath + SSEP + directory );
|
||||||
|
this->basePath = NormalizeFilename ( basePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
Include::~Include ()
|
Include::~Include ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
Include::Initialize()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Include::ProcessXML()
|
Include::ProcessXML()
|
||||||
{
|
{
|
||||||
const XMLAttribute* att;
|
const XMLAttribute* att;
|
||||||
att = node.GetAttribute ( "base",
|
att = node->GetAttribute ( "base",
|
||||||
false );
|
false );
|
||||||
if ( att )
|
if ( att )
|
||||||
{
|
{
|
||||||
if ( !module )
|
if ( !module )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
node.location,
|
node->location,
|
||||||
"'base' attribute illegal from global <include>" );
|
"'base' attribute illegal from global <include>" );
|
||||||
bool referenceResolved = false;
|
bool referenceResolved = false;
|
||||||
if ( att->value == project.name )
|
if ( att->value == project.name )
|
||||||
|
@ -63,11 +67,11 @@ Include::ProcessXML()
|
||||||
}
|
}
|
||||||
if ( !referenceResolved )
|
if ( !referenceResolved )
|
||||||
throw InvalidBuildFileException (
|
throw InvalidBuildFileException (
|
||||||
node.location,
|
node->location,
|
||||||
"<include> attribute 'base' references non-existant project or module '%s'",
|
"<include> attribute 'base' references non-existant project or module '%s'",
|
||||||
att->value.c_str() );
|
att->value.c_str() );
|
||||||
directory = FixSeparator ( basePath + "/" + node.value );
|
directory = NormalizeFilename ( basePath + SSEP + node->value );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
directory = FixSeparator ( node.value );
|
directory = NormalizeFilename ( node->value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,7 +367,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "include" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
Include* include = new Include ( project, this, e );
|
Include* include = new Include ( project, this, &e );
|
||||||
if ( pIf )
|
if ( pIf )
|
||||||
pIf->data.includes.push_back ( include );
|
pIf->data.includes.push_back ( include );
|
||||||
else
|
else
|
||||||
|
|
|
@ -290,7 +290,7 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
||||||
}
|
}
|
||||||
else if ( e.name == "include" )
|
else if ( e.name == "include" )
|
||||||
{
|
{
|
||||||
Include* include = new Include ( *this, e );
|
Include* include = new Include ( *this, &e );
|
||||||
if ( pIf )
|
if ( pIf )
|
||||||
pIf->data.includes.push_back ( include );
|
pIf->data.includes.push_back ( include );
|
||||||
else
|
else
|
||||||
|
|
|
@ -253,19 +253,21 @@ class Include
|
||||||
public:
|
public:
|
||||||
const Project& project;
|
const Project& project;
|
||||||
const Module* module;
|
const Module* module;
|
||||||
const XMLElement& node;
|
const XMLElement* node;
|
||||||
std::string directory;
|
std::string directory;
|
||||||
std::string basePath;
|
std::string basePath;
|
||||||
|
|
||||||
Include ( const Project& project,
|
Include ( const Project& project,
|
||||||
const XMLElement& includeNode );
|
const XMLElement* includeNode );
|
||||||
Include ( const Project& project,
|
Include ( const Project& project,
|
||||||
const Module* module,
|
const Module* module,
|
||||||
const XMLElement& includeNode );
|
const XMLElement* includeNode );
|
||||||
|
Include ( const Project& project,
|
||||||
|
std::string directory,
|
||||||
|
std::string basePath );
|
||||||
~Include ();
|
~Include ();
|
||||||
void ProcessXML();
|
void ProcessXML();
|
||||||
private:
|
private:
|
||||||
void Initialize();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -556,6 +558,7 @@ private:
|
||||||
void Open ();
|
void Open ();
|
||||||
void SkipWhitespace ();
|
void SkipWhitespace ();
|
||||||
bool ReadInclude ( std::string& filename,
|
bool ReadInclude ( std::string& filename,
|
||||||
|
bool& searchCurrentDirectory,
|
||||||
bool& includeNext );
|
bool& includeNext );
|
||||||
bool IsIncludedFrom ( const std::string& normalizedFilename );
|
bool IsIncludedFrom ( const std::string& normalizedFilename );
|
||||||
SourceFile* GetParentSourceFile ();
|
SourceFile* GetParentSourceFile ();
|
||||||
|
@ -583,6 +586,7 @@ public:
|
||||||
bool LocateIncludedFile ( SourceFile* sourceFile,
|
bool LocateIncludedFile ( SourceFile* sourceFile,
|
||||||
Module& module,
|
Module& module,
|
||||||
const std::string& includedFilename,
|
const std::string& includedFilename,
|
||||||
|
bool searchCurrentDirectory,
|
||||||
bool includeNext,
|
bool includeNext,
|
||||||
std::string& resolvedFilename );
|
std::string& resolvedFilename );
|
||||||
SourceFile* RetrieveFromCacheOrParse ( Module& module,
|
SourceFile* RetrieveFromCacheOrParse ( Module& module,
|
||||||
|
@ -597,6 +601,10 @@ public:
|
||||||
bool parseFiles );
|
bool parseFiles );
|
||||||
void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
|
void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
|
||||||
private:
|
private:
|
||||||
|
void GetIncludeDirectories ( std::vector<Include*>& includes,
|
||||||
|
Module& module,
|
||||||
|
Include& currentDirectory,
|
||||||
|
bool searchCurrentDirectory );
|
||||||
void GetModuleFiles ( Module& module,
|
void GetModuleFiles ( Module& module,
|
||||||
std::vector<File*>& files ) const;
|
std::vector<File*>& files ) const;
|
||||||
void ParseFiles ();
|
void ParseFiles ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue