ENH: added help target and made custom commands execute in start output directory
This commit is contained in:
parent
db3d203893
commit
60bcce7fa2
|
@ -101,7 +101,7 @@ void cmGlobalUnixMakefileGenerator3::Generate()
|
|||
this->WriteMainCMakefile();
|
||||
|
||||
// now write the support Makefiles
|
||||
this->WriteBuildMakefile();
|
||||
//this->WriteBuildMakefile();
|
||||
this->WriteCleanMakefile();
|
||||
}
|
||||
|
||||
|
@ -167,6 +167,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile()
|
|||
this->WriteConvenienceRules(makefileStream,lg,exclude);
|
||||
}
|
||||
|
||||
this->WriteHelpRule(makefileStream);
|
||||
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
||||
lg->WriteSpecialTargetsBottom(makefileStream);
|
||||
}
|
||||
|
@ -667,3 +668,52 @@ cmGlobalUnixMakefileGenerator3
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
cmGlobalUnixMakefileGenerator3::WriteHelpRule(std::ostream& ruleFileStream)
|
||||
{
|
||||
cmLocalUnixMakefileGenerator3 *lg =
|
||||
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
||||
|
||||
// add the help target
|
||||
std::string path;
|
||||
std::vector<std::string> no_depends;
|
||||
std::vector<std::string> commands;
|
||||
lg->AppendEcho(commands,
|
||||
"The following are some of the valid targets for this Makefile:");
|
||||
lg->AppendEcho(commands,"... all (the default if no target is provided)");
|
||||
lg->AppendEcho(commands,"... clean");
|
||||
lg->AppendEcho(commands,"... depend");
|
||||
lg->AppendEcho(commands,"... install");
|
||||
lg->AppendEcho(commands,"... rebuild_cache");
|
||||
|
||||
// for each local generator
|
||||
unsigned int i;
|
||||
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
||||
{
|
||||
lg = static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
||||
|
||||
|
||||
// for each target Generate the rule files for each target.
|
||||
const cmTargets& targets = lg->GetMakefile()->GetTargets();
|
||||
for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t)
|
||||
{
|
||||
if((t->second.GetType() == cmTarget::EXECUTABLE) ||
|
||||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
|
||||
(t->second.GetType() == cmTarget::UTILITY))
|
||||
{
|
||||
path = "... ";
|
||||
path += t->second.GetName();
|
||||
lg->AppendEcho(commands,path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
lg->WriteMakeRule(ruleFileStream, "Help Target",
|
||||
"help:",
|
||||
no_depends, commands);
|
||||
ruleFileStream << "\n\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ protected:
|
|||
void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream);
|
||||
void WriteAllRules(cmLocalUnixMakefileGenerator3 *lg,
|
||||
std::ostream& makefileStream);
|
||||
|
||||
void WriteHelpRule(std::ostream& ruleFileStream);
|
||||
|
||||
void WriteConvenienceRules(std::ostream& ruleFileStream,
|
||||
cmLocalUnixMakefileGenerator3 *,
|
||||
bool exclude);
|
||||
|
|
|
@ -645,7 +645,10 @@ cmLocalUnixMakefileGenerator3
|
|||
temp = relativeObj;
|
||||
temp += ".provides.build";
|
||||
std::vector<std::string> r_commands;
|
||||
r_commands.push_back(this->GetRecursiveMakeCall("build.make",temp.c_str()));
|
||||
std::string tgtMakefileName = this->GetRelativeTargetDirectory(target);
|
||||
tgtMakefileName += "/build.make";
|
||||
r_commands.push_back(this->GetRecursiveMakeCall(tgtMakefileName.c_str(),
|
||||
temp.c_str()));
|
||||
p_depends.clear();
|
||||
p_depends.push_back(objectRequires);
|
||||
this->WriteMakeRule(ruleFileStream, 0,
|
||||
|
@ -2514,6 +2517,8 @@ cmLocalUnixMakefileGenerator3
|
|||
const cmCustomCommand& cc)
|
||||
{
|
||||
// TODO: Convert outputs/dependencies (arguments?) to relative paths.
|
||||
|
||||
std::vector<std::string> commands1;
|
||||
|
||||
// Add each command line to the set of commands.
|
||||
for(cmCustomCommandLines::const_iterator cl = cc.GetCommandLines().begin();
|
||||
|
@ -2523,7 +2528,7 @@ cmLocalUnixMakefileGenerator3
|
|||
const cmCustomCommandLine& commandLine = *cl;
|
||||
std::string cmd = commandLine[0];
|
||||
cmSystemTools::ReplaceString(cmd, "/./", "/");
|
||||
cmd = this->Convert(cmd.c_str(),HOME_OUTPUT);
|
||||
cmd = this->Convert(cmd.c_str(),START_OUTPUT);
|
||||
if(cmd.find("/") == cmd.npos &&
|
||||
commandLine[0].find("/") != cmd.npos)
|
||||
{
|
||||
|
@ -2536,6 +2541,45 @@ cmLocalUnixMakefileGenerator3
|
|||
cmd += " ";
|
||||
cmd += cmSystemTools::EscapeSpaces(commandLine[j].c_str());
|
||||
}
|
||||
|
||||
commands1.push_back(cmd);
|
||||
}
|
||||
|
||||
// stick this group of commands into a cd of the proper path
|
||||
// Build the jump-and-build command list.
|
||||
if(m_WindowsShell)
|
||||
{
|
||||
// On Windows we must perform each step separately and then jump
|
||||
// back because the shell keeps the working directory between
|
||||
// commands.
|
||||
std::string cmd = "cd ";
|
||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetStartOutputDirectory());
|
||||
commands.push_back(cmd);
|
||||
|
||||
// push back the custom commands
|
||||
commands.insert(commands.end(), commands1.begin(), commands1.end());
|
||||
|
||||
// Jump back to the home directory.
|
||||
cmd = "cd ";
|
||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetHomeOutputDirectory());
|
||||
commands.push_back(cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On UNIX we must construct a single shell command to jump and
|
||||
// build because make resets the directory between each command.
|
||||
std::string cmd = "cd ";
|
||||
cmd += this->ConvertToOutputForExisting(m_Makefile->GetStartOutputDirectory());
|
||||
|
||||
// add the commands
|
||||
unsigned int i;
|
||||
for (i = 0; i < commands1.size(); ++i)
|
||||
{
|
||||
cmd += " && ";
|
||||
cmd += commands1[i];
|
||||
}
|
||||
|
||||
// Add the command as a single line.
|
||||
commands.push_back(cmd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,6 +150,9 @@ public:
|
|||
void AppendGlobalTargetDepends(std::vector<std::string>& depends,
|
||||
const cmTarget& target);
|
||||
|
||||
void AppendEcho(std::vector<std::string>& commands,
|
||||
const char* text);
|
||||
|
||||
protected:
|
||||
|
||||
// write the target rules for the local Makefile into the stream
|
||||
|
@ -302,8 +305,6 @@ protected:
|
|||
const cmCustomCommand& cc);
|
||||
void AppendCleanCommand(std::vector<std::string>& commands,
|
||||
const std::vector<std::string>& files);
|
||||
void AppendEcho(std::vector<std::string>& commands,
|
||||
const char* text);
|
||||
|
||||
//==========================================================================
|
||||
bool SamePath(const char* path1, const char* path2);
|
||||
|
|
Loading…
Reference in New Issue