beginnings of makefile output
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-01-05 19:01:27 UTC (rev 12825)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/project.cpp	2005-01-05 19:02:00 UTC (rev 12826)
@@ -6,6 +6,36 @@
 using std::string;
 using std::vector;
 
+#ifdef WIN32
+#define EXEPOSTFIX ".exe"
+#define SEP "\\"
+string FixSep ( const string& s )
+{
+	string s2(s);
+	char* p = strchr ( &s2[0], '/' );
+	while ( p )
+	{
+		*p++ = '\\';
+		p = strchr ( p, '/' );
+	}
+	return s2;
+}
+#else
+#define EXEPOSTFIX
+#define SEP "/"
+string FixSep ( const string& s )
+{
+	string s2(s);
+	char* p = strchr ( &s2[0], '\\' );
+	while ( p )
+	{
+		*p++ = '/';
+		p = strchr ( p, '\\' );
+	}
+	return s2;
+}
+#endif
+
 Project::Project()
 {
 }
@@ -21,28 +51,24 @@
 {
 	for ( size_t i = 0; i < modules.size(); i++ )
 		delete modules[i];
+	delete head;
 }
 
 void Project::ReadXml()
 {
 	Path path;
-	bool projectFound = false;
-	do
+
+	head = XMLParse ( xmlfile, path );
+	if ( !head )
+		throw InvalidBuildFileException ( "Document contains no 'project' tag." );
+
+	if ( head->name != "project" )
 	{
-		XMLElement* head = XMLParse ( xmlfile, path );
-		if ( !head )
-			throw InvalidBuildFileException ( "Document contains no 'project' tag." );
+		throw InvalidBuildFileException ( "Expected 'project', got '%s'.",
+			                              head->name.c_str());
+	}
 
-		if ( head->name != "project" )
-		{
-			throw InvalidBuildFileException ( "Expected 'project', got '%s'.",
-			                                  head->name.c_str());
-		}
-
-		this->ProcessXML ( *head, "." );
-		delete head;
-		projectFound = true;
-	} while (!projectFound);
+	this->ProcessXML ( *head, "." );
 }
 
 void
@@ -79,3 +105,32 @@
 	for ( size_t i = 0; i < e.subElements.size(); i++ )
 		ProcessXML ( *e.subElements[i], subpath );
 }
+
+bool
+Project::GenerateOutput()
+{
+	const XMLAttribute* att;
+	size_t i;
+
+	att = head->GetAttribute ( "makefile", true );
+	if ( !att )
+		return false;
+	FILE* f = fopen ( att->value.c_str(), "w" );
+	if ( !f )
+	{
+		throw Exception ( "Unable to open '%s' for output", att->value.c_str() );
+		return false;
+	}
+	fprintf ( f, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
+
+	// generate module list:
+	fprintf ( f, "all: " );
+	for ( i = 0; i < modules.size(); i++ )
+	{
+		Module& m = *modules[i];
+		fprintf ( f, " %s" SEP "%s" EXEPOSTFIX, FixSep(m.path).c_str(), m.name.c_str() );
+	}
+	fprintf ( f, "\n\n" );
+
+	return true;
+}

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-01-05 19:01:27 UTC (rev 12825)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.cpp	2005-01-05 19:02:00 UTC (rev 12826)
@@ -1,6 +1,7 @@
 // rbuild.cpp
 
 #include "pch.h"
+#include <typeinfo>
 
 #include <stdio.h>
 #include <io.h>
@@ -17,14 +18,15 @@
 	try
 	{
 		string projectFilename ( "ReactOS.xml" );
-		Project* project = new Project( projectFilename );
+		Project project ( projectFilename );
+		project.GenerateOutput();
 
-		Path path;
 		// REM TODO FIXME actually do something with Project object...
-		printf ( "Found %d modules:\n", project->modules.size() );
-		for ( size_t i = 0; i < project->modules.size(); i++ )
+#if 0
+		printf ( "Found %d modules:\n", project.modules.size() );
+		for ( size_t i = 0; i < project.modules.size(); i++ )
 		{
-			Module& m = *project->modules[i];
+			Module& m = *project.modules[i];
 			printf ( "\t%s in folder: %s\n",
 			         m.name.c_str(),
 			         m.path.c_str() );
@@ -49,15 +51,14 @@
 				printf ( "\t\t%s\n", m.files[j]->name.c_str() );
 			}
 		}
-	
-		delete project;
+#endif
 
 		return 0;
 	}
 	catch (Exception& ex)
 	{
-		printf ( "%s\n",
-		         ex.Message.c_str() );
+		printf ( "%s: %s\n",
+		         typeid(ex).name(), ex.Message.c_str() );
 		return 1;
 	}
 }

Modified: branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h
--- branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-05 19:01:27 UTC (rev 12825)
+++ branches/xmlbuildsystem/reactos/tools/rbuild/rbuild.h	2005-01-05 19:02:00 UTC (rev 12826)
@@ -21,9 +21,11 @@
 	Project ( const std::string& filename );
 	~Project ();
 	void ProcessXML ( const XMLElement& e, const std::string& path );
+	bool GenerateOutput();
 private:
 	void ReadXml ();
 	XMLFile xmlfile;
+	XMLElement* head;
 };
 
 class Module