Factories for Backend creation
[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 Backend::InitFactories();
21 if ( argc != 2 )
22 {
23 printf ( "syntax: rbuild {buildtarget}\n" );
24 return 1;
25 }
26 string buildtarget ( argv[1] );
27 strlwr ( &buildtarget[0] );
28 try
29 {
30 string projectFilename ( "ReactOS.xml" );
31 Project project ( projectFilename );
32 Backend* backend = Backend::Create ( buildtarget, project );
33 backend->Process ();
34 delete backend;
35
36 // REM TODO FIXME actually do something with Project object...
37 #if 0
38 printf ( "Found %d modules:\n", project.modules.size() );
39 for ( size_t i = 0; i < project.modules.size(); i++ )
40 {
41 Module& m = *project.modules[i];
42 printf ( "\t%s in folder: %s\n",
43 m.name.c_str(),
44 m.path.c_str() );
45 printf ( "\txml dependencies:\n\t\t%s\n",
46 projectFilename.c_str() );
47 const XMLElement* e = &m.node;
48 while ( e )
49 {
50 if ( e->name == "xi:include" )
51 {
52 const XMLAttribute* att = e->GetAttribute("top_href",false);
53 if ( att )
54 {
55 printf ( "\t\t%s\n", att->value.c_str() );
56 }
57 }
58 e = e->parentElement;
59 }
60 printf ( "\tfiles:\n" );
61 for ( size_t j = 0; j < m.files.size(); j++ )
62 {
63 printf ( "\t\t%s\n", m.files[j]->name.c_str() );
64 }
65 }
66 #endif
67
68 return 0;
69 }
70 catch (Exception& ex)
71 {
72 printf ( "%s: %s\n",
73 typeid(ex).name(), ex.Message.c_str() );
74 return 1;
75 }
76 }