From 1c89a135da609c7a36998c8282d6e69a385d3a24 Mon Sep 17 00:00:00 2001 From: Casper Hornstrup Date: Mon, 11 Apr 2005 18:45:48 +0000 Subject: [PATCH] Have the object files of a module depend on the build file that contain the module svn path=/branches/xmlbuildsystem/; revision=14591 --- reactos/tools/rbuild/XML.cpp | 31 ++++++++------- reactos/tools/rbuild/XML.h | 4 +- .../rbuild/backend/mingw/modulehandler.cpp | 39 +++++++++++++------ reactos/tools/rbuild/module.cpp | 2 + reactos/tools/rbuild/rbuild.h | 1 + 5 files changed, 51 insertions(+), 26 deletions(-) diff --git a/reactos/tools/rbuild/XML.cpp b/reactos/tools/rbuild/XML.cpp index 07b9c8f93f6..6a60fe1d61e 100644 --- a/reactos/tools/rbuild/XML.cpp +++ b/reactos/tools/rbuild/XML.cpp @@ -339,9 +339,11 @@ XMLAttribute& XMLAttribute::operator = ( const XMLAttribute& src ) return *this; } -XMLElement::XMLElement ( const string& location_ ) - : location(location_), - parentElement(NULL) +XMLElement::XMLElement ( XMLFile* xmlFile, + const string& location ) + : xmlFile ( xmlFile ), + location ( location ), + parentElement ( NULL ) { } @@ -517,7 +519,8 @@ XMLParse ( XMLFile& f, return NULL; } - XMLElement* e = new XMLElement ( f.Location () ); + XMLElement* e = new XMLElement ( &f, + f.Location () ); bool bNeedEnd = e->Parse ( token, end_tag ); if ( e->name == "xi:include" && includes ) @@ -634,8 +637,8 @@ XMLLoadInclude ( XMLInclude& include, string file ( include.path.Fixup(att->value, true) ); string top_file ( Path::RelativeFromWorkingDirectory ( file ) ); include.e->attributes.push_back ( new XMLAttribute ( "top_href", top_file ) ); - XMLFile fInc; - if ( !fInc.open ( file ) ) + XMLFile* fInc = new XMLFile(); + if ( !fInc->open ( file ) ) { include.fileExists = false; // look for xi:fallback element @@ -669,10 +672,11 @@ XMLLoadInclude ( XMLInclude& include, else { include.fileExists = true; - XMLElement* new_e = new XMLElement ( include.e->location ); + XMLElement* new_e = new XMLElement ( fInc, + include.e->location ); new_e->name = "xi:included"; Path path2 ( include.path, att->value ); - XMLReadFile ( fInc, *new_e, includes, path2 ); + XMLReadFile ( *fInc, *new_e, includes, path2 ); return new_e; } } @@ -682,14 +686,15 @@ XMLLoadFile ( const string& filename, const Path& path, XMLIncludes& includes ) { - XMLFile f; + XMLFile* f = new XMLFile(); - if ( !f.open ( filename ) ) + if ( !f->open ( filename ) ) throw FileNotFoundException ( filename ); - XMLElement* head = new XMLElement ( "(virtual)" ); + XMLElement* head = new XMLElement ( f, + "(virtual)" ); - XMLReadFile ( f, *head, includes, path ); + XMLReadFile ( *f, *head, includes, path ); for ( size_t i = 0; i < includes.size (); i++ ) { @@ -700,7 +705,7 @@ XMLLoadFile ( const string& filename, throw FileNotFoundException ( ssprintf ( "%s (referenced from %s)", e->GetAttribute ( "top_href", true )->value.c_str (), - f.Location ().c_str () ) ); + f->Location ().c_str () ) ); } XMLElement* parent = e->parentElement; XMLElement** parent_container = NULL; diff --git a/reactos/tools/rbuild/XML.h b/reactos/tools/rbuild/XML.h index 82933d5e5e9..171f40205e2 100644 --- a/reactos/tools/rbuild/XML.h +++ b/reactos/tools/rbuild/XML.h @@ -88,6 +88,7 @@ public: class XMLElement { public: + XMLFile* xmlFile; std::string location; std::string name; std::vector attributes; @@ -95,7 +96,8 @@ public: std::vector subElements; std::string value; - XMLElement ( const std::string& location_ ); + XMLElement ( XMLFile* xmlFile, + const std::string& location ); ~XMLElement(); bool Parse(const std::string& token, bool& end_tag); diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp index 9290027ed69..5d1b43baf20 100644 --- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp +++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp @@ -786,19 +786,20 @@ MingwModuleHandler::GenerateGccCommand ( const string& cc, const string& cflagsMacro ) { - string deps = sourceFilename; + string dependencies = sourceFilename; if ( module.pch && use_pch ) - deps += " " + module.pch->header + ".gch"; + dependencies += " " + module.pch->header + ".gch"; /* WIDL generated headers may be used */ - deps += " " + GetLinkingDependenciesMacro (); + dependencies += " " + GetLinkingDependenciesMacro (); + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); string objectFilename = GetObjectFilename ( sourceFilename, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", objectFilename.c_str (), - deps.c_str (), + dependencies.c_str (), GetDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_CC)\n" ); fprintf ( fMakefile, @@ -813,12 +814,14 @@ MingwModuleHandler::GenerateGccAssemblerCommand ( const string& cc, const string& cflagsMacro ) { + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); string objectFilename = GetObjectFilename ( sourceFilename, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", objectFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_GAS)\n" ); fprintf ( fMakefile, @@ -832,12 +835,14 @@ MingwModuleHandler::GenerateNasmCommand ( const string& sourceFilename, const string& nasmflagsMacro ) { + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); string objectFilename = GetObjectFilename ( sourceFilename, &clean_files ); fprintf ( fMakefile, "%s: %s | %s\n", objectFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_NASM)\n" ); fprintf ( fMakefile, @@ -851,6 +856,8 @@ MingwModuleHandler::GenerateWindresCommand ( const string& sourceFilename, const string& windresflagsMacro ) { + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); string objectFilename = GetObjectFilename ( sourceFilename, &clean_files ); string rciFilename = ros_temp + @@ -862,7 +869,7 @@ MingwModuleHandler::GenerateWindresCommand ( fprintf ( fMakefile, "%s: %s $(WRC_TARGET) | %s\n", objectFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, @@ -890,7 +897,7 @@ MingwModuleHandler::GenerateWindresCommand ( fprintf ( fMakefile, "%s: %s $(WRC_TARGET) | %s\n", objectFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( objectFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WRC)\n" ); fprintf ( fMakefile, @@ -904,8 +911,10 @@ void MingwModuleHandler::GenerateWinebuildCommands ( const string& sourceFilename ) { - string basename = GetBasename ( sourceFilename ); + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); + string basename = GetBasename ( sourceFilename ); string def_file = PassThruCacheDirectory ( basename + ".spec.def", backend->intermediateDirectory ); @@ -919,7 +928,7 @@ MingwModuleHandler::GenerateWinebuildCommands ( fprintf ( fMakefile, "%s: %s $(WINEBUILD_TARGET)\n", def_file.c_str (), - sourceFilename.c_str () ); + dependencies.c_str () ); fprintf ( fMakefile, "\t$(ECHO_WINEBLD)\n" ); fprintf ( fMakefile, "\t%s --def=%s -o %s\n", @@ -944,6 +953,9 @@ MingwModuleHandler::GenerateWidlCommandsServer ( const string& sourceFilename, const string& widlflagsMacro ) { + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); + string basename = GetBasename ( sourceFilename ); /*string generatedHeaderFilename = PassThruCacheDirectory ( @@ -963,7 +975,7 @@ MingwModuleHandler::GenerateWidlCommandsServer ( "%s %s: %s $(WIDL_TARGET) | %s\n", generatedServerFilename.c_str (), generatedHeaderFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( generatedServerFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, @@ -980,6 +992,9 @@ MingwModuleHandler::GenerateWidlCommandsClient ( const string& sourceFilename, const string& widlflagsMacro ) { + string dependencies = sourceFilename; + dependencies += " " + NormalizeFilename ( module.xmlbuildFile ); + string basename = GetBasename ( sourceFilename ); /*string generatedHeaderFilename = PassThruCacheDirectory ( @@ -999,7 +1014,7 @@ MingwModuleHandler::GenerateWidlCommandsClient ( "%s %s: %s $(WIDL_TARGET) | %s\n", generatedClientFilename.c_str (), generatedHeaderFilename.c_str (), - sourceFilename.c_str (), + dependencies.c_str (), GetDirectory ( generatedClientFilename ).c_str () ); fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" ); fprintf ( fMakefile, diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index d51ebda5f86..efdd7aebc32 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -137,6 +137,8 @@ Module::Module ( const Project& project, __LINE__, "Module created with non- node" ); + xmlbuildFile = Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename() ); + path = FixSeparator ( modulePath ); const XMLAttribute* att = moduleNode.GetAttribute ( "name", true ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index b50b587027f..c461c283592 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -154,6 +154,7 @@ class Module public: const Project& project; const XMLElement& node; + std::string xmlbuildFile; std::string name; std::string extension; std::string entrypoint;