Author: hpoussin Date: Mon Sep 10 10:52:07 2007 New Revision: 28986
URL: http://svn.reactos.org/svn/reactos?rev=28986&view=rev Log: Continue rbuild cleanup (Include class)
Modified: trunk/reactos/tools/rbuild/automaticdependency.cpp trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp trunk/reactos/tools/rbuild/include.cpp trunk/reactos/tools/rbuild/module.cpp trunk/reactos/tools/rbuild/project.cpp trunk/reactos/tools/rbuild/rbuild.h trunk/reactos/tools/rbuild/wineresource.cpp
Modified: trunk/reactos/tools/rbuild/automaticdependency.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/automaticdepen... ============================================================================== --- trunk/reactos/tools/rbuild/automaticdependency.cpp (original) +++ trunk/reactos/tools/rbuild/automaticdependency.cpp Mon Sep 10 10:52:07 2007 @@ -367,11 +367,36 @@ }
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 @@ 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 @@ return true; } } + /*printf ( "Unable to find %s, included in %s.\n", + includedFilename.c_str (), + sourceFile->filename.c_str () );*/ resolvedFilename = ""; return false; }
Modified: trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/codebl... ============================================================================== --- trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp (original) +++ trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp Mon Sep 10 10:52:07 2007 @@ -429,7 +429,7 @@ 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 );
Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/... ============================================================================== --- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original) +++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Mon Sep 10 10:52:07 2007 @@ -105,6 +105,8 @@ { switch ( file->directory ) { + case SourceDirectory: + break; case IntermediateDirectory: backend->AddDirectoryTarget ( file->relative_path, backend->intermediateDirectory ); break; @@ -670,14 +672,7 @@ 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 @@ 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++ ) {
Modified: trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msbuil... ============================================================================== --- trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp Mon Sep 10 10:52:07 2007 @@ -120,7 +120,7 @@ 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 );
Modified: trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/m... ============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp Mon Sep 10 10:52:07 2007 @@ -118,15 +118,15 @@ {
// 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 ); }
Modified: trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/v... ============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp Mon Sep 10 10:52:07 2007 @@ -171,7 +171,7 @@ 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 @@ } } // 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 ); }
Modified: trunk/reactos/tools/rbuild/include.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/include.cpp?re... ============================================================================== --- trunk/reactos/tools/rbuild/include.cpp (original) +++ trunk/reactos/tools/rbuild/include.cpp Mon Sep 10 10:52:07 2007 @@ -25,95 +25,98 @@
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 ( att->value == project.name ) + { + 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 ) - { - 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 = base->output->relative_path; + if ( node->value.length () > 0 && node->value != "." ) + relative_path += sSep + node->value; } - - 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 ); } 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 ); - } + if ( att->value == "intermediate" ) + root = IntermediateDirectory; + else if ( att->value == "output" ) + root = OutputDirectory; + else + throw InvalidAttributeValueException ( node->location, + "root", + att->value ); + }
- 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; +}
Modified: trunk/reactos/tools/rbuild/module.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/module.cpp?rev... ============================================================================== --- trunk/reactos/tools/rbuild/module.cpp (original) +++ trunk/reactos/tools/rbuild/module.cpp Mon Sep 10 10:52:07 2007 @@ -289,6 +289,10 @@ else extension = GetDefaultModuleExtension ();
+ output = new FileLocation ( GetTargetDirectoryTree (), + modulePath, + name + extension ); + att = moduleNode.GetAttribute ( "unicode", false ); if ( att != NULL ) { @@ -485,9 +489,6 @@ } }
- output = new FileLocation ( GetTargetDirectoryTree (), - modulePath, - name + extension ); SetImportLibrary ( NULL ); }
@@ -658,7 +659,7 @@ } 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 @@ return IntermediateDirectory; } throw InvalidOperationException ( __FILE__, - __LINE__ ); + __LINE__, + "Invalid module type %d.", + type ); }
string
Modified: trunk/reactos/tools/rbuild/project.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/project.cpp?re... ============================================================================== --- trunk/reactos/tools/rbuild/project.cpp (original) +++ trunk/reactos/tools/rbuild/project.cpp Mon Sep 10 10:52:07 2007 @@ -110,7 +110,8 @@ 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 @@ relative_path.c_str () ); }
- if ( strpbrk ( name.c_str (), "/\:" ) ) + if ( name.find_first_of ( "/\:" ) != string::npos ) { throw InvalidOperationException ( __FILE__, __LINE__,
Modified: trunk/reactos/tools/rbuild/rbuild.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/rbuild.h?rev=2... ============================================================================== --- trunk/reactos/tools/rbuild/rbuild.h (original) +++ trunk/reactos/tools/rbuild/rbuild.h Mon Sep 10 10:52:07 2007 @@ -386,25 +386,23 @@ 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(); -private: + void ProcessXML (); +private: + const Project& project; + const XMLElement* node; + const Module* module; + DirectoryLocation GetDefaultDirectoryTree ( const Module* module ) const; };
@@ -769,7 +767,7 @@ 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,
Modified: trunk/reactos/tools/rbuild/wineresource.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/wineresource.c... ============================================================================== --- trunk/reactos/tools/rbuild/wineresource.cpp (original) +++ trunk/reactos/tools/rbuild/wineresource.cpp Mon Sep 10 10:52:07 2007 @@ -120,6 +120,6 @@ exitcode ); } module.non_if_data.includes.push_back( new Include ( module.project, - module.output->relative_path, - "$(INTERMEDIATE)" ) ); + IntermediateDirectory, + module.output->relative_path ) ); }