QtAutogen: Make some methods appropriately file-static.

This commit is contained in:
Stephen Kelly 2014-01-24 14:00:34 +01:00
parent 394e86df2a
commit c48d877d31
2 changed files with 31 additions and 38 deletions

View File

@ -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<std::string>& 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();
}

View File

@ -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<std::string>& 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<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);