diff options
author | Brad King <brad.king@kitware.com> | 2004-11-03 12:51:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2004-11-03 12:51:51 (GMT) |
commit | a5ae290a5bdacf492f31928adb271b85d1d6c4b2 (patch) | |
tree | e7449908786332210ad77275356dfc4a711c5cc5 /Source | |
parent | e34207c1f0493c002da8c74897b81a72ef3ef2d4 (diff) | |
download | CMake-a5ae290a5bdacf492f31928adb271b85d1d6c4b2.zip CMake-a5ae290a5bdacf492f31928adb271b85d1d6c4b2.tar.gz CMake-a5ae290a5bdacf492f31928adb271b85d1d6c4b2.tar.bz2 |
STYLE: Adjusted signature of cmGeneratedFileStream to make copy-if-different more explicity.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmExportLibraryDependencies.cxx | 3 | ||||
-rw-r--r-- | Source/cmGeneratedFileStream.cxx | 17 | ||||
-rw-r--r-- | Source/cmGeneratedFileStream.h | 17 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 3 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmLocalKdevelopGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator2.cxx | 29 | ||||
-rw-r--r-- | Source/cmVTKMakeInstantiatorCommand.cxx | 9 |
9 files changed, 49 insertions, 40 deletions
diff --git a/Source/cmExportLibraryDependencies.cxx b/Source/cmExportLibraryDependencies.cxx index a83d7e1..16537a4 100644 --- a/Source/cmExportLibraryDependencies.cxx +++ b/Source/cmExportLibraryDependencies.cxx @@ -73,7 +73,8 @@ void cmExportLibraryDependenciesCommand::FinalPass() else { std::auto_ptr<cmGeneratedFileStream> ap( - new cmGeneratedFileStream(fname.c_str(), true, true)); + new cmGeneratedFileStream(fname.c_str(), true)); + ap->SetCopyIfDifferent(true); foutNew = ap; foutPtr = foutNew.get(); } diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 1e470c8..254b6bf 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -27,10 +27,8 @@ #endif //---------------------------------------------------------------------------- -cmGeneratedFileStream::cmGeneratedFileStream(const char* name, - bool copy_if_different, - bool quiet): - cmGeneratedFileStreamBase(name, copy_if_different), +cmGeneratedFileStream::cmGeneratedFileStream(const char* name, bool quiet): + cmGeneratedFileStreamBase(name), Stream(m_TempName.c_str()) { // Check if the file opened. @@ -53,11 +51,16 @@ cmGeneratedFileStream::~cmGeneratedFileStream() } //---------------------------------------------------------------------------- -cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name, - bool copy_if_different): +void cmGeneratedFileStream::SetCopyIfDifferent(bool copy_if_different) +{ + m_CopyIfDifferent = copy_if_different; +} + +//---------------------------------------------------------------------------- +cmGeneratedFileStreamBase::cmGeneratedFileStreamBase(const char* name): m_Name(name), m_TempName(name), - m_CopyIfDifferent(copy_if_different), + m_CopyIfDifferent(false), m_Okay(false) { // Create the name of the temporary file. diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h index f447370..7430ef9 100644 --- a/Source/cmGeneratedFileStream.h +++ b/Source/cmGeneratedFileStream.h @@ -26,7 +26,7 @@ class cmGeneratedFileStreamBase { protected: // 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. ~cmGeneratedFileStreamBase(); @@ -65,13 +65,11 @@ public: /** * The constructor takes the name of the file to be generated. It - * automatically generates a name for the temporary file. The - * second argument specifies whether the copy-if-different check - * should be done. If the file cannot be opened an error message is - * produced unless the third argument is set to true. + * automatically generates a name for the temporary file. If the + * file cannot be opened an error message is produced unless the + * second argument is set to true. */ - cmGeneratedFileStream(const char* name, bool copy_if_different, - bool quiet = false); + cmGeneratedFileStream(const char* name, bool quiet=false); /** * The destructor checks the stream status to be sure the temporary @@ -79,6 +77,11 @@ public: * replaced. */ ~cmGeneratedFileStream(); + + /** + * Set whether copy-if-different is done. + */ + void SetCopyIfDifferent(bool copy_if_different); }; #endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 0184833..e85a80c 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -289,7 +289,8 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile(cmLocalGenerator* root, fname += "/"; fname += root->GetMakefile()->GetProjectName(); fname += ".sln"; - cmGeneratedFileStream fout(fname.c_str(), true); + cmGeneratedFileStream fout(fname.c_str()); + fout.SetCopyIfDifferent(true); if(!fout) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 033ca6d..92cb202 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -92,7 +92,8 @@ void cmLocalGenerator::GenerateInstallRules() toplevel_install = 1; } 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() << std::endl << std::endl; diff --git a/Source/cmLocalKdevelopGenerator.cxx b/Source/cmLocalKdevelopGenerator.cxx index 03c77b1..c5821d0 100644 --- a/Source/cmLocalKdevelopGenerator.cxx +++ b/Source/cmLocalKdevelopGenerator.cxx @@ -120,7 +120,7 @@ void cmLocalKdevelopGenerator::MergeProjectFiles(const std::string& outputDir, } oldProjectFile.close(); - cmGeneratedFileStream fout(filename.c_str(), false); + cmGeneratedFileStream fout(filename.c_str()); if(!fout) { return; @@ -171,7 +171,7 @@ void cmLocalKdevelopGenerator::CreateNewProjectFile(const std::string& outputDir const std::string& cmakeFilePattern) { - cmGeneratedFileStream fout(filename.c_str(), false); + cmGeneratedFileStream fout(filename.c_str()); if(!fout) { return; @@ -364,7 +364,7 @@ bool cmLocalKdevelopGenerator::CreateFilelistFile(const std::string& outputDir, } //now write the new filename - cmGeneratedFileStream fout(filename.c_str(), false); + cmGeneratedFileStream fout(filename.c_str()); if(!fout) { return false; diff --git a/Source/cmLocalUnixMakefileGenerator.cxx b/Source/cmLocalUnixMakefileGenerator.cxx index 586bf29..0a8a6ac 100644 --- a/Source/cmLocalUnixMakefileGenerator.cxx +++ b/Source/cmLocalUnixMakefileGenerator.cxx @@ -186,7 +186,7 @@ void cmLocalUnixMakefileGenerator::OutputMakefile(const char* file, // Create a stream that writes to a temporary file // then does a copy at the end. This is to allow users // to hit control-c during the make of the makefile - cmGeneratedFileStream fout(file, false); + cmGeneratedFileStream fout(file); if(!fout) { return; diff --git a/Source/cmLocalUnixMakefileGenerator2.cxx b/Source/cmLocalUnixMakefileGenerator2.cxx index d29f545..6fd0575 100644 --- a/Source/cmLocalUnixMakefileGenerator2.cxx +++ b/Source/cmLocalUnixMakefileGenerator2.cxx @@ -46,8 +46,6 @@ void cmLocalUnixMakefileGenerator2::SetEmptyCommand(const char* cmd) //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop) { - // TODO: Account for control-c during Makefile generation. - // TODO: Think about unifying generation of "@" for silent commands. // Generate old style for now. @@ -88,15 +86,14 @@ void cmLocalUnixMakefileGenerator2::Generate(bool fromTheTop) //---------------------------------------------------------------------------- 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(); makefileName += "/Makefile2"; - std::ofstream makefileStream(makefileName.c_str()); + cmGeneratedFileStream makefileStream(makefileName.c_str()); if(!makefileStream) { - cmSystemTools::Error("Error can not open for write: ", - makefileName.c_str()); - cmSystemTools::ReportLastSystemError(""); return; } @@ -134,12 +131,9 @@ void cmLocalUnixMakefileGenerator2::GenerateCMakefile() cmakefileName += ".cmake"; // Open the output file. - std::ofstream cmakefileStream(cmakefileName.c_str()); + cmGeneratedFileStream cmakefileStream(cmakefileName.c_str()); if(!cmakefileStream) { - cmSystemTools::Error("Error can not open for write: ", - cmakefileName.c_str()); - cmSystemTools::ReportLastSystemError(""); return; } @@ -237,7 +231,8 @@ cmLocalUnixMakefileGenerator2 // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true); + cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + ruleFileStream.SetCopyIfDifferent(true); if(!ruleFileStream) { return; @@ -351,7 +346,8 @@ cmLocalUnixMakefileGenerator2 std::string ruleFileName = obj; ruleFileName += ".make"; std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true); + cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + ruleFileStream.SetCopyIfDifferent(true); if(!ruleFileStream) { return; @@ -526,7 +522,8 @@ cmLocalUnixMakefileGenerator2 // Open the rule file. This should be copy-if-different because the // rules may depend on this file itself. std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName); - cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str(), true); + cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); + ruleFileStream.SetCopyIfDifferent(true); if(!ruleFileStream) { return; @@ -2228,7 +2225,7 @@ cmLocalUnixMakefileGenerator2 std::string depMakeFile = objFile; depMarkFile += ".depends"; depMakeFile += ".depends.make"; - std::ofstream fout(depMakeFile.c_str()); + cmGeneratedFileStream fout(depMakeFile.c_str()); fout << "# Dependencies for " << objFile << std::endl; for(std::set<cmStdString>::iterator i=dependencies.begin(); i != dependencies.end(); ++i) @@ -2406,7 +2403,7 @@ cmLocalUnixMakefileGenerator2 cmSystemTools::RemoveFile(depMarkFileFull); // Write an empty dependency file. - std::ofstream depFileStream(depMakeFileFull); + cmGeneratedFileStream depFileStream(depMakeFileFull); depFileStream << "# Empty dependencies file for " << file << ".\n" << "# This may be replaced when dependencies are built.\n"; diff --git a/Source/cmVTKMakeInstantiatorCommand.cxx b/Source/cmVTKMakeInstantiatorCommand.cxx index 6f2239b..5d96b80 100644 --- a/Source/cmVTKMakeInstantiatorCommand.cxx +++ b/Source/cmVTKMakeInstantiatorCommand.cxx @@ -127,7 +127,8 @@ cmVTKMakeInstantiatorCommand std::string fullName = headerPath+"/"+fileName; // 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. if(!oldVersion) @@ -147,7 +148,8 @@ cmVTKMakeInstantiatorCommand // 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. if(!oldVersion) @@ -188,7 +190,8 @@ cmVTKMakeInstantiatorCommand // 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 = (block < numFullBlocks)? groupSize:lastBlockSize; |