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 ParseCompilationUnitSwitch ( char switchChar2
,
68 switch ( switchChar2
)
71 configuration
.CompilationUnitsEnabled
= false;
74 printf ( "Unknown switch -u%c\n",
82 ParseVCProjectSwitch ( char switchChar2
,
85 switch ( switchChar2
)
88 if ( strlen ( switchStart
) <= 3 )
90 printf ( "Switch -dm requires a module name\n" );
93 configuration
.VSProjectVersion
= string(&switchStart
[3]);
95 if (configuration
.VSProjectVersion
.at(0) == '{') {
96 printf ( "Error: invalid char {\n" );
100 if (configuration
.VSProjectVersion
.length() == 1) //7,8
101 configuration
.VSProjectVersion
.append(".00");
103 if (configuration
.VSProjectVersion
.length() == 3) //7.1
104 configuration
.VSProjectVersion
.append("0");
108 printf ( "Unknown switch -d%c\n",
116 ParseMakeSwitch ( char switchChar2
)
118 switch ( switchChar2
)
121 configuration
.MakeHandlesInstallDirectories
= true;
124 printf ( "Unknown switch -m%c\n",
132 ParseProxyMakefileSwitch ( char switchChar2
)
134 switch ( switchChar2
)
137 configuration
.GenerateProxyMakefilesInSourceTree
= true;
140 printf ( "Unknown switch -p%c\n",
148 ParseSwitch ( int argc
, char** argv
, int index
)
150 char switchChar
= strlen ( argv
[index
] ) > 1 ? argv
[index
][1] : ' ';
151 char switchChar2
= strlen ( argv
[index
] ) > 2 ? argv
[index
][2] : ' ';
152 switch ( switchChar
)
155 if (switchChar2
== 's')
156 return ParseVCProjectSwitch ( switchChar2
,
159 configuration
.Verbose
= true;
162 configuration
.CleanAsYouGo
= true;
165 return ParseAutomaticDependencySwitch ( switchChar2
,
168 return ParseCompilationUnitSwitch ( switchChar2
,
171 RootXmlFile
= string(&argv
[index
][2]);
174 return ParseMakeSwitch ( switchChar2
);
176 return ParseProxyMakefileSwitch ( switchChar2
);
178 printf ( "Unknown switch -%c\n",
186 ParseArguments ( int argc
, char** argv
)
191 for ( int i
= 1; i
< argc
; i
++ )
193 if ( argv
[i
][0] == '-' )
195 if ( !ParseSwitch ( argc
, argv
, i
) )
199 BuildSystem
= argv
[i
];
206 main ( int argc
, char** argv
)
208 InitializeEnvironment ();
210 if ( !ParseArguments ( argc
, argv
) )
212 printf ( "Generates project files for buildsystems\n\n" );
213 printf ( " rbuild [switches] buildsystem\n\n" );
214 printf ( "Switches:\n" );
215 printf ( " -v Be verbose.\n" );
216 printf ( " -c Clean as you go. Delete generated files as soon as they are not\n" );
217 printf ( " needed anymore.\n" );
218 printf ( " -r{file.xml} Name of the root xml file. Default is ReactOS.xml.\n" );
219 printf ( " -dd Disable automatic dependencies.\n" );
220 printf ( " -dm{module} Check only automatic dependencies for this module.\n" );
221 printf ( " -ud Disable multiple source files per compilation unit.\n" );
222 printf ( " -mi Let make handle creation of install directories. Rbuild will\n" );
223 printf ( " not generate the directories.\n" );
224 printf ( " -ps Generate proxy makefiles in source tree instead of the output.\n" );
225 printf ( " tree.\n" );
226 printf ( " -vs{version} Version of MS VS project files. Default is %s.\n", MS_VS_DEF_VERSION
);
228 printf ( " buildsystem Target build system. Can be one of:\n" );
229 printf ( " mingw MinGW\n" );
230 printf ( " devcpp DevC++\n" );
231 printf ( " msvc MS Visual Studio\n" );
236 string
projectFilename ( RootXmlFile
);
237 printf ( "Reading build files..." );
238 Project
project ( configuration
, projectFilename
);
240 project
.WriteConfigurationFile ();
241 project
.ExecuteInvocations ();
242 Backend
* backend
= Backend::Factory::Create ( BuildSystem
,
250 catch (Exception
& ex
)
253 ex
.Message
.c_str () );