STYLE: Adjusted signature of cmGeneratedFileStream to make copy-if-different more explicity.
This commit is contained in:
parent
e34207c1f0
commit
a5ae290a5b
@ -73,7 +73,8 @@ void cmExportLibraryDependenciesCommand::FinalPass()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::auto_ptr<cmGeneratedFileStream> ap(
|
std::auto_ptr<cmGeneratedFileStream> ap(
|
||||||
new cmGeneratedFileStream(fname.c_str(), true, true));
|
new cmGeneratedFileStream(fname.c_str(), true));
|
||||||
|
ap->SetCopyIfDifferent(true);
|
||||||
foutNew = ap;
|
foutNew = ap;
|
||||||
foutPtr = foutNew.get();
|
foutPtr = foutNew.get();
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmGeneratedFileStream::cmGeneratedFileStream(const char* name,
|
cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet):
|
||||||
bool copy_if_different,
|
cmGeneratedFileStreamBase(name),
|
||||||
bool quiet):
|
|
||||||
cmGeneratedFileStreamBase(name, copy_if_different),
|
|
||||||
Stream(m_TempName.c_str())
|
Stream(m_TempName.c_str())
|
||||||
{
|
{
|
||||||
// Check if the file opened.
|
// Check if the file opened.
|
||||||
@ -53,11 +51,16 @@ cmGeneratedFileStream::~cmGeneratedFileStream()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name,
|
void cmGeneratedFileStream::SetCopyIfDifferent(bool copy_if_different)
|
||||||
bool copy_if_different):
|
{
|
||||||
|
m_CopyIfDifferent = copy_if_different;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name):
|
||||||
m_Name(name),
|
m_Name(name),
|
||||||
m_TempName(name),
|
m_TempName(name),
|
||||||
m_CopyIfDifferent(copy_if_different),
|
m_CopyIfDifferent(false),
|
||||||
m_Okay(false)
|
m_Okay(false)
|
||||||
{
|
{
|
||||||
// Create the name of the temporary file.
|
// Create the name of the temporary file.
|
||||||
|
@ -26,7 +26,7 @@ class cmGeneratedFileStreamBase
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// The constructor prepares the temporary output file.
|
// The constructor prepares the temporary output file.
|
||||||
cmGeneratedFileStreamBase(const char* name, bool copy_if_different);
|
cmGeneratedFileStreamBase(const char* name);
|
||||||
|
|
||||||
// The destructor renames the temporary output file to the real name.
|
// The destructor renames the temporary output file to the real name.
|
||||||
~cmGeneratedFileStreamBase();
|
~cmGeneratedFileStreamBase();
|
||||||
@ -65,13 +65,11 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The constructor takes the name of the file to be generated. It
|
* The constructor takes the name of the file to be generated. It
|
||||||
* automatically generates a name for the temporary file. The
|
* automatically generates a name for the temporary file. If the
|
||||||
* second argument specifies whether the copy-if-different check
|
* file cannot be opened an error message is produced unless the
|
||||||
* should be done. If the file cannot be opened an error message is
|
* second argument is set to true.
|
||||||
* produced unless the third argument is set to true.
|
|
||||||
*/
|
*/
|
||||||
cmGeneratedFileStream(const char* name, bool copy_if_different,
|
cmGeneratedFileStream(const char* name, bool quiet=false);
|
||||||
bool quiet = false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The destructor checks the stream status to be sure the temporary
|
* The destructor checks the stream status to be sure the temporary
|
||||||
@ -79,6 +77,11 @@ public:
|
|||||||
* replaced.
|
* replaced.
|
||||||
*/
|
*/
|
||||||
~cmGeneratedFileStream();
|
~cmGeneratedFileStream();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether copy-if-different is done.
|
||||||
|
*/
|
||||||
|
void SetCopyIfDifferent(bool copy_if_different);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,7 +289,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(cmLocalGenerator* root,
|
|||||||
fname += "/";
|
fname += "/";
|
||||||
fname += root->GetMakefile()->GetProjectName();
|
fname += root->GetMakefile()->GetProjectName();
|
||||||
fname += ".sln";
|
fname += ".sln";
|
||||||
cmGeneratedFileStream fout(fname.c_str(), true);
|
cmGeneratedFileStream fout(fname.c_str());
|
||||||
|
fout.SetCopyIfDifferent(true);
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +92,8 @@ void cmLocalGenerator::GenerateInstallRules()
|
|||||||
toplevel_install = 1;
|
toplevel_install = 1;
|
||||||
}
|
}
|
||||||
file += "/cmake_install.cmake";
|
file += "/cmake_install.cmake";
|
||||||
cmGeneratedFileStream fout(file.c_str(), true);
|
cmGeneratedFileStream fout(file.c_str());
|
||||||
|
fout.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
fout << "# Install script for directory: " << m_Makefile->GetCurrentDirectory()
|
fout << "# Install script for directory: " << m_Makefile->GetCurrentDirectory()
|
||||||
<< std::endl << std::endl;
|
<< std::endl << std::endl;
|
||||||
|
@ -120,7 +120,7 @@ void cmLocalKdevelopGenerator::MergeProjectFiles(const std::string& outputDir,
|
|||||||
}
|
}
|
||||||
oldProjectFile.close();
|
oldProjectFile.close();
|
||||||
|
|
||||||
cmGeneratedFileStream fout(filename.c_str(), false);
|
cmGeneratedFileStream fout(filename.c_str());
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -171,7 +171,7 @@ void cmLocalKdevelopGenerator::CreateNewProjectFile(const std::string& outputDir
|
|||||||
const std::string& cmakeFilePattern)
|
const std::string& cmakeFilePattern)
|
||||||
{
|
{
|
||||||
|
|
||||||
cmGeneratedFileStream fout(filename.c_str(), false);
|
cmGeneratedFileStream fout(filename.c_str());
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -364,7 +364,7 @@ bool cmLocalKdevelopGenerator::CreateFilelistFile(const std::string& outputDir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//now write the new filename
|
//now write the new filename
|
||||||
cmGeneratedFileStream fout(filename.c_str(), false);
|
cmGeneratedFileStream fout(filename.c_str());
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -186,7 +186,7 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file,
|
|||||||
// Create a stream that writes to a temporary file
|
// Create a stream that writes to a temporary file
|
||||||
// then does a copy at the end. This is to allow users
|
// then does a copy at the end. This is to allow users
|
||||||
// to hit control-c during the make of the makefile
|
// to hit control-c during the make of the makefile
|
||||||
cmGeneratedFileStream fout(file, false);
|
cmGeneratedFileStream fout(file);
|
||||||
if(!fout)
|
if(!fout)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -46,8 +46,6 @@ void cmLocalUnixMakefileGenerator2::SetEmptyCommand(const char* cmd)
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop)
|
void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop)
|
||||||
{
|
{
|
||||||
// TODO: Account for control-c during Makefile generation.
|
|
||||||
|
|
||||||
// TODO: Think about unifying generation of "@" for silent commands.
|
// TODO: Think about unifying generation of "@" for silent commands.
|
||||||
|
|
||||||
// Generate old style for now.
|
// Generate old style for now.
|
||||||
@ -88,15 +86,14 @@ void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop)
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmLocalUnixMakefileGenerator2::GenerateMakefile()
|
void cmLocalUnixMakefileGenerator2::GenerateMakefile()
|
||||||
{
|
{
|
||||||
// Open the output file.
|
// Open the output file. This should not be copy-if-different
|
||||||
|
// because the check-build-system step compares the makefile time to
|
||||||
|
// see if the build system must be regenerated.
|
||||||
std::string makefileName = m_Makefile->GetStartOutputDirectory();
|
std::string makefileName = m_Makefile->GetStartOutputDirectory();
|
||||||
makefileName += "/Makefile2";
|
makefileName += "/Makefile2";
|
||||||
std::ofstream makefileStream(makefileName.c_str());
|
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
||||||
if(!makefileStream)
|
if(!makefileStream)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Error can not open for write: ",
|
|
||||||
makefileName.c_str());
|
|
||||||
cmSystemTools::ReportLastSystemError("");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,12 +131,9 @@ void cmLocalUnixMakefileGenerator2::GenerateCMakefile()
|
|||||||
cmakefileName += ".cmake";
|
cmakefileName += ".cmake";
|
||||||
|
|
||||||
// Open the output file.
|
// Open the output file.
|
||||||
std::ofstream cmakefileStream(cmakefileName.c_str());
|
cmGeneratedFileStream cmakefileStream(cmakefileName.c_str());
|
||||||
if(!cmakefileStream)
|
if(!cmakefileStream)
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("Error can not open for write: ",
|
|
||||||
cmakefileName.c_str());
|
|
||||||
cmSystemTools::ReportLastSystemError("");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +231,8 @@ cmLocalUnixMakefileGenerator2
|
|||||||
// Open the rule file. This should be copy-if-different because the
|
// Open the rule file. This should be copy-if-different because the
|
||||||
// rules may depend on this file itself.
|
// rules may depend on this file itself.
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true);
|
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
||||||
|
ruleFileStream.SetCopyIfDifferent(true);
|
||||||
if(!ruleFileStream)
|
if(!ruleFileStream)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -351,7 +346,8 @@ cmLocalUnixMakefileGenerator2
|
|||||||
std::string ruleFileName = obj;
|
std::string ruleFileName = obj;
|
||||||
ruleFileName += ".make";
|
ruleFileName += ".make";
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true);
|
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
||||||
|
ruleFileStream.SetCopyIfDifferent(true);
|
||||||
if(!ruleFileStream)
|
if(!ruleFileStream)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -526,7 +522,8 @@ cmLocalUnixMakefileGenerator2
|
|||||||
// Open the rule file. This should be copy-if-different because the
|
// Open the rule file. This should be copy-if-different because the
|
||||||
// rules may depend on this file itself.
|
// rules may depend on this file itself.
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true);
|
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
||||||
|
ruleFileStream.SetCopyIfDifferent(true);
|
||||||
if(!ruleFileStream)
|
if(!ruleFileStream)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -2228,7 +2225,7 @@ cmLocalUnixMakefileGenerator2
|
|||||||
std::string depMakeFile = objFile;
|
std::string depMakeFile = objFile;
|
||||||
depMarkFile += ".depends";
|
depMarkFile += ".depends";
|
||||||
depMakeFile += ".depends.make";
|
depMakeFile += ".depends.make";
|
||||||
std::ofstream fout(depMakeFile.c_str());
|
cmGeneratedFileStream fout(depMakeFile.c_str());
|
||||||
fout << "# Dependencies for " << objFile << std::endl;
|
fout << "# Dependencies for " << objFile << std::endl;
|
||||||
for(std::set<cmStdString>::iterator i=dependencies.begin();
|
for(std::set<cmStdString>::iterator i=dependencies.begin();
|
||||||
i != dependencies.end(); ++i)
|
i != dependencies.end(); ++i)
|
||||||
@ -2406,7 +2403,7 @@ cmLocalUnixMakefileGenerator2
|
|||||||
cmSystemTools::RemoveFile(depMarkFileFull);
|
cmSystemTools::RemoveFile(depMarkFileFull);
|
||||||
|
|
||||||
// Write an empty dependency file.
|
// Write an empty dependency file.
|
||||||
std::ofstream depFileStream(depMakeFileFull);
|
cmGeneratedFileStream depFileStream(depMakeFileFull);
|
||||||
depFileStream
|
depFileStream
|
||||||
<< "# Empty dependencies file for " << file << ".\n"
|
<< "# Empty dependencies file for " << file << ".\n"
|
||||||
<< "# This may be replaced when dependencies are built.\n";
|
<< "# This may be replaced when dependencies are built.\n";
|
||||||
|
@ -127,7 +127,8 @@ cmVTKMakeInstantiatorCommand
|
|||||||
std::string fullName = headerPath+"/"+fileName;
|
std::string fullName = headerPath+"/"+fileName;
|
||||||
|
|
||||||
// Generate the output file with copy-if-different.
|
// Generate the output file with copy-if-different.
|
||||||
cmGeneratedFileStream fout(fullName.c_str(), true);
|
cmGeneratedFileStream fout(fullName.c_str());
|
||||||
|
fout.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
// Actually generate the code in the file.
|
// Actually generate the code in the file.
|
||||||
if(!oldVersion)
|
if(!oldVersion)
|
||||||
@ -147,7 +148,8 @@ cmVTKMakeInstantiatorCommand
|
|||||||
|
|
||||||
// Generate the output file with copy-if-different.
|
// Generate the output file with copy-if-different.
|
||||||
{
|
{
|
||||||
cmGeneratedFileStream fout(fullName.c_str(), true);
|
cmGeneratedFileStream fout(fullName.c_str());
|
||||||
|
fout.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
// Actually generate the code in the file.
|
// Actually generate the code in the file.
|
||||||
if(!oldVersion)
|
if(!oldVersion)
|
||||||
@ -188,7 +190,8 @@ cmVTKMakeInstantiatorCommand
|
|||||||
|
|
||||||
// Generate the output file with copy-if-different.
|
// Generate the output file with copy-if-different.
|
||||||
{
|
{
|
||||||
cmGeneratedFileStream fout(fullName.c_str(), true);
|
cmGeneratedFileStream fout(fullName.c_str());
|
||||||
|
fout.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
size_t thisBlockSize =
|
size_t thisBlockSize =
|
||||||
(block < numFullBlocks)? groupSize:lastBlockSize;
|
(block < numFullBlocks)? groupSize:lastBlockSize;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user