mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 14:40:48 +08:00
Autogen: Initializer file type scanning optimizations
This commit is contained in:
@@ -720,8 +720,6 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
|||||||
const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
|
const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
|
||||||
const std::string workingDirectory =
|
const std::string workingDirectory =
|
||||||
cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
|
cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
|
||||||
const std::string qtMajorVersion = GetQtMajorVersion(target);
|
|
||||||
const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
|
|
||||||
const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile);
|
const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile);
|
||||||
std::set<std::string> autogenDependsSet;
|
std::set<std::string> autogenDependsSet;
|
||||||
std::vector<std::string> autogenProvides;
|
std::vector<std::string> autogenProvides;
|
||||||
@@ -837,99 +835,119 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extract relevant source files
|
||||||
|
std::vector<std::string> generatedSources;
|
||||||
|
std::vector<std::pair<std::string, bool> > qrcSources;
|
||||||
{
|
{
|
||||||
cmFilePathChecksum fpathCheckSum(makefile);
|
const std::string qrcExt = "qrc";
|
||||||
// Iterate over all source files
|
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
target->GetConfigCommonSourceFiles(srcFiles);
|
target->GetConfigCommonSourceFiles(srcFiles);
|
||||||
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
||||||
fileIt != srcFiles.end(); ++fileIt) {
|
fileIt != srcFiles.end(); ++fileIt) {
|
||||||
cmSourceFile* sf = *fileIt;
|
cmSourceFile* sf = *fileIt;
|
||||||
if (!sf->GetPropertyAsBool("SKIP_AUTOGEN")) {
|
if (sf->GetPropertyAsBool("SKIP_AUTOGEN")) {
|
||||||
std::string const& ext = sf->GetExtension();
|
continue;
|
||||||
// Add generated file that will be scanned by moc or uic to
|
}
|
||||||
// the dependencies
|
// sf->GetExtension() is only valid after sf->GetFullPath() ...
|
||||||
if (mocEnabled || uicEnabled) {
|
const std::string& fPath = sf->GetFullPath();
|
||||||
const cmSystemTools::FileFormat fileType =
|
const std::string& ext = sf->GetExtension();
|
||||||
cmSystemTools::GetFileFormat(ext.c_str());
|
// Register generated files that will be scanned by moc or uic
|
||||||
if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
|
if (mocEnabled || uicEnabled) {
|
||||||
(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
|
const cmSystemTools::FileFormat fileType =
|
||||||
if (sf->GetPropertyAsBool("GENERATED")) {
|
cmSystemTools::GetFileFormat(ext.c_str());
|
||||||
if ((mocEnabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) ||
|
if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
|
||||||
(uicEnabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) {
|
(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
|
||||||
autogenDependsSet.insert(
|
if (sf->GetPropertyAsBool("GENERATED")) {
|
||||||
cmsys::SystemTools::GetRealPath(sf->GetFullPath()));
|
if ((mocEnabled && !sf->GetPropertyAsBool("SKIP_AUTOMOC")) ||
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
(uicEnabled && !sf->GetPropertyAsBool("SKIP_AUTOUIC"))) {
|
||||||
// Cannot use PRE_BUILD with generated files
|
generatedSources.push_back(
|
||||||
usePRE_BUILD = false;
|
cmsys::SystemTools::GetRealPath(fPath));
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Process rcc enabled files
|
}
|
||||||
if (rccEnabled && (ext == "qrc") &&
|
// Register rcc enabled files
|
||||||
!sf->GetPropertyAsBool("SKIP_AUTORCC")) {
|
if (rccEnabled && (ext == qrcExt) &&
|
||||||
const std::string absFile =
|
!sf->GetPropertyAsBool("SKIP_AUTORCC")) {
|
||||||
cmsys::SystemTools::GetRealPath(sf->GetFullPath());
|
qrcSources.push_back(
|
||||||
|
std::pair<std::string, bool>(cmsys::SystemTools::GetRealPath(fPath),
|
||||||
|
sf->GetPropertyAsBool("GENERATED")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's
|
||||||
|
// sources meta data cache. Clear it so that OBJECT library targets that
|
||||||
|
// are AUTOGEN initialized after this target get their added
|
||||||
|
// mocs_compilation.cpp source acknowledged by this target.
|
||||||
|
target->ClearSourcesCache();
|
||||||
|
}
|
||||||
|
|
||||||
// Compose rcc output file name
|
if (!generatedSources.empty()) {
|
||||||
{
|
for (std::vector<std::string>::const_iterator it =
|
||||||
std::string rccBuildFile = autogenBuildDir + "/";
|
generatedSources.begin();
|
||||||
rccBuildFile += fpathCheckSum.getPart(absFile);
|
it != generatedSources.end(); ++it) {
|
||||||
rccBuildFile += "/qrc_";
|
autogenDependsSet.insert(*it);
|
||||||
rccBuildFile +=
|
}
|
||||||
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
|
}
|
||||||
rccBuildFile += ".cpp";
|
|
||||||
|
|
||||||
// Register rcc ouput file as generated
|
if (!qrcSources.empty()) {
|
||||||
AddGeneratedSource(target, rccBuildFile,
|
const std::string qtMajorVersion = GetQtMajorVersion(target);
|
||||||
cmQtAutoGeneratorCommon::RCC);
|
const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
|
||||||
// Register rcc ouput file as generated by the _autogen target
|
const cmFilePathChecksum fpathCheckSum(makefile);
|
||||||
autogenProvides.push_back(rccBuildFile);
|
for (std::vector<std::pair<std::string, bool> >::const_iterator it =
|
||||||
}
|
qrcSources.begin();
|
||||||
|
it != qrcSources.end(); ++it) {
|
||||||
|
const std::string& absFile = it->first;
|
||||||
|
|
||||||
if (sf->GetPropertyAsBool("GENERATED")) {
|
// Compose rcc output file name
|
||||||
// Add generated qrc file to the dependencies
|
{
|
||||||
autogenDependsSet.insert(absFile);
|
std::string rccBuildFile = autogenBuildDir + "/";
|
||||||
|
rccBuildFile += fpathCheckSum.getPart(absFile);
|
||||||
|
rccBuildFile += "/qrc_";
|
||||||
|
rccBuildFile +=
|
||||||
|
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
|
||||||
|
rccBuildFile += ".cpp";
|
||||||
|
|
||||||
|
// Register rcc ouput file as generated
|
||||||
|
AddGeneratedSource(target, rccBuildFile, cmQtAutoGeneratorCommon::RCC);
|
||||||
|
// Register rcc ouput file as generated by the _autogen target
|
||||||
|
autogenProvides.push_back(rccBuildFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it->second) {
|
||||||
|
// Add generated qrc file to the dependencies
|
||||||
|
autogenDependsSet.insert(absFile);
|
||||||
|
} else {
|
||||||
|
// Run cmake again when .qrc file changes
|
||||||
|
makefile->AddCMakeDependFile(absFile);
|
||||||
|
// Add the qrc input files to the dependencies
|
||||||
|
{
|
||||||
|
std::string error;
|
||||||
|
std::vector<std::string> extraDepends;
|
||||||
|
if (cmQtAutoGeneratorCommon::RccListInputs(
|
||||||
|
qtMajorVersion, rccCommand, absFile, extraDepends, &error)) {
|
||||||
|
autogenDependsSet.insert(extraDepends.begin(), extraDepends.end());
|
||||||
} else {
|
} else {
|
||||||
// Run cmake again when .qrc file changes
|
cmSystemTools::Error(error.c_str());
|
||||||
makefile->AddCMakeDependFile(absFile);
|
|
||||||
// Add the qrc input files to the dependencies
|
|
||||||
{
|
|
||||||
std::string error;
|
|
||||||
std::vector<std::string> extraDepends;
|
|
||||||
if (cmQtAutoGeneratorCommon::RccListInputs(
|
|
||||||
qtMajorVersion, rccCommand, absFile, extraDepends,
|
|
||||||
&error)) {
|
|
||||||
autogenDependsSet.insert(extraDepends.begin(),
|
|
||||||
extraDepends.end());
|
|
||||||
} else {
|
|
||||||
cmSystemTools::Error(error.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
// Cannot use PRE_BUILD because the resource files themselves
|
|
||||||
// may not be sources within the target so VS may not know the
|
|
||||||
// target needs to re-build at all.
|
|
||||||
usePRE_BUILD = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's
|
|
||||||
// sources meta data cache. Clear it so that OBJECT library targets that
|
|
||||||
// are AUTOGEN initialized after this target get their added
|
|
||||||
// mocs_compilation.cpp source acknowledged by this target.
|
|
||||||
target->ClearSourcesCache();
|
|
||||||
|
|
||||||
// Convert std::set to std::vector
|
// Convert std::set to std::vector
|
||||||
const std::vector<std::string> autogenDepends(autogenDependsSet.begin(),
|
const std::vector<std::string> autogenDepends(autogenDependsSet.begin(),
|
||||||
autogenDependsSet.end());
|
autogenDependsSet.end());
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
|
if (usePRE_BUILD) {
|
||||||
|
if (!generatedSources.empty() || !qrcSources.empty()) {
|
||||||
|
// - Cannot use PRE_BUILD with generated files
|
||||||
|
// - Cannot use PRE_BUILD because the resource files themselves
|
||||||
|
// may not be sources within the target so VS may not know the
|
||||||
|
// target needs to re-build at all.
|
||||||
|
usePRE_BUILD = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (usePRE_BUILD) {
|
if (usePRE_BUILD) {
|
||||||
// If the autogen target depends on an other target don't use PRE_BUILD
|
// If the autogen target depends on an other target don't use PRE_BUILD
|
||||||
for (std::vector<std::string>::const_iterator it = autogenDepends.begin();
|
for (std::vector<std::string>::const_iterator it = autogenDepends.begin();
|
||||||
|
Reference in New Issue
Block a user