ENH: add silent mode for makefile builds and fix borland and nmake after the depend stuff

This commit is contained in:
Bill Hoffman 2001-12-19 18:45:22 -05:00
parent 384cf0c7f3
commit b67dc16be6
4 changed files with 36 additions and 143 deletions

View File

@ -100,7 +100,7 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
"CMAKE_SHLIB_SUFFIX = @CMAKE_SHLIB_SUFFIX@\n"
"CMAKE_LINKER_FLAGS = @CMAKE_LINKER_FLAGS@ @LINKER_BUILD_FLAGS@\n"
"CMAKE_CXX_FLAGS = -P @CMAKE_CXX_FLAGS@ @BUILD_FLAGS@\n"
"RM = del";
"RM = del\n";
std::string buildType = "CMAKE_CXX_FLAGS_";
buildType += m_Makefile->GetDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
@ -165,100 +165,6 @@ void cmBorlandMakefileGenerator::OutputMakeVariables(std::ostream& fout)
}
void cmBorlandMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
const char* directory,
const char* target1,
const char* target2)
{
if(target1)
{
std::string dir = directory;
cmSystemTools::ConvertToWindowsSlashes(dir);
fout << "\tif not exist " << cmSystemTools::EscapeSpaces(dir.c_str())
<< " "
<< "$(MAKE) rebuild_cache\n"
<< "\tcd .\\" << directory << "\n"
<< "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
}
if(target2)
{
fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
}
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
cmSystemTools::ConvertToWindowsSlashes(currentDir);
fout << "\tcd " << cmSystemTools::EscapeSpaces(currentDir.c_str()) << "\n";
}
// This needs to be overriden because nmake requires commands to be quoted
// if the are full paths to the executable????
void cmBorlandMakefileGenerator::OutputMakeRule(std::ostream& fout,
const char* comment,
const char* target,
const char* depends,
const char* command,
const char* command2,
const char* command3,
const char* command4)
{
if(!target)
{
cmSystemTools::Error("no target for OutputMakeRule");
return;
}
std::string replace;
if(comment)
{
replace = comment;
m_Makefile->ExpandVariablesInString(replace);
fout << "#---------------------------------------------------------\n";
fout << "# " << comment;
fout << "\n#\n";
}
fout << "\n";
replace = target;
m_Makefile->ExpandVariablesInString(replace);
replace = cmSystemTools::EscapeSpaces(replace.c_str());
fout << replace.c_str() << ": ";
if(depends)
{
replace = depends;
m_Makefile->ExpandVariablesInString(replace);
fout << replace.c_str();
}
fout << "\n";
const char* startCommand = "\t";
const char* endCommand = "\n";
if(command)
{
replace = ShortPathCommand(command);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
}
if(command2)
{
replace = ShortPathCommand(command2);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
}
if(command3)
{
replace = ShortPathCommand(command3);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
}
if(command4)
{
replace = ShortPathCommand(command4);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
}
fout << "\n";
}
void
cmBorlandMakefileGenerator::
@ -500,13 +406,4 @@ bool cmBorlandMakefileGenerator::SamePath(const char* path1, const char* path2)
cmSystemTools::LowerCase(ShortPath(path2));
}
void cmBorlandMakefileGenerator::OutputBuildLibraryInDir(std::ostream& fout,
const char* path,
const char* s,
const char* fullpath)
{
cmNMakeMakefileGenerator::OutputBuildLibraryInDir(fout, path, s, fullpath);
}

View File

@ -68,19 +68,6 @@ public:
virtual void ComputeSystemInfo();
protected:
virtual void OutputMakeVariables(std::ostream&);
virtual void BuildInSubDirectory(std::ostream& fout,
const char* directory,
const char* target1,
const char* target2);
void OutputMakeRule(std::ostream& fout,
const char* comment,
const char* target,
const char* depends,
const char* command,
const char* command2=0,
const char* command3=0,
const char* command4=0);
virtual void OutputBuildObjectFromSource(std::ostream& fout,
const char* shortName,
@ -96,10 +83,6 @@ protected:
virtual void OutputExecutableRule(std::ostream&, const char* name,
const cmTarget &);
virtual std::string GetOutputExtension(const char* sourceExtension);
virtual void OutputBuildLibraryInDir(std::ostream& fout,
const char* path,
const char* library,
const char* fullpath);
///! return true if the two paths are the same (checks short paths)
virtual bool SamePath(const char* path1, const char* path2);
};

View File

@ -239,14 +239,17 @@ void cmNMakeMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
{
std::string dir = directory;
cmSystemTools::ConvertToWindowsSlashes(dir);
fout << "\tif not exist " << cmSystemTools::EscapeSpaces(dir.c_str())
dir = cmSystemTools::EscapeSpaces(dir.c_str());
fout << "\tif not exist " << dir
<< " "
<< "$(MAKE) rebuild_cache\n"
<< "\tcd .\\" << directory << "\n"
<< "\techo Building " << target1 << " in directory " << directory << "\n"
<< "\tcd " << dir << "\n"
<< "\t$(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
}
if(target2)
{
fout << "\techo Building " << target2 << " in directory " << directory << "\n";
fout << "\t$(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
}
std::string currentDir = m_Makefile->GetCurrentOutputDirectory();
@ -296,31 +299,33 @@ void cmNMakeMakefileGenerator::OutputMakeRule(std::ostream& fout,
fout << replace.c_str();
}
fout << "\n";
const char* startCommand = "\t";
const char* endCommand = "\n";
if(command)
{
replace = ShortPathCommand(command);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command2)
{
replace = ShortPathCommand(command2);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command3)
{
replace = ShortPathCommand(command3);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command4)
{
replace = ShortPathCommand(command4);
m_Makefile->ExpandVariablesInString(replace);
fout << startCommand << replace.c_str() << endCommand;
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
fout << "\n";
}

View File

@ -972,11 +972,13 @@ void cmUnixMakefileGenerator::BuildInSubDirectory(std::ostream& fout,
{
fout << "\t@if test ! -d " << directory
<< "; then $(MAKE) rebuild_cache; fi\n"
"\t@cd " << directory
<< "\techo Building " << target1 << " in directory " << directory << "\n"
<< "\t@cd " << directory
<< "; $(MAKE) -$(MAKEFLAGS) " << target1 << "\n";
}
if(target2)
{
fout << "\techo Building " << target2 << " in directory " << directory << "\n";
fout << "\t@cd " << directory
<< "; $(MAKE) -$(MAKEFLAGS) " << target2 << "\n";
}
@ -1029,7 +1031,10 @@ OutputSubDirectoryVars(std::ostream& fout,
fout << "\n";
last = subdir;
this->BuildInSubDirectory(fout, SubDirectories[i].c_str(),
std::string dir = m_Makefile->GetCurrentOutputDirectory();
dir += "/";
dir += SubDirectories[i];
this->BuildInSubDirectory(fout, dir.c_str(),
target1, target2);
}
fout << "\n\n";
@ -1499,24 +1504,23 @@ void cmUnixMakefileGenerator::OutputMakeRules(std::ostream& fout)
"-@ $(RM) $(CLEAN_OBJECT_FILES) $(EXECUTABLES)"
" $(TARGETS)");
}
{
std::string cmake_depends_mark = "@cd ";
cmake_depends_mark += m_Makefile->GetHomeOutputDirectory();
cmake_depends_mark += " ; $(MAKE) depend";
this->OutputMakeRule(fout,
"Rule to build the cmake.depends and Makefile as side effect",
"cmake.depends_mark",
"$(CMAKE_MAKEFILE_SOURCES) ",
cmake_depends_mark.c_str());
}
fout << "# Suppresses display of executed commands\n";
fout << ".SILENT:\n";
fout << "\n#Rule to build the cmake.depends and Makefile as side effect\n";
fout << "cmake.depends_mark: $(CMAKE_MAKEFILE_SOURCES)\n";
this->BuildInSubDirectory(fout,
m_Makefile->GetHomeOutputDirectory(),
"depend", 0);
this->OutputMakeRule(fout,
"Rule to force the build of cmake.depends",
"depend",
"$(SUBDIR_DEPEND)",
"$(CMAKE_COMMAND) "
"-S$(CMAKE_CURRENT_SOURCE) -O$(CMAKE_CURRENT_BINARY) "
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)\n"
"\t-@ $(RM) cmake.depends_mark ; echo mark > cmake.depends_mark");
"-H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)",
"-$(RM) cmake.depends_mark",
"echo mark > cmake.depends_mark"
);
this->OutputMakeRule(fout,
"Rebuild CMakeCache.txt file",
"rebuild_cache",
@ -1735,24 +1739,28 @@ void cmUnixMakefileGenerator::OutputMakeRule(std::ostream& fout,
{
replace = command;
m_Makefile->ExpandVariablesInString(replace);
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command2)
{
replace = command2;
m_Makefile->ExpandVariablesInString(replace);
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command3)
{
replace = command3;
m_Makefile->ExpandVariablesInString(replace);
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
if(command4)
{
replace = command4;
m_Makefile->ExpandVariablesInString(replace);
fout << "\t" << "echo " << replace.c_str() << "\n";
fout << "\t" << replace.c_str() << "\n";
}
fout << "\n";