mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +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
|
||||
SourceFile::ReadInclude ( string& filename,
|
||||
bool& searchCurrentDirectory,
|
||||
bool& includeNext)
|
||||
{
|
||||
while ( p < end )
|
||||
|
@ -117,6 +118,7 @@ SourceFile::ReadInclude ( string& filename,
|
|||
register char ch = *p;
|
||||
if ( ch == '<' || ch == '"' )
|
||||
{
|
||||
searchCurrentDirectory = (ch == '"');
|
||||
p++;
|
||||
filename.resize ( MAX_PATH );
|
||||
int i = 0;
|
||||
|
@ -138,6 +140,7 @@ SourceFile::ReadInclude ( string& filename,
|
|||
p++;
|
||||
}
|
||||
filename = "";
|
||||
searchCurrentDirectory = false;
|
||||
includeNext = false;
|
||||
return false;
|
||||
}
|
||||
|
@ -230,14 +233,17 @@ SourceFile::Parse ()
|
|||
{
|
||||
string includedFilename ( "" );
|
||||
|
||||
bool searchCurrentDirectory;
|
||||
bool includeNext;
|
||||
while ( ReadInclude ( includedFilename,
|
||||
searchCurrentDirectory,
|
||||
includeNext ) )
|
||||
{
|
||||
string resolvedFilename ( "" );
|
||||
bool locatedFile = automaticDependency->LocateIncludedFile ( this,
|
||||
module,
|
||||
includedFilename,
|
||||
searchCurrentDirectory,
|
||||
includeNext,
|
||||
resolvedFilename );
|
||||
if ( locatedFile )
|
||||
|
@ -347,23 +353,32 @@ AutomaticDependency::GetFilename ( const string& filename )
|
|||
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
|
||||
AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
||||
Module& module,
|
||||
const string& includedFilename,
|
||||
bool searchCurrentDirectory,
|
||||
bool includeNext,
|
||||
string& resolvedFilename )
|
||||
{
|
||||
size_t i, j;
|
||||
const vector<Include*>* pincludes;
|
||||
for ( i = 0; i < 2; i++ )
|
||||
{
|
||||
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++ )
|
||||
vector<Include*> includes;
|
||||
Include currentDirectory ( module.project, ".", sourceFile->directoryPart );
|
||||
GetIncludeDirectories ( includes, module, currentDirectory, searchCurrentDirectory );
|
||||
for ( size_t j = 0; j < includes.size (); j++ )
|
||||
{
|
||||
Include& include = *includes[j];
|
||||
if ( LocateIncludedFile ( include.directory,
|
||||
|
@ -376,8 +391,6 @@ AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
|||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resolvedFilename = "";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -6,45 +6,49 @@
|
|||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
Include::Include ( const Project& project_,
|
||||
const XMLElement& includeNode )
|
||||
: project (project_),
|
||||
Include::Include ( const Project& project,
|
||||
const XMLElement* includeNode )
|
||||
: project ( project ),
|
||||
module ( NULL ),
|
||||
node ( includeNode )
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Include::Include ( const Project& project_,
|
||||
const Module* module_,
|
||||
const XMLElement& includeNode )
|
||||
: project (project_),
|
||||
module (module_),
|
||||
Include::Include ( const Project& project,
|
||||
const Module* module,
|
||||
const XMLElement* includeNode )
|
||||
: project ( project ),
|
||||
module ( module ),
|
||||
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 ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Include::Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Include::ProcessXML()
|
||||
{
|
||||
const XMLAttribute* att;
|
||||
att = node.GetAttribute ( "base",
|
||||
att = node->GetAttribute ( "base",
|
||||
false );
|
||||
if ( att )
|
||||
{
|
||||
if ( !module )
|
||||
throw InvalidBuildFileException (
|
||||
node.location,
|
||||
node->location,
|
||||
"'base' attribute illegal from global <include>" );
|
||||
bool referenceResolved = false;
|
||||
if ( att->value == project.name )
|
||||
|
@ -63,11 +67,11 @@ Include::ProcessXML()
|
|||
}
|
||||
if ( !referenceResolved )
|
||||
throw InvalidBuildFileException (
|
||||
node.location,
|
||||
node->location,
|
||||
"<include> attribute 'base' references non-existant project or module '%s'",
|
||||
att->value.c_str() );
|
||||
directory = FixSeparator ( basePath + "/" + node.value );
|
||||
directory = NormalizeFilename ( basePath + SSEP + node->value );
|
||||
}
|
||||
else
|
||||
directory = FixSeparator ( node.value );
|
||||
directory = NormalizeFilename ( node->value );
|
||||
}
|
||||
|
|
|
@ -367,7 +367,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
else if ( e.name == "include" )
|
||||
{
|
||||
Include* include = new Include ( project, this, e );
|
||||
Include* include = new Include ( project, this, &e );
|
||||
if ( pIf )
|
||||
pIf->data.includes.push_back ( include );
|
||||
else
|
||||
|
|
|
@ -290,7 +290,7 @@ Project::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
else if ( e.name == "include" )
|
||||
{
|
||||
Include* include = new Include ( *this, e );
|
||||
Include* include = new Include ( *this, &e );
|
||||
if ( pIf )
|
||||
pIf->data.includes.push_back ( include );
|
||||
else
|
||||
|
|
|
@ -253,19 +253,21 @@ class Include
|
|||
public:
|
||||
const Project& project;
|
||||
const Module* module;
|
||||
const XMLElement& node;
|
||||
const XMLElement* node;
|
||||
std::string directory;
|
||||
std::string basePath;
|
||||
|
||||
Include ( const Project& project,
|
||||
const XMLElement& includeNode );
|
||||
const XMLElement* includeNode );
|
||||
Include ( const Project& project,
|
||||
const Module* module,
|
||||
const XMLElement& includeNode );
|
||||
const XMLElement* includeNode );
|
||||
Include ( const Project& project,
|
||||
std::string directory,
|
||||
std::string basePath );
|
||||
~Include ();
|
||||
void ProcessXML();
|
||||
private:
|
||||
void Initialize();
|
||||
};
|
||||
|
||||
|
||||
|
@ -556,6 +558,7 @@ private:
|
|||
void Open ();
|
||||
void SkipWhitespace ();
|
||||
bool ReadInclude ( std::string& filename,
|
||||
bool& searchCurrentDirectory,
|
||||
bool& includeNext );
|
||||
bool IsIncludedFrom ( const std::string& normalizedFilename );
|
||||
SourceFile* GetParentSourceFile ();
|
||||
|
@ -583,6 +586,7 @@ public:
|
|||
bool LocateIncludedFile ( SourceFile* sourceFile,
|
||||
Module& module,
|
||||
const std::string& includedFilename,
|
||||
bool searchCurrentDirectory,
|
||||
bool includeNext,
|
||||
std::string& resolvedFilename );
|
||||
SourceFile* RetrieveFromCacheOrParse ( Module& module,
|
||||
|
@ -597,6 +601,10 @@ public:
|
|||
bool parseFiles );
|
||||
void CheckAutomaticDependenciesForFile ( SourceFile* sourceFile );
|
||||
private:
|
||||
void GetIncludeDirectories ( std::vector<Include*>& includes,
|
||||
Module& module,
|
||||
Include& currentDirectory,
|
||||
bool searchCurrentDirectory );
|
||||
void GetModuleFiles ( Module& module,
|
||||
std::vector<File*>& files ) const;
|
||||
void ParseFiles ();
|
||||
|
|
Loading…
Reference in a new issue