forked from qt-creator/qt-creator
Utils: FilePathify Environment::{ap,pre}pendOrSetPath etc
Change-Id: Idfa5ec247337570936b0236cab9d3a5669792ca0 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -52,16 +52,22 @@ QProcessEnvironment Environment::toProcessEnvironment() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::appendOrSetPath(const QString &value)
|
void Environment::appendOrSetPath(const FilePath &value)
|
||||||
{
|
{
|
||||||
appendOrSet("PATH", QDir::toNativeSeparators(value),
|
QTC_CHECK(value.osType() == m_osType);
|
||||||
|
if (value.isEmpty())
|
||||||
|
return;
|
||||||
|
appendOrSet("PATH", value.deviceLocalPath(),
|
||||||
QString(OsSpecificAspects::pathListSeparator(m_osType)));
|
QString(OsSpecificAspects::pathListSeparator(m_osType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::prependOrSetPath(const QString &value)
|
void Environment::prependOrSetPath(const FilePath &value)
|
||||||
{
|
{
|
||||||
prependOrSet("PATH", QDir::toNativeSeparators(value),
|
QTC_CHECK(value.osType() == m_osType);
|
||||||
QString(OsSpecificAspects::pathListSeparator(m_osType)));
|
if (value.isEmpty())
|
||||||
|
return;
|
||||||
|
prependOrSet("PATH", value.deviceLocalPath(),
|
||||||
|
QString(OsSpecificAspects::pathListSeparator(m_osType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::appendOrSet(const QString &key, const QString &value, const QString &sep)
|
void Environment::appendOrSet(const QString &key, const QString &value, const QString &sep)
|
||||||
@@ -92,17 +98,18 @@ void Environment::prependOrSet(const QString &key, const QString &value, const Q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::prependOrSetLibrarySearchPath(const QString &value)
|
void Environment::prependOrSetLibrarySearchPath(const FilePath &value)
|
||||||
{
|
{
|
||||||
|
QTC_CHECK(value.osType() == m_osType);
|
||||||
switch (m_osType) {
|
switch (m_osType) {
|
||||||
case OsTypeWindows: {
|
case OsTypeWindows: {
|
||||||
const QChar sep = ';';
|
const QChar sep = ';';
|
||||||
prependOrSet("PATH", QDir::toNativeSeparators(value), QString(sep));
|
prependOrSet("PATH", value.deviceLocalPath(), QString(sep));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OsTypeMac: {
|
case OsTypeMac: {
|
||||||
const QString sep = ":";
|
const QString sep = ":";
|
||||||
const QString nativeValue = QDir::toNativeSeparators(value);
|
const QString nativeValue = value.deviceLocalPath();
|
||||||
prependOrSet("DYLD_LIBRARY_PATH", nativeValue, sep);
|
prependOrSet("DYLD_LIBRARY_PATH", nativeValue, sep);
|
||||||
prependOrSet("DYLD_FRAMEWORK_PATH", nativeValue, sep);
|
prependOrSet("DYLD_FRAMEWORK_PATH", nativeValue, sep);
|
||||||
break;
|
break;
|
||||||
@@ -110,7 +117,7 @@ void Environment::prependOrSetLibrarySearchPath(const QString &value)
|
|||||||
case OsTypeLinux:
|
case OsTypeLinux:
|
||||||
case OsTypeOtherUnix: {
|
case OsTypeOtherUnix: {
|
||||||
const QChar sep = ':';
|
const QChar sep = ':';
|
||||||
prependOrSet("LD_LIBRARY_PATH", QDir::toNativeSeparators(value), QString(sep));
|
prependOrSet("LD_LIBRARY_PATH", value.deviceLocalPath(), QString(sep));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -118,9 +125,9 @@ void Environment::prependOrSetLibrarySearchPath(const QString &value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Environment::prependOrSetLibrarySearchPaths(const QStringList &values)
|
void Environment::prependOrSetLibrarySearchPaths(const FilePaths &values)
|
||||||
{
|
{
|
||||||
Utils::reverseForeach(values, [this](const QString &value) {
|
Utils::reverseForeach(values, [this](const FilePath &value) {
|
||||||
prependOrSetLibrarySearchPath(value);
|
prependOrSetLibrarySearchPath(value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -431,17 +438,17 @@ void EnvironmentChange::addUnsetValue(const QString &key)
|
|||||||
m_changeItems.append([key](Environment &env) { env.unset(key); });
|
m_changeItems.append([key](Environment &env) { env.unset(key); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentChange::addPrependToPath(const QStringList &values)
|
void EnvironmentChange::addPrependToPath(const FilePaths &values)
|
||||||
{
|
{
|
||||||
for (int i = values.size(); --i >= 0; ) {
|
for (int i = values.size(); --i >= 0; ) {
|
||||||
const QString value = values.at(i);
|
const FilePath value = values.at(i);
|
||||||
m_changeItems.append([value](Environment &env) { env.prependOrSetPath(value); });
|
m_changeItems.append([value](Environment &env) { env.prependOrSetPath(value); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EnvironmentChange::addAppendToPath(const QStringList &values)
|
void EnvironmentChange::addAppendToPath(const FilePaths &values)
|
||||||
{
|
{
|
||||||
for (const QString &value : values)
|
for (const FilePath &value : values)
|
||||||
m_changeItems.append([value](Environment &env) { env.appendOrSetPath(value); });
|
m_changeItems.append([value](Environment &env) { env.appendOrSetPath(value); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -51,11 +51,11 @@ public:
|
|||||||
void appendOrSet(const QString &key, const QString &value, const QString &sep = QString());
|
void appendOrSet(const QString &key, const QString &value, const QString &sep = QString());
|
||||||
void prependOrSet(const QString &key, const QString &value, const QString &sep = QString());
|
void prependOrSet(const QString &key, const QString &value, const QString &sep = QString());
|
||||||
|
|
||||||
void appendOrSetPath(const QString &value);
|
void appendOrSetPath(const Utils::FilePath &value);
|
||||||
void prependOrSetPath(const QString &value);
|
void prependOrSetPath(const Utils::FilePath &value);
|
||||||
|
|
||||||
void prependOrSetLibrarySearchPath(const QString &value);
|
void prependOrSetLibrarySearchPath(const Utils::FilePath &value);
|
||||||
void prependOrSetLibrarySearchPaths(const QStringList &values);
|
void prependOrSetLibrarySearchPaths(const Utils::FilePaths &values);
|
||||||
|
|
||||||
void setupEnglishOutput();
|
void setupEnglishOutput();
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ public:
|
|||||||
|
|
||||||
void addSetValue(const QString &key, const QString &value);
|
void addSetValue(const QString &key, const QString &value);
|
||||||
void addUnsetValue(const QString &key);
|
void addUnsetValue(const QString &key);
|
||||||
void addPrependToPath(const QStringList &values);
|
void addPrependToPath(const Utils::FilePaths &values);
|
||||||
void addAppendToPath(const QStringList &values);
|
void addAppendToPath(const Utils::FilePaths &values);
|
||||||
void addModify(const NameValueItems &items);
|
void addModify(const NameValueItems &items);
|
||||||
void addChange(const Item &item) { m_changeItems.append(item); }
|
void addChange(const Item &item) { m_changeItems.append(item); }
|
||||||
|
|
||||||
|
@@ -476,7 +476,7 @@ void FileUtils::setDeviceFileHooks(const DeviceFileHooks &hooks)
|
|||||||
s_deviceHooks = hooks;
|
s_deviceHooks = hooks;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \returns a QString to display to the user
|
/// \returns a QString to display to the user, including the device prefix
|
||||||
/// Converts the separators to the native format of the system
|
/// Converts the separators to the native format of the system
|
||||||
/// this path belongs to.
|
/// this path belongs to.
|
||||||
QString FilePath::toUserOutput() const
|
QString FilePath::toUserOutput() const
|
||||||
@@ -487,6 +487,17 @@ QString FilePath::toUserOutput() const
|
|||||||
return tmp.toString();
|
return tmp.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \returns a QString to pass to target system native commands, without the device prefix.
|
||||||
|
/// Converts the separators to the native format of the system
|
||||||
|
/// this path belongs to.
|
||||||
|
QString FilePath::deviceLocalPath() const
|
||||||
|
{
|
||||||
|
QString data = m_data;
|
||||||
|
if (osType() == OsTypeWindows)
|
||||||
|
data.replace('/', '\\');
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
QString FilePath::fileName() const
|
QString FilePath::fileName() const
|
||||||
{
|
{
|
||||||
const QChar slash = QLatin1Char('/');
|
const QChar slash = QLatin1Char('/');
|
||||||
|
@@ -66,6 +66,7 @@ public:
|
|||||||
[[nodiscard]] static FilePath fromUrl(const QUrl &url);
|
[[nodiscard]] static FilePath fromUrl(const QUrl &url);
|
||||||
|
|
||||||
QString toUserOutput() const;
|
QString toUserOutput() const;
|
||||||
|
QString deviceLocalPath() const;
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
QVariant toVariant() const;
|
QVariant toVariant() const;
|
||||||
QUrl toUrl() const;
|
QUrl toUrl() const;
|
||||||
|
@@ -1414,7 +1414,7 @@ Environment AndroidConfigurations::toolsEnvironment(const AndroidConfig &config)
|
|||||||
FilePath jdkLocation = config.openJDKLocation();
|
FilePath jdkLocation = config.openJDKLocation();
|
||||||
if (!jdkLocation.isEmpty()) {
|
if (!jdkLocation.isEmpty()) {
|
||||||
env.set("JAVA_HOME", jdkLocation.toUserOutput());
|
env.set("JAVA_HOME", jdkLocation.toUserOutput());
|
||||||
env.prependOrSetPath(jdkLocation.pathAppended("bin").toUserOutput());
|
env.prependOrSetPath(jdkLocation.pathAppended("bin"));
|
||||||
}
|
}
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
@@ -124,7 +124,7 @@ void AndroidToolChain::addToEnvironment(Environment &env) const
|
|||||||
const FilePath javaBin = javaHome.pathAppended("bin");
|
const FilePath javaBin = javaHome.pathAppended("bin");
|
||||||
const FilePath currentJavaFilePath = env.searchInPath("java");
|
const FilePath currentJavaFilePath = env.searchInPath("java");
|
||||||
if (!currentJavaFilePath.isChildOf(javaBin))
|
if (!currentJavaFilePath.isChildOf(javaBin))
|
||||||
env.prependOrSetPath(javaBin.toUserOutput());
|
env.prependOrSetPath(javaBin);
|
||||||
}
|
}
|
||||||
env.set(QLatin1String("ANDROID_HOME"), config.sdkLocation().toString());
|
env.set(QLatin1String("ANDROID_HOME"), config.sdkLocation().toString());
|
||||||
env.set(QLatin1String("ANDROID_SDK_ROOT"), config.sdkLocation().toString());
|
env.set(QLatin1String("ANDROID_SDK_ROOT"), config.sdkLocation().toString());
|
||||||
|
@@ -361,10 +361,8 @@ ToolChain::BuiltInHeaderPathsRunner IarToolChain::createBuiltInHeaderPathsRunner
|
|||||||
|
|
||||||
void IarToolChain::addToEnvironment(Environment &env) const
|
void IarToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
if (!compilerCommand().isEmpty()) {
|
if (!compilerCommand().isEmpty())
|
||||||
const FilePath path = compilerCommand().parentDir();
|
env.prependOrSetPath(compilerCommand().parentDir());
|
||||||
env.prependOrSetPath(path.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Utils::OutputLineParser *> IarToolChain::createOutputParsers() const
|
QList<Utils::OutputLineParser *> IarToolChain::createOutputParsers() const
|
||||||
|
@@ -486,10 +486,8 @@ ToolChain::BuiltInHeaderPathsRunner KeilToolChain::createBuiltInHeaderPathsRunne
|
|||||||
|
|
||||||
void KeilToolChain::addToEnvironment(Environment &env) const
|
void KeilToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
if (!compilerCommand().isEmpty()) {
|
if (!compilerCommand().isEmpty())
|
||||||
const FilePath path = compilerCommand().parentDir();
|
env.prependOrSetPath(compilerCommand().parentDir());
|
||||||
env.prependOrSetPath(path.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<OutputLineParser *> KeilToolChain::createOutputParsers() const
|
QList<OutputLineParser *> KeilToolChain::createOutputParsers() const
|
||||||
|
@@ -265,10 +265,8 @@ ToolChain::BuiltInHeaderPathsRunner SdccToolChain::createBuiltInHeaderPathsRunne
|
|||||||
|
|
||||||
void SdccToolChain::addToEnvironment(Environment &env) const
|
void SdccToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
if (!compilerCommand().isEmpty()) {
|
if (!compilerCommand().isEmpty())
|
||||||
const FilePath path = compilerCommand().parentDir();
|
env.prependOrSetPath(compilerCommand().parentDir());
|
||||||
env.prependOrSetPath(path.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Utils::OutputLineParser *> SdccToolChain::createOutputParsers() const
|
QList<Utils::OutputLineParser *> SdccToolChain::createOutputParsers() const
|
||||||
|
@@ -87,8 +87,7 @@ BuildDirParameters::BuildDirParameters(CMakeBuildConfiguration *bc)
|
|||||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||||
if (!settings->ninjaPath.filePath().isEmpty()) {
|
if (!settings->ninjaPath.filePath().isEmpty()) {
|
||||||
const Utils::FilePath ninja = settings->ninjaPath.filePath();
|
const Utils::FilePath ninja = settings->ninjaPath.filePath();
|
||||||
const Utils::FilePath ninjaDir = ninja.isFile() ? ninja.parentDir() : ninja;
|
environment.appendOrSetPath(ninja.isFile() ? ninja.parentDir() : ninja);
|
||||||
environment.appendOrSetPath(ninjaDir.path());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmakeToolId = CMakeKitAspect::cmakeToolId(k);
|
cmakeToolId = CMakeKitAspect::cmakeToolId(k);
|
||||||
|
@@ -1022,10 +1022,8 @@ const QList<BuildTargetInfo> CMakeBuildSystem::appTargets() const
|
|||||||
|
|
||||||
// Workaround for QTCREATORBUG-19354:
|
// Workaround for QTCREATORBUG-19354:
|
||||||
bti.runEnvModifier = [this, buildKey](Environment &env, bool enabled) {
|
bti.runEnvModifier = [this, buildKey](Environment &env, bool enabled) {
|
||||||
if (enabled) {
|
if (enabled)
|
||||||
const Utils::FilePaths paths = librarySearchPaths(this, buildKey);
|
env.prependOrSetLibrarySearchPaths(librarySearchPaths(this, buildKey));
|
||||||
env.prependOrSetLibrarySearchPaths(Utils::transform(paths, &FilePath::toString));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
appTargetList.append(bti);
|
appTargetList.append(bti);
|
||||||
|
@@ -848,8 +848,8 @@ void CMakeGeneratorKitAspect::addToBuildEnvironment(const Kit *k, Environment &e
|
|||||||
if (info.generator == "NMake Makefiles JOM") {
|
if (info.generator == "NMake Makefiles JOM") {
|
||||||
if (env.searchInPath("jom.exe").exists())
|
if (env.searchInPath("jom.exe").exists())
|
||||||
return;
|
return;
|
||||||
env.appendOrSetPath(Core::ICore::libexecPath().toUserOutput());
|
env.appendOrSetPath(Core::ICore::libexecPath());
|
||||||
env.appendOrSetPath(Core::ICore::libexecPath("jom").toUserOutput());
|
env.appendOrSetPath(Core::ICore::libexecPath("jom"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
#include "vcsmanager.h"
|
#include "vcsmanager.h"
|
||||||
|
|
||||||
#include <app/app_version.h>
|
#include <app/app_version.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/consoleprocess.h>
|
#include <utils/consoleprocess.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
@@ -324,7 +326,7 @@ void SystemSettingsWidget::resetFileBrowser()
|
|||||||
void SystemSettingsWidget::updatePath()
|
void SystemSettingsWidget::updatePath()
|
||||||
{
|
{
|
||||||
EnvironmentChange change;
|
EnvironmentChange change;
|
||||||
change.addAppendToPath(VcsManager::additionalToolsPath());
|
change.addAppendToPath(Utils::transform(VcsManager::additionalToolsPath(), &FilePath::fromString));
|
||||||
m_ui.patchChooser->setEnvironmentChange(change);
|
m_ui.patchChooser->setEnvironmentChange(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -217,8 +217,7 @@ void LldbEngine::setupEngine()
|
|||||||
FilePath androidPythonDir = lldbCmd.parentDir().parentDir().pathAppended("python3");
|
FilePath androidPythonDir = lldbCmd.parentDir().parentDir().pathAppended("python3");
|
||||||
if (HostOsInfo::isAnyUnixHost())
|
if (HostOsInfo::isAnyUnixHost())
|
||||||
androidPythonDir = androidPythonDir.pathAppended("bin");
|
androidPythonDir = androidPythonDir.pathAppended("bin");
|
||||||
if (androidPythonDir.exists())
|
environment.prependOrSetPath(androidPythonDir);
|
||||||
environment.prependOrSetPath(androidPythonDir.path());
|
|
||||||
}
|
}
|
||||||
m_lldbProc.setEnvironment(environment);
|
m_lldbProc.setEnvironment(environment);
|
||||||
|
|
||||||
|
@@ -2217,7 +2217,7 @@ Environment GitClient::processEnvironment() const
|
|||||||
{
|
{
|
||||||
Environment environment = VcsBaseClientImpl::processEnvironment();
|
Environment environment = VcsBaseClientImpl::processEnvironment();
|
||||||
QString gitPath = settings().path.value();
|
QString gitPath = settings().path.value();
|
||||||
environment.prependOrSetPath(gitPath);
|
environment.prependOrSetPath(FilePath::fromUserInput(gitPath));
|
||||||
if (HostOsInfo::isWindowsHost() && settings().winSetHomeEnvironment.value())
|
if (HostOsInfo::isWindowsHost() && settings().winSetHomeEnvironment.value())
|
||||||
environment.set("HOME", QDir::toNativeSeparators(QDir::homePath()));
|
environment.set("HOME", QDir::toNativeSeparators(QDir::homePath()));
|
||||||
environment.set("GIT_EDITOR", m_disableEditor ? "true" : m_gitQtcEditor);
|
environment.set("GIT_EDITOR", m_disableEditor ? "true" : m_gitQtcEditor);
|
||||||
|
@@ -143,8 +143,7 @@ FilePath GitSettings::gitExecutable(bool *ok, QString *errorMessage) const
|
|||||||
FilePath binPath = binaryPath.filePath();
|
FilePath binPath = binaryPath.filePath();
|
||||||
if (!binPath.isAbsolutePath()) {
|
if (!binPath.isAbsolutePath()) {
|
||||||
Environment env = Environment::systemEnvironment();
|
Environment env = Environment::systemEnvironment();
|
||||||
if (!path.filePath().isEmpty())
|
env.prependOrSetPath(path.filePath());
|
||||||
env.prependOrSetPath(path.filePath().toString());
|
|
||||||
binPath = env.searchInPath(binPath.toString());
|
binPath = env.searchInPath(binPath.toString());
|
||||||
}
|
}
|
||||||
if (binPath.isEmpty()) {
|
if (binPath.isEmpty()) {
|
||||||
|
@@ -66,7 +66,7 @@ NimbleBuildStep::NimbleBuildStep(BuildStepList *parentList, Id id)
|
|||||||
});
|
});
|
||||||
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
||||||
setEnvironmentModifier([this](Environment &env) {
|
setEnvironmentModifier([this](Environment &env) {
|
||||||
env.appendOrSetPath(Nim::nimPathFromKit(kit()).toUserOutput());
|
env.appendOrSetPath(Nim::nimPathFromKit(kit()));
|
||||||
});
|
});
|
||||||
|
|
||||||
setSummaryUpdater([this] {
|
setSummaryUpdater([this] {
|
||||||
|
@@ -77,7 +77,7 @@ ToolChain::BuiltInHeaderPathsRunner NimToolChain::createBuiltInHeaderPathsRunner
|
|||||||
void NimToolChain::addToEnvironment(Environment &env) const
|
void NimToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
if (isValid())
|
if (isValid())
|
||||||
env.prependOrSetPath(compilerCommand().parentDir().toString());
|
env.prependOrSetPath(compilerCommand().parentDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath NimToolChain::makeCommand(const Environment &env) const
|
FilePath NimToolChain::makeCommand(const Environment &env) const
|
||||||
|
@@ -153,11 +153,11 @@ ToolChain::BuiltInHeaderPathsRunner CustomToolChain::createBuiltInHeaderPathsRun
|
|||||||
void CustomToolChain::addToEnvironment(Environment &env) const
|
void CustomToolChain::addToEnvironment(Environment &env) const
|
||||||
{
|
{
|
||||||
if (!m_compilerCommand.isEmpty()) {
|
if (!m_compilerCommand.isEmpty()) {
|
||||||
FilePath path = m_compilerCommand.parentDir();
|
const FilePath path = m_compilerCommand.parentDir();
|
||||||
env.prependOrSetPath(path.toString());
|
env.prependOrSetPath(path);
|
||||||
FilePath makePath = m_makeCommand.parentDir();
|
const FilePath makePath = m_makeCommand.parentDir();
|
||||||
if (makePath != path)
|
if (makePath != path)
|
||||||
env.prependOrSetPath(makePath.toString());
|
env.prependOrSetPath(makePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -633,9 +633,7 @@ ToolChain::BuiltInHeaderPathsRunner GccToolChain::createBuiltInHeaderPathsRunner
|
|||||||
|
|
||||||
void GccToolChain::addCommandPathToEnvironment(const FilePath &command, Environment &env)
|
void GccToolChain::addCommandPathToEnvironment(const FilePath &command, Environment &env)
|
||||||
{
|
{
|
||||||
const Utils::FilePath compilerDir = command.parentDir();
|
env.prependOrSetPath(command.parentDir());
|
||||||
if (!compilerDir.isEmpty())
|
|
||||||
env.prependOrSetPath(compilerDir.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GccToolChain::addToEnvironment(Environment &env) const
|
void GccToolChain::addToEnvironment(Environment &env) const
|
||||||
@@ -1526,7 +1524,7 @@ void ClangToolChain::addToEnvironment(Environment &env) const
|
|||||||
|
|
||||||
const QString sysroot = sysRoot();
|
const QString sysroot = sysRoot();
|
||||||
if (!sysroot.isEmpty())
|
if (!sysroot.isEmpty())
|
||||||
env.prependOrSetPath(sysroot + "/bin");
|
env.prependOrSetPath(FilePath::fromString(sysroot) / "bin");
|
||||||
|
|
||||||
// Clang takes PWD as basis for debug info, if set.
|
// Clang takes PWD as basis for debug info, if set.
|
||||||
// When running Qt Creator from a shell, PWD is initially set to an "arbitrary" value.
|
// When running Qt Creator from a shell, PWD is initially set to an "arbitrary" value.
|
||||||
|
@@ -1701,8 +1701,7 @@ bool ClangClToolChain::isValid() const
|
|||||||
void ClangClToolChain::addToEnvironment(Utils::Environment &env) const
|
void ClangClToolChain::addToEnvironment(Utils::Environment &env) const
|
||||||
{
|
{
|
||||||
MsvcToolChain::addToEnvironment(env);
|
MsvcToolChain::addToEnvironment(env);
|
||||||
QDir path = QFileInfo(m_clangPath).absoluteDir(); // bin folder
|
env.prependOrSetPath(FilePath::fromString(m_clangPath).parentDir()); // bin folder
|
||||||
env.prependOrSetPath(path.canonicalPath());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::FilePath ClangClToolChain::compilerCommand() const
|
Utils::FilePath ClangClToolChain::compilerCommand() const
|
||||||
|
@@ -1187,7 +1187,7 @@ void QmakeBuildSystem::updateBuildSystemData()
|
|||||||
bti.usesTerminal = !qt.contains("testlib") && !qt.contains("qmltest");
|
bti.usesTerminal = !qt.contains("testlib") && !qt.contains("qmltest");
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList libraryPaths;
|
FilePaths libraryPaths;
|
||||||
|
|
||||||
// The user could be linking to a library found via a -L/some/dir switch
|
// The user could be linking to a library found via a -L/some/dir switch
|
||||||
// to find those libraries while actually running we explicitly prepend those
|
// to find those libraries while actually running we explicitly prepend those
|
||||||
@@ -1202,12 +1202,12 @@ void QmakeBuildSystem::updateBuildSystemData()
|
|||||||
const QFileInfo fi(dir);
|
const QFileInfo fi(dir);
|
||||||
if (!fi.isAbsolute())
|
if (!fi.isAbsolute())
|
||||||
dir = QDir::cleanPath(proDirectory + '/' + dir);
|
dir = QDir::cleanPath(proDirectory + '/' + dir);
|
||||||
libraryPaths.append(dir);
|
libraryPaths.append(FilePath::fromUserInput(dir));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit());
|
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(kit());
|
||||||
if (qtVersion)
|
if (qtVersion)
|
||||||
libraryPaths.append(qtVersion->librarySearchPath().toString());
|
libraryPaths.append(qtVersion->librarySearchPath());
|
||||||
|
|
||||||
bti.runEnvModifierHash = qHash(libraryPaths);
|
bti.runEnvModifierHash = qHash(libraryPaths);
|
||||||
bti.runEnvModifier = [libraryPaths](Environment &env, bool useLibrarySearchPath) {
|
bti.runEnvModifier = [libraryPaths](Environment &env, bool useLibrarySearchPath) {
|
||||||
|
@@ -485,8 +485,7 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
|
|||||||
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(m_target->kit());
|
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(m_target->kit());
|
||||||
if (QTC_GUARD(qt)) { // Kits without a Qt version should not have a puppet!
|
if (QTC_GUARD(qt)) { // Kits without a Qt version should not have a puppet!
|
||||||
// Update PATH to include QT_HOST_BINS
|
// Update PATH to include QT_HOST_BINS
|
||||||
const Utils::FilePath qtBinPath = qt->hostBinPath();
|
environment.prependOrSetPath(qt->hostBinPath());
|
||||||
environment.prependOrSetPath(qtBinPath.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -156,8 +156,7 @@ void QnxQtVersion::addToEnvironment(const Kit *k, Environment &env) const
|
|||||||
QtSupport::BaseQtVersion::addToEnvironment(k, env);
|
QtSupport::BaseQtVersion::addToEnvironment(k, env);
|
||||||
updateEnvironment();
|
updateEnvironment();
|
||||||
env.modify(m_qnxEnv);
|
env.modify(m_qnxEnv);
|
||||||
|
env.prependOrSetLibrarySearchPath(libraryPath());
|
||||||
env.prependOrSetLibrarySearchPath(libraryPath().toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QnxQtVersion::setupQmakeRunEnvironment(Environment &env) const
|
void QnxQtVersion::setupQmakeRunEnvironment(Environment &env) const
|
||||||
|
@@ -381,17 +381,11 @@ void QtKitAspect::setQtVersion(Kit *k, const BaseQtVersion *v)
|
|||||||
|
|
||||||
void QtKitAspect::addHostBinariesToPath(const Kit *k, Environment &env)
|
void QtKitAspect::addHostBinariesToPath(const Kit *k, Environment &env)
|
||||||
{
|
{
|
||||||
if (const ToolChain *tc = ToolChainKitAspect::cxxToolChain(k)) {
|
if (const ToolChain *tc = ToolChainKitAspect::cxxToolChain(k))
|
||||||
const FilePath compilerDir = tc->compilerCommand().parentDir();
|
env.prependOrSetPath(tc->compilerCommand().parentDir());
|
||||||
if (!compilerDir.isEmpty())
|
|
||||||
env.prependOrSetPath(compilerDir.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (const BaseQtVersion *qt = qtVersion(k)) {
|
if (const BaseQtVersion *qt = qtVersion(k))
|
||||||
const FilePath hostBinPath = qt->hostBinPath();
|
env.prependOrSetPath(qt->hostBinPath());
|
||||||
if (!hostBinPath.isEmpty())
|
|
||||||
env.prependOrSetPath(hostBinPath.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtKitAspect::qtVersionsChanged(const QList<int> &addedIds,
|
void QtKitAspect::qtVersionsChanged(const QList<int> &addedIds,
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
#include <coreplugin/vcsmanager.h>
|
#include <coreplugin/vcsmanager.h>
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
@@ -156,7 +157,8 @@ CommonSettingsWidget::CommonSettingsWidget(CommonOptionsPage *page)
|
|||||||
void CommonSettingsWidget::updatePath()
|
void CommonSettingsWidget::updatePath()
|
||||||
{
|
{
|
||||||
EnvironmentChange change;
|
EnvironmentChange change;
|
||||||
change.addAppendToPath(Core::VcsManager::additionalToolsPath());
|
change.addAppendToPath(Utils::transform(Core::VcsManager::additionalToolsPath(),
|
||||||
|
&FilePath::fromString));
|
||||||
m_page->settings().sshPasswordPrompt.setEnvironmentChange(change);
|
m_page->settings().sshPasswordPrompt.setEnvironmentChange(change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ static void parseEmSdkEnvOutputAndAddToEnv(const QString &output, Environment &e
|
|||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
const QStringList prependParts = line.trimmed().split(" += ");
|
const QStringList prependParts = line.trimmed().split(" += ");
|
||||||
if (prependParts.count() == 2)
|
if (prependParts.count() == 2)
|
||||||
env.prependOrSetPath(prependParts.last());
|
env.prependOrSetPath(FilePath::fromUserInput(prependParts.last()));
|
||||||
|
|
||||||
const QStringList setParts = line.trimmed().split(" = ");
|
const QStringList setParts = line.trimmed().split(" = ");
|
||||||
if (setParts.count() == 2) {
|
if (setParts.count() == 2) {
|
||||||
@@ -89,7 +89,7 @@ static void parseEmSdkEnvOutputAndAddToEnv(const QString &output, Environment &e
|
|||||||
// QTCREATORBUG-26199: Wrapper scripts (e.g. emcc.bat) of older emsdks might not find python
|
// QTCREATORBUG-26199: Wrapper scripts (e.g. emcc.bat) of older emsdks might not find python
|
||||||
const QString emsdkPython = env.value("EMSDK_PYTHON");
|
const QString emsdkPython = env.value("EMSDK_PYTHON");
|
||||||
if (!emsdkPython.isEmpty())
|
if (!emsdkPython.isEmpty())
|
||||||
env.appendOrSetPath(FilePath::fromUserInput(emsdkPython).parentDir().toUserOutput());
|
env.appendOrSetPath(FilePath::fromUserInput(emsdkPython).parentDir());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebAssemblyEmSdk::isValid(const FilePath &sdkRoot)
|
bool WebAssemblyEmSdk::isValid(const FilePath &sdkRoot)
|
||||||
|
@@ -64,10 +64,8 @@ static void addRegisteredMinGWToEnvironment(Environment &env)
|
|||||||
const ToolChain *toolChain = ToolChainManager::toolChain([](const ToolChain *t){
|
const ToolChain *toolChain = ToolChainManager::toolChain([](const ToolChain *t){
|
||||||
return t->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
return t->typeId() == ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID;
|
||||||
});
|
});
|
||||||
if (toolChain) {
|
if (toolChain)
|
||||||
const QString mingwPath = toolChain->compilerCommand().parentDir().toUserOutput();
|
env.appendOrSetPath(toolChain->compilerCommand().parentDir());
|
||||||
env.appendOrSetPath(mingwPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebAssemblyToolChain::addToEnvironment(Environment &env) const
|
void WebAssemblyToolChain::addToEnvironment(Environment &env) const
|
||||||
|
@@ -1224,10 +1224,10 @@ void tst_Dumpers::initTestCase()
|
|||||||
if (m_makeBinary.isEmpty())
|
if (m_makeBinary.isEmpty())
|
||||||
m_makeBinary = "mingw32-make";
|
m_makeBinary = "mingw32-make";
|
||||||
if (m_makeBinary != "mingw32-make")
|
if (m_makeBinary != "mingw32-make")
|
||||||
env.prependOrSetPath(QDir::toNativeSeparators(QFileInfo(m_makeBinary).absolutePath()));
|
env.prependOrSetPath(Utils::FilePath::fromString(m_makeBinary));
|
||||||
// if qmake is not in PATH make sure the correct libs for inferior are prepended to PATH
|
// if qmake is not in PATH make sure the correct libs for inferior are prepended to PATH
|
||||||
if (m_qmakeBinary != "qmake")
|
if (m_qmakeBinary != "qmake")
|
||||||
env.prependOrSetPath(QDir::toNativeSeparators(QFileInfo(m_qmakeBinary).absolutePath()));
|
env.prependOrSetPath(Utils::FilePath::fromString(m_qmakeBinary));
|
||||||
m_env = env.toProcessEnvironment();
|
m_env = env.toProcessEnvironment();
|
||||||
#else
|
#else
|
||||||
m_env = QProcessEnvironment::systemEnvironment();
|
m_env = QProcessEnvironment::systemEnvironment();
|
||||||
@@ -1248,7 +1248,7 @@ void tst_Dumpers::initTestCase()
|
|||||||
cdbextPath = QString(CDBEXT_PATH "\\qtcreatorcdbext64");
|
cdbextPath = QString(CDBEXT_PATH "\\qtcreatorcdbext64");
|
||||||
QVERIFY(QFile::exists(cdbextPath + "\\qtcreatorcdbext.dll"));
|
QVERIFY(QFile::exists(cdbextPath + "\\qtcreatorcdbext.dll"));
|
||||||
env.set("_NT_DEBUGGER_EXTENSION_PATH", cdbextPath);
|
env.set("_NT_DEBUGGER_EXTENSION_PATH", cdbextPath);
|
||||||
env.prependOrSetPath(QDir::toNativeSeparators(QFileInfo(m_qmakeBinary).absolutePath()));
|
env.prependOrSetPath(Utils::FilePath::fromString(m_qmakeBinary));
|
||||||
m_makeBinary = env.searchInPath("nmake.exe").toString();
|
m_makeBinary = env.searchInPath("nmake.exe").toString();
|
||||||
m_env = env.toProcessEnvironment();
|
m_env = env.toProcessEnvironment();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user