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",
66 ParseVCProjectSwitch ( char switchChar2
,
69 switch ( switchChar2
)
72 if ( strlen ( switchStart
) <= 3 )
74 printf ( "Switch -dm requires a module name\n" );
77 configuration
.VSProjectVersion
= string(&switchStart
[3]);
79 if (configuration
.VSProjectVersion
.at(0) == '{') {
80 printf ( "Error: invalid char {\n" );
84 if (configuration
.VSProjectVersion
.length() == 1) //7,8
85 configuration
.VSProjectVersion
.append(".00");
87 if (configuration
.VSProjectVersion
.length() == 3) //7.1
88 configuration
.VSProjectVersion
.append("0");
92 printf ( "Unknown switch -d%c\n",
100 ParseMakeSwitch ( char switchChar2
)
102 switch ( switchChar2
)
105 configuration
.MakeHandlesInstallDirectories
= true;
108 printf ( "Unknown switch -m%c\n",
116 ParseProxyMakefileSwitch ( char switchChar2
)
118 switch ( switchChar2
)
121 configuration
.GenerateProxyMakefilesInSourceTree
= true;
124 printf ( "Unknown switch -p%c\n",
132 ParseSwitch ( int argc
, char** argv
, int index
)
134 char switchChar
= strlen ( argv
[index
] ) > 1 ? argv
[index
][1] : ' ';
135 char switchChar2
= strlen ( argv
[index
] ) > 2 ? argv
[index
][2] : ' ';
136 switch ( switchChar
)
139 if (switchChar2
== 's')
140 return ParseVCProjectSwitch ( switchChar2
,
143 configuration
.Verbose
= true;
146 configuration
.CleanAsYouGo
= true;
149 return ParseAutomaticDependencySwitch ( switchChar2
,
152 RootXmlFile
= string(&argv
[index
][2]);
155 return ParseMakeSwitch ( switchChar2
);
157 return ParseProxyMakefileSwitch ( switchChar2
);
159 printf ( "Unknown switch -%c\n",
167 ParseArguments ( int argc
, char** argv
)
172 for ( int i
= 1; i
< argc
; i
++ )
174 if ( argv
[i
][0] == '-' )
176 if ( !ParseSwitch ( argc
, argv
, i
) )
180 BuildSystem
= argv
[i
];
187 main ( int argc
, char** argv
)
189 if ( !ParseArguments ( argc
, argv
) )
191 printf ( "Generates project files for buildsystems\n\n" );
192 printf ( " rbuild [switches] buildsystem\n\n" );
193 printf ( "Switches:\n" );
194 printf ( " -v Be verbose.\n" );
195 printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" );
196 printf ( " needed anymore.\n" );
197 printf ( " -dd Disable automatic dependencies.\n" );
198 printf ( " -dm{module} Check only automatic dependencies for this module.\n" );
199 printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" );
200 printf ( " -mi Let make handle creation of install directories. Rbuild will\n" );
201 printf ( " not generate the directories.\n" );
202 printf ( " -ps Generate proxy makefiles in source tree instead of the output.\n" );
203 printf ( " tree.\n" );
204 printf ( " -vs{version} Version of MS VS project files. Default is %s.\n", MS_VS_DEF_VERSION
);
206 printf ( " buildsystem Target build system. Can be one of:\n" );
207 printf ( " mingw MinGW\n" );
208 printf ( " devcpp DevC++\n" );
209 printf ( " msvc MS Visual Studio\n" );
214 string
projectFilename ( RootXmlFile
);
215 printf ( "Reading build files..." );
216 Project
project ( projectFilename
);
218 project
.WriteConfigurationFile ();
219 project
.ExecuteInvocations ();
220 Backend
* backend
= Backend::Factory::Create ( BuildSystem
,
228 catch (Exception
& ex
)
231 ex
.Message
.c_str () );