aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/qbs/modules/cpp/DarwinGCC.qbs23
-rw-r--r--share/qbs/modules/nodejs/NodeJS.qbs4
-rw-r--r--src/app/qbs/commandlinefrontend.cpp2
-rw-r--r--src/lib/corelib/api/project.cpp3
-rw-r--r--src/lib/corelib/api/project.h1
-rw-r--r--src/lib/corelib/api/runenvironment.cpp17
-rw-r--r--src/lib/corelib/api/runenvironment.h2
-rw-r--r--src/lib/corelib/buildgraph/productinstaller.cpp8
-rw-r--r--src/lib/corelib/tools/installoptions.cpp16
-rw-r--r--src/lib/corelib/tools/installoptions.h7
-rw-r--r--src/lib/qtprofilesetup/templates/core.qbs17
11 files changed, 79 insertions, 21 deletions
diff --git a/share/qbs/modules/cpp/DarwinGCC.qbs b/share/qbs/modules/cpp/DarwinGCC.qbs
index 104d4f007..1b12fd069 100644
--- a/share/qbs/modules/cpp/DarwinGCC.qbs
+++ b/share/qbs/modules/cpp/DarwinGCC.qbs
@@ -41,6 +41,29 @@ UnixGCC {
}
}
+ setupRunEnvironment: {
+ var env;
+ var installRoot = getEnv("QBS_INSTALL_ROOT");
+
+ env = new ModUtils.EnvironmentVariable("DYLD_FRAMEWORK_PATH", qbs.pathListSeparator);
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix, "Library", "Frameworks"));
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix, "lib"));
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix));
+ env.set();
+
+ env = new ModUtils.EnvironmentVariable("DYLD_LIBRARY_PATH", qbs.pathListSeparator);
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix, "lib"));
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix, "Library", "Frameworks"));
+ env.append(FileInfo.joinPaths(installRoot, qbs.installPrefix));
+ env.set();
+
+ if (qbs.sysroot) {
+ env = new ModUtils.EnvironmentVariable("DYLD_ROOT_PATH", qbs.pathListSeparator);
+ env.append(qbs.sysroot);
+ env.set();
+ }
+ }
+
// private properties
readonly property var buildEnv: {
var env = {
diff --git a/share/qbs/modules/nodejs/NodeJS.qbs b/share/qbs/modules/nodejs/NodeJS.qbs
index a18d5d98b..9677cd000 100644
--- a/share/qbs/modules/nodejs/NodeJS.qbs
+++ b/share/qbs/modules/nodejs/NodeJS.qbs
@@ -16,9 +16,7 @@ Module {
setupRunEnvironment: {
var v = new ModUtils.EnvironmentVariable("NODE_PATH", qbs.pathListSeparator, qbs.hostOS.contains("windows"));
- // can't use product.buildDirectory here, but RunEnvironment always sets the working
- // directory to the directory containing the target file so we can exploit this for now
- v.prepend(".");
+ v.prepend(FileInfo.path(getEnv("QBS_RUN_FILE_PATH")));
v.set();
}
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp
index 5ecd22f71..8fb8db188 100644
--- a/src/app/qbs/commandlinefrontend.cpp
+++ b/src/app/qbs/commandlinefrontend.cpp
@@ -385,6 +385,7 @@ int CommandLineFrontend::runShell()
const QList<ProductData> &products = productMap.begin().value();
Q_ASSERT(products.count() == 1);
RunEnvironment runEnvironment = project.getRunEnvironment(products.first(),
+ m_parser.installOptions(),
QProcessEnvironment::systemEnvironment(), m_settings);
return runEnvironment.runShell();
}
@@ -462,6 +463,7 @@ int CommandLineFrontend::runTarget()
.arg(productToRun.name()));
}
RunEnvironment runEnvironment = project.getRunEnvironment(productToRun,
+ m_parser.installOptions(),
QProcessEnvironment::systemEnvironment(), m_settings);
return runEnvironment.runTarget(executableFilePath, m_parser.runArgs());
} catch (const ErrorInfo &error) {
diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp
index f07a8692d..151b75c5d 100644
--- a/src/lib/corelib/api/project.cpp
+++ b/src/lib/corelib/api/project.cpp
@@ -829,11 +829,12 @@ QString Project::targetExecutable(const ProductData &product,
}
RunEnvironment Project::getRunEnvironment(const ProductData &product,
+ const InstallOptions &installOptions,
const QProcessEnvironment &environment, Settings *settings) const
{
QBS_CHECK(product.isEnabled());
const ResolvedProductPtr resolvedProduct = d->internalProduct(product);
- return RunEnvironment(resolvedProduct, environment, settings, d->logger);
+ return RunEnvironment(resolvedProduct, installOptions, environment, settings, d->logger);
}
/*!
diff --git a/src/lib/corelib/api/project.h b/src/lib/corelib/api/project.h
index efe6e35dc..affdba790 100644
--- a/src/lib/corelib/api/project.h
+++ b/src/lib/corelib/api/project.h
@@ -86,6 +86,7 @@ public:
QString targetExecutable(const ProductData &product,
const InstallOptions &installoptions) const;
RunEnvironment getRunEnvironment(const ProductData &product,
+ const InstallOptions &installOptions,
const QProcessEnvironment &environment, Settings *settings) const;
BuildJob *buildAllProducts(const BuildOptions &options, QObject *jobOwner = 0) const;
diff --git a/src/lib/corelib/api/runenvironment.cpp b/src/lib/corelib/api/runenvironment.cpp
index e8face23f..f1fd3267a 100644
--- a/src/lib/corelib/api/runenvironment.cpp
+++ b/src/lib/corelib/api/runenvironment.cpp
@@ -30,12 +30,14 @@
#include "runenvironment.h"
#include <api/projectdata.h>
+#include <buildgraph/productinstaller.h>
#include <language/language.h>
#include <language/scriptengine.h>
#include <logging/logger.h>
#include <logging/translator.h>
#include <tools/error.h>
#include <tools/hostosinfo.h>
+#include <tools/installoptions.h>
#include <tools/preferences.h>
#include <tools/propertyfinder.h>
@@ -54,10 +56,11 @@ using namespace Internal;
class RunEnvironment::RunEnvironmentPrivate
{
public:
- RunEnvironmentPrivate(const ResolvedProductPtr &product,
+ RunEnvironmentPrivate(const ResolvedProductPtr &product, const InstallOptions &installOptions,
const QProcessEnvironment &environment, Settings *settings, const Logger &logger)
: engine(logger)
, resolvedProduct(product)
+ , installOptions(installOptions)
, environment(environment)
, settings(settings)
, logger(logger)
@@ -66,14 +69,16 @@ public:
ScriptEngine engine;
const ResolvedProductPtr resolvedProduct;
+ InstallOptions installOptions;
const QProcessEnvironment environment;
Settings * const settings;
Logger logger;
};
RunEnvironment::RunEnvironment(const ResolvedProductPtr &product,
+ const InstallOptions &installOptions,
const QProcessEnvironment &environment, Settings *settings, const Logger &logger)
- : d(new RunEnvironmentPrivate(product, environment, settings, logger))
+ : d(new RunEnvironmentPrivate(product, installOptions, environment, settings, logger))
{
}
@@ -186,11 +191,15 @@ int RunEnvironment::runTarget(const QString &targetBin, const QStringList &argum
return EXIT_FAILURE;
}
- d->resolvedProduct->setupRunEnvironment(&d->engine, d->environment);
+ const QString installRoot = effectiveInstallRoot(d->installOptions,
+ d->resolvedProduct->topLevelProject());
+ QProcessEnvironment env = d->environment;
+ env.insert(QLatin1String("QBS_INSTALL_ROOT"), installRoot);
+ env.insert(QLatin1String("QBS_RUN_FILE_PATH"), targetBin);
+ d->resolvedProduct->setupRunEnvironment(&d->engine, env);
d->logger.qbsInfo() << Tr::tr("Starting target '%1'.").arg(QDir::toNativeSeparators(targetBin));
QProcess process;
- process.setWorkingDirectory(QFileInfo(targetBin).absolutePath());
process.setProcessEnvironment(d->resolvedProduct->runEnvironment);
process.setProcessChannelMode(QProcess::ForwardedChannels);
process.start(targetExecutable, targetArguments);
diff --git a/src/lib/corelib/api/runenvironment.h b/src/lib/corelib/api/runenvironment.h
index f20fedbfc..eb7689b58 100644
--- a/src/lib/corelib/api/runenvironment.h
+++ b/src/lib/corelib/api/runenvironment.h
@@ -40,6 +40,7 @@ class QProcessEnvironment;
QT_END_NAMESPACE
namespace qbs {
+class InstallOptions;
class Settings;
namespace Internal {
@@ -62,6 +63,7 @@ public:
private:
RunEnvironment(const Internal::ResolvedProductPtr &product,
+ const InstallOptions &installOptions,
const QProcessEnvironment &environment, Settings *settings,
const Internal::Logger &logger);
diff --git a/src/lib/corelib/buildgraph/productinstaller.cpp b/src/lib/corelib/buildgraph/productinstaller.cpp
index c7df23d24..0acd515ae 100644
--- a/src/lib/corelib/buildgraph/productinstaller.cpp
+++ b/src/lib/corelib/buildgraph/productinstaller.cpp
@@ -123,13 +123,7 @@ void ProductInstaller::initInstallRoot(const TopLevelProject *project,
if (!options.installRoot().isEmpty())
return;
- if (options.installIntoSysroot()) {
- options.setInstallRoot(PropertyFinder().propertyValue(project->buildConfiguration(),
- QLatin1String("qbs"), QLatin1String("sysroot")).toString());
- } else {
- options.setInstallRoot(project->buildDirectory + QLatin1Char('/') +
- InstallOptions::defaultInstallRoot());
- }
+ options.setInstallRoot(effectiveInstallRoot(options, project));
}
void ProductInstaller::removeInstallRoot()
diff --git a/src/lib/corelib/tools/installoptions.cpp b/src/lib/corelib/tools/installoptions.cpp
index 66e82fd23..42f2fe246 100644
--- a/src/lib/corelib/tools/installoptions.cpp
+++ b/src/lib/corelib/tools/installoptions.cpp
@@ -27,6 +27,8 @@
**
****************************************************************************/
#include "installoptions.h"
+#include "propertyfinder.h"
+#include "language/language.h"
#include <QDir>
#include <QSharedData>
@@ -50,6 +52,20 @@ public:
bool logElapsedTime;
};
+QString effectiveInstallRoot(const InstallOptions &options, const TopLevelProject *project)
+{
+ const QString installRoot = options.installRoot();
+ if (!installRoot.isEmpty())
+ return installRoot;
+
+ if (options.installIntoSysroot()) {
+ return PropertyFinder().propertyValue(project->buildConfiguration(),
+ QLatin1String("qbs"), QLatin1String("sysroot")).toString();
+ }
+
+ return project->buildDirectory + QLatin1Char('/') + InstallOptions::defaultInstallRoot();
+}
+
} // namespace Internal
/*!
diff --git a/src/lib/corelib/tools/installoptions.h b/src/lib/corelib/tools/installoptions.h
index 2b6194fb0..ef0ac4253 100644
--- a/src/lib/corelib/tools/installoptions.h
+++ b/src/lib/corelib/tools/installoptions.h
@@ -35,7 +35,12 @@
#include <QString>
namespace qbs {
-namespace Internal { class InstallOptionsPrivate; }
+class InstallOptions;
+namespace Internal {
+class InstallOptionsPrivate;
+class TopLevelProject;
+QString effectiveInstallRoot(const InstallOptions &options, const TopLevelProject *project);
+}
class QBS_EXPORT InstallOptions
{
diff --git a/src/lib/qtprofilesetup/templates/core.qbs b/src/lib/qtprofilesetup/templates/core.qbs
index 18b5d5eaf..aefd9c48d 100644
--- a/src/lib/qtprofilesetup/templates/core.qbs
+++ b/src/lib/qtprofilesetup/templates/core.qbs
@@ -171,12 +171,19 @@ Module {
}
setupRunEnvironment: {
+ var env;
if (qbs.targetOS.contains('windows')) {
- var v = getEnv('PATH') || '';
- if (v.length > 0 && v.charAt(0) != ';')
- v = ';' + v;
- v = FileInfo.toWindowsSeparators(binPath) + v;
- putEnv('PATH', v);
+ env = new ModUtils.EnvironmentVariable("PATH", qbs.pathListSeparator, true);
+ env.append(binPath);
+ env.set();
+ } else if (qbs.targetOS.contains("darwin")) {
+ env = new ModUtils.EnvironmentVariable("DYLD_FRAMEWORK_PATH", qbs.pathListSeparator);
+ env.append(libPath);
+ env.set();
+
+ env = new ModUtils.EnvironmentVariable("DYLD_LIBRARY_PATH", qbs.pathListSeparator);
+ env.append(libPath);
+ env.set();
}
}