Merge topic 'autogen-cleanups'
840b830b Autogen: Qrc processing: Generate single map with final input / output names bc4c7751 Autogen: Ui processing: Generate single map with final input / output names 47e60bc5 Autogen: Split out UI file generation code to dedicated method cf679ea8 Autogen: Split out moc file generation code to dedicated method 3ea1d090 Autogen: Rename method GenerateQrc{ => Files} 8ced8bb9 Autogen: New logCommand method. It prints commands using std::cout. 95064a6d Autogen: Rename header extension Join method to JoinExts 7a73c404 Autogen: Use SystemTools string functions instead of rolling out own
This commit is contained in:
commit
f223652790
@ -410,9 +410,11 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(
|
|||||||
|
|
||||||
void cmQtAutoGenerators::Init()
|
void cmQtAutoGenerators::Init()
|
||||||
{
|
{
|
||||||
|
this->OutMocCppFilenameRel = this->TargetName;
|
||||||
|
this->OutMocCppFilenameRel += ".cpp";
|
||||||
|
|
||||||
this->OutMocCppFilename = this->Builddir;
|
this->OutMocCppFilename = this->Builddir;
|
||||||
this->OutMocCppFilename += this->TargetName;
|
this->OutMocCppFilename += this->OutMocCppFilenameRel;
|
||||||
this->OutMocCppFilename += ".cpp";
|
|
||||||
|
|
||||||
std::vector<std::string> cdefList;
|
std::vector<std::string> cdefList;
|
||||||
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
|
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
|
||||||
@ -464,7 +466,7 @@ void cmQtAutoGenerators::Init()
|
|||||||
std::list<std::string>::iterator it = this->MocIncludes.begin();
|
std::list<std::string>::iterator it = this->MocIncludes.begin();
|
||||||
while (it != this->MocIncludes.end())
|
while (it != this->MocIncludes.end())
|
||||||
{
|
{
|
||||||
if (this->StartsWith(*it, binDir))
|
if (cmsys::SystemTools::StringStartsWith(*it, binDir.c_str()))
|
||||||
{
|
{
|
||||||
sortedMocIncludes.push_back(*it);
|
sortedMocIncludes.push_back(*it);
|
||||||
it = this->MocIncludes.erase(it);
|
it = this->MocIncludes.erase(it);
|
||||||
@ -477,7 +479,7 @@ void cmQtAutoGenerators::Init()
|
|||||||
it = this->MocIncludes.begin();
|
it = this->MocIncludes.begin();
|
||||||
while (it != this->MocIncludes.end())
|
while (it != this->MocIncludes.end())
|
||||||
{
|
{
|
||||||
if (this->StartsWith(*it, srcDir))
|
if (cmsys::SystemTools::StringStartsWith(*it, srcDir.c_str()))
|
||||||
{
|
{
|
||||||
sortedMocIncludes.push_back(*it);
|
sortedMocIncludes.push_back(*it);
|
||||||
it = this->MocIncludes.erase(it);
|
it = this->MocIncludes.erase(it);
|
||||||
@ -589,56 +591,17 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|||||||
std::map<std::string, std::string> notIncludedMocs;
|
std::map<std::string, std::string> notIncludedMocs;
|
||||||
this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis);
|
this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis);
|
||||||
|
|
||||||
// run moc on all the moc's that are #included in source files
|
if(!this->MocExecutable.empty())
|
||||||
for(std::map<std::string, std::string>::const_iterator
|
|
||||||
it = includedMocs.begin();
|
|
||||||
it != includedMocs.end();
|
|
||||||
++it)
|
|
||||||
{
|
{
|
||||||
this->GenerateMoc(it->first, it->second);
|
this->GenerateMocFiles ( includedMocs, notIncludedMocs );
|
||||||
}
|
}
|
||||||
for(std::map<std::string, std::vector<std::string> >::const_iterator
|
if(!this->UicExecutable.empty())
|
||||||
it = includedUis.begin();
|
|
||||||
it != includedUis.end();
|
|
||||||
++it)
|
|
||||||
{
|
{
|
||||||
for (std::vector<std::string>::const_iterator nit = it->second.begin();
|
this->GenerateUiFiles ( includedUis );
|
||||||
nit != it->second.end();
|
|
||||||
++nit)
|
|
||||||
{
|
|
||||||
this->GenerateUi(it->first, *nit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this->RccExecutable.empty())
|
if(!this->RccExecutable.empty())
|
||||||
{
|
{
|
||||||
this->GenerateQrc();
|
this->GenerateQrcFiles();
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream outStream;
|
|
||||||
outStream << "/* This file is autogenerated, do not edit*/\n";
|
|
||||||
|
|
||||||
bool automocCppChanged = false;
|
|
||||||
if (notIncludedMocs.empty())
|
|
||||||
{
|
|
||||||
outStream << "enum some_compilers { need_more_than_nothing };\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// run moc on the remaining headers and include them in
|
|
||||||
// the _automoc.cpp file
|
|
||||||
for(std::map<std::string, std::string>::const_iterator
|
|
||||||
it = notIncludedMocs.begin();
|
|
||||||
it != notIncludedMocs.end();
|
|
||||||
++it)
|
|
||||||
{
|
|
||||||
bool mocSuccess = this->GenerateMoc(it->first, it->second);
|
|
||||||
if (mocSuccess)
|
|
||||||
{
|
|
||||||
automocCppChanged = true;
|
|
||||||
}
|
|
||||||
outStream << "#include \"" << it->second << "\"\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->RunMocFailed)
|
if (this->RunMocFailed)
|
||||||
@ -646,7 +609,6 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|||||||
std::cerr << "moc failed..." << std::endl;
|
std::cerr << "moc failed..." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->RunUicFailed)
|
if (this->RunUicFailed)
|
||||||
{
|
{
|
||||||
std::cerr << "uic failed..." << std::endl;
|
std::cerr << "uic failed..." << std::endl;
|
||||||
@ -657,25 +619,6 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|||||||
std::cerr << "rcc failed..." << std::endl;
|
std::cerr << "rcc failed..." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
outStream.flush();
|
|
||||||
std::string automocSource = outStream.str();
|
|
||||||
if (!automocCppChanged)
|
|
||||||
{
|
|
||||||
// compare contents of the _automoc.cpp file
|
|
||||||
const std::string oldContents = ReadAll(this->OutMocCppFilename);
|
|
||||||
if (oldContents == automocSource)
|
|
||||||
{
|
|
||||||
// nothing changed: don't touch the _automoc.cpp file
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// source file that includes all remaining moc files (_automoc.cpp file)
|
|
||||||
cmsys::ofstream outfile;
|
|
||||||
outfile.open(this->OutMocCppFilename.c_str(),
|
|
||||||
std::ios::trunc);
|
|
||||||
outfile << automocSource;
|
|
||||||
outfile.close();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -762,7 +705,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
|
|||||||
std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
|
std::cerr << "AUTOGEN: error: " << absFilename << ": The file "
|
||||||
<< "includes the moc file \"" << currentMoc << "\", "
|
<< "includes the moc file \"" << currentMoc << "\", "
|
||||||
<< "but could not find header \"" << basename
|
<< "but could not find header \"" << basename
|
||||||
<< '{' << this->Join(headerExtensions, ',') << "}\" ";
|
<< '{' << this->JoinExts(headerExtensions) << "}\" ";
|
||||||
if (mocSubDir.empty())
|
if (mocSubDir.empty())
|
||||||
{
|
{
|
||||||
std::cerr << "in " << absPath << "\n" << std::endl;
|
std::cerr << "in " << absPath << "\n" << std::endl;
|
||||||
@ -937,7 +880,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
|
|||||||
std::cerr << "AUTOGEN: error: " << absFilename << " The file "
|
std::cerr << "AUTOGEN: error: " << absFilename << " The file "
|
||||||
<< "includes the moc file \"" << currentMoc << "\", "
|
<< "includes the moc file \"" << currentMoc << "\", "
|
||||||
<< "but could not find header \"" << basename
|
<< "but could not find header \"" << basename
|
||||||
<< '{' << this->Join(headerExtensions, ',') << "}\" ";
|
<< '{' << this->JoinExts(headerExtensions) << "}\" ";
|
||||||
if (mocSubDir.empty())
|
if (mocSubDir.empty())
|
||||||
{
|
{
|
||||||
std::cerr << "in " << absPath << "\n" << std::endl;
|
std::cerr << "in " << absPath << "\n" << std::endl;
|
||||||
@ -1119,6 +1062,102 @@ void cmQtAutoGenerators::ParseHeaders(const std::set<std::string>& absHeaders,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool cmQtAutoGenerators::GenerateMocFiles(
|
||||||
|
const std::map<std::string, std::string>& includedMocs,
|
||||||
|
const std::map<std::string, std::string>& notIncludedMocs )
|
||||||
|
{
|
||||||
|
// generate moc files that are included by source files.
|
||||||
|
for(std::map<std::string, std::string>::const_iterator
|
||||||
|
it = includedMocs.begin(); it != includedMocs.end(); ++it)
|
||||||
|
{
|
||||||
|
if (!this->GenerateMoc(it->first, it->second))
|
||||||
|
{
|
||||||
|
if (this->RunMocFailed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate moc files that are _not_ included by source files.
|
||||||
|
bool automocCppChanged = false;
|
||||||
|
for(std::map<std::string, std::string>::const_iterator
|
||||||
|
it = notIncludedMocs.begin(); it != notIncludedMocs.end(); ++it)
|
||||||
|
{
|
||||||
|
if (this->GenerateMoc(it->first, it->second))
|
||||||
|
{
|
||||||
|
automocCppChanged = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this->RunMocFailed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// compose _automoc.cpp content
|
||||||
|
std::string automocSource;
|
||||||
|
{
|
||||||
|
std::stringstream outStream;
|
||||||
|
outStream << "/* This file is autogenerated, do not edit*/\n";
|
||||||
|
if( notIncludedMocs.empty() )
|
||||||
|
{
|
||||||
|
outStream << "enum some_compilers { need_more_than_nothing };\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(std::map<std::string, std::string>::const_iterator
|
||||||
|
it = notIncludedMocs.begin();
|
||||||
|
it != notIncludedMocs.end();
|
||||||
|
++it)
|
||||||
|
{
|
||||||
|
outStream << "#include \"" << it->second << "\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outStream.flush();
|
||||||
|
automocSource = outStream.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if we even need to update _automoc.cpp
|
||||||
|
if (!automocCppChanged)
|
||||||
|
{
|
||||||
|
// compare contents of the _automoc.cpp file
|
||||||
|
const std::string oldContents = ReadAll(this->OutMocCppFilename);
|
||||||
|
if (oldContents == automocSource)
|
||||||
|
{
|
||||||
|
// nothing changed: don't touch the _automoc.cpp file
|
||||||
|
if (this->Verbose)
|
||||||
|
{
|
||||||
|
std::cout << "AUTOGEN: " << this->OutMocCppFilenameRel
|
||||||
|
<< " still up to date" << std::endl;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// actually write _automoc.cpp
|
||||||
|
{
|
||||||
|
std::string msg = "Generating ";
|
||||||
|
msg += this->OutMocCppFilenameRel;
|
||||||
|
cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
|
||||||
|
|cmsysTerminal_Color_ForegroundBold,
|
||||||
|
msg.c_str(), true, this->ColorOutput);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
cmsys::ofstream outfile;
|
||||||
|
outfile.open(this->OutMocCppFilename.c_str(),
|
||||||
|
std::ios::trunc);
|
||||||
|
outfile << automocSource;
|
||||||
|
outfile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
||||||
const std::string& mocFileName)
|
const std::string& mocFileName)
|
||||||
{
|
{
|
||||||
@ -1159,13 +1198,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|||||||
|
|
||||||
if (this->Verbose)
|
if (this->Verbose)
|
||||||
{
|
{
|
||||||
for(std::vector<std::string>::const_iterator cmdIt = command.begin();
|
this->LogCommand(command);
|
||||||
cmdIt != command.end();
|
|
||||||
++cmdIt)
|
|
||||||
{
|
|
||||||
std::cout << *cmdIt << " ";
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
@ -1184,28 +1217,74 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool cmQtAutoGenerators::GenerateUiFiles(
|
||||||
|
const std::map<std::string, std::vector<std::string> >& includedUis )
|
||||||
|
{
|
||||||
|
// single map with input / output names
|
||||||
|
std::map<std::string, std::map<std::string, std::string> > uiGenMap;
|
||||||
|
for(std::map<std::string, std::vector<std::string> >::const_iterator
|
||||||
|
it = includedUis.begin(); it != includedUis.end(); ++it)
|
||||||
|
{
|
||||||
|
// source file path
|
||||||
|
std::string sourcePath = cmsys::SystemTools::GetFilenamePath(it->first);
|
||||||
|
sourcePath += '/';
|
||||||
|
// insert new map for source file an use new reference
|
||||||
|
uiGenMap[it->first] = std::map<std::string, std::string>();
|
||||||
|
std::map<std::string, std::string>& sourceMap = uiGenMap[it->first];
|
||||||
|
for (std::vector<std::string>::const_iterator sit = it->second.begin();
|
||||||
|
sit != it->second.end();
|
||||||
|
++sit)
|
||||||
|
{
|
||||||
|
const std::string & uiFileName = *sit;
|
||||||
|
const std::string uiInputFile = sourcePath + uiFileName + ".ui";
|
||||||
|
const std::string uiOutputFile = "ui_" + uiFileName + ".h";
|
||||||
|
sourceMap[uiInputFile] = uiOutputFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate ui files
|
||||||
|
for(std::map<std::string, std::map<std::string, std::string> >::
|
||||||
|
const_iterator it = uiGenMap.begin(); it != uiGenMap.end(); ++it)
|
||||||
|
{
|
||||||
|
for(std::map<std::string, std::string>::const_iterator
|
||||||
|
sit = it->second.begin();
|
||||||
|
sit != it->second.end();
|
||||||
|
++sit)
|
||||||
|
{
|
||||||
|
if (!this->GenerateUi(it->first, sit->first, sit->second) )
|
||||||
|
{
|
||||||
|
if (this->RunUicFailed)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
||||||
const std::string& uiFileName)
|
const std::string& uiInputFile,
|
||||||
|
const std::string& uiOutputFile)
|
||||||
{
|
{
|
||||||
if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
|
if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
|
||||||
{
|
{
|
||||||
cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
|
cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string path = cmsys::SystemTools::GetFilenamePath(
|
const ::std::string uiBuildFile = this->Builddir + uiOutputFile;
|
||||||
realName) + '/';
|
|
||||||
|
|
||||||
std::string ui_output_file = "ui_" + uiFileName + ".h";
|
|
||||||
std::string ui_input_file = path + uiFileName + ".ui";
|
|
||||||
|
|
||||||
int sourceNewerThanUi = 0;
|
int sourceNewerThanUi = 0;
|
||||||
bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file,
|
bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile,
|
||||||
this->Builddir + ui_output_file,
|
uiBuildFile,
|
||||||
&sourceNewerThanUi);
|
&sourceNewerThanUi);
|
||||||
if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
|
if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
|
||||||
{
|
{
|
||||||
std::string msg = "Generating ";
|
std::string msg = "Generating ";
|
||||||
msg += ui_output_file;
|
msg += uiOutputFile;
|
||||||
cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
|
cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
|
||||||
|cmsysTerminal_Color_ForegroundBold,
|
|cmsysTerminal_Color_ForegroundBold,
|
||||||
msg.c_str(), true, this->ColorOutput);
|
msg.c_str(), true, this->ColorOutput);
|
||||||
@ -1215,7 +1294,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|||||||
|
|
||||||
std::vector<std::string> opts = this->UicTargetOptions;
|
std::vector<std::string> opts = this->UicTargetOptions;
|
||||||
std::map<std::string, std::string>::const_iterator optionIt
|
std::map<std::string, std::string>::const_iterator optionIt
|
||||||
= this->UicOptions.find(ui_input_file);
|
= this->UicOptions.find(uiInputFile);
|
||||||
if (optionIt != this->UicOptions.end())
|
if (optionIt != this->UicOptions.end())
|
||||||
{
|
{
|
||||||
std::vector<std::string> fileOpts;
|
std::vector<std::string> fileOpts;
|
||||||
@ -1226,18 +1305,12 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|||||||
command.insert(command.end(), opts.begin(), opts.end());
|
command.insert(command.end(), opts.begin(), opts.end());
|
||||||
|
|
||||||
command.push_back("-o");
|
command.push_back("-o");
|
||||||
command.push_back(this->Builddir + ui_output_file);
|
command.push_back(uiBuildFile);
|
||||||
command.push_back(ui_input_file);
|
command.push_back(uiInputFile);
|
||||||
|
|
||||||
if (this->Verbose)
|
if (this->Verbose)
|
||||||
{
|
{
|
||||||
for(std::vector<std::string>::const_iterator cmdIt = command.begin();
|
this->LogCommand(command);
|
||||||
cmdIt != command.end();
|
|
||||||
++cmdIt)
|
|
||||||
{
|
|
||||||
std::cout << *cmdIt << " ";
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
}
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
@ -1245,11 +1318,11 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|||||||
&retVal);
|
&retVal);
|
||||||
if (!result || retVal)
|
if (!result || retVal)
|
||||||
{
|
{
|
||||||
std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
|
std::cerr << "AUTOUIC: error: process for " << uiOutputFile <<
|
||||||
" needed by\n \"" << realName << "\"\nfailed:\n" << output
|
" needed by\n \"" << realName << "\"\nfailed:\n" << output
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
this->RunUicFailed = true;
|
this->RunUicFailed = true;
|
||||||
cmSystemTools::RemoveFile(ui_output_file);
|
cmSystemTools::RemoveFile(uiOutputFile);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1276,70 +1349,32 @@ bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmQtAutoGenerators::GenerateQrc()
|
bool cmQtAutoGenerators::GenerateQrcFiles()
|
||||||
{
|
{
|
||||||
|
// generate single map with input / output names
|
||||||
|
std::map<std::string, std::string> qrcGenMap;
|
||||||
for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
|
for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
|
||||||
si != this->RccSources.end(); ++si)
|
si != this->RccSources.end(); ++si)
|
||||||
{
|
{
|
||||||
std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
|
const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
|
||||||
|
if (ext == ".qrc")
|
||||||
if (ext != ".qrc")
|
|
||||||
{
|
{
|
||||||
continue;
|
std::string basename = cmsys::SystemTools::
|
||||||
|
GetFilenameWithoutLastExtension(*si);
|
||||||
|
std::string qrcOutputFile = "CMakeFiles/" + this->OriginTargetName
|
||||||
|
+ ".dir/qrc_" + basename + ".cpp";
|
||||||
|
qrcGenMap[*si] = qrcOutputFile;
|
||||||
}
|
}
|
||||||
std::vector<std::string> command;
|
}
|
||||||
command.push_back(this->RccExecutable);
|
|
||||||
|
|
||||||
std::string basename = cmsys::SystemTools::
|
// generate qrc files
|
||||||
GetFilenameWithoutLastExtension(*si);
|
for(std::map<std::string, std::string>::const_iterator
|
||||||
|
si = qrcGenMap.begin(); si != qrcGenMap.end(); ++si)
|
||||||
std::string rcc_output_file = this->Builddir
|
{
|
||||||
+ "CMakeFiles/" + this->OriginTargetName
|
if (!this->GenerateQrc( si->first, si->second))
|
||||||
+ ".dir/qrc_" + basename + ".cpp";
|
|
||||||
|
|
||||||
int sourceNewerThanQrc = 0;
|
|
||||||
bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si,
|
|
||||||
rcc_output_file,
|
|
||||||
&sourceNewerThanQrc);
|
|
||||||
generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
|
|
||||||
generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si,
|
|
||||||
rcc_output_file);
|
|
||||||
|
|
||||||
if (this->GenerateAll || generateQrc)
|
|
||||||
{
|
{
|
||||||
std::map<std::string, std::string>::const_iterator optionIt
|
if (this->RunRccFailed)
|
||||||
= this->RccOptions.find(*si);
|
|
||||||
if (optionIt != this->RccOptions.end())
|
|
||||||
{
|
{
|
||||||
cmSystemTools::ExpandListArgument(optionIt->second, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
command.push_back("-name");
|
|
||||||
command.push_back(basename);
|
|
||||||
command.push_back("-o");
|
|
||||||
command.push_back(rcc_output_file);
|
|
||||||
command.push_back(*si);
|
|
||||||
|
|
||||||
if (this->Verbose)
|
|
||||||
{
|
|
||||||
for(std::vector<std::string>::const_iterator cmdIt = command.begin();
|
|
||||||
cmdIt != command.end();
|
|
||||||
++cmdIt)
|
|
||||||
{
|
|
||||||
std::cout << *cmdIt << " ";
|
|
||||||
}
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
std::string output;
|
|
||||||
int retVal = 0;
|
|
||||||
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
|
||||||
&retVal);
|
|
||||||
if (!result || retVal)
|
|
||||||
{
|
|
||||||
std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
|
|
||||||
" failed:\n" << output << std::endl;
|
|
||||||
this->RunRccFailed = true;
|
|
||||||
cmSystemTools::RemoveFile(rcc_output_file);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1347,8 +1382,88 @@ bool cmQtAutoGenerators::GenerateQrc()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
|
bool cmQtAutoGenerators::GenerateQrc (
|
||||||
char separator)
|
const std::string& qrcInputFile,
|
||||||
|
const std::string& qrcOutputFile )
|
||||||
|
{
|
||||||
|
const std::string basename = cmsys::SystemTools::
|
||||||
|
GetFilenameWithoutLastExtension(qrcInputFile);
|
||||||
|
const ::std::string qrcBuildFile = this->Builddir + qrcOutputFile;
|
||||||
|
|
||||||
|
int sourceNewerThanQrc = 0;
|
||||||
|
bool generateQrc = !cmsys::SystemTools::FileTimeCompare(qrcInputFile,
|
||||||
|
qrcBuildFile,
|
||||||
|
&sourceNewerThanQrc);
|
||||||
|
generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
|
||||||
|
generateQrc = generateQrc || this->InputFilesNewerThanQrc(qrcInputFile,
|
||||||
|
qrcBuildFile);
|
||||||
|
|
||||||
|
if (this->GenerateAll || generateQrc)
|
||||||
|
{
|
||||||
|
std::string msg = "Generating ";
|
||||||
|
msg += qrcOutputFile;
|
||||||
|
cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue
|
||||||
|
|cmsysTerminal_Color_ForegroundBold,
|
||||||
|
msg.c_str(), true, this->ColorOutput);
|
||||||
|
|
||||||
|
std::vector<std::string> command;
|
||||||
|
command.push_back(this->RccExecutable);
|
||||||
|
|
||||||
|
std::map<std::string, std::string>::const_iterator optionIt
|
||||||
|
= this->RccOptions.find(qrcInputFile);
|
||||||
|
if (optionIt != this->RccOptions.end())
|
||||||
|
{
|
||||||
|
cmSystemTools::ExpandListArgument(optionIt->second, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
command.push_back("-name");
|
||||||
|
command.push_back(basename);
|
||||||
|
command.push_back("-o");
|
||||||
|
command.push_back(qrcBuildFile);
|
||||||
|
command.push_back(qrcInputFile);
|
||||||
|
|
||||||
|
if (this->Verbose)
|
||||||
|
{
|
||||||
|
this->LogCommand(command);
|
||||||
|
}
|
||||||
|
std::string output;
|
||||||
|
int retVal = 0;
|
||||||
|
bool result = cmSystemTools::RunSingleCommand(command, &output, &output,
|
||||||
|
&retVal);
|
||||||
|
if (!result || retVal)
|
||||||
|
{
|
||||||
|
std::cerr << "AUTORCC: error: process for " << qrcOutputFile <<
|
||||||
|
" failed:\n" << output << std::endl;
|
||||||
|
this->RunRccFailed = true;
|
||||||
|
cmSystemTools::RemoveFile(qrcBuildFile);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
|
||||||
|
{
|
||||||
|
std::stringstream sbuf;
|
||||||
|
for(std::vector<std::string>::const_iterator cmdIt = command.begin();
|
||||||
|
cmdIt != command.end();
|
||||||
|
++cmdIt)
|
||||||
|
{
|
||||||
|
if ( cmdIt != command.begin() )
|
||||||
|
{
|
||||||
|
sbuf << " ";
|
||||||
|
}
|
||||||
|
sbuf << *cmdIt;
|
||||||
|
}
|
||||||
|
sbuf.flush();
|
||||||
|
if ( !sbuf.str().empty() )
|
||||||
|
{
|
||||||
|
std::cout << sbuf.str();
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst)
|
||||||
{
|
{
|
||||||
if (lst.empty())
|
if (lst.empty())
|
||||||
{
|
{
|
||||||
@ -1356,30 +1471,17 @@ std::string cmQtAutoGenerators::Join(const std::vector<std::string>& lst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
|
std::string separator = ",";
|
||||||
for (std::vector<std::string>::const_iterator it = lst.begin();
|
for (std::vector<std::string>::const_iterator it = lst.begin();
|
||||||
it != lst.end();
|
it != lst.end();
|
||||||
++it)
|
++it)
|
||||||
{
|
{
|
||||||
result += "." + (*it) + separator;
|
if(it != lst.begin())
|
||||||
|
{
|
||||||
|
result += separator;
|
||||||
|
}
|
||||||
|
result += '.' + (*it);
|
||||||
}
|
}
|
||||||
result.erase(result.end() - 1);
|
result.erase(result.end() - 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool cmQtAutoGenerators::StartsWith(const std::string& str,
|
|
||||||
const std::string& with)
|
|
||||||
{
|
|
||||||
return (str.substr(0, with.length()) == with);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool cmQtAutoGenerators::EndsWith(const std::string& str,
|
|
||||||
const std::string& with)
|
|
||||||
{
|
|
||||||
if (with.length() > (str.length()))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (str.substr(str.length() - with.length(), with.length()) == with);
|
|
||||||
}
|
|
||||||
|
@ -39,10 +39,19 @@ private:
|
|||||||
std::string MakeCompileSettingsString(cmMakefile* makefile);
|
std::string MakeCompileSettingsString(cmMakefile* makefile);
|
||||||
|
|
||||||
bool RunAutogen(cmMakefile* makefile);
|
bool RunAutogen(cmMakefile* makefile);
|
||||||
|
bool GenerateMocFiles(
|
||||||
|
const std::map<std::string, std::string>& includedMocs,
|
||||||
|
const std::map<std::string, std::string>& notIncludedMocs);
|
||||||
bool GenerateMoc(const std::string& sourceFile,
|
bool GenerateMoc(const std::string& sourceFile,
|
||||||
const std::string& mocFileName);
|
const std::string& mocFileName);
|
||||||
bool GenerateUi(const std::string& realName, const std::string& uiFileName);
|
bool GenerateUiFiles(
|
||||||
bool GenerateQrc();
|
const std::map<std::string, std::vector<std::string> >& includedUis );
|
||||||
|
bool GenerateUi(const std::string& realName,
|
||||||
|
const std::string& uiInputFile,
|
||||||
|
const std::string& uiOutputFile );
|
||||||
|
bool GenerateQrcFiles();
|
||||||
|
bool GenerateQrc(const std::string& qrcInputFile,
|
||||||
|
const std::string& qrcOutputFile);
|
||||||
void ParseCppFile(const std::string& absFilename,
|
void ParseCppFile(const std::string& absFilename,
|
||||||
const std::vector<std::string>& headerExtensions,
|
const std::vector<std::string>& headerExtensions,
|
||||||
std::map<std::string, std::string>& includedMocs,
|
std::map<std::string, std::string>& includedMocs,
|
||||||
@ -69,9 +78,8 @@ private:
|
|||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
std::string Join(const std::vector<std::string>& lst, char separator);
|
void LogCommand(const std::vector<std::string>& command);
|
||||||
bool EndsWith(const std::string& str, const std::string& with);
|
std::string JoinExts(const std::vector<std::string>& lst);
|
||||||
bool StartsWith(const std::string& str, const std::string& with);
|
|
||||||
|
|
||||||
static void MergeUicOptions(std::vector<std::string> &opts,
|
static void MergeUicOptions(std::vector<std::string> &opts,
|
||||||
const std::vector<std::string> &fileOpts, bool isQt5);
|
const std::vector<std::string> &fileOpts, bool isQt5);
|
||||||
@ -101,6 +109,7 @@ private:
|
|||||||
std::string CurrentCompileSettingsStr;
|
std::string CurrentCompileSettingsStr;
|
||||||
std::string OldCompileSettingsStr;
|
std::string OldCompileSettingsStr;
|
||||||
|
|
||||||
|
std::string OutMocCppFilenameRel;
|
||||||
std::string OutMocCppFilename;
|
std::string OutMocCppFilename;
|
||||||
std::list<std::string> MocIncludes;
|
std::list<std::string> MocIncludes;
|
||||||
std::list<std::string> MocDefinitions;
|
std::list<std::string> MocDefinitions;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user