Commit 3e6fcd60 authored by Christian Kandeler's avatar Christian Kandeler

QbsProjectManager: Support using an installed qbs.

Distributions will want to make Creator work with
their qbs package instead of adding it a second time
via the submodule, so we support that by checking for
the QBS_INSTALL_DIR environment variable.
This supersedes the current mechanism using QBS_SOURCE_DIR
and QBS_BUILD_DIR.

Change-Id: I2cff651cd23ea47b1a1434e33f80cb74ca0fc96b
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent a8d7e15a
......@@ -49,7 +49,8 @@ SUBDIRS = \
qnx \
clearcase
exists(../shared/qbs/qbs.pro): \
isEmpty(QBS_INSTALL_DIR): QBS_INSTALL_DIR = $$(QBS_INSTALL_DIR)
exists(../shared/qbs/qbs.pro)|!isEmpty(QBS_INSTALL_DIR): \
SUBDIRS += \
qbsprojectmanager
......
......@@ -423,9 +423,9 @@ void QbsProject::parse(const QVariantMap &config, const Environment &env, const
params.setIgnoreDifferentProjectFilePath(false);
params.setEnvironment(env.toProcessEnvironment());
qbs::Preferences *prefs = QbsManager::preferences();
const QString buildDir = qbsBuildDir();
params.setSearchPaths(prefs->searchPaths(buildDir));
params.setPluginPaths(prefs->pluginPaths(buildDir));
const QString qbsDir = qbsDirectory();
params.setSearchPaths(prefs->searchPaths(qbsDir));
params.setPluginPaths(prefs->pluginPaths(qbsDir));
// Do the parsing:
prepareForParsing();
......@@ -658,12 +658,12 @@ void QbsProject::updateDeploymentInfo(const qbs::Project *project)
activeTarget()->setDeploymentData(deploymentData);
}
QString QbsProject::qbsBuildDir() const
QString QbsProject::qbsDirectory() const
{
QString buildDir = Environment::systemEnvironment().value(QLatin1String("QBS_BUILD_DIR"));
if (buildDir.isEmpty())
buildDir = ICore::resourcePath() + QLatin1String("/qbs");
return buildDir;
const QString qbsInstallDir = QLatin1String(QBS_INSTALL_DIR);
if (!qbsInstallDir.isEmpty())
return qbsInstallDir;
return ICore::resourcePath() + QLatin1String("/qbs");
}
} // namespace Internal
......
......@@ -130,7 +130,7 @@ private:
void updateQmlJsCodeModel(const qbs::ProjectData &prj);
void updateApplicationTargets(const qbs::ProjectData &projectData);
void updateDeploymentInfo(const qbs::Project *project);
QString qbsBuildDir() const;
QString qbsDirectory() const;
QbsManager *const m_manager;
const QString m_projectName;
......
include(../../qtcreatorplugin.pri)
# Look for qbs in the environment
isEmpty(QBS_SOURCE_DIR): QBS_SOURCE_DIR = $$(QBS_SOURCE_DIR)
isEmpty(QBS_BUILD_DIR): QBS_BUILD_DIR = $$(QBS_BUILD_DIR)
# Fallback to the submodule
isEmpty(QBS_SOURCE_DIR): QBS_SOURCE_DIR = $$PWD/../../shared/qbs
isEmpty(QBS_BUILD_DIR): QBS_BUILD_DIR = $$IDE_BUILD_TREE/src/shared/qbs
isEmpty(QBS_INSTALL_DIR): QBS_INSTALL_DIR = $$(QBS_INSTALL_DIR)
isEmpty(QBS_INSTALL_DIR) {
QBS_SOURCE_DIR = $$PWD/../../shared/qbs
include($$QBS_SOURCE_DIR/src/lib/use.pri)
macx:QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../ # Mac: fix rpath for qbscore soname
} else {
include($${QBS_INSTALL_DIR}/include/qbs/use_installed.pri)
}
QBS_INSTALL_DIR_FWD_SLASHES = $$replace(QBS_INSTALL_DIR, \\\\, /)
DEFINES += QBS_INSTALL_DIR=\\\"$$QBS_INSTALL_DIR_FWD_SLASHES\\\"
include($$QBS_SOURCE_DIR/src/lib/use.pri)
# Mac: fix rpath for qbscore soname
macx:QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../
QBS_BUILD_DIR_FWD_SLASHES = $$replace(QBS_BUILD_DIR, \\\\, /)
DEFINES += QBS_BUILD_DIR=\\\"$$QBS_BUILD_DIR_FWD_SLASHES\\\"
DEFINES += \
QBSPROJECTMANAGER_LIBRARY
......
......@@ -5,11 +5,12 @@ import "../QtcPlugin.qbs" as QtcPlugin
QtcPlugin {
name: "QbsProjectManager"
property var externalQbsDefines: project.useExternalQbs
? ['QBS_BUILD_DIR="' + project.qbs_build_dir +'"'] : []
property var externalQbsIncludes: project.useExternalQbs ? [project.qbs_source_dir + "/src/lib"] : []
property var externalQbsLibraryPaths: project.useExternalQbs ? [project.qbs_build_dir + "/lib"] : []
property var externalQbsRPaths: project.useExternalQbs ? [project.qbs_build_dir + "/lib"] : []
property var externalQbsIncludes: project.useExternalQbs
? [project.qbs_install_dir + "/include/qbs"] : []
property var externalQbsLibraryPaths: project.useExternalQbs
? [project.qbs_install_dir + "/lib"] : []
property var externalQbsRPaths: project.useExternalQbs
? [project.qbs_install_dir + "/lib"] : []
property var externalQbsDynamicLibraries: {
var libs = []
if (!project.useExternalQbs)
......@@ -42,8 +43,11 @@ QtcPlugin {
}
cpp.defines: base.concat([
'QML_BUILD_STATIC_LIB'
]).concat(externalQbsDefines)
'QML_BUILD_STATIC_LIB',
'QBS_INSTALL_DIR="'
+ (project.useExternalQbs ? project.qbs_install_dir.split("\\").join("/") : '')
+ '"'
])
cpp.includePaths: base.concat(externalQbsIncludes)
cpp.libraryPaths: base.concat(externalQbsLibraryPaths)
cpp.rpaths: base.concat(externalQbsRPaths)
......
......@@ -12,9 +12,8 @@ Project {
]
property bool qbsSubModuleExists: File.exists(qbsProject.qbsBaseDir + "/qbs.qbs")
property path qbs_build_dir: qbs.getenv("QBS_BUILD_DIR")
property path qbs_source_dir: qbs.getenv("QBS_SOURCE_DIR")
property bool useExternalQbs: qbs_build_dir && qbs_source_dir
property path qbs_install_dir: qbs.getenv("QBS_INSTALL_DIR")
property bool useExternalQbs: qbs_install_dir
property bool buildQbsProjectManager: useExternalQbs || qbsSubModuleExists
Project {
name: "qbs"
......
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