summaryrefslogtreecommitdiff
path: root/src/lib/buildgraph
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2013-08-20 17:12:02 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2013-08-21 17:36:23 +0200
commitd1bbb4180f24f70d8a3823d1774bae2828077c18 (patch)
treeb46bbfb2b55c3d6728b68bbc5f7cb1ae8560ce0f /src/lib/buildgraph
parent38a3026d5cb7d81397192865d1d8b6acb7fe67a8 (diff)
downloadqbs-d1bbb4180f24f70d8a3823d1774bae2828077c18.tar.gz
API: Add ability to retrieve the list of files to be installed.
This sort of information is something an IDE would like to show. Change-Id: I2284f3e36c7ed90a880b1df9027a976b2ce7fb63 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib/buildgraph')
-rw-r--r--src/lib/buildgraph/productinstaller.cpp62
-rw-r--r--src/lib/buildgraph/productinstaller.h6
2 files changed, 52 insertions, 16 deletions
diff --git a/src/lib/buildgraph/productinstaller.cpp b/src/lib/buildgraph/productinstaller.cpp
index bd48c2364..3c485dc39 100644
--- a/src/lib/buildgraph/productinstaller.cpp
+++ b/src/lib/buildgraph/productinstaller.cpp
@@ -48,7 +48,11 @@ namespace Internal {
ProductInstaller::ProductInstaller(const TopLevelProjectPtr &project,
const QList<ResolvedProductPtr> &products, const InstallOptions &options,
ProgressObserver *observer, const Logger &logger)
- : m_products(products), m_options(options), m_observer(observer), m_logger(logger)
+ : m_project(project),
+ m_products(products),
+ m_options(options),
+ m_observer(observer),
+ m_logger(logger)
{
if (!m_options.installRoot().isEmpty()) {
QFileInfo installRootFileInfo(m_options.installRoot());
@@ -66,12 +70,8 @@ ProductInstaller::ProductInstaller(const TopLevelProjectPtr &project,
if (m_options.installIntoSysroot()) {
if (m_options.removeExistingInstallation())
throw ErrorInfo(Tr::tr("Refusing to remove sysroot."));
- m_options.setInstallRoot(PropertyFinder().propertyValue(project->buildConfiguration(),
- QLatin1String("qbs"), QLatin1String("sysroot")).toString());
- } else {
- m_options.setInstallRoot(project->buildDirectory + QLatin1Char('/') +
- InstallOptions::defaultInstallRoot());
}
+ initInstallRoot(project.data(), m_options);
}
void ProductInstaller::install()
@@ -95,6 +95,43 @@ void ProductInstaller::install()
}
}
+QString ProductInstaller::targetFilePath(const TopLevelProject *project,
+ const QString &sourceFilePath, const PropertyMapConstPtr &properties,
+ InstallOptions &options, QString *targetDirectory)
+{
+ if (!properties->qbsPropertyValue(QLatin1String("install")).toBool())
+ return QString();
+ const QString relativeInstallDir
+ = properties->qbsPropertyValue(QLatin1String("installDir")).toString();
+ const QString installPrefix
+ = properties->qbsPropertyValue(QLatin1String("installPrefix")).toString();
+ initInstallRoot(project, options);
+ QString targetDir = options.installRoot();
+ targetDir.append(QLatin1Char('/')).append(installPrefix)
+ .append(QLatin1Char('/')).append(relativeInstallDir);
+ targetDir = QDir::cleanPath(targetDir);
+ const QString targetFilePath = QDir::cleanPath(targetDir + QLatin1Char('/')
+ + FileInfo::fileName(sourceFilePath));
+ if (targetDirectory)
+ *targetDirectory = targetDir;
+ return targetFilePath;
+}
+
+void ProductInstaller::initInstallRoot(const TopLevelProject *project,
+ InstallOptions &options)
+{
+ 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());
+ }
+}
+
void ProductInstaller::removeInstallRoot()
{
const QString nativeInstallRoot = QDir::toNativeSeparators(m_options.installRoot());
@@ -119,14 +156,9 @@ void ProductInstaller::copyFile(const Artifact *artifact)
throw ErrorInfo(Tr::tr("Installation canceled for configuration '%1'.")
.arg(m_products.first()->project->topLevelProject()->id()));
}
- 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(installPrefix)
- .append(QLatin1Char('/')).append(relativeInstallDir);
- targetDir = QDir::cleanPath(targetDir);
+ QString targetDir;
+ const QString targetFilePath = this->targetFilePath(m_project.data(), artifact->filePath(),
+ artifact->properties, m_options, &targetDir);
const QString nativeFilePath = QDir::toNativeSeparators(artifact->filePath());
const QString nativeTargetDir = QDir::toNativeSeparators(targetDir);
if (m_options.dryRun()) {
@@ -141,8 +173,6 @@ void ProductInstaller::copyFile(const Artifact *artifact)
handleError(Tr::tr("Directory '%1' could not be created.").arg(nativeTargetDir));
return;
}
- const QString targetFilePath = QDir::cleanPath(targetDir + QLatin1Char('/')
- + FileInfo::fileName(artifact->filePath()));
QString errorMessage;
if (!copyFileRecursion(artifact->filePath(), targetFilePath, true, &errorMessage))
handleError(Tr::tr("Installation error: %1").arg(errorMessage));
diff --git a/src/lib/buildgraph/productinstaller.h b/src/lib/buildgraph/productinstaller.h
index 1c711f02a..1b782ac3e 100644
--- a/src/lib/buildgraph/productinstaller.h
+++ b/src/lib/buildgraph/productinstaller.h
@@ -48,11 +48,17 @@ public:
const InstallOptions &options, ProgressObserver *observer, const Logger &logger);
void install();
+ static QString targetFilePath(const TopLevelProject *project,
+ const QString &sourceFilePath, const PropertyMapConstPtr &properties,
+ InstallOptions &options, QString *targetDirectory = 0);
+ static void initInstallRoot(const TopLevelProject *project, InstallOptions &options);
+
private:
void removeInstallRoot();
void copyFile(const Artifact *artifact);
void handleError(const QString &message);
+ const TopLevelProjectConstPtr m_project;
const QList<ResolvedProductPtr> m_products;
InstallOptions m_options;
ProgressObserver * const m_observer;