qmake: Fix infinite make loop if RESOURCES contains nonexistent .qrc

If RESOURCES contained a non-existent .qrc file, qmake produced
Makefiles that resulted in an infinite loop when running GNU Make.

Introduce a new extra compiler CONFIG value "remove_no_exist" that
removes non-existent extra compiler input. This value is now used in the
extra compiler that handles the RESOURCES variable.

The difference to the existing CONFIG value "ignore_no_exist" is that
qmake still prints a warning about the non-existent file.

Pick-to: 6.5
Fixes: QTBUG-112743
Change-Id: I3293af75b75f217e1a1738b49da0af1117cfdecb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Joerg Bornemann 2023-04-12 13:06:53 +02:00
parent 69d4ecd6ef
commit 0aa9b08536
3 changed files with 19 additions and 9 deletions

View File

@ -13,7 +13,7 @@ qtEnsurePluginResourcesCpp()
rcc.input = RESOURCES rcc.input = RESOURCES
rcc.name = RCC ${QMAKE_FILE_IN} rcc.name = RCC ${QMAKE_FILE_IN}
rcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN} rcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
rcc.CONFIG += add_inputs_as_makefile_deps dep_lines rcc.CONFIG += add_inputs_as_makefile_deps dep_lines remove_no_exist
!resources_big|ltcg|macx-xcode|wasm|contains(TEMPLATE, "vc.*") { !resources_big|ltcg|macx-xcode|wasm|contains(TEMPLATE, "vc.*") {

View File

@ -297,9 +297,9 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString
debug_msg(1, "%s:%d Failure to find %s in vpath (%s)", debug_msg(1, "%s:%d Failure to find %s in vpath (%s)",
__FILE__, __LINE__, val.toLatin1().constData(), __FILE__, __LINE__, val.toLatin1().constData(),
vpath.join(QString("::")).toLatin1().constData()); vpath.join(QString("::")).toLatin1().constData());
if(flags & VPATH_RemoveMissingFiles) if (flags & VPATH_RemoveMissingFiles)
remove_file = true; remove_file = true;
else if(flags & VPATH_WarnMissingFiles) if (flags & VPATH_WarnMissingFiles)
warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData()); warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData());
} else { } else {
l.removeAt(val_it); l.removeAt(val_it);
@ -315,9 +315,9 @@ MakefileGenerator::findFilesInVPATH(ProStringList l, uchar flags, const QString
debug_msg(1, "%s:%d Cannot match %s%s, as %s does not exist.", debug_msg(1, "%s:%d Cannot match %s%s, as %s does not exist.",
__FILE__, __LINE__, real_dir.toLatin1().constData(), __FILE__, __LINE__, real_dir.toLatin1().constData(),
regex.toLatin1().constData(), real_dir.toLatin1().constData()); regex.toLatin1().constData(), real_dir.toLatin1().constData());
if(flags & VPATH_RemoveMissingFiles) if (flags & VPATH_RemoveMissingFiles)
remove_file = true; remove_file = true;
else if(flags & VPATH_WarnMissingFiles) if (flags & VPATH_WarnMissingFiles)
warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData()); warn_msg(WarnLogic, "Failure to find: %s", val.toLatin1().constData());
} }
} }
@ -338,9 +338,14 @@ MakefileGenerator::initCompiler(const MakefileGenerator::Compiler &comp)
// find all the relevant file inputs // find all the relevant file inputs
if(!init_compiler_already.contains(comp.variable_in)) { if(!init_compiler_already.contains(comp.variable_in)) {
init_compiler_already.insert(comp.variable_in, true); init_compiler_already.insert(comp.variable_in, true);
if(!noIO()) if(!noIO()) {
l = findFilesInVPATH(l, (comp.flags & Compiler::CompilerRemoveNoExist) ? uchar flags = 0;
VPATH_RemoveMissingFiles : VPATH_WarnMissingFiles, "VPATH_" + comp.variable_in); if (comp.flags & Compiler::CompilerRemoveNoExist)
flags |= VPATH_RemoveMissingFiles;
if (comp.flags & Compiler::CompilerWarnNoExist)
flags |= VPATH_WarnMissingFiles;
l = findFilesInVPATH(l, flags, "VPATH_" + comp.variable_in);
}
} }
} }
@ -613,6 +618,10 @@ MakefileGenerator::init()
const ProStringList &config = v[ProKey(*it + ".CONFIG")]; const ProStringList &config = v[ProKey(*it + ".CONFIG")];
if (config.indexOf("ignore_no_exist") != -1) if (config.indexOf("ignore_no_exist") != -1)
compiler.flags |= Compiler::CompilerRemoveNoExist; compiler.flags |= Compiler::CompilerRemoveNoExist;
else
compiler.flags |= Compiler::CompilerWarnNoExist;
if (config.indexOf("remove_no_exist") != -1)
compiler.flags |= Compiler::CompilerRemoveNoExist;
if (config.indexOf("no_dependencies") != -1) if (config.indexOf("no_dependencies") != -1)
compiler.flags |= Compiler::CompilerNoCheckDeps; compiler.flags |= Compiler::CompilerNoCheckDeps;
if (config.indexOf("add_inputs_as_makefile_deps") != -1) if (config.indexOf("add_inputs_as_makefile_deps") != -1)

View File

@ -145,7 +145,8 @@ protected:
CompilerBuiltin = 0x01, CompilerBuiltin = 0x01,
CompilerNoCheckDeps = 0x02, CompilerNoCheckDeps = 0x02,
CompilerRemoveNoExist = 0x04, CompilerRemoveNoExist = 0x04,
CompilerAddInputsAsMakefileDeps = 0x08 CompilerWarnNoExist = 0x08,
CompilerAddInputsAsMakefileDeps = 0x10
}; };
uint flags, type; uint flags, type;
}; };