mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Continue rbuild cleanup (Include class)
svn path=/trunk/; revision=28986
This commit is contained in:
parent
f53a2fd07d
commit
621618fbbb
11 changed files with 132 additions and 126 deletions
|
@ -367,11 +367,36 @@ AutomaticDependency::ResolveVariablesInPath ( const string& path )
|
|||
}
|
||||
|
||||
bool
|
||||
AutomaticDependency::LocateIncludedFile ( const string& directory,
|
||||
AutomaticDependency::LocateIncludedFile ( const FileLocation& directory,
|
||||
const string& includedFilename,
|
||||
string& resolvedFilename )
|
||||
{
|
||||
string normalizedFilename = NormalizeFilename ( directory + sSep + includedFilename );
|
||||
string path;
|
||||
switch ( directory.directory )
|
||||
{
|
||||
case SourceDirectory:
|
||||
path = "";
|
||||
break;
|
||||
case IntermediateDirectory:
|
||||
path = Environment::GetIntermediatePath ();
|
||||
break;
|
||||
case OutputDirectory:
|
||||
path = Environment::GetOutputPath ();
|
||||
break;
|
||||
default:
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
__LINE__,
|
||||
"Invalid directory %d.",
|
||||
directory.directory );
|
||||
}
|
||||
if ( directory.relative_path.length () > 0 )
|
||||
{
|
||||
if ( path.length () > 0 )
|
||||
path += sSep;
|
||||
path += directory.relative_path;
|
||||
}
|
||||
|
||||
string normalizedFilename = NormalizeFilename ( path + sSep + includedFilename );
|
||||
FILE* f = fopen ( normalizedFilename.c_str (), "rb" );
|
||||
if ( f != NULL )
|
||||
{
|
||||
|
@ -418,12 +443,12 @@ AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
|||
string& resolvedFilename )
|
||||
{
|
||||
vector<Include*> includes;
|
||||
Include currentDirectory ( module.project, ".", sourceFile->directoryPart );
|
||||
Include currentDirectory ( module.project, SourceDirectory, sourceFile->directoryPart );
|
||||
GetIncludeDirectories ( includes, module, currentDirectory, searchCurrentDirectory );
|
||||
for ( size_t j = 0; j < includes.size (); j++ )
|
||||
{
|
||||
Include& include = *includes[j];
|
||||
if ( LocateIncludedFile ( include.directory,
|
||||
if ( LocateIncludedFile ( *include.directory,
|
||||
includedFilename,
|
||||
resolvedFilename ) )
|
||||
{
|
||||
|
@ -433,6 +458,9 @@ AutomaticDependency::LocateIncludedFile ( SourceFile* sourceFile,
|
|||
return true;
|
||||
}
|
||||
}
|
||||
/*printf ( "Unable to find %s, included in %s.\n",
|
||||
includedFilename.c_str (),
|
||||
sourceFile->filename.c_str () );*/
|
||||
resolvedFilename = "";
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ CBBackend::_generate_cbproj ( const Module& module )
|
|||
for ( i = 0; i < incs.size(); i++ )
|
||||
{
|
||||
string path = Path::RelativeFromDirectory (
|
||||
incs[i]->directory,
|
||||
incs[i]->directory->relative_path,
|
||||
module.output->relative_path );
|
||||
|
||||
includes.push_back ( path );
|
||||
|
|
|
@ -105,6 +105,8 @@ MingwModuleHandler::PassThruCacheDirectory (const FileLocation* file )
|
|||
{
|
||||
switch ( file->directory )
|
||||
{
|
||||
case SourceDirectory:
|
||||
break;
|
||||
case IntermediateDirectory:
|
||||
backend->AddDirectoryTarget ( file->relative_path, backend->intermediateDirectory );
|
||||
break;
|
||||
|
@ -670,14 +672,7 @@ MingwModuleHandler::GenerateGccIncludeParametersFromVector ( const vector<Includ
|
|||
Include& include = *includes[i];
|
||||
if ( parameters.length () > 0 )
|
||||
parameters += " ";
|
||||
if ( include.root == "intermediate" )
|
||||
path_prefix = "$(INTERMEDIATE)" + sSep;
|
||||
else if (include.root == "output" )
|
||||
path_prefix = "$(OUTPUT)" + sSep;
|
||||
else
|
||||
path_prefix = "";
|
||||
|
||||
parameters += "-I" + path_prefix + include.directory;
|
||||
parameters += "-I" + strDirectory ( include.directory );;
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
@ -783,33 +778,11 @@ MingwModuleHandler::GenerateMacro (
|
|||
for ( i = 0; i < data.includes.size(); i++ )
|
||||
{
|
||||
const Include& include = *data.includes[i];
|
||||
string includeDirectory, path_prefix;
|
||||
if ( include.baseModule != NULL &&
|
||||
( include.baseModule->type == RpcServer ||
|
||||
include.baseModule->type == RpcClient ||
|
||||
include.baseModule->type == IdlHeader) )
|
||||
{
|
||||
path_prefix = "$(INTERMEDIATE)" + sSep;
|
||||
includeDirectory = NormalizeFilename ( include.directory );
|
||||
}
|
||||
else
|
||||
includeDirectory = include.directory;
|
||||
|
||||
if ( include.root == "intermediate" )
|
||||
path_prefix = "$(INTERMEDIATE)" + sSep;
|
||||
else if (include.root == "output" )
|
||||
path_prefix = "$(OUTPUT)" + sSep;
|
||||
else if ( include.root != "" )
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
__LINE__,
|
||||
"Unsupported root prefix '%s'",
|
||||
include.root.c_str () );
|
||||
|
||||
const FileLocation* includeDirectory = include.directory;
|
||||
fprintf (
|
||||
fMakefile,
|
||||
" -I%s%s",
|
||||
path_prefix.c_str(),
|
||||
includeDirectory.c_str() );
|
||||
" -I%s",
|
||||
strDirectory ( includeDirectory ).c_str() );
|
||||
}
|
||||
for ( i = 0; i < data.defines.size(); i++ )
|
||||
{
|
||||
|
|
|
@ -120,7 +120,7 @@ MsBuildBackend::_generate_sources ( const Module& module )
|
|||
for ( i = 0; i < incs.size(); i++ )
|
||||
{
|
||||
string path = Path::RelativeFromDirectory (
|
||||
incs[i]->directory,
|
||||
incs[i]->directory->relative_path,
|
||||
module.output->relative_path );
|
||||
|
||||
includes.push_back ( path );
|
||||
|
|
|
@ -118,15 +118,15 @@ MSVCBackend::_generate_dsp ( const Module& module )
|
|||
{
|
||||
|
||||
// explicitly omit win32api directories
|
||||
if ( !strncmp(incs[i]->directory.c_str(), "w32api", 6 ) )
|
||||
if ( !strncmp(incs[i]->directory->relative_path.c_str(), "w32api", 6 ) )
|
||||
continue;
|
||||
|
||||
// explicitly omit include/wine directories
|
||||
if ( !strncmp(incs[i]->directory.c_str(), "include\\wine", 12 ) )
|
||||
if ( !strncmp(incs[i]->directory->relative_path.c_str(), "include\\wine", 12 ) )
|
||||
continue;
|
||||
|
||||
string path = Path::RelativeFromDirectory (
|
||||
incs[i]->directory,
|
||||
incs[i]->directory->relative_path,
|
||||
module.output->relative_path );
|
||||
includes.push_back ( path );
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
|||
for ( i = 0; i < incs.size(); i++ )
|
||||
{
|
||||
string path = Path::RelativeFromDirectory (
|
||||
incs[i]->directory,
|
||||
incs[i]->directory->relative_path,
|
||||
module.output->relative_path );
|
||||
if ( module.type != RpcServer && module.type != RpcClient )
|
||||
{
|
||||
|
@ -182,12 +182,12 @@ MSVCBackend::_generate_vcproj ( const Module& module )
|
|||
}
|
||||
}
|
||||
// add to another list win32api and include/wine directories
|
||||
if ( !strncmp(incs[i]->directory.c_str(), "include\\ddk", 11 ) ||
|
||||
!strncmp(incs[i]->directory.c_str(), "include\\crt", 11 ) ||
|
||||
!strncmp(incs[i]->directory.c_str(), "include\\GL", 10 ) ||
|
||||
!strncmp(incs[i]->directory.c_str(), "include\\ddk", 11 ) ||
|
||||
!strncmp(incs[i]->directory.c_str(), "include\\psdk", 12 ) ||
|
||||
!strncmp(incs[i]->directory.c_str(), "include\\reactos\\wine", 20 ) )
|
||||
if ( !strncmp(incs[i]->directory->relative_path.c_str(), "include\\ddk", 11 ) ||
|
||||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 ) ||
|
||||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\GL", 10 ) ||
|
||||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\ddk", 11 ) ||
|
||||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\psdk", 12 ) ||
|
||||
!strncmp(incs[i]->directory->relative_path.c_str(), "include\\reactos\\wine", 20 ) )
|
||||
{
|
||||
includes_ros.push_back ( path );
|
||||
}
|
||||
|
|
|
@ -25,95 +25,98 @@ using std::vector;
|
|||
|
||||
Include::Include ( const Project& project,
|
||||
const XMLElement* includeNode )
|
||||
: project ( project ),
|
||||
module ( NULL ),
|
||||
: directory ( NULL ),
|
||||
project ( project ),
|
||||
node ( includeNode ),
|
||||
baseModule ( NULL )
|
||||
module ( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
Include::Include ( const Project& project,
|
||||
const Module* module,
|
||||
const XMLElement* includeNode )
|
||||
: project ( project ),
|
||||
module ( module ),
|
||||
const XMLElement* includeNode,
|
||||
const Module* module )
|
||||
: directory ( NULL ),
|
||||
project ( project ),
|
||||
node ( includeNode ),
|
||||
baseModule ( NULL )
|
||||
module ( module )
|
||||
{
|
||||
}
|
||||
|
||||
Include::Include ( const Project& project,
|
||||
string directory,
|
||||
string basePath )
|
||||
DirectoryLocation root,
|
||||
const std::string& relative_path )
|
||||
: project ( project ),
|
||||
module ( NULL ),
|
||||
node ( NULL ),
|
||||
baseModule ( NULL )
|
||||
node ( NULL )
|
||||
{
|
||||
this->directory = NormalizeFilename ( basePath + sSep + directory );
|
||||
this->basePath = NormalizeFilename ( basePath );
|
||||
directory = new FileLocation ( root, relative_path, "" );
|
||||
}
|
||||
|
||||
Include::~Include ()
|
||||
Include::~Include()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Include::ProcessXML()
|
||||
Include::ProcessXML ()
|
||||
{
|
||||
const XMLAttribute* att;
|
||||
att = node->GetAttribute ( "base", false );
|
||||
DirectoryLocation root = SourceDirectory;
|
||||
|
||||
string relative_path;
|
||||
const XMLAttribute* att = node->GetAttribute ( "base", false );
|
||||
if ( att )
|
||||
{
|
||||
bool referenceResolved = false;
|
||||
|
||||
if ( !module )
|
||||
{
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"'base' attribute illegal from global <include>" );
|
||||
}
|
||||
|
||||
if ( !referenceResolved )
|
||||
if ( att->value == project.name )
|
||||
{
|
||||
if ( att->value == project.name )
|
||||
{
|
||||
basePath = ".";
|
||||
referenceResolved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Module* base = project.LocateModule ( att->value );
|
||||
if ( base != NULL )
|
||||
{
|
||||
baseModule = base;
|
||||
basePath = base->output->relative_path;
|
||||
referenceResolved = true;
|
||||
}
|
||||
}
|
||||
relative_path = node->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Module* base = project.LocateModule ( att->value );
|
||||
if ( !base )
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"<include> attribute 'base' references non-existant project or module '%s'",
|
||||
att->value.c_str() );
|
||||
root = GetDefaultDirectoryTree ( base );
|
||||
|
||||
if ( !referenceResolved )
|
||||
throw XMLInvalidBuildFileException (
|
||||
node->location,
|
||||
"<include> attribute 'base' references non-existant project or module '%s'",
|
||||
att->value.c_str() );
|
||||
directory = NormalizeFilename ( basePath + sSep + node->value );
|
||||
relative_path = base->output->relative_path;
|
||||
if ( node->value.length () > 0 && node->value != "." )
|
||||
relative_path += sSep + node->value;
|
||||
}
|
||||
}
|
||||
else
|
||||
directory = NormalizeFilename ( node->value );
|
||||
relative_path = node->value;
|
||||
|
||||
att = node->GetAttribute ( "root", false );
|
||||
if ( att )
|
||||
{
|
||||
if ( att->value != "intermediate" && att->value != "output" )
|
||||
{
|
||||
throw InvalidAttributeValueException (
|
||||
node->location,
|
||||
"root",
|
||||
att->value );
|
||||
}
|
||||
|
||||
root = att->value;
|
||||
if ( att->value == "intermediate" )
|
||||
root = IntermediateDirectory;
|
||||
else if ( att->value == "output" )
|
||||
root = OutputDirectory;
|
||||
else
|
||||
throw InvalidAttributeValueException ( node->location,
|
||||
"root",
|
||||
att->value );
|
||||
}
|
||||
|
||||
directory = new FileLocation ( root,
|
||||
relative_path,
|
||||
"" );
|
||||
}
|
||||
|
||||
DirectoryLocation
|
||||
Include::GetDefaultDirectoryTree ( const Module* module ) const
|
||||
{
|
||||
if ( module != NULL &&
|
||||
( module->type == RpcServer ||
|
||||
module->type == RpcClient ||
|
||||
module->type == IdlHeader) )
|
||||
return IntermediateDirectory;
|
||||
else
|
||||
return SourceDirectory;
|
||||
}
|
||||
|
|
|
@ -289,6 +289,10 @@ Module::Module ( const Project& project,
|
|||
else
|
||||
extension = GetDefaultModuleExtension ();
|
||||
|
||||
output = new FileLocation ( GetTargetDirectoryTree (),
|
||||
modulePath,
|
||||
name + extension );
|
||||
|
||||
att = moduleNode.GetAttribute ( "unicode", false );
|
||||
if ( att != NULL )
|
||||
{
|
||||
|
@ -485,9 +489,6 @@ Module::Module ( const Project& project,
|
|||
}
|
||||
}
|
||||
|
||||
output = new FileLocation ( GetTargetDirectoryTree (),
|
||||
modulePath,
|
||||
name + extension );
|
||||
SetImportLibrary ( NULL );
|
||||
}
|
||||
|
||||
|
@ -658,7 +659,7 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
|
|||
}
|
||||
else if ( e.name == "include" )
|
||||
{
|
||||
Include* include = new Include ( project, this, &e );
|
||||
Include* include = new Include ( project, &e, this );
|
||||
if ( parseContext.ifData )
|
||||
parseContext.ifData->data.includes.push_back ( include );
|
||||
else
|
||||
|
@ -948,7 +949,9 @@ Module::GetTargetDirectoryTree () const
|
|||
return IntermediateDirectory;
|
||||
}
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
__LINE__ );
|
||||
__LINE__,
|
||||
"Invalid module type %d.",
|
||||
type );
|
||||
}
|
||||
|
||||
string
|
||||
|
|
|
@ -110,7 +110,8 @@ FileLocation::FileLocation ( const DirectoryLocation directory,
|
|||
relative_path[0] == '\\' ||
|
||||
relative_path.find ( '$' ) != string::npos ||
|
||||
( relative_path.length () > 1 && ( relative_path[1] == ':' ||
|
||||
relative_path.find_last_of ( "/\\" ) == relative_path.length () - 1 ) )
|
||||
relative_path.find_last_of ( "/\\" ) == relative_path.length () - 1 ) ) ||
|
||||
( relative_path.length () > 3 && relative_path.find ( ':' ) != string::npos )
|
||||
)
|
||||
{
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
|
@ -119,7 +120,7 @@ FileLocation::FileLocation ( const DirectoryLocation directory,
|
|||
relative_path.c_str () );
|
||||
}
|
||||
|
||||
if ( strpbrk ( name.c_str (), "/\\:" ) )
|
||||
if ( name.find_first_of ( "/\\:" ) != string::npos )
|
||||
{
|
||||
throw InvalidOperationException ( __FILE__,
|
||||
__LINE__,
|
||||
|
|
|
@ -386,25 +386,23 @@ private:
|
|||
class Include
|
||||
{
|
||||
public:
|
||||
const Project& project;
|
||||
const Module* module;
|
||||
const XMLElement* node;
|
||||
const Module* baseModule;
|
||||
std::string directory;
|
||||
std::string basePath;
|
||||
std::string root;
|
||||
FileLocation *directory;
|
||||
|
||||
Include ( const Project& project,
|
||||
const XMLElement* includeNode );
|
||||
Include ( const Project& project,
|
||||
const Module* module,
|
||||
const XMLElement* includeNode );
|
||||
const XMLElement* includeNode,
|
||||
const Module* module );
|
||||
Include ( const Project& project,
|
||||
std::string directory,
|
||||
std::string basePath );
|
||||
DirectoryLocation directory,
|
||||
const std::string& relative_path );
|
||||
~Include ();
|
||||
void ProcessXML();
|
||||
void ProcessXML ();
|
||||
private:
|
||||
const Project& project;
|
||||
const XMLElement* node;
|
||||
const Module* module;
|
||||
DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -769,7 +767,7 @@ public:
|
|||
AutomaticDependency ( const Project& project );
|
||||
~AutomaticDependency ();
|
||||
std::string GetFilename ( const std::string& filename );
|
||||
bool LocateIncludedFile ( const std::string& directory,
|
||||
bool LocateIncludedFile ( const FileLocation& directory,
|
||||
const std::string& includedFilename,
|
||||
std::string& resolvedFilename );
|
||||
bool LocateIncludedFile ( SourceFile* sourceFile,
|
||||
|
|
|
@ -120,6 +120,6 @@ WineResource::UnpackResourcesInModule ( Module& module,
|
|||
exitcode );
|
||||
}
|
||||
module.non_if_data.includes.push_back( new Include ( module.project,
|
||||
module.output->relative_path,
|
||||
"$(INTERMEDIATE)" ) );
|
||||
IntermediateDirectory,
|
||||
module.output->relative_path ) );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue