create only the project files specified on cmdline
[reactos.git] / reactos / tools / rbuild / rbuild.cpp
index 6502145..377e6f5 100644 (file)
@@ -1,5 +1,20 @@
-// rbuild.cpp
-
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
 #include "pch.h"
 #include <typeinfo>
 
@@ -20,26 +35,128 @@ static string BuildSystem;
 static string RootXmlFile = "ReactOS.xml";
 static Configuration configuration;
 
+bool
+ParseAutomaticDependencySwitch ( char switchChar2,
+                                    char* switchStart )
+{
+       switch ( switchChar2 )
+       {
+               case 'd':
+                       configuration.AutomaticDependencies = false;
+                       break;
+               case 'm':
+                       if ( strlen ( switchStart ) <= 3 )
+                       {
+                               printf ( "Switch -dm requires a module name\n" );
+                               return false;
+                       }
+                       configuration.CheckDependenciesForModuleOnly = true;
+                       configuration.CheckDependenciesForModuleOnlyModule = string(&switchStart[3]);
+                       break;
+               default:
+                       printf ( "Unknown switch -d%c\n",
+                                switchChar2 );
+                       return false;
+       }
+       return true;
+}
+
+
+bool
+ParseVCProjectSwitch ( char switchChar2,
+                      char* switchStart )
+{
+       switch ( switchChar2 )
+       {
+               case 's':
+                       if ( strlen ( switchStart ) <= 3 )
+                       {
+                               printf ( "Switch -dm requires a module name\n" );
+                               return false;
+                       }
+                       configuration.VSProjectVersion = string(&switchStart[3]);
+
+                       if (configuration.VSProjectVersion.at(0) == '{') {
+                               printf ( "Error: invalid char {\n" );
+                               return false;
+                       }
+
+                       if (configuration.VSProjectVersion.length() == 1) //7,8
+                               configuration.VSProjectVersion.append(".00");
+
+                       if (configuration.VSProjectVersion.length() == 3) //7.1
+                               configuration.VSProjectVersion.append("0");
+
+                       break;
+               default:
+                       printf ( "Unknown switch -d%c\n",
+                                switchChar2 );
+                       return false;
+       }
+       return true;
+}
+
+bool
+ParseMakeSwitch ( char switchChar2 )
+{
+       switch ( switchChar2 )
+       {
+               case 'i':
+                       configuration.MakeHandlesInstallDirectories = true;
+                       break;
+               default:
+                       printf ( "Unknown switch -m%c\n",
+                                switchChar2 );
+                       return false;
+       }
+       return true;
+}
+
+bool
+ParseProxyMakefileSwitch ( char switchChar2 )
+{
+       switch ( switchChar2 )
+       {
+               case 's':
+                       configuration.GenerateProxyMakefilesInSourceTree = true;
+                       break;
+               default:
+                       printf ( "Unknown switch -p%c\n",
+                                switchChar2 );
+                       return false;
+       }
+       return true;
+}
+
 bool
 ParseSwitch ( int argc, char** argv, int index )
 {
-       char switchChar = argv[index][1];
+       char switchChar = strlen ( argv[index] ) > 1 ? argv[index][1] : ' ';
+       char switchChar2 = strlen ( argv[index] ) > 2 ? argv[index][2] : ' ';
        switch ( switchChar )
        {
                case 'v':
-                       configuration.Verbose = true;
+                       if (switchChar2 == 's')
+                               return ParseVCProjectSwitch ( switchChar2,
+                                                             argv[index] );
+                       else
+                               configuration.Verbose = true;
                        break;
                case 'c':
                        configuration.CleanAsYouGo = true;
                        break;
                case 'd':
-                       configuration.AutomaticDependencies = false;
-                       break;
+                       return ParseAutomaticDependencySwitch ( switchChar2,
+                                                               argv[index] );
                case 'r':
                        RootXmlFile = string(&argv[index][2]);
                        break;
+               case 'm':
+                       return ParseMakeSwitch ( switchChar2 );
+               case 'p':
+                       return ParseProxyMakefileSwitch ( switchChar2 );
                default:
-                       printf ( "Unknown switch -%c",
+                       printf ( "Unknown switch -%c\n",
                                 switchChar );
                        return false;
        }
@@ -72,16 +189,24 @@ main ( int argc, char** argv )
        if ( !ParseArguments ( argc, argv ) )
        {
                printf ( "Generates project files for buildsystems\n\n" );
-               printf ( "  rbuild [-v] [-rfile.xml] buildsystem\n\n" );
+               printf ( "  rbuild [switches] buildsystem\n\n" );
                printf ( "Switches:\n" );
-               printf ( "  -v           Be verbose\n" );
-               printf ( "  -c           Clean as you go. Delete generated files as soon as they are not needed anymore\n" );
-               printf ( "  -d           Disable automatic dependencies.\n" );
-               printf ( "  -rfile.xml   Name of the root xml file. Default is ReactOS.xml\n" );
+               printf ( "  -v            Be verbose.\n" );
+               printf ( "  -c            Clean as you go. Delete generated files as soon as they are not\n" );
+               printf ( "                needed anymore.\n" );
+               printf ( "  -dd           Disable automatic dependencies.\n" );
+               printf ( "  -dm{module}   Check only automatic dependencies for this module.\n" );
+               printf ( "  -r{file.xml}  Name of the root xml file. Default is ReactOS.xml.\n" );
+               printf ( "  -mi           Let make handle creation of install directories. Rbuild will\n" );
+               printf ( "                not generate the directories.\n" );
+               printf ( "  -ps           Generate proxy makefiles in source tree instead of the output.\n" );
+               printf ( "                tree.\n" );
+               printf ( "  -vs{version}  Version of MS VS project files. Default is %s.\n", MS_VS_DEF_VERSION );
                printf ( "\n" );
-               printf ( "  buildsystem  Target build system. Can be one of:\n" );
+               printf ( "  buildsystem   Target build system. Can be one of:\n" );
                printf ( "                 mingw   MinGW\n" );
                printf ( "                 devcpp  DevC++\n" );
+               printf ( "                 msvc    MS Visual Studio\n" );
                return 1;
        }
        try