Have the object files of a module depend on the build file that contain the module
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp	2005-04-11 17:59:52 UTC (rev 14590)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/XML.cpp	2005-04-11 18:45:48 UTC (rev 14591)
@@ -339,9 +339,11 @@
 	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 @@
 			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 @@
 	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 @@
 	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 @@
 	          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 @@
 			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;

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/XML.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/XML.h	2005-04-11 17:59:52 UTC (rev 14590)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/XML.h	2005-04-11 18:45:48 UTC (rev 14591)
@@ -88,6 +88,7 @@
 class XMLElement
 {
 public:
+	XMLFile* xmlFile;
 	std::string location;
 	std::string name;
 	std::vector<XMLAttribute*> attributes;
@@ -95,7 +96,8 @@
 	std::vector<XMLElement*> 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);

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-11 17:59:52 UTC (rev 14590)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-11 18:45:48 UTC (rev 14591)
@@ -786,19 +786,20 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 		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 @@
 		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 @@
 MingwModuleHandler::GenerateWinebuildCommands (
 	const string& 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 @@
 	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 @@
 	const string& sourceFilename,
 	const string& widlflagsMacro )
 {
+	string dependencies = sourceFilename;
+	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
+
 	string basename = GetBasename ( sourceFilename );
 
 	/*string generatedHeaderFilename = PassThruCacheDirectory (
@@ -963,7 +975,7 @@
 	          "%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 @@
 	const string& sourceFilename,
 	const string& widlflagsMacro )
 {
+	string dependencies = sourceFilename;
+	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
+
 	string basename = GetBasename ( sourceFilename );
 
 	/*string generatedHeaderFilename = PassThruCacheDirectory (
@@ -999,7 +1014,7 @@
 	          "%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,

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-04-11 17:59:52 UTC (rev 14590)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/module.cpp	2005-04-11 18:45:48 UTC (rev 14591)
@@ -137,6 +137,8 @@
 		                                  __LINE__,
 		                                  "Module created with non-<module> node" );
 
+	xmlbuildFile = Path::RelativeFromWorkingDirectory ( moduleNode.xmlFile->filename() );
+
 	path = FixSeparator ( modulePath );
 
 	const XMLAttribute* att = moduleNode.GetAttribute ( "name", true );

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-04-11 17:59:52 UTC (rev 14590)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-04-11 18:45:48 UTC (rev 14591)
@@ -154,6 +154,7 @@
 public:
 	const Project& project;
 	const XMLElement& node;
+	std::string xmlbuildFile;
 	std::string name;
 	std::string extension;
 	std::string entrypoint;