From c48d877d3116ea4aed581fda42591c3d86d8df40 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 24 Jan 2014 14:00:34 +0100 Subject: [PATCH] QtAutogen: Make some methods appropriately file-static. --- Source/cmQtAutoGenerators.cxx | 65 +++++++++++++++++------------------ Source/cmQtAutoGenerators.h | 4 --- 2 files changed, 31 insertions(+), 38 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 23a39983f..166bbe05a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -115,6 +115,15 @@ static void copyTargetProperty(cmTarget* destinationTarget, } +static std::string ReadAll(const std::string& filename) +{ + cmsys::ifstream file(filename.c_str()); + cmsys_ios::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} + cmQtAutoGenerators::cmQtAutoGenerators() :Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) ,ColorOutput(true) @@ -960,11 +969,27 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) } } +static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, + const char* targetDirectory) +{ + cmGlobalGenerator* gg = new cmGlobalGenerator(); + gg->SetCMakeInstance(cm); + + cmLocalGenerator* lg = gg->CreateLocalGenerator(); + lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); + lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); + lg->GetMakefile()->SetHomeDirectory(targetDirectory); + lg->GetMakefile()->SetStartDirectory(targetDirectory); + gg->SetCurrentLocalGenerator(lg); + + return gg; +} + bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) { bool success = true; cmake cm; - cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); + cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory); cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); this->ReadAutogenInfoFile(makefile, targetDirectory, config); @@ -985,24 +1010,6 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config) return success; } - -cmGlobalGenerator* cmQtAutoGenerators::CreateGlobalGenerator(cmake* cm, - const char* targetDirectory) -{ - cmGlobalGenerator* gg = new cmGlobalGenerator(); - gg->SetCMakeInstance(cm); - - cmLocalGenerator* lg = gg->CreateLocalGenerator(); - lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); - lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); - lg->GetMakefile()->SetHomeDirectory(targetDirectory); - lg->GetMakefile()->SetStartDirectory(targetDirectory); - gg->SetCurrentLocalGenerator(lg); - - return gg; -} - - bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config) @@ -1424,7 +1431,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) if (!automocCppChanged) { // compare contents of the _automoc.cpp file - const std::string oldContents = this->ReadAll(this->OutMocCppFilename); + const std::string oldContents = ReadAll(this->OutMocCppFilename); if (oldContents == automocSource) { // nothing changed: don't touch the _automoc.cpp file @@ -1452,7 +1459,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" @@ -1635,7 +1642,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, "[\n][ \t]*#[ \t]*include[ \t]+" "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" @@ -1748,7 +1755,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, { return; } - const std::string contentsString = this->ReadAll(absFilename); + const std::string contentsString = ReadAll(absFilename); if (contentsString.empty()) { std::cerr << "AUTOGEN: warning: " << absFilename << ": file is empty\n" @@ -1843,7 +1850,7 @@ void cmQtAutoGenerators::ParseHeaders(const std::set& absHeaders, ++hIt) { const std::string& headerName = *hIt; - const std::string contents = this->ReadAll(headerName); + const std::string contents = ReadAll(headerName); if (includedMocs.find(headerName) == includedMocs.end()) { @@ -2122,13 +2129,3 @@ bool cmQtAutoGenerators::EndsWith(const std::string& str, } return (str.substr(str.length() - with.length(), with.length()) == with); } - - -std::string cmQtAutoGenerators::ReadAll(const std::string& filename) -{ - cmsys::ifstream file(filename.c_str()); - cmsys_ios::stringstream stream; - stream << file.rdbuf(); - file.close(); - return stream.str(); -} diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 80123d88c..ac0fd9ec9 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -36,9 +36,6 @@ private: void InitializeAutoRccTarget(cmTarget* target); void SetupAutoRccTarget(cmTarget const* target); - cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const char* targetDirectory); - bool ReadAutogenInfoFile(cmMakefile* makefile, const char* targetDirectory, const char *config); @@ -82,7 +79,6 @@ private: std::string Join(const std::vector& lst, char separator); bool EndsWith(const std::string& str, const std::string& with); bool StartsWith(const std::string& str, const std::string& with); - std::string ReadAll(const std::string& filename); void MergeUicOptions(std::vector &opts, const std::vector &fileOpts, bool isQt5);