summaryrefslogtreecommitdiffstats
path: root/src/linguist/shared/runqttool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/linguist/shared/runqttool.cpp')
-rw-r--r--src/linguist/shared/runqttool.cpp64
1 files changed, 27 insertions, 37 deletions
diff --git a/src/linguist/shared/runqttool.cpp b/src/linguist/shared/runqttool.cpp
index caf1e4135..f0be67c8d 100644
--- a/src/linguist/shared/runqttool.cpp
+++ b/src/linguist/shared/runqttool.cpp
@@ -1,32 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Linguist 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) 2018 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "runqttool.h"
+#include "fmt.h"
#include "profileutils.h"
@@ -41,10 +17,6 @@
#include <sys/wait.h>
#endif
-class FMT {
- Q_DECLARE_TR_FUNCTIONS(Linguist)
-};
-
static QString qtToolFilePath(const QString &toolName, QLibraryInfo::LibraryPath location)
{
QString filePath = QLibraryInfo::path(location) + QLatin1Char('/') + toolName;
@@ -54,7 +26,7 @@ static QString qtToolFilePath(const QString &toolName, QLibraryInfo::LibraryPath
return QDir::cleanPath(filePath);
}
-static void printErr(const QString &out)
+static void rtPrintErr(const QString &out)
{
std::cerr << qUtf8Printable(out);
}
@@ -88,8 +60,8 @@ static QString commandLineForSystem(const QString &program,
+ shellQuoted(arguments).join(QLatin1Char(' '));
}
-void runQtTool(const QString &toolName, const QStringList &arguments,
- QLibraryInfo::LibraryPath location)
+static int runQtToolHelper(const QString &toolName, const QStringList &arguments,
+ QLibraryInfo::LibraryPath location)
{
int exitCode = 0;
const QString commandLine = commandLineForSystem(qtToolFilePath(toolName, location), arguments);
@@ -101,24 +73,42 @@ void runQtTool(const QString &toolName, const QStringList &arguments,
#else
exitCode = std::system(qPrintable(commandLine));
#endif
+ return exitCode;
+}
+
+void runQtTool(const QString &toolName, const QStringList &arguments,
+ QLibraryInfo::LibraryPath location)
+{
+ const int exitCode = runQtToolHelper(toolName, arguments, location);
if (exitCode != 0)
exit(exitCode);
}
+static int runInternalQtToolHelper(const QString &toolName, const QStringList &arguments)
+{
+ return runQtToolHelper(toolName, arguments, QLibraryInfo::LibraryExecutablesPath);
+}
+
void runInternalQtTool(const QString &toolName, const QStringList &arguments)
{
- runQtTool(toolName, arguments, QLibraryInfo::LibraryExecutablesPath);
+ const int exitCode = runInternalQtToolHelper(toolName, arguments);
+ if (exitCode != 0)
+ exit(exitCode);
}
std::unique_ptr<QTemporaryFile> createProjectDescription(QStringList args)
{
std::unique_ptr<QTemporaryFile> file(new QTemporaryFile(QStringLiteral("XXXXXX.json")));
if (!file->open()) {
- printErr(FMT::tr("Cannot create temporary file: %1\n").arg(file->errorString()));
+ rtPrintErr(FMT::tr("Cannot create temporary file: %1\n").arg(file->errorString()));
exit(1);
}
file->close();
args << QStringLiteral("-out") << file->fileName();
- runInternalQtTool(QStringLiteral("lprodump"), args);
+ const int exitCode = runInternalQtToolHelper(QStringLiteral("lprodump"), args);
+ if (exitCode != 0) {
+ file.reset();
+ exit(exitCode);
+ }
return file;
}