Commit e6e18ceb authored by Daniel Teske's avatar Daniel Teske

Desktop Qmake RC: Add option to disable setting of PATH/(LD|DYLD)_LIBRARY_PATH

Change-Id: Iddb3b2c79cdbf6564f0b1acef469f375716b043e
Task-number: QTCREATORBUG-8727
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@theqtcompany.com>
parent 168508e8
......@@ -70,6 +70,7 @@ const char COMMAND_LINE_ARGUMENTS_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration
const char PRO_FILE_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.ProFile";
const char USE_TERMINAL_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal";
const char USE_DYLD_IMAGE_SUFFIX_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix";
const char USE_LIBRARY_SEARCH_PATH[] = "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath";
const char USER_WORKING_DIRECTORY_KEY[] = "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory";
static Utils::FileName pathFromId(Core::Id id)
......@@ -100,6 +101,7 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Deskt
m_proFilePath(source->m_proFilePath),
m_runMode(source->m_runMode),
m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix),
m_isUsingLibrarySearchPath(source->m_isUsingLibrarySearchPath),
m_userWorkingDirectory(source->m_userWorkingDirectory),
m_parseSuccess(source->m_parseSuccess),
m_parseInProgress(source->m_parseInProgress)
......@@ -250,6 +252,26 @@ DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQm
this, SLOT(usingDyldImageSuffixToggled(bool)));
}
QString librarySeachPathLabel;
if (HostOsInfo::isMacHost()) {
librarySeachPathLabel
= tr("Add build library search path to DYLD_LIBRARY_PATH and DYLD_FRAMEWORK_PATH");
} else if (HostOsInfo::isWindowsHost()) {
librarySeachPathLabel
= tr("Add build library search path to PATH");
} else if (HostOsInfo::isLinuxHost() || HostOsInfo::isAnyUnixHost()) {
librarySeachPathLabel
= tr("Add build library search path to LD_LIBRARY_PATH");
}
if (!librarySeachPathLabel.isEmpty()) {
m_usingLibrarySearchPath = new QCheckBox(librarySeachPathLabel);
m_usingLibrarySearchPath->setChecked(m_qmakeRunConfiguration->isUsingLibrarySearchPath());
toplayout->addRow(QString(), m_usingLibrarySearchPath);
connect(m_usingLibrarySearchPath, &QCheckBox::toggled,
this, &DesktopQmakeRunConfigurationWidget::usingLibrarySearchPathToggled);
}
runConfigurationEnabledChange();
connect(m_workingDirectoryEdit, SIGNAL(rawPathChanged(QString)),
......@@ -274,6 +296,8 @@ DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQm
this, SLOT(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)));
connect(qmakeRunConfiguration, SIGNAL(usingDyldImageSuffixChanged(bool)),
this, SLOT(usingDyldImageSuffixChanged(bool)));
connect(qmakeRunConfiguration, &DesktopQmakeRunConfiguration::usingLibrarySearchPathChanged,
this, &DesktopQmakeRunConfigurationWidget::usingLibrarySearchPathChanged);
connect(qmakeRunConfiguration, SIGNAL(effectiveTargetInformationChanged()),
this, SLOT(effectiveTargetInformationChanged()), Qt::QueuedConnection);
......@@ -347,6 +371,13 @@ void DesktopQmakeRunConfigurationWidget::usingDyldImageSuffixToggled(bool state)
m_ignoreChange = false;
}
void DesktopQmakeRunConfigurationWidget::usingLibrarySearchPathToggled(bool state)
{
m_ignoreChange = true;
m_qmakeRunConfiguration->setUsingLibrarySearchPath(state);
m_ignoreChange = false;
}
void DesktopQmakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory)
{
if (!m_ignoreChange)
......@@ -372,6 +403,12 @@ void DesktopQmakeRunConfigurationWidget::usingDyldImageSuffixChanged(bool state)
m_usingDyldImageSuffix->setChecked(state);
}
void DesktopQmakeRunConfigurationWidget::usingLibrarySearchPathChanged(bool state)
{
if (!m_ignoreChange && m_usingLibrarySearchPath)
m_usingLibrarySearchPath->setChecked(state);
}
void DesktopQmakeRunConfigurationWidget::effectiveTargetInformationChanged()
{
if (m_isShown) {
......@@ -408,6 +445,7 @@ QVariantMap DesktopQmakeRunConfiguration::toMap() const
map.insert(QLatin1String(PRO_FILE_KEY), projectDir.relativeFilePath(m_proFilePath.toString()));
map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console);
map.insert(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), m_isUsingDyldImageSuffix);
map.insert(QLatin1String(USE_LIBRARY_SEARCH_PATH), m_isUsingLibrarySearchPath);
map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory);
return map;
}
......@@ -420,6 +458,7 @@ bool DesktopQmakeRunConfiguration::fromMap(const QVariantMap &map)
m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY), false).toBool()
? ApplicationLauncher::Console : ApplicationLauncher::Gui;
m_isUsingDyldImageSuffix = map.value(QLatin1String(USE_DYLD_IMAGE_SUFFIX_KEY), false).toBool();
m_isUsingLibrarySearchPath = map.value(QLatin1String(USE_LIBRARY_SEARCH_PATH), true).toBool();
m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString();
......@@ -456,6 +495,21 @@ void DesktopQmakeRunConfiguration::setUsingDyldImageSuffix(bool state)
aspect->environmentChanged();
}
bool DesktopQmakeRunConfiguration::isUsingLibrarySearchPath() const
{
return m_isUsingLibrarySearchPath;
}
void DesktopQmakeRunConfiguration::setUsingLibrarySearchPath(bool state)
{
m_isUsingLibrarySearchPath = state;
emit usingLibrarySearchPathChanged(state);
LocalEnvironmentAspect *aspect = extraAspect<LocalEnvironmentAspect>();
QTC_ASSERT(aspect, return);
aspect->environmentChanged();
}
QString DesktopQmakeRunConfiguration::workingDirectory() const
{
EnvironmentAspect *aspect = extraAspect<EnvironmentAspect>();
......@@ -518,7 +572,7 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
// to find those libraries while actually running we explicitly prepend those
// dirs to the library search path
const QmakeProFileNode *node = static_cast<QmakeProject *>(target()->project())->rootQmakeProjectNode()->findProFileFor(m_proFilePath);
if (node) {
if (m_isUsingLibrarySearchPath && node) {
const QStringList libDirectories = node->variableValue(LibDirectoriesVar);
if (!libDirectories.isEmpty()) {
const QString proDirectory = node->buildDir();
......@@ -533,7 +587,7 @@ void DesktopQmakeRunConfiguration::addToBaseEnvironment(Environment &env) const
} // node
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (qtVersion)
if (qtVersion && m_isUsingLibrarySearchPath)
env.prependOrSetLibrarySearchPath(qtVersion->qmakeProperty("QT_INSTALL_LIBS"));
}
......
......@@ -86,6 +86,9 @@ public:
bool isUsingDyldImageSuffix() const;
void setUsingDyldImageSuffix(bool state);
bool isUsingLibrarySearchPath() const;
void setUsingLibrarySearchPath(bool state);
Utils::FileName proFilePath() const;
QVariantMap toMap() const;
......@@ -95,12 +98,12 @@ public:
void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode);
void addToBaseEnvironment(Utils::Environment &env) const;
signals:
void commandLineArgumentsChanged(const QString&);
void baseWorkingDirectoryChanged(const QString&);
void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode);
void usingDyldImageSuffixChanged(bool);
void usingLibrarySearchPathChanged(bool);
// Note: These signals might not get emitted for every change!
void effectiveTargetInformationChanged();
......@@ -130,6 +133,7 @@ private:
// Cached startup sub project information
ProjectExplorer::ApplicationLauncher::Mode m_runMode = ProjectExplorer::ApplicationLauncher::Gui;
bool m_isUsingDyldImageSuffix = false;
bool m_isUsingLibrarySearchPath = true;
QString m_userWorkingDirectory;
bool m_parseSuccess = false;
bool m_parseInProgress = false;
......@@ -163,6 +167,8 @@ private slots:
void qvfbToggled(bool);
void usingDyldImageSuffixToggled(bool);
void usingDyldImageSuffixChanged(bool);
void usingLibrarySearchPathToggled(bool state);
void usingLibrarySearchPathChanged(bool state);
private:
DesktopQmakeRunConfiguration *m_qmakeRunConfiguration = nullptr;
......@@ -175,6 +181,7 @@ private:
QCheckBox *m_useTerminalCheck = nullptr;
QCheckBox *m_useQvfbCheck = nullptr;
QCheckBox *m_usingDyldImageSuffix = nullptr;
QCheckBox *m_usingLibrarySearchPath = nullptr;
QLineEdit *m_qmlDebugPort = nullptr;
Utils::DetailsWidget *m_detailsContainer;
bool m_isShown = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment