}
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 )
{
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 ) )
{
return true;
}
}
+ /*printf ( "Unable to find %s, included in %s.\n",
+ includedFilename.c_str (),
+ sourceFile->filename.c_str () );*/
resolvedFilename = "";
return false;
}
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 );
{
switch ( file->directory )
{
+ case SourceDirectory:
+ break;
case IntermediateDirectory:
backend->AddDirectoryTarget ( file->relative_path, backend->intermediateDirectory );
break;
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;
}
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++ )
{
for ( i = 0; i < incs.size(); i++ )\r
{\r
string path = Path::RelativeFromDirectory (\r
- incs[i]->directory,\r
+ incs[i]->directory->relative_path,\r
module.output->relative_path );\r
\r
includes.push_back ( path );\r
{
// 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 );
}
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 )
{
}
}
// 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 );
}
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;
}
else
extension = GetDefaultModuleExtension ();
+ output = new FileLocation ( GetTargetDirectoryTree (),
+ modulePath,
+ name + extension );
+
att = moduleNode.GetAttribute ( "unicode", false );
if ( att != NULL )
{
}
}
- output = new FileLocation ( GetTargetDirectoryTree (),
- modulePath,
- name + extension );
SetImportLibrary ( NULL );
}
}
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
return IntermediateDirectory;
}
throw InvalidOperationException ( __FILE__,
- __LINE__ );
+ __LINE__,
+ "Invalid module type %d.",
+ type );
}
string
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__,
relative_path.c_str () );
}
- if ( strpbrk ( name.c_str (), "/\\:" ) )
+ if ( name.find_first_of ( "/\\:" ) != string::npos )
{
throw InvalidOperationException ( __FILE__,
__LINE__,
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;
};
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,
exitcode );
}
module.non_if_data.includes.push_back( new Include ( module.project,
- module.output->relative_path,
- "$(INTERMEDIATE)" ) );
+ IntermediateDirectory,
+ module.output->relative_path ) );
}