Author: hpoussin Date: Mon Sep 10 17:13:16 2007 New Revision: 28990
URL: http://svn.reactos.org/svn/reactos?rev=28990&view=rev Log: Continue rbuild cleanup (File class)
Modified: trunk/reactos/tools/rbuild/automaticdependency.cpp trunk/reactos/tools/rbuild/backend/codeblocks/codeblocks.cpp trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp trunk/reactos/tools/rbuild/backend/devcpp/devcpp.h trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp trunk/reactos/tools/rbuild/backend/msbuild/msbuild.cpp trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp trunk/reactos/tools/rbuild/backend/msvc/msvcmaker.cpp trunk/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp trunk/reactos/tools/rbuild/compilationunit.cpp trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp trunk/reactos/tools/rbuild/module.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 17:13:16 2007 @@ -321,7 +321,8 @@
if ( module.pch != NULL ) { - File *file = new File ( module.pch->file.relative_path + sSep + module.pch->file.name , false, "", true ); + const FileLocation& pch = module.pch->file; + File *file = new File ( pch.directory, pch.relative_path, pch.name , false, "", true ); files.push_back ( file ); } } @@ -541,7 +542,7 @@ for ( size_t fi = 0; fi < files.size (); fi++ ) { File& file = *files[fi]; - string normalizedFilename = NormalizeFilename ( file.name ); + string normalizedFilename = NormalizeFilename ( file.GetFullPath () );
SourceFile* sourceFile = RetrieveFromCache ( normalizedFilename ); if ( sourceFile != NULL )
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 17:13:16 2007 @@ -251,7 +251,7 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size (); i++ ) { - string file = files[i]->name; + string file = files[i]->file.relative_path + sSep + files[i]->file.name; string::size_type pos = file.find_last_of ("\"); if ( pos != string::npos ) file.erase ( 0, pos+1 ); @@ -418,7 +418,8 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size(); i++ ) { - string file = string(".") + &files[i]->name[cbproj_path.size()]; + string fullpath = files[i]->file.relative_path + sSep + files[i]->file.name; + string file = string(".") + &fullpath[cbproj_path.size()];
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) resource_files.push_back ( file );
Modified: trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/devcpp... ============================================================================== --- trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp (original) +++ trunk/reactos/tools/rbuild/backend/devcpp/devcpp.cpp Mon Sep 10 17:13:16 2007 @@ -133,7 +133,7 @@ { File &file = *module.non_if_data.files[k]; - ProcessFile(file.name); + ProcessFile( file.file.relative_path + sSep + file.file.name ); } } } @@ -149,7 +149,7 @@ return true; }
-void DevCppBackend::ProcessFile(string &filepath) +void DevCppBackend::ProcessFile(string filepath) { // Remove the .\ at the start of the filenames if ((filepath[0] == '.') && (filepath[1] == '\')) filepath.erase(0, 2);
Modified: trunk/reactos/tools/rbuild/backend/devcpp/devcpp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/devcpp... ============================================================================== --- trunk/reactos/tools/rbuild/backend/devcpp/devcpp.h (original) +++ trunk/reactos/tools/rbuild/backend/devcpp/devcpp.h Mon Sep 10 17:13:16 2007 @@ -45,7 +45,7 @@ private:
void ProcessModules(); - void ProcessFile(std::string &filename); + void ProcessFile(std::string filename); bool CheckFolderAdded(std::string &folder); void AddFolders(std::string &folder);
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 17:13:16 2007 @@ -336,7 +336,7 @@ for ( size_t i = 0; i < compilationUnit.files.size (); i++ ) { File& file = *compilationUnit.files[i]; - sourceFiles.push_back ( NormalizeFilename ( file.name ) ); + sourceFiles.push_back ( strFile ( &file.file ) ); } return v2s ( sourceFiles, 10 ); } @@ -354,7 +354,7 @@ bool MingwModuleHandler::IsGeneratedFile ( const File& file ) const { - string extension = GetExtension ( file.name ); + string extension = GetExtension ( file.file.name ); return ( extension == ".spec" || extension == ".SPEC" ); }
@@ -3533,10 +3533,9 @@ void MingwTestModuleHandler::GetModuleSpecificCompilationUnits ( vector<CompilationUnit*>& compilationUnits ) { - string basePath = "$(INTERMEDIATE)" + sSep + module.output->relative_path; - compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_hooks.c", false, "", false ) ) ); - compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_stubs.S", false, "", false ) ) ); - compilationUnits.push_back ( new CompilationUnit ( new File ( basePath + sSep + "_startup.c", false, "", false ) ) ); + compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_hooks.c", false, "", false ) ) ); + compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_stubs.S", false, "", false ) ) ); + compilationUnits.push_back ( new CompilationUnit ( new File ( IntermediateDirectory, module.output->relative_path + sSep + "..", module.name + "_startup.c", false, "", false ) ) ); }
void
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 17:13:16 2007 @@ -113,8 +113,7 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size(); i++ ) { - string file = &files[i]->name[proj_path.size()+1]; - source_files.push_back ( file ); + source_files.push_back ( files[i]->file.name ); } const vector<Include*>& incs = data.includes; for ( i = 0; i < incs.size(); i++ )
Modified: trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/msvc/m... ============================================================================== --- trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp (original) +++ trunk/reactos/tools/rbuild/backend/msvc/msvc.cpp Mon Sep 10 17:13:16 2007 @@ -337,7 +337,7 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size (); i++ ) { - string file = files[i]->name; + string file = files[i]->file.relative_path + sSep + files[i]->file.name; string::size_type pos = file.find_last_of (DEF_SSEP); if ( pos != string::npos ) file.erase ( 0, pos+1 );
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 17:13:16 2007 @@ -102,8 +102,8 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size(); i++ ) { - // TODO FIXME - do we want the full path of the file here? - string file = string(".") + &files[i]->name[dsp_path.size()]; + // TODO FIXME - do we want only the name of the file here? + string file = files[i]->file.name;
source_files.push_back ( file ); if ( !stricmp ( Right(file,2).c_str(), ".c" ) )
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 17:13:16 2007 @@ -157,8 +157,8 @@ const vector<File*>& files = data.files; for ( i = 0; i < files.size(); i++ ) { - // TODO FIXME - do we want the full path of the file here? - string file = string(".") + &files[i]->name[vcproj_path.size()]; + // TODO FIXME - do we want only the name of the file here? + string file = files[i]->file.name;
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) resource_files.push_back ( file );
Modified: trunk/reactos/tools/rbuild/compilationunit.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationuni... ============================================================================== --- trunk/reactos/tools/rbuild/compilationunit.cpp (original) +++ trunk/reactos/tools/rbuild/compilationunit.cpp Mon Sep 10 17:13:16 2007 @@ -28,8 +28,8 @@ module(NULL), node(NULL) { - local_name = file->name; - name = file->name; + local_name = file->file.name; + name = file->file.relative_path + sSep + file->file.name; files.push_back ( file ); }
@@ -67,7 +67,7 @@ if ( files.size () != 1 ) return false; File* file = files[0]; - string extension = GetExtension ( file->name ); + string extension = GetExtension ( file->file.name ); return ( extension == ".spec" || extension == ".SPEC" ); }
@@ -78,7 +78,7 @@ for ( i = 0; i < files.size (); i++ ) { File& file = *files[i]; - string fileExtension = GetExtension ( file.name ); + string fileExtension = GetExtension ( file.file.name ); if ( !stricmp ( fileExtension.c_str (), extension.c_str () ) ) return true; } @@ -106,28 +106,7 @@ }
File* file = files[0]; - - DirectoryLocation directory; - if ( file->path_prefix.length () == 0 ) - directory = SourceDirectory; - else if ( file->path_prefix == "$(INTERMEDIATE)" ) - directory = IntermediateDirectory; - else - throw InvalidOperationException ( __FILE__, - __LINE__, - "Invalid path prefix '%s'", - file->path_prefix.c_str () ); - - size_t pos = file->name.find_last_of ( "/\" ); - assert ( pos != string::npos ); - string relative_path = file->name.substr ( 0, pos ); - string name = file->name.substr ( pos + 1 ); - if ( relative_path.compare ( 0, 15, "$(INTERMEDIATE)") == 0 ) - { - directory = IntermediateDirectory; - relative_path.erase ( 0, 16 ); - } - return new FileLocation ( directory, relative_path, name ); + return new FileLocation ( file->file ); }
std::string
Modified: trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/compilationuni... ============================================================================== --- trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp (original) +++ trunk/reactos/tools/rbuild/compilationunitsupportcode.cpp Mon Sep 10 17:13:16 2007 @@ -86,7 +86,7 @@ for ( size_t i = 0; i < compilationUnit.files.size () ; i++ ) { File& file = *compilationUnit.files[i]; - s = s + sprintf ( s, "#include <%s>\n", ChangeSeparator ( file.name, '\', '/' ).c_str () ); + s = s + sprintf ( s, "#include <%s/%s>\n", ChangeSeparator ( file.file.relative_path, '\', '/' ).c_str (), file.file.name.c_str () ); }
s = s + sprintf ( s, "\n" );
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 17:13:16 2007 @@ -538,7 +538,7 @@ for ( i = 0; i < node.subElements.size(); i++ ) { ParseContext parseContext; - ProcessXMLSubElement ( *node.subElements[i], output->relative_path, "", parseContext ); + ProcessXMLSubElement ( *node.subElements[i], SourceDirectory, output->relative_path, parseContext ); } for ( i = 0; i < invocations.size(); i++ ) invocations[i]->ProcessXML (); @@ -561,15 +561,15 @@
void Module::ProcessXMLSubElement ( const XMLElement& e, - const string& path, - const string& path_prefix, + DirectoryLocation directory, + const string& relative_path, ParseContext& parseContext ) { If* pOldIf = parseContext.ifData; CompilationUnit* pOldCompilationUnit = parseContext.compilationUnit; bool subs_invalid = false; - string subpath ( path ); - string subpath_prefix ( "" ); + string subpath ( relative_path ); + DirectoryLocation subdirectory = SourceDirectory; if ( e.name == "file" && e.value.size () > 0 ) { bool first = false; @@ -600,8 +600,9 @@ else if ( !stricmp ( ext.c_str(), ".cxx" ) ) cplusplus = true; } - File* pFile = new File ( FixSeparator ( path + cSep + e.value ), - path_prefix, + File* pFile = new File ( directory, + relative_path, + e.value, first, switches, false ); @@ -644,9 +645,9 @@ if ( root ) { if ( root->value == "intermediate" ) - subpath_prefix = "$(INTERMEDIATE)"; + subdirectory = IntermediateDirectory; else if ( root->value == "output" ) - subpath_prefix = "$(OUTPUT)"; + subdirectory = OutputDirectory; else { throw InvalidAttributeValueException ( @@ -655,7 +656,7 @@ root->value ); } } - subpath = GetSubPath ( this->project, e.location, path, att->value ); + subpath = GetSubPath ( this->project, e.location, relative_path, att->value ); } else if ( e.name == "include" ) { @@ -802,14 +803,14 @@ if ( pos == string::npos ) { pch = new PchFile ( - e, *this, FileLocation ( SourceDirectory, path, e.value ) ); + e, *this, FileLocation ( SourceDirectory, relative_path, e.value ) ); } else { string dir = e.value.substr ( 0, pos ); string name = e.value.substr ( pos + 1); pch = new PchFile ( - e, *this, FileLocation ( SourceDirectory, path + sSep + dir, name ) ); + e, *this, FileLocation ( SourceDirectory, relative_path + sSep + dir, name ) ); } subs_invalid = true; } @@ -846,7 +847,7 @@ e.name.c_str() ); } for ( size_t i = 0; i < e.subElements.size (); i++ ) - ProcessXMLSubElement ( *e.subElements[i], subpath, subpath_prefix, parseContext ); + ProcessXMLSubElement ( *e.subElements[i], subdirectory, subpath, parseContext ); parseContext.ifData = pOldIf; parseContext.compilationUnit = pOldCompilationUnit; } @@ -1233,12 +1234,13 @@ }
-File::File ( const string& _name, +File::File ( DirectoryLocation directory, + const string& relative_path, + const string& name, bool _first, - std::string _switches, + const string& _switches, bool _isPreCompiledHeader ) - : name(_name), - path_prefix(""), + : file ( directory, relative_path, name ), first(_first), switches(_switches), isPreCompiledHeader(_isPreCompiledHeader) @@ -1246,19 +1248,6 @@ }
-File::File ( const string& _name, - const string& _path_prefix, - bool _first, - std::string _switches, - bool _isPreCompiledHeader ) - : name(_name), - path_prefix(_path_prefix), - first(_first), - switches(_switches), - isPreCompiledHeader(_isPreCompiledHeader) -{ -} - void File::ProcessXML() { @@ -1267,10 +1256,11 @@
std::string File::GetFullPath () const { - if ( path_prefix.length () > 0 ) - return path_prefix + sSep + name; - else - return name; + // TODO FIXME take care of file.directory? return a full path? + if ( file.relative_path.length () > 0 ) + return file.relative_path + sSep + file.name; + else + return file.name; }
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 17:13:16 2007 @@ -309,6 +309,20 @@ OutputDirectory, InstallDirectory, TemporaryDirectory, +}; + +class FileLocation +{ +public: + DirectoryLocation directory; + std::string relative_path; + std::string name; + + FileLocation ( const DirectoryLocation directory, + const std::string& relative_path, + const std::string& name ); + + FileLocation ( const FileLocation& other ); };
class Module @@ -377,8 +391,8 @@ std::string GetDefaultModuleBaseaddress () const; std::string entrypoint; void ProcessXMLSubElement ( const XMLElement& e, - const std::string& path, - const std::string& path_prefix, + DirectoryLocation directory, + const std::string& relative_path, ParseContext& parseContext ); };
@@ -435,21 +449,16 @@ class File { public: - std::string name; - std::string path_prefix; + FileLocation file; bool first; std::string switches; bool isPreCompiledHeader;
- File ( const std::string& _name, + File ( DirectoryLocation directory, + const std::string& relative_path, + const std::string& name, bool _first, - std::string _switches, - bool _isPreCompiledHeader ); - - File ( const std::string& _name, - const std::string& _path_prefix, - bool _first, - std::string _switches, + const std::string& _switches, bool _isPreCompiledHeader );
void ProcessXML(); @@ -829,21 +838,6 @@ };
-class FileLocation -{ -public: - DirectoryLocation directory; - std::string relative_path; - std::string name; - - FileLocation ( const DirectoryLocation directory, - const std::string& relative_path, - const std::string& name ); - - FileLocation ( const FileLocation& other ); -}; - - class CDFile : public XmlNode { public:
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 17:13:16 2007 @@ -37,7 +37,7 @@ bool WineResource::IsSpecFile ( const File& file ) { - string extension = GetExtension ( file.name ); + string extension = GetExtension ( file.file.name ); if ( extension == ".spec" || extension == ".SPEC" ) return true; return false; @@ -58,7 +58,7 @@ bool WineResource::IsResourceFile ( const File& file ) { - string extension = GetExtension ( file.name ); + string extension = GetExtension ( file.file.name ); if ( extension == ".rc" || extension == ".RC" ) return true; return false; @@ -71,7 +71,7 @@ for ( size_t i = 0; i < files.size (); i++ ) { if ( IsResourceFile ( *files[i] ) ) - return files[i]->name; + return files[i]->file.relative_path + sSep + files[i]->file.name; } return ""; }