ENH: Start working on command that will abstract generating of build command

This commit is contained in:
Andy Cedilnik 2005-04-28 18:34:58 -04:00
parent cb3ea2328a
commit 064ca3834b
2 changed files with 20 additions and 37 deletions

View File

@ -51,42 +51,39 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
int cmGlobalXCodeGenerator::Build( std::string cmGlobalXCodeGenerator::GenerateBuildCommand(const char* makeProgram,
const char *, const char *projectName, const char *targetName, const char* config)
const char *bindir,
const char *projectName,
const char *targetName,
std::string *output,
const char *makeCommandCSTR,
const char *,
bool clean)
{ {
// now build the test // now build the test
if(makeCommandCSTR == 0 || !strlen(makeCommandCSTR)) if(makeProgram == 0 || !strlen(makeProgram))
{ {
cmSystemTools::Error( cmSystemTools::Error(
"Generator cannot find the appropriate make command."); "Generator cannot find the appropriate make command.");
return 1; return "";
} }
std::string makeCommand = std::string makeCommand =
cmSystemTools::ConvertToOutputPath(makeCommandCSTR); cmSystemTools::ConvertToOutputPath(makeProgram);
std::string lowerCaseCommand = makeCommand; std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand); cmSystemTools::LowerCase(lowerCaseCommand);
/**
* Run an executable command and put the stdout in output.
*/
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(bindir);
makeCommand += " -project "; makeCommand += " -project ";
makeCommand += projectName; makeCommand += projectName;
makeCommand += ".xcode"; makeCommand += ".xcode";
bool clean = false;
if ( targetName && strcmp(targetName, "clean") == 0 )
{
clean = true;
targetName = "ALL_BUILD";
}
if(clean) if(clean)
{ {
makeCommand += " clean "; makeCommand += " clean";
} }
makeCommand += " build -target "; else
{
makeCommand += " build";
}
makeCommand += " -target ";
if (targetName && strlen(targetName)) if (targetName && strlen(targetName))
{ {
makeCommand += targetName; makeCommand += targetName;
@ -96,18 +93,7 @@ int cmGlobalXCodeGenerator::Build(
makeCommand += "ALL_BUILD"; makeCommand += "ALL_BUILD";
} }
makeCommand += " -buildstyle Development "; makeCommand += " -buildstyle Development ";
int retVal; return makeCommand;
int timeout = cmGlobalGenerator::s_TryCompileTimeout;
if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, &retVal,
0, false, timeout))
{
cmSystemTools::Error("Generator: execution of xcodebuild failed.");
// return to the original directory
cmSystemTools::ChangeDirectory(cwd.c_str());
return 1;
}
cmSystemTools::ChangeDirectory(cwd.c_str());
return retVal;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------

View File

@ -57,11 +57,8 @@ public:
* Try running cmake and building a file. This is used for dynalically * Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process. * loaded commands, not as part of the usual build process.
*/ */
virtual int Build(const char *srcdir, const char *bindir, virtual std::string GenerateBuildCommand(const char* makeProgram,
const char *projectName, const char *targetName, const char *projectName, const char *targetName, const char* config);
std::string *output,
const char *makeProgram,
const char *config, bool clean);
/** /**
* Generate the all required files for building this project/tree. This * Generate the all required files for building this project/tree. This