Clean-as-you-go mode to remove generated files as soon as possible to minimize disk space requirements
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.cpp	2005-04-21 12:54:15 UTC (rev 14729)
@@ -34,7 +34,8 @@
 /*static*/ Backend*
 Backend::Factory::Create ( const string& name,
                            Project& project,
-                           bool verbose )
+                           bool verbose,
+                           bool cleanAsYouGo )
 {
 	string sname ( name );
 	strlwr ( &sname[0] );
@@ -48,11 +49,14 @@
 		throw UnknownBackendException ( sname );
 		return NULL;
 	}
-	return (*f) ( project, verbose );
+	return (*f) ( project, verbose, cleanAsYouGo );
 }
 
-Backend::Backend ( Project& project, bool verbose )
+Backend::Backend ( Project& project,
+                   bool verbose,
+                   bool cleanAsYouGo )
 	: ProjectNode ( project ),
-	  verbose ( verbose )
+	  verbose ( verbose ),
+	  cleanAsYouGo ( cleanAsYouGo )
 {
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/backend.h	2005-04-21 12:54:15 UTC (rev 14729)
@@ -21,23 +21,27 @@
 		Factory ( const std::string& name_ );
 		virtual ~Factory();
 
-		virtual Backend* operator() ( Project&, bool verbose ) = 0;
+		virtual Backend* operator() ( Project&,
+		                              bool verbose,
+		                              bool cleanAsYouGo ) = 0;
 
 	public:
 		static Backend* Create ( const std::string& name,
 		                         Project& project,
-		                         bool verbose );
+		                         bool verbose,
+		                         bool cleanAsYouGo );
 	};
 
 protected:
-	Backend ( Project& project, bool verbose );
+	Backend ( Project& project,
+	          bool verbose,
+	          bool cleanAsYouGo );
 
 public:
 	virtual void Process () = 0;
-
-protected:
 	Project& ProjectNode;
 	bool verbose;
+	bool cleanAsYouGo;
 };
 
 #endif /* __BACKEND_H */

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.cpp	2005-04-21 12:54:15 UTC (rev 14729)
@@ -34,15 +34,19 @@
 	public:
 
 		DevCppFactory() : Factory("devcpp") {}
-		Backend *operator() (Project &project, bool verbose)
+		Backend *operator() (Project &project,
+		                     bool verbose,
+		                     bool cleanAsYouGo)
 		{
-			return new DevCppBackend(project, verbose);
+			return new DevCppBackend(project, verbose, cleanAsYouGo);
 		}
 		
 } factory;
 
 
-DevCppBackend::DevCppBackend(Project &project, bool verbose) : Backend(project, verbose)
+DevCppBackend::DevCppBackend(Project &project,
+                             bool verbose,
+                             bool cleanAsYouGo) : Backend(project, verbose, cleanAsYouGo)
 {
 	m_unitCount = 0;
 }
@@ -107,7 +111,10 @@
 	
 	cout << "Creating Makefile: " << ProjectNode.makefile << endl;
 	
-	Backend *backend = Backend::Factory::Create("mingw", ProjectNode, verbose );
+	Backend *backend = Backend::Factory::Create("mingw",
+	                                            ProjectNode,
+	                                            verbose,
+	                                            cleanAsYouGo );
 	backend->Process();
 	delete backend;
 

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.h	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/devcpp/devcpp.h	2005-04-21 12:54:15 UTC (rev 14729)
@@ -19,7 +19,9 @@
 {
 	public:
 
-		DevCppBackend(Project &project, bool verbose);
+		DevCppBackend(Project &project,
+	                  bool verbose,
+	                  bool cleanAsYouGo);
 		virtual ~DevCppBackend() {}
 
 		virtual void Process();

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.cpp	2005-04-21 12:54:15 UTC (rev 14729)
@@ -202,15 +202,21 @@
 {
 public:
 	MingwFactory() : Factory ( "mingw" ) {}
-	Backend* operator() ( Project& project, bool verbose )
+	Backend* operator() ( Project& project,
+	                      bool verbose,
+	                      bool cleanAsYouGo )
 	{
-		return new MingwBackend ( project, verbose );
+		return new MingwBackend ( project,
+		                          verbose,
+		                          cleanAsYouGo );
 	}
 } factory;
 
 
-MingwBackend::MingwBackend ( Project& project, bool verbose )
-	: Backend ( project, verbose ),
+MingwBackend::MingwBackend ( Project& project,
+                             bool verbose,
+                             bool cleanAsYouGo )
+	: Backend ( project, verbose, cleanAsYouGo ),
 	  intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
 	  outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
 	  installDirectory ( new Directory ( "$(INSTALL)" ) )

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/mingw.h	2005-04-21 12:54:15 UTC (rev 14729)
@@ -54,7 +54,9 @@
 class MingwBackend : public Backend
 {
 public:
-	MingwBackend ( Project& project, bool verbose );
+	MingwBackend ( Project& project,
+	               bool verbose,
+	               bool cleanAsYouGo );
 	virtual ~MingwBackend ();
 	virtual void Process ();
 	std::string AddDirectoryTarget ( const std::string& directory,

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.cpp	2005-04-21 12:54:15 UTC (rev 14729)
@@ -8,7 +8,7 @@
 using std::string;
 using std::vector;
 
-#define CLEAN_FILE(f) clean_files.push_back ( f ); /*if ( module.name == "crt" ) printf ( "%s(%i): clean: %s\n", __FILE__, __LINE__, f.c_str() )*/
+#define CLEAN_FILE(f) clean_files.push_back ( f );
 
 static string ros_temp = "$(TEMPORARY)";
 MingwBackend*
@@ -1149,6 +1149,17 @@
 }
 
 void
+MingwModuleHandler::GenerateCleanObjectsAsYouGoCode ( const string& files )
+{
+	if ( backend->cleanAsYouGo )
+	{
+		fprintf ( fMakefile,
+		          "\t-@${rm} %s 2>$(NUL)\n",
+		          files.c_str () );
+	}
+}
+
+void
 MingwModuleHandler::GenerateLinkerCommand (
 	const string& dependencies,
 	const string& linker,
@@ -1216,6 +1227,8 @@
 		fprintf ( fMakefile,
 		          "\t-@${rm} %s 2>$(NUL)\n",
 		          temp_exp.c_str () );
+		
+		GenerateCleanObjectsAsYouGoCode ( objectsMacro );
 	}
 	else
 	{
@@ -1227,6 +1240,8 @@
 		          objectsMacro.c_str (),
 		          libsMacro.c_str (),
 		          GetLinkerMacro ().c_str () );
+
+		GenerateCleanObjectsAsYouGoCode ( objectsMacro );
 	}
 
 	GenerateBuildMapCode ();

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/backend/mingw/modulehandler.h	2005-04-21 12:54:15 UTC (rev 14729)
@@ -77,6 +77,7 @@
 	std::string GetLinkingDependenciesMacro () const;
 	std::string GetLibsMacro () const;
 	std::string GetLinkerMacro () const;
+	void GenerateCleanObjectsAsYouGoCode ( const std::string& files );
 	void GenerateLinkerCommand ( const std::string& dependencies,
 	                             const std::string& linker,
 	                             const std::string& linkerParameters,

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-04-21 09:52:11 UTC (rev 14728)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-04-21 12:54:15 UTC (rev 14729)
@@ -19,6 +19,7 @@
 static string BuildSystem;
 static string RootXmlFile = "ReactOS.xml";
 static bool Verbose = false;
+static bool CleanAsYouGo = false;
 
 bool
 ParseSwitch ( int argc, char** argv, int index )
@@ -29,6 +30,9 @@
 		case 'v':
 			Verbose = true;
 			break;
+		case 'c':
+			CleanAsYouGo = true;
+			break;
 		case 'r':
 			RootXmlFile = string(&argv[index][2]);
 			break;
@@ -69,6 +73,7 @@
 		printf ( "  rbuild [-v] [-rfile.xml] buildsystem\n\n" );
 		printf ( "Switches:\n" );
 		printf ( "  -v           Be verbose\n" );
+		printf ( "  -c           Clean as you go. Delete generated files as soon as they are not needed anymore\n" );
 		printf ( "  -rfile.xml   Name of the root xml file. Default is ReactOS.xml\n" );
 		printf ( "\n" );
 		printf ( "  buildsystem  Target build system. Can be one of:\n" );
@@ -86,7 +91,8 @@
 		project.ExecuteInvocations ();
 		Backend* backend = Backend::Factory::Create ( BuildSystem,
 		                                              project,
-		                                              Verbose );
+		                                              Verbose,
+		                                              CleanAsYouGo );
 		backend->Process ();
 		delete backend;