summaryrefslogtreecommitdiffstats
path: root/qmake/library
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-07-15 18:09:24 +0200
committerLars Knoll <lars.knoll@qt.io>2016-08-10 15:42:29 +0000
commit0eff800e81f3e7f803dffd77737faaed73002ac8 (patch)
treeaf34639c0caf41335c9d7359549f83cfe9ca6380 /qmake/library
parent62838f07d4e4e8ae578801167b11e02480d34daa (diff)
add support for returning the command's exit status to $$system()
... and make use of it in qtRunLoggedCommand(). Change-Id: I242dfde344f555800cef1f55d3cb85418a93277f Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'qmake/library')
-rw-r--r--qmake/library/qmakebuiltins.cpp21
-rw-r--r--qmake/library/qmakeevaluator.h2
2 files changed, 17 insertions, 6 deletions
diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp
index ac3a866848..0cc3b52458 100644
--- a/qmake/library/qmakebuiltins.cpp
+++ b/qmake/library/qmakebuiltins.cpp
@@ -450,12 +450,13 @@ void QMakeEvaluator::runProcess(QProcess *proc, const QString &command) const
}
#endif
-QByteArray QMakeEvaluator::getCommandOutput(const QString &args) const
+QByteArray QMakeEvaluator::getCommandOutput(const QString &args, int *exitCode) const
{
QByteArray out;
#ifndef QT_BOOTSTRAPPED
QProcess proc;
runProcess(&proc, args);
+ *exitCode = (proc.exitStatus() == QProcess::NormalExit) ? proc.exitCode() : -1;
QByteArray errout = proc.readAllStandardError();
# ifdef PROEVALUATOR_FULL
// FIXME: Qt really should have the option to set forwarding per channel
@@ -483,7 +484,12 @@ QByteArray QMakeEvaluator::getCommandOutput(const QString &args) const
break;
out += QByteArray(buff, read_in);
}
- QT_PCLOSE(proc);
+ int ec = QT_PCLOSE(proc);
+# ifdef Q_OS_WIN
+ *exitCode = ec >= 0 ? ec : -1;
+# else
+ *exitCode = WIFEXITED(ec) ? WEXITSTATUS(ec) : -1;
+# endif
}
# ifdef Q_OS_WIN
out.replace("\r\n", "\n");
@@ -871,8 +877,8 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
break;
case E_SYSTEM:
if (!m_skipLevel) {
- if (args.count() < 1 || args.count() > 2) {
- evalError(fL1S("system(execute) requires one or two arguments."));
+ if (args.count() < 1 || args.count() > 3) {
+ evalError(fL1S("system(command, [mode], [stsvar]) requires one to three arguments."));
} else {
bool blob = false;
bool lines = false;
@@ -885,7 +891,12 @@ ProStringList QMakeEvaluator::evaluateBuiltinExpand(
else if (!args.at(1).compare(QLatin1String("lines"), Qt::CaseInsensitive))
lines = true;
}
- QByteArray bytes = getCommandOutput(args.at(0).toQString(m_tmp2));
+ int exitCode;
+ QByteArray bytes = getCommandOutput(args.at(0).toQString(m_tmp2), &exitCode);
+ if (args.count() > 2 && !args.at(2).isEmpty()) {
+ m_valuemapStack.top()[args.at(2).toKey()] =
+ ProStringList(ProString(QString::number(exitCode)));
+ }
if (lines) {
QTextStream stream(bytes);
while (!stream.atEnd())
diff --git a/qmake/library/qmakeevaluator.h b/qmake/library/qmakeevaluator.h
index eddabe39a0..3f2a22c567 100644
--- a/qmake/library/qmakeevaluator.h
+++ b/qmake/library/qmakeevaluator.h
@@ -240,7 +240,7 @@ public:
#ifndef QT_BOOTSTRAPPED
void runProcess(QProcess *proc, const QString &command) const;
#endif
- QByteArray getCommandOutput(const QString &args) const;
+ QByteArray getCommandOutput(const QString &args, int *exitCode) const;
QMakeEvaluator *m_caller;
#ifdef PROEVALUATOR_CUMULATIVE