forked from qt-creator/qt-creator
Utils: Use qtcEnvironmentVariable* instead of qEnvironmentVariable*
And instead of qgetenv. Takes Qt Creator's setting at "Environment > System > Environment" into account, which makes it easier on some platforms to set them (e.g. macOS), can be configured differently in different settings paths, and potentially can be changed at runtime (depending on usage). Change-Id: I50e457bab2d3495e5c69676fe1a0257a5fea3e52 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "benchmarker.h"
|
#include "benchmarker.h"
|
||||||
|
#include "environment.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
@@ -48,7 +49,7 @@ void Benchmarker::report(const QString &testsuite,
|
|||||||
void Benchmarker::report(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase,
|
void Benchmarker::report(const QLoggingCategory &cat, const QString &testsuite, const QString &testcase,
|
||||||
qint64 ms, const QString &tags)
|
qint64 ms, const QString &tags)
|
||||||
{
|
{
|
||||||
static const QByteArray quitAfter = qgetenv("QTC_QUIT_AFTER_BENCHMARK");
|
static const QByteArray quitAfter = qtcEnvironmentVariable("QTC_QUIT_AFTER_BENCHMARK").toLatin1();
|
||||||
QString t = "unit=ms";
|
QString t = "unit=ms";
|
||||||
if (!tags.isEmpty())
|
if (!tags.isEmpty())
|
||||||
t += "," + tags;
|
t += "," + tags;
|
||||||
|
@@ -644,13 +644,13 @@ bool ProcessArgs::prepareCommand(const CommandLine &cmdLine, QString *outCmd, Pr
|
|||||||
*outCmd = executable.toString();
|
*outCmd = executable.toString();
|
||||||
} else {
|
} else {
|
||||||
if (executable.osType() == OsTypeWindows) {
|
if (executable.osType() == OsTypeWindows) {
|
||||||
*outCmd = QString::fromLatin1(qgetenv("COMSPEC"));
|
*outCmd = qtcEnvironmentVariable("COMSPEC");
|
||||||
*outArgs = ProcessArgs::createWindowsArgs(QLatin1String("/v:off /s /c \"")
|
*outArgs = ProcessArgs::createWindowsArgs(QLatin1String("/v:off /s /c \"")
|
||||||
+ quoteArg(executable.toUserOutput()) + ' ' + arguments + '"');
|
+ quoteArg(executable.toUserOutput()) + ' ' + arguments + '"');
|
||||||
} else {
|
} else {
|
||||||
if (err != ProcessArgs::FoundMeta)
|
if (err != ProcessArgs::FoundMeta)
|
||||||
return false;
|
return false;
|
||||||
*outCmd = qEnvironmentVariable("SHELL", "/bin/sh");
|
*outCmd = qtcEnvironmentVariable("SHELL", "/bin/sh");
|
||||||
*outArgs = ProcessArgs::createUnixArgs({"-c", quoteArg(executable.toString()) + ' ' + arguments});
|
*outArgs = ProcessArgs::createUnixArgs({"-c", quoteArg(executable.toString()) + ' ' + arguments});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "filesystemmodel.h"
|
#include "filesystemmodel.h"
|
||||||
|
|
||||||
|
#include "environment.h"
|
||||||
#include "hostosinfo.h"
|
#include "hostosinfo.h"
|
||||||
#include "qtcassert.h"
|
#include "qtcassert.h"
|
||||||
|
|
||||||
@@ -432,7 +433,8 @@ ExtendedInformation FileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
|
|||||||
info.displayType = m_iconProvider->type(fileInfo);
|
info.displayType = m_iconProvider->type(fileInfo);
|
||||||
if (useFileSystemWatcher()) {
|
if (useFileSystemWatcher()) {
|
||||||
// ### Not ready to listen all modifications by default
|
// ### Not ready to listen all modifications by default
|
||||||
static const bool watchFiles = qEnvironmentVariableIsSet("QT_FILESYSTEMMODEL_WATCH_FILES");
|
static const bool watchFiles = qtcEnvironmentVariableIsSet(
|
||||||
|
"QT_FILESYSTEMMODEL_WATCH_FILES");
|
||||||
if (watchFiles) {
|
if (watchFiles) {
|
||||||
if (!fileInfo.exists() && !fileInfo.isSymLink()) {
|
if (!fileInfo.exists() && !fileInfo.isSymLink()) {
|
||||||
const_cast<FileInfoGatherer *>(this)->
|
const_cast<FileInfoGatherer *>(this)->
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "qtcprocess.h"
|
#include "qtcprocess.h"
|
||||||
|
|
||||||
#include "algorithm.h"
|
#include "algorithm.h"
|
||||||
|
#include "environment.h"
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
#include "hostosinfo.h"
|
#include "hostosinfo.h"
|
||||||
#include "launcherinterface.h"
|
#include "launcherinterface.h"
|
||||||
@@ -50,7 +51,7 @@ class MeasureAndRun
|
|||||||
public:
|
public:
|
||||||
MeasureAndRun(const char *functionName)
|
MeasureAndRun(const char *functionName)
|
||||||
: m_functionName(functionName)
|
: m_functionName(functionName)
|
||||||
, m_measureProcess(qEnvironmentVariableIsSet("QTC_MEASURE_PROCESS"))
|
, m_measureProcess(qtcEnvironmentVariableIsSet("QTC_MEASURE_PROCESS"))
|
||||||
{}
|
{}
|
||||||
template <typename Function, typename... Args>
|
template <typename Function, typename... Args>
|
||||||
std::invoke_result_t<Function, Args...> measureAndRun(Function &&function, Args&&... args)
|
std::invoke_result_t<Function, Args...> measureAndRun(Function &&function, Args&&... args)
|
||||||
@@ -507,7 +508,7 @@ private:
|
|||||||
|
|
||||||
static ProcessImpl defaultProcessImpl()
|
static ProcessImpl defaultProcessImpl()
|
||||||
{
|
{
|
||||||
if (qEnvironmentVariableIsSet("QTC_USE_QPROCESS"))
|
if (qtcEnvironmentVariableIsSet("QTC_USE_QPROCESS"))
|
||||||
return ProcessImpl::QProcess;
|
return ProcessImpl::QProcess;
|
||||||
return ProcessImpl::ProcessLauncher;
|
return ProcessImpl::ProcessLauncher;
|
||||||
}
|
}
|
||||||
|
@@ -182,15 +182,15 @@ void TerminalImpl::start()
|
|||||||
QStringList envStrings = env;
|
QStringList envStrings = env;
|
||||||
// add PATH if necessary (for DLL loading)
|
// add PATH if necessary (for DLL loading)
|
||||||
if (envStrings.filter(QRegularExpression("^PATH=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) {
|
if (envStrings.filter(QRegularExpression("^PATH=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) {
|
||||||
QByteArray path = qgetenv("PATH");
|
const QString path = qtcEnvironmentVariable("PATH");
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
envStrings.prepend(QString::fromLatin1("PATH=%1").arg(QString::fromLocal8Bit(path)));
|
envStrings.prepend(QString::fromLatin1("PATH=%1").arg(path));
|
||||||
}
|
}
|
||||||
// add systemroot if needed
|
// add systemroot if needed
|
||||||
if (envStrings.filter(QRegularExpression("^SystemRoot=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) {
|
if (envStrings.filter(QRegularExpression("^SystemRoot=.*", QRegularExpression::CaseInsensitiveOption)).isEmpty()) {
|
||||||
QByteArray systemRoot = qgetenv("SystemRoot");
|
const QString systemRoot = qtcEnvironmentVariable("SystemRoot");
|
||||||
if (!systemRoot.isEmpty())
|
if (!systemRoot.isEmpty())
|
||||||
envStrings.prepend(QString::fromLatin1("SystemRoot=%1").arg(QString::fromLocal8Bit(systemRoot)));
|
envStrings.prepend(QString::fromLatin1("SystemRoot=%1").arg(systemRoot));
|
||||||
}
|
}
|
||||||
return envStrings;
|
return envStrings;
|
||||||
}();
|
}();
|
||||||
@@ -324,7 +324,7 @@ void TerminalImpl::start()
|
|||||||
" is currently not supported."));
|
" is currently not supported."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pcmd = qEnvironmentVariable("SHELL", "/bin/sh");
|
pcmd = qtcEnvironmentVariable("SHELL", "/bin/sh");
|
||||||
pargs = ProcessArgs::createUnixArgs(
|
pargs = ProcessArgs::createUnixArgs(
|
||||||
{"-c", (ProcessArgs::quoteArg(m_setup.m_commandLine.executable().toString())
|
{"-c", (ProcessArgs::quoteArg(m_setup.m_commandLine.executable().toString())
|
||||||
+ ' ' + m_setup.m_commandLine.arguments())});
|
+ ' ' + m_setup.m_commandLine.arguments())});
|
||||||
|
Reference in New Issue
Block a user