summaryrefslogtreecommitdiffstats
path: root/qmake/option.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qmake/option.cpp')
-rw-r--r--qmake/option.cpp73
1 files changed, 31 insertions, 42 deletions
diff --git a/qmake/option.cpp b/qmake/option.cpp
index 72edf9c271..0e2d199232 100644
--- a/qmake/option.cpp
+++ b/qmake/option.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the qmake application of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "option.h"
#include "cachekeys.h"
@@ -37,6 +12,7 @@
#include <stdarg.h>
#include <qmakelibraryinfo.h>
+#include <qtversion.h>
#include <private/qlibraryinfo_p.h>
QT_BEGIN_NAMESPACE
@@ -101,7 +77,7 @@ static Option::QMAKE_MODE default_mode(QString progname)
{
int s = progname.lastIndexOf(QDir::separator());
if(s != -1)
- progname = progname.right(progname.length() - (s + 1));
+ progname = progname.right(progname.size() - (s + 1));
if(progname == "qmakegen")
return Option::QMAKE_GENERATE_PROJECT;
else if(progname == "qt-config")
@@ -109,15 +85,18 @@ static Option::QMAKE_MODE default_mode(QString progname)
return Option::QMAKE_GENERATE_MAKEFILE;
}
-static QString detectProjectFile(const QString &path)
+static QString detectProjectFile(const QString &path, QString *singleProFileCandidate = nullptr)
{
QString ret;
QDir dir(path);
- if(dir.exists(dir.dirName() + Option::pro_ext)) {
- ret = dir.filePath(dir.dirName()) + Option::pro_ext;
+ const QString candidate = dir.filePath(dir.dirName() + Option::pro_ext);
+ if (singleProFileCandidate)
+ *singleProFileCandidate = candidate;
+ if (QFile::exists(candidate)) {
+ ret = candidate;
} else { //last try..
QStringList profiles = dir.entryList(QStringList("*" + Option::pro_ext));
- if(profiles.count() == 1)
+ if(profiles.size() == 1)
ret = dir.filePath(profiles.at(0));
}
return ret;
@@ -195,7 +174,7 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
{
enum { ArgNone, ArgOutput } argState = ArgNone;
int x = 0;
- while (x < args.count()) {
+ while (x < args.size()) {
switch (argState) {
case ArgOutput:
Option::output.setFileName(args.at(x--));
@@ -208,7 +187,8 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
fprintf(stderr, "***Option %s requires a parameter\n", qPrintable(args.at(x - 1)));
return Option::QMAKE_CMDLINE_SHOW_USAGE | Option::QMAKE_CMDLINE_ERROR;
}
- QLibraryInfoPrivate::qtconfManualPath = globals->qtconf;
+ if (!globals->qtconf.isEmpty())
+ QLibraryInfoPrivate::setQtconfManualPath(&globals->qtconf);
if (cmdRet == QMakeGlobals::ArgumentsOk)
break;
Q_ASSERT(cmdRet == QMakeGlobals::ArgumentUnknown);
@@ -287,11 +267,20 @@ Option::parseCommandLine(QStringList &args, QMakeCmdLineParserState &state)
if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE ||
Option::qmake_mode == Option::QMAKE_GENERATE_PRL) {
if(fi.isDir()) {
- QString proj = detectProjectFile(arg);
- if (!proj.isNull())
- arg = proj;
+ QString singleProFileCandidate;
+ QString proj = detectProjectFile(arg, &singleProFileCandidate);
+ 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) {
Option::projfile::project_dirs.append(arg);
} else {
@@ -401,7 +390,7 @@ Option::init(int argc, char **argv)
} else if (opt == "-qtconf") {
// Skip "-qtconf <file>" and proceed.
++idx;
- if (idx + 1 < args.length())
+ if (idx + 1 < args.size())
++idx;
continue;
} else {
@@ -476,7 +465,7 @@ bool Option::postProcessProject(QMakeProject *project)
if (!project->buildRoot().isEmpty() && Option::output_dir.startsWith(project->buildRoot()))
Option::mkfile::cachefile_depth =
- Option::output_dir.mid(project->buildRoot().length()).count('/');
+ Option::output_dir.mid(project->buildRoot().size()).count('/');
return true;
}
@@ -539,7 +528,7 @@ Option::fixString(QString string, uchar flags)
if ((string.startsWith("\"") && string.endsWith("\"")) ||
(string.startsWith("\'") && string.endsWith("\'")))
- string = string.mid(1, string.length()-2);
+ string = string.mid(1, string.size()-2);
//cache
//qDebug() << "Fix" << orig_string << "->" << string;
@@ -618,7 +607,7 @@ public:
*data = nullptr;
}
};
-static QList<QMakeCacheClearItem*> cache_items;
+Q_CONSTINIT static QList<QMakeCacheClearItem*> cache_items;
void
qmakeClearCaches()