diff options
| -rw-r--r-- | doc/qbs.qdoc | 12 | ||||
| -rw-r--r-- | share/qbs/modules/qbs/common.qbs | 1 | ||||
| -rw-r--r-- | src/lib/api/project.cpp | 8 | ||||
| -rw-r--r-- | src/lib/buildgraph/productinstaller.cpp | 5 | ||||
| -rw-r--r-- | src/lib/tools/installoptions.cpp | 2 | ||||
| -rw-r--r-- | tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs | 1 | ||||
| -rw-r--r-- | tests/auto/blackbox/tst_blackbox.cpp | 6 |
7 files changed, 27 insertions, 8 deletions
diff --git a/doc/qbs.qdoc b/doc/qbs.qdoc index e8735e0c1..c431380ac 100644 --- a/doc/qbs.qdoc +++ b/doc/qbs.qdoc @@ -981,8 +981,18 @@ \endtable Specifies the installation directory for the files of a product or a \c{Group}. The value of - this property is a path that is relative to the install root. + this property is a path that is relative to \c installPrefix. + + \section1 installPrefix + + \table + \row \li \b{Type:} \li \c{string} + \row \li \b{Default:} \li \c{empty} + \endtable + Specifies the global installation prefix. It is implicitly prepended to all values + of \c installDir. The \c installPrefix itself is relative to the install root, which is not + a property of qbs, but an external installation parameter. \section1 pathListSeparator diff --git a/share/qbs/modules/qbs/common.qbs b/share/qbs/modules/qbs/common.qbs index 1f287cb7b..6b80649dc 100644 --- a/share/qbs/modules/qbs/common.qbs +++ b/share/qbs/modules/qbs/common.qbs @@ -23,6 +23,7 @@ Module { property bool install: false property string installDir + property string installPrefix: "" property string sysroot PropertyOptions { diff --git a/src/lib/api/project.cpp b/src/lib/api/project.cpp index c3d84c243..9d7ebc3b7 100644 --- a/src/lib/api/project.cpp +++ b/src/lib/api/project.cpp @@ -46,6 +46,7 @@ #include <tools/installoptions.h> #include <tools/preferences.h> #include <tools/processresult.h> +#include <tools/propertyfinder.h> #include <tools/scannerpluginmanager.h> #include <tools/scripttools.h> #include <tools/setupprojectparameters.h> @@ -369,8 +370,11 @@ QString Project::targetExecutable(const ProductData &product, } QString installDir = artifact->properties ->qbsPropertyValue(QLatin1String("installDir")).toString(); - return QDir::cleanPath(installRoot + QLatin1Char('/') + installDir + QLatin1Char('/') - + fileName); + const QString installPrefix = artifact->properties + ->qbsPropertyValue(QLatin1String("installPrefix")).toString(); + installDir.prepend(QLatin1Char('/')).prepend(installPrefix) + .prepend(QLatin1Char('/')).prepend(installRoot); + return QDir::cleanPath(installDir + QLatin1Char('/') + fileName); } } return QString(); diff --git a/src/lib/buildgraph/productinstaller.cpp b/src/lib/buildgraph/productinstaller.cpp index 468f79f9d..bd48c2364 100644 --- a/src/lib/buildgraph/productinstaller.cpp +++ b/src/lib/buildgraph/productinstaller.cpp @@ -121,8 +121,11 @@ void ProductInstaller::copyFile(const Artifact *artifact) } const QString relativeInstallDir = artifact->properties->qbsPropertyValue(QLatin1String("installDir")).toString(); + const QString installPrefix + = artifact->properties->qbsPropertyValue(QLatin1String("installPrefix")).toString(); QString targetDir = m_options.installRoot(); - targetDir.append(QLatin1Char('/')).append(relativeInstallDir); + targetDir.append(QLatin1Char('/')).append(installPrefix) + .append(QLatin1Char('/')).append(relativeInstallDir); targetDir = QDir::cleanPath(targetDir); const QString nativeFilePath = QDir::toNativeSeparators(artifact->filePath()); const QString nativeTargetDir = QDir::toNativeSeparators(targetDir); diff --git a/src/lib/tools/installoptions.cpp b/src/lib/tools/installoptions.cpp index 33f57ddb4..6b01cde5f 100644 --- a/src/lib/tools/installoptions.cpp +++ b/src/lib/tools/installoptions.cpp @@ -85,7 +85,7 @@ QString InstallOptions::defaultInstallRoot() /*! * Returns the base directory for the installation. - * All "qbs.installDir" paths are relative to this root. If the string is empty, either the value of + * The \c qbs.installPrefix path is relative to this root. If the string is empty, either the value of * qbs.sysroot or "<build dir>/install-root" will be used, depending on what \c installIntoSysroot() * returns. * The default is empty. diff --git a/tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs b/tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs index aaac7aef1..6492471e6 100644 --- a/tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs +++ b/tests/auto/blackbox/testdata/installed_artifact/installed_artifact.qbs @@ -4,6 +4,7 @@ Application { name: "installedApp" Depends { name: "cpp" } files: "main.cpp" + qbs.installPrefix: "/usr" Group { fileTagsFilter: "application" qbs.install: true diff --git a/tests/auto/blackbox/tst_blackbox.cpp b/tests/auto/blackbox/tst_blackbox.cpp index d8faaa07e..201a36355 100644 --- a/tests/auto/blackbox/tst_blackbox.cpp +++ b/tests/auto/blackbox/tst_blackbox.cpp @@ -956,12 +956,12 @@ void TestBlackbox::installedApp() QCOMPARE(runQbs(QbsRunParameters("install")), 0); QVERIFY(QFile::exists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/bin/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp")))); QCOMPARE(runQbs(QbsRunParameters(QStringList("install") << "--install-root" << (testDataDir + "/installed-app"))), 0); QVERIFY(QFile::exists(testDataDir - + HostOsInfo::appendExecutableSuffix("/installed-app/bin/installedApp"))); + + HostOsInfo::appendExecutableSuffix("/installed-app/usr/bin/installedApp"))); QFile addedFile(defaultInstallRoot + QLatin1String("/blubb.txt")); QVERIFY(addedFile.open(QIODevice::WriteOnly)); @@ -969,7 +969,7 @@ void TestBlackbox::installedApp() QVERIFY(addedFile.exists()); QCOMPARE(runQbs(QbsRunParameters(QStringList("install") << "--remove-first")), 0); QVERIFY(QFile::exists(defaultInstallRoot - + HostOsInfo::appendExecutableSuffix(QLatin1String("/bin/installedApp")))); + + HostOsInfo::appendExecutableSuffix(QLatin1String("/usr/bin/installedApp")))); QVERIFY(!addedFile.exists()); rmDirR(buildDir); |
