[Cmake-commits] [cmake-commits] hoffman committed cmGlobalGenerator.cxx 1.244 1.245 cmGlobalGenerator.h 1.115 1.116 cmProjectCommand.cxx 1.25 1.26 cmake.cxx 1.398 1.399 cmake.h 1.117 1.118 cmakemain.cxx 1.86 1.87
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Oct 15 13:56:09 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv20763/Source
Modified Files:
cmGlobalGenerator.cxx cmGlobalGenerator.h cmProjectCommand.cxx
cmake.cxx cmake.h cmakemain.cxx
Log Message:
BUG: 4244, add a --build option to cmake that can build projects configured by CMake
Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -C 2 -d -r1.117 -r1.118
*** cmake.h 4 Sep 2008 21:34:24 -0000 1.117
--- cmake.h 15 Oct 2008 17:56:06 -0000 1.118
***************
*** 357,361 ****
--- 357,368 ----
void IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace);
+ // * run the --build option
+ static int DoBuild(int ac, char* av[]);
protected:
+ int Build(const std::string& dir,
+ const std::string& target,
+ const std::string& config,
+ const std::string& extraBuildOptions,
+ bool clean);
void InitializeProperties();
int HandleDeleteCacheVariables(const char* var);
Index: cmGlobalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -C 2 -d -r1.115 -r1.116
*** cmGlobalGenerator.h 1 Oct 2008 13:50:11 -0000 1.115
--- cmGlobalGenerator.h 15 Oct 2008 17:56:06 -0000 1.116
***************
*** 106,116 ****
const char *makeProgram, const char *config,
bool clean, bool fast,
! double timeout);
! virtual std::string GenerateBuildCommand
! (const char* makeProgram,
! const char *projectName, const char* additionalOptions,
! const char *targetName,
! const char* config, bool ignoreErrors, bool fast);
!
///! Set the CMake instance
--- 106,118 ----
const char *makeProgram, const char *config,
bool clean, bool fast,
! double timeout, bool verbose=false,
! const char* extraOptions = 0);
!
! virtual std::string GenerateBuildCommand(
! const char* makeProgram,
! const char *projectName, const char* additionalOptions,
! const char *targetName,
! const char* config, bool ignoreErrors, bool fast);
!
///! Set the CMake instance
Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.244
retrieving revision 1.245
diff -C 2 -d -r1.244 -r1.245
*** cmGlobalGenerator.cxx 1 Oct 2008 16:45:49 -0000 1.244
--- cmGlobalGenerator.cxx 15 Oct 2008 17:56:06 -0000 1.245
***************
*** 1118,1122 ****
const char *config,
bool clean, bool fast,
! double timeout)
{
/**
--- 1118,1124 ----
const char *config,
bool clean, bool fast,
! double timeout,
! bool verbose,
! const char* extraOptions)
{
/**
***************
*** 1156,1160 ****
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
! &retVal, 0, false, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
--- 1158,1162 ----
if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr,
! &retVal, 0, verbose, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
***************
*** 1179,1183 ****
std::string makeCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName,
! 0, target, config, false, fast);
if(output)
{
--- 1181,1186 ----
std::string makeCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName,
! extraOptions, target,
! config, false, fast);
if(output)
{
***************
*** 1188,1192 ****
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), outputPtr,
! &retVal, 0, false, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
--- 1191,1195 ----
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), outputPtr,
! &retVal, 0, verbose, timeout))
{
cmSystemTools::SetRunCommandHideConsole(hideconsole);
Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.398
retrieving revision 1.399
diff -C 2 -d -r1.398 -r1.399
*** cmake.cxx 1 Oct 2008 20:16:43 -0000 1.398
--- cmake.cxx 15 Oct 2008 17:56:06 -0000 1.399
***************
*** 37,40 ****
--- 37,41 ----
#endif
+ #include <cmsys/CommandLineArguments.hxx>
#include <cmsys/Directory.hxx>
#include <cmsys/Process.h>
***************
*** 948,952 ****
<< "cmake bootstrap\n";
#endif
!
errorStream
<< "Usage: " << program << " -E [command] [arguments ...]\n"
--- 949,954 ----
<< "cmake bootstrap\n";
#endif
! // If you add new commands, change here,
! // and in cmakemain.cxx in the options table
errorStream
<< "Usage: " << program << " -E [command] [arguments ...]\n"
***************
*** 974,977 ****
--- 976,980 ----
<< " touch file - touch a file.\n"
<< " touch_nocreate file - touch a file but do not create it.\n"
+ << " build build_dir - build the project in build_dir.\n"
#if defined(_WIN32) && !defined(__CYGWIN__)
<< " write_regv key value - write registry value\n"
***************
*** 988,991 ****
--- 991,995 ----
int cmake::ExecuteCMakeCommand(std::vector<std::string>& args)
{
+ // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
if (args.size() > 1)
{
***************
*** 1189,1193 ****
return ret;
}
-
// Command to calculate the md5sum of a file
else if (args[1] == "md5sum" && args.size() >= 3)
--- 1193,1196 ----
***************
*** 4330,4331 ****
--- 4333,4417 ----
return this->DebugConfigs;
}
+
+
+ int cmake::Build(const std::string& dir,
+ const std::string& target,
+ const std::string& config,
+ const std::string& extraBuildOptions,
+ bool clean)
+ {
+ if(!cmSystemTools::FileIsDirectory(dir.c_str()))
+ {
+ std::cerr << "Error: " << dir << " is not a directory\n";
+ return 1;
+ }
+ std::string cachePath = dir;
+ cmSystemTools::ConvertToUnixSlashes(cachePath);
+ cmCacheManager* cachem = this->GetCacheManager();
+ cmCacheManager::CacheIterator it = cachem->NewIterator();
+ if(!cachem->LoadCache(cachePath.c_str()))
+ {
+ std::cerr << "Error: could not load cache\n";
+ return 1;
+ }
+ if(!it.Find("CMAKE_GENERATOR"))
+ {
+ std::cerr << "Error: could find generator in Cache\n";
+ return 1;
+ }
+ cmGlobalGenerator* gen =
+ this->CreateGlobalGenerator(it.GetValue());
+ std::string output;
+ std::string projName;
+ std::string makeProgram;
+ if(!it.Find("CMAKE_PROJECT_NAME"))
+ {
+ std::cerr << "Error: could not find CMAKE_PROJECT_NAME in Cache\n";
+ return 1;
+ }
+ projName = it.GetValue();
+ if(!it.Find("CMAKE_MAKE_PROGRAM"))
+ {
+ std::cerr << "Error: could not find CMAKE_MAKE_PROGRAM in Cache\n";
+ return 1;
+ }
+ makeProgram = it.GetValue();
+ return gen->Build(0, dir.c_str(),
+ projName.c_str(), target.c_str(),
+ &output,
+ makeProgram.c_str(),
+ config.c_str(), clean, false, 0, true);
+ }
+
+ int cmake::DoBuild(int ac, char* av[])
+ {
+ std::string target;
+ std::string config = "Debug";
+ std::string extraBuildOptions;
+ std::string dir;
+ bool clean = false;
+ cmsys::CommandLineArguments arg;
+ arg.Initialize(ac, av);
+ typedef cmsys::CommandLineArguments argT;
+ arg.AddArgument("--build", argT::SPACE_ARGUMENT, &dir,
+ "Build a configured cmake project --build dir.");
+ arg.AddArgument("--target", argT::SPACE_ARGUMENT, &target,
+ "Specifiy the target to build,"
+ " if missing, all targets are built.");
+ arg.AddArgument("--config", argT::SPACE_ARGUMENT, &config,
+ "Specify configuration to build"
+ " if missing Debug is built.");
+ arg.AddArgument("--extra-options", argT::SPACE_ARGUMENT, &extraBuildOptions,
+ "Specify extra options to pass to build program,"
+ " for example with gmake -jN.");
+ arg.AddArgument("--clean", argT::NO_ARGUMENT, &clean,
+ "Clean before building.");
+ if ( !arg.Parse() )
+ {
+ std::cerr << "Problem parsing --build arguments:\n";
+ std::cerr << arg.GetHelp() << "\n";
+ return 1;
+ }
+ cmake cm;
+ return cm.Build(dir, target, config, extraBuildOptions, clean);
+ }
Index: cmakemain.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmakemain.cxx,v
retrieving revision 1.86
retrieving revision 1.87
diff -C 2 -d -r1.86 -r1.87
*** cmakemain.cxx 10 Oct 2008 14:20:49 -0000 1.86
--- cmakemain.cxx 15 Oct 2008 17:56:06 -0000 1.87
***************
*** 86,89 ****
--- 86,94 ----
"advanced variables. If H is specified, it will also display help for "
"each variable."},
+ {"--build dir", "Build a configured cmake tree found in dir.",
+ "This option will use the native build tool from the command line to"
+ " build the project. Other options that can be specified with this one"
+ " are --target, --config, --extra-options, and --clean. For complete "
+ "help run --build with no options."},
{"-N", "View mode only.",
"Only load the cache. Do not actually run configure and generate steps."},
***************
*** 408,411 ****
--- 413,417 ----
bool view_only = false;
bool script_mode = false;
+ bool build = false;
std::vector<std::string> args;
for(int i =0; i < ac; ++i)
***************
*** 415,418 ****
--- 421,428 ----
wiz = true;
}
+ else if(!command && strcmp(av[i], "--build") == 0)
+ {
+ return cmake::DoBuild(ac, av);
+ }
else if(!command && strcmp(av[i], "--system-information") == 0)
{
***************
*** 466,469 ****
--- 476,484 ----
}
}
+ if(build)
+ {
+ int ret = cmake::DoBuild(ac, av);
+ return ret;
+ }
if(command)
{
Index: cmProjectCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmProjectCommand.cxx,v
retrieving revision 1.25
retrieving revision 1.26
diff -C 2 -d -r1.25 -r1.26
*** cmProjectCommand.cxx 23 Jan 2008 15:27:59 -0000 1.25
--- cmProjectCommand.cxx 15 Oct 2008 17:56:06 -0000 1.26
***************
*** 58,61 ****
--- 58,65 ----
{
this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str());
+ this->Makefile->AddCacheDefinition
+ ("CMAKE_PROJECT_NAME",
+ args[0].c_str(),
+ "Value Computed by CMake", cmCacheManager::STATIC);
}
More information about the Cmake-commits
mailing list