qmake: Print proper error if no .pro file could be detected
When passing a directory to qmake, it tries to detect a .pro file in that directory. Whenever the detection failed, qmake printed an error message like "Access is denied." or "file to open is a directory". Now, qmake prints an actually helpful error message: ***Cannot detect .pro file in directory '../foo'. QMake expects the file '../foo/foo.pro' or exactly one .pro file in the given directory. Fixes: QTBUG-34673 Change-Id: I3d21ead247734172eee4eb68d3f9782d3ddaea52 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
parent
747bca3d67
commit
9b2bf17f3e
@ -109,12 +109,15 @@ static Option::QMAKE_MODE default_mode(QString progname)
|
|||||||
return Option::QMAKE_GENERATE_MAKEFILE;
|
return Option::QMAKE_GENERATE_MAKEFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString detectProjectFile(const QString &path)
|
static QString detectProjectFile(const QString &path, QString *singleProFileCandidate = nullptr)
|
||||||
{
|
{
|
||||||
QString ret;
|
QString ret;
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if(dir.exists(dir.dirName() + Option::pro_ext)) {
|
const QString candidate = dir.filePath(dir.dirName() + Option::pro_ext);
|
||||||
ret = dir.filePath(dir.dirName()) + Option::pro_ext;
|
if (singleProFileCandidate)
|
||||||
|
*singleProFileCandidate = candidate;
|
||||||
|
if (QFile::exists(candidate)) {
|
||||||
|
ret = candidate;
|
||||||
} else { //last try..
|
} else { //last try..
|
||||||
QStringList profiles = dir.entryList(QStringList("*" + Option::pro_ext));
|
QStringList profiles = dir.entryList(QStringList("*" + Option::pro_ext));
|
||||||
if(profiles.count() == 1)
|
if(profiles.count() == 1)
|
||||||
@ -287,11 +290,20 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
|
|||||||
if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
|
if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
|
||||||
Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
|
Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
|
||||||
if(fi.isDir()) {
|
if(fi.isDir()) {
|
||||||
QString proj = detectProjectFile(arg);
|
QString singleProFileCandidate;
|
||||||
if (!proj.isNull())
|
QString proj = detectProjectFile(arg, &singleProFileCandidate);
|
||||||
arg = proj;
|
if (proj.isNull()) {
|
||||||
|
fprintf(stderr, "***Cannot detect .pro file in directory '%s'.\n\n"
|
||||||
|
"QMake expects the file '%s' "
|
||||||
|
"or exactly one .pro file in the given directory.\n",
|
||||||
|
qUtf8Printable(arg),
|
||||||
|
qUtf8Printable(singleProFileCandidate));
|
||||||
|
return Option::QMAKE_CMDLINE_ERROR;
|
||||||
}
|
}
|
||||||
|
Option::mkfile::project_files.append(proj);
|
||||||
|
} else {
|
||||||
Option::mkfile::project_files.append(arg);
|
Option::mkfile::project_files.append(arg);
|
||||||
|
}
|
||||||
} else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
|
} else if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) {
|
||||||
Option::projfile::project_dirs.append(arg);
|
Option::projfile::project_dirs.append(arg);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user