much better factory implementation - thanks art yerkes
[reactos.git] / reactos / tools / rbuild / rbuild.cpp
1 // rbuild.cpp
2
3 #include "pch.h"
4 #include <typeinfo>
5
6 #include <stdio.h>
7 #include <io.h>
8 #include <assert.h>
9
10 #include "rbuild.h"
11 #include "backend/backend.h"
12 #include "backend/mingw/mingw.h"
13
14 using std::string;
15 using std::vector;
16
17 int
18 main ( int argc, char** argv )
19 {
20 if ( argc != 2 )
21 {
22 printf ( "syntax: rbuild {buildtarget}\n" );
23 return 1;
24 }
25 string buildtarget ( argv[1] );
26 strlwr ( &buildtarget[0] );
27 try
28 {
29 string projectFilename ( "ReactOS.xml" );
30 Project project ( projectFilename );
31 Backend* backend = Backend::Factory::Create ( buildtarget, project );
32 backend->Process ();
33 delete backend;
34
35 // REM TODO FIXME actually do something with Project object...
36 #if 0
37 printf ( "Found %d modules:\n", project.modules.size() );
38 for ( size_t i = 0; i < project.modules.size(); i++ )
39 {
40 Module& m = *project.modules[i];
41 printf ( "\t%s in folder: %s\n",
42 m.name.c_str(),
43 m.path.c_str() );
44 printf ( "\txml dependencies:\n\t\t%s\n",
45 projectFilename.c_str() );
46 const XMLElement* e = &m.node;
47 while ( e )
48 {
49 if ( e->name == "xi:include" )
50 {
51 const XMLAttribute* att = e->GetAttribute("top_href",false);
52 if ( att )
53 {
54 printf ( "\t\t%s\n", att->value.c_str() );
55 }
56 }
57 e = e->parentElement;
58 }
59 printf ( "\tfiles:\n" );
60 for ( size_t j = 0; j < m.files.size(); j++ )
61 {
62 printf ( "\t\t%s\n", m.files[j]->name.c_str() );
63 }
64 }
65 #endif
66
67 return 0;
68 }
69 catch (Exception& ex)
70 {
71 printf ( "%s: %s\n",
72 typeid(ex).name(), ex.Message.c_str() );
73 return 1;
74 }
75 }