qmake: add line-based mode for .depend_commands

Task-number: QTBUG-48919
Change-Id: I6988fb2f26fd62ab40eb7392ccb0e033ad291fe6
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
This commit is contained in:
Oswald Buddenhagen 2018-03-21 18:50:01 +01:00
parent 9c71693de4
commit 9b48b3514f
4 changed files with 25 additions and 7 deletions

View File

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

View File

@ -9,7 +9,7 @@ uic.depend_command = $$QMAKE_UIC_DEP -d ${QMAKE_FILE_IN}
uic.output = $$UI_DIR/$${QMAKE_MOD_UIC}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_H)}
uic.input = FORMS
uic.variable_out = GENERATED_FILES
uic.CONFIG += no_link target_predeps
uic.CONFIG += no_link target_predeps dep_lines
uic.name = UIC ${QMAKE_FILE_IN}
silent:uic.commands = @echo uic ${QMAKE_FILE_IN} && $$uic.commands
QMAKE_EXTRA_COMPILERS += uic

View File

@ -4521,6 +4521,11 @@
\li explicit_dependencies
\li The dependencies for the output only get generated from the depends
member and from nowhere else.
\row
\li dep_lines
\li The output from the .depend_command is interpreted to be one file
per line. The default is to split on whitespace and is maintained
only for backwards compatibility reasons.
\row
\li no_link
\li Indicates that the output should not be added to the list of objects

View File

@ -1839,12 +1839,27 @@ MakefileGenerator::writeExtraTargets(QTextStream &t)
}
}
static QStringList splitDeps(const QString &indeps, bool lineMode)
{
if (!lineMode)
return indeps.simplified().split(' ');
QStringList deps = indeps.split('\n', QString::SkipEmptyParts);
#ifdef Q_OS_WIN
for (auto &dep : deps) {
if (dep.endsWith(QLatin1Char('\r')))
dep.chop(1);
}
#endif
return deps;
}
void
MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
{
QString clean_targets;
const ProStringList &quc = project->values("QMAKE_EXTRA_COMPILERS");
for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) {
const ProStringList &config = project->values(ProKey(*it + ".CONFIG"));
QString tmp_out = fileFixify(project->first(ProKey(*it + ".output")).toQString(),
FileFixifyFromOutdir);
const QString tmp_cmd = project->values(ProKey(*it + ".commands")).join(' ');
@ -1855,6 +1870,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
}
const bool dep_lines = (config.indexOf("dep_lines") != -1);
const ProStringList &vars = project->values(ProKey(*it + ".variables"));
if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
continue;
@ -1871,7 +1887,6 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
}
t << "compiler_" << (*it) << "_make_all:";
const ProStringList &config = project->values(ProKey(*it + ".CONFIG"));
if (config.indexOf("combine") != -1) {
// compilers with a combined input only have one output
QString input = project->first(ProKey(*it + ".output")).toQString();
@ -1978,8 +1993,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QT_PCLOSE(proc);
if(!indeps.isEmpty()) {
QDir outDir(Option::output_dir);
// ### This is basically fubar. Add 'lines' flag to CONFIG?
QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' ');
QStringList dep_cmd_deps = splitDeps(indeps, dep_lines);
for(int i = 0; i < dep_cmd_deps.count(); ++i) {
QString &file = dep_cmd_deps[i];
QString absFile = outDir.absoluteFilePath(file);
@ -2072,8 +2086,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QT_PCLOSE(proc);
if(!indeps.isEmpty()) {
QDir outDir(Option::output_dir);
// ### This is basically fubar. Add 'lines' flag to CONFIG?
QStringList dep_cmd_deps = indeps.replace('\n', ' ').simplified().split(' ');
QStringList dep_cmd_deps = splitDeps(indeps, dep_lines);
for(int i = 0; i < dep_cmd_deps.count(); ++i) {
QString &file = dep_cmd_deps[i];
QString absFile = outDir.absoluteFilePath(file);