2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #include "backend/backend.h"
29 #include "backend/mingw/mingw.h"
34 static string BuildSystem
;
35 static string RootXmlFile
= "ReactOS.xml";
36 static Configuration configuration
;
39 ParseAutomaticDependencySwitch ( char switchChar2
,
42 switch ( switchChar2
)
45 configuration
.AutomaticDependencies
= false;
48 if ( strlen ( switchStart
) <= 3 )
50 printf ( "Switch -dm requires a module name\n" );
53 configuration
.CheckDependenciesForModuleOnly
= true;
54 configuration
.CheckDependenciesForModuleOnlyModule
= string(&switchStart
[3]);
57 printf ( "Unknown switch -d%c\n",
65 ParseMakeSwitch ( char switchChar2
)
67 switch ( switchChar2
)
70 configuration
.MakeHandlesInstallDirectories
= true;
73 printf ( "Unknown switch -m%c\n",
81 ParseProxyMakefileSwitch ( char switchChar2
)
83 switch ( switchChar2
)
86 configuration
.GenerateProxyMakefilesInSourceTree
= true;
89 printf ( "Unknown switch -p%c\n",
97 ParseSwitch ( int argc
, char** argv
, int index
)
99 char switchChar
= strlen ( argv
[index
] ) > 1 ? argv
[index
][1] : ' ';
100 char switchChar2
= strlen ( argv
[index
] ) > 2 ? argv
[index
][2] : ' ';
101 switch ( switchChar
)
104 configuration
.Verbose
= true;
107 configuration
.CleanAsYouGo
= true;
110 return ParseAutomaticDependencySwitch ( switchChar2
,
113 RootXmlFile
= string(&argv
[index
][2]);
116 return ParseMakeSwitch ( switchChar2
);
118 return ParseProxyMakefileSwitch ( switchChar2
);
120 printf ( "Unknown switch -%c\n",
128 ParseArguments ( int argc
, char** argv
)
133 for ( int i
= 1; i
< argc
; i
++ )
135 if ( argv
[i
][0] == '-' )
137 if ( !ParseSwitch ( argc
, argv
, i
) )
141 BuildSystem
= argv
[i
];
148 main ( int argc
, char** argv
)
150 if ( !ParseArguments ( argc
, argv
) )
152 printf ( "Generates project files for buildsystems\n\n" );
153 printf ( " rbuild [switches] buildsystem\n" );
154 printf ( " rbuild msvc\n" );
155 printf ( "Switches:\n" );
156 printf ( " -v Be verbose.\n" );
157 printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" );
158 printf ( " needed anymore.\n" );
159 printf ( " -dd Disable automatic dependencies.\n" );
160 printf ( " -dm{module} Check only automatic dependencies for this module.\n" );
161 printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" );
162 printf ( " -mi Let make handle creation of install directories. Rbuild will\n" );
163 printf ( " not generate the directories.\n" );
164 printf ( " -ps Generate proxy makefiles in source tree instead of the output.\n" );
165 printf ( " tree.\n" );
167 printf ( " buildsystem Target build system. Can be one of:\n" );
168 printf ( " mingw MinGW\n" );
169 printf ( " devcpp DevC++\n\n" );
170 printf ( " msvc Generates dsp files for MSVC" );
175 string
projectFilename ( RootXmlFile
);
176 printf ( "Reading build files..." );
177 Project
project ( projectFilename
);
179 project
.WriteConfigurationFile ();
180 project
.ExecuteInvocations ();
181 Backend
* backend
= Backend::Factory::Create ( BuildSystem
,
189 catch (Exception
& ex
)
192 ex
.Message
.c_str () );