added outputEcho method and fixed make help for nmake and borland

This commit is contained in:
Ken Martin 2003-08-05 08:49:23 -04:00
parent c17220091c
commit e8d1ee2712
2 changed files with 52 additions and 35 deletions

View File

@ -367,20 +367,42 @@ std::string cmLocalUnixMakefileGenerator::GetFullTargetName(const char* n,
return name; return name;
} }
// Output the rules for any targets
void cmLocalUnixMakefileGenerator::OutputEcho(std::ostream& fout,
const char *msg)
{
std::string echostring = msg;
// for unix we want to quote the output of echo
// for nmake and borland, the echo should not be quoted
if(strcmp(m_GlobalGenerator->GetName(), "Unix Makefiles") == 0)
{
cmSystemTools::ReplaceString(echostring, "\\\n", " ");
cmSystemTools::ReplaceString(echostring, " \t", " ");
cmSystemTools::ReplaceString(echostring, "\n\t", "\"\n\t@echo \"");
fout << "\t@echo \"" << echostring.c_str() << "\"\n";
}
else
{
cmSystemTools::ReplaceString(echostring, "\n\t", "\n\t@echo ");
fout << "\t@echo " << echostring.c_str() << "\n";
}
}
// Output the rules for any targets // Output the rules for any targets
void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout) void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
{ {
const cmTargets &tgts = m_Makefile->GetTargets(); const cmTargets &tgts = m_Makefile->GetTargets();
// add the help target // add the help target
fout << "help:\n"; fout << "help:\n";
fout << "\t@echo \"The following are some of the valid targets for this Makefile:\"\n"; this->OutputEcho(fout,"The following are some of the valid targets for this Makefile:");
fout << "\t@echo \" all (the default if no target is provided)\"\n"; this->OutputEcho(fout,"... all (the default if no target is provided)");
fout << "\t@echo \" clean\"\n"; this->OutputEcho(fout,"... clean");
fout << "\t@echo \" depend\"\n"; this->OutputEcho(fout,"... depend");
fout << "\t@echo \" rebuild_cache\"\n"; this->OutputEcho(fout,"... rebuild_cache");
// libraries // libraries
std::string path;
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
@ -388,9 +410,11 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
(l->second.GetType() == cmTarget::SHARED_LIBRARY) || (l->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(l->second.GetType() == cmTarget::MODULE_LIBRARY)) (l->second.GetType() == cmTarget::MODULE_LIBRARY))
{ {
std::string path = m_LibraryOutputPath; std::string path2 = m_LibraryOutputPath;
path += this->GetFullTargetName(l->first.c_str(), l->second); path2 += this->GetFullTargetName(l->first.c_str(), l->second);
fout << "\t@echo \" " << cmSystemTools::ConvertToOutputPath(path.c_str()) << "\"\n"; path = "... ";
path += cmSystemTools::ConvertToOutputPath(path2.c_str());
this->OutputEcho(fout,path.c_str());
} }
} }
// executables // executables
@ -398,20 +422,22 @@ void cmLocalUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if ((l->second.GetType() == cmTarget::EXECUTABLE || if ((l->second.GetType() == cmTarget::EXECUTABLE ||
l->second.GetType() == cmTarget::WIN32_EXECUTABLE) && l->second.GetType() == cmTarget::WIN32_EXECUTABLE))
l->second.IsInAll())
{ {
fout << "\t@echo \" " << l->first << "\"\n"; path = "... ";
path += l->first + cmSystemTools::GetExecutableExtension();
this->OutputEcho(fout,path.c_str());
} }
} }
// list utilities last // list utilities last
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (l->second.GetType() == cmTarget::UTILITY && if (l->second.GetType() == cmTarget::UTILITY)
l->second.IsInAll())
{ {
fout << "\t@echo \" " << l->first << "\"\n"; path = "... ";
path += l->first;
this->OutputEcho(fout,path.c_str());
} }
} }
fout << "\n\n"; fout << "\n\n";
@ -1725,11 +1751,12 @@ inline std::string FixDirectoryName(const char* dir)
} }
void cmLocalUnixMakefileGenerator::BuildInSubDirectoryWindows(std::ostream& fout, void cmLocalUnixMakefileGenerator::
const char* directory, BuildInSubDirectoryWindows(std::ostream& fout,
const char* target1, const char* directory,
const char* target2, const char* target1,
bool silent) const char* target2,
bool silent)
{ {
if(target1) if(target1)
{ {
@ -2819,21 +2846,7 @@ void cmLocalUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
echostring += " "; echostring += " ";
echostring += target; echostring += target;
echostring += "..."; echostring += "...";
this->OutputEcho(fout,echostring.c_str());
// for unix we want to quote the output of echo
// for nmake and borland, the echo should not be quoted
if(strcmp(m_GlobalGenerator->GetName(), "Unix Makefiles") == 0)
{
cmSystemTools::ReplaceString(echostring, "\\\n", " ");
cmSystemTools::ReplaceString(echostring, " \t", " ");
cmSystemTools::ReplaceString(echostring, "\n\t", "\"\n\t@echo \"");
fout << "\t@echo \"" << echostring.c_str() << "\"\n";
}
else
{
cmSystemTools::ReplaceString(echostring, "\n\t", "\n\t@echo ");
fout << "\t@echo " << echostring.c_str() << "\n";
}
} }
fout << "\t" << replace.c_str() << "\n"; fout << "\t" << replace.c_str() << "\n";
count++; count++;

View File

@ -207,6 +207,10 @@ protected:
/** Get the full name of the target's file, without path. */ /** Get the full name of the target's file, without path. */
std::string GetFullTargetName(const char* n, const cmTarget& t); std::string GetFullTargetName(const char* n, const cmTarget& t);
/** Output an echo command to the Makefile */
void OutputEcho(std::ostream& fout, const char *msg);
protected: protected:
int m_MakefileVariableSize; int m_MakefileVariableSize;
std::map<cmStdString, cmStdString> m_MakeVariableMap; std::map<cmStdString, cmStdString> m_MakeVariableMap;