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 (
43 switch ( switchChar2
)
46 configuration
.AutomaticDependencies
= false;
49 if ( strlen ( switchStart
) <= 3 )
51 printf ( "Switch -dm requires a module name\n" );
54 configuration
.CheckDependenciesForModuleOnly
= true;
55 configuration
.CheckDependenciesForModuleOnlyModule
= string(&switchStart
[3]);
58 printf ( "Unknown switch -d%c\n",
66 ParseCompilationUnitSwitch (
70 switch ( switchChar2
)
73 configuration
.CompilationUnitsEnabled
= false;
76 printf ( "Unknown switch -u%c\n",
84 ParseVCProjectSwitch (
88 switch ( switchChar2
)
91 if ( strlen ( switchStart
) <= 3 )
93 printf ( "Switch -dm requires a module name\n" );
96 configuration
.VSProjectVersion
= string(&switchStart
[3]);
98 if (configuration
.VSProjectVersion
.at(0) == '{') {
99 printf ( "Error: invalid char {\n" );
103 if (configuration
.VSProjectVersion
.length() == 1) //7,8
104 configuration
.VSProjectVersion
.append(".00");
106 if (configuration
.VSProjectVersion
.length() == 3) //7.1
107 configuration
.VSProjectVersion
.append("0");
111 printf ( "Unknown switch -d%c\n",
119 ParseMakeSwitch ( char switchChar2
)
121 switch ( switchChar2
)
124 configuration
.MakeHandlesInstallDirectories
= true;
127 printf ( "Unknown switch -m%c\n",
135 ParseProxyMakefileSwitch ( char switchChar2
)
137 switch ( switchChar2
)
140 configuration
.GenerateProxyMakefilesInSourceTree
= true;
143 printf ( "Unknown switch -p%c\n",
151 ParseSwitch ( int argc
, char** argv
, int index
)
153 char switchChar
= strlen ( argv
[index
] ) > 1 ? argv
[index
][1] : ' ';
154 char switchChar2
= strlen ( argv
[index
] ) > 2 ? argv
[index
][2] : ' ';
155 switch ( switchChar
)
158 if (switchChar2
== 's')
160 return ParseVCProjectSwitch (
165 configuration
.Verbose
= true;
168 configuration
.CleanAsYouGo
= true;
171 return ParseAutomaticDependencySwitch (
175 return ParseCompilationUnitSwitch (
179 RootXmlFile
= string(&argv
[index
][2]);
182 return ParseMakeSwitch ( switchChar2
);
184 return ParseProxyMakefileSwitch ( switchChar2
);
187 "Unknown switch -%c\n",
195 ParseArguments ( int argc
, char** argv
)
200 for ( int i
= 1; i
< argc
; i
++ )
202 if ( argv
[i
][0] == '-' )
204 if ( !ParseSwitch ( argc
, argv
, i
) )
208 BuildSystem
= argv
[i
];
215 main ( int argc
, char** argv
)
217 InitializeEnvironment ();
219 if ( !ParseArguments ( argc
, argv
) )
221 printf ( "Generates project files for buildsystems\n\n" );
222 printf ( " rbuild [switches] buildsystem\n\n" );
223 printf ( "Switches:\n" );
224 printf ( " -v Be verbose.\n" );
225 printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" );
226 printf ( " needed anymore.\n" );
227 printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" );
228 printf ( " -dd Disable automatic dependencies.\n" );
229 printf ( " -dm{module} Check only automatic dependencies for this module.\n" );
230 printf ( " -ud Disable multiple source files per compilation unit.\n" );
231 printf ( " -mi Let make handle creation of install directories. Rbuild will\n" );
232 printf ( " not generate the directories.\n" );
233 printf ( " -ps Generate proxy makefiles in source tree instead of the output.\n" );
234 printf ( " tree.\n" );
235 printf ( " -vs{version} Version of MS VS project files. Default is %s.\n", MS_VS_DEF_VERSION
);
237 printf ( " buildsystem Target build system. Can be one of:\n" );
238 printf ( " mingw MinGW\n" );
239 printf ( " devcpp DevC++\n" );
240 printf ( " msvc MS Visual Studio\n" );
245 string
projectFilename ( RootXmlFile
);
247 printf ( "Reading build files..." );
248 Project
project ( configuration
, projectFilename
);
251 project
.SetBackend ( Backend::Factory::Create (
256 project
.WriteConfigurationFile ();
257 project
.ExecuteInvocations ();
258 project
.GetBackend().Process();
262 catch ( Exception
& ex
)
264 printf ( "%s\n", (*ex
).c_str () );
267 catch ( XMLException
& ex
)
269 printf ( "%s\n", (*ex
).c_str () );