QNX: Fixed paths to bar package to match build directory

Unless the package path, or application descriptor path, are changed
actively by the user, those values will now be automatically generated
from the build directory and source directory respectively.

This fixes a problem where the path to the package would be in
the debug build directory, even though the build mode was switched
to release.

Task-number: QTCREATORBUG-8991
Change-Id: I78137fc8a6ba0532663808ac9800c03e8371e148
Reviewed-by: Mehdi Fekari <mfekari@rim.com>
Reviewed-by: Nicolas Arnaud-Cormos <nicolas@kdab.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Tobias Nätterlund
2013-03-21 11:01:13 +01:00
committed by Tobias Nätterlund
parent 2bb4f6c175
commit 25f9de1140
5 changed files with 66 additions and 27 deletions

View File

@@ -102,17 +102,17 @@ bool BlackBerryCreatePackageStep::init()
}
foreach (const BarPackageDeployInformation &info, packagesToDeploy) {
if (info.appDescriptorPath.isEmpty()) {
if (info.appDescriptorPath().isEmpty()) {
raiseError(tr("Application descriptor file not specified, please check deployment settings"));
return false;
}
if (info.packagePath.isEmpty()) {
if (info.packagePath().isEmpty()) {
raiseError(tr("No package specified, please check deployment settings"));
return false;
}
const QString buildDir = target()->activeBuildConfiguration()->buildDirectory();
const QString buildDir = QFileInfo(info.packagePath()).absolutePath();
QDir dir(buildDir);
if (!dir.exists()) {
if (!dir.mkpath(buildDir)) {
@@ -122,7 +122,7 @@ bool BlackBerryCreatePackageStep::init()
}
const QString preparedFilePath = buildDir + QLatin1String("/bar-descriptor-") + project()->displayName() + QLatin1String("-qtc-generated.xml");
if (!prepareAppDescriptorFile(info.appDescriptorPath, preparedFilePath))
if (!prepareAppDescriptorFile(info.appDescriptorPath(), preparedFilePath))
// If there is an error, prepareAppDescriptorFile() will raise it
return false;
@@ -131,7 +131,7 @@ bool BlackBerryCreatePackageStep::init()
args << QLatin1String("-devMode");
if (!debugToken().isEmpty())
args << QLatin1String("-debugToken") << QnxUtils::addQuotes(QDir::toNativeSeparators(debugToken()));
args << QLatin1String("-package") << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath));
args << QLatin1String("-package") << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath()));
args << QnxUtils::addQuotes(QDir::toNativeSeparators(preparedFilePath));
addCommand(packageCmd, args);
}

View File

@@ -50,8 +50,28 @@ const char ENABLED_KEY[] = "Qnx.BlackBerry.DeployInformation.Enabled";
const char APPDESCRIPTOR_KEY[] = "Qnx.BlackBerry.DeployInformation.AppDescriptor";
const char PACKAGE_KEY[] = "Qnx.BlackBerry.DeployInformation.Package";
const char PROFILE_KEY[] = "Qnx.BlackBerry.DeployInformation.ProFile";
const char TARGET_KEY[] = "Qnx.BlackBerry.DeployInformation.Target";
const char SOURCE_KEY[] = "Qnx.BlackBerry.DeployInformation.Source";
}
QString BarPackageDeployInformation::appDescriptorPath() const
{
if (userAppDescriptorPath.isEmpty())
return sourceDir + QLatin1String("/bar-descriptor.xml");
return userAppDescriptorPath;
}
QString BarPackageDeployInformation::packagePath() const
{
if (userPackagePath.isEmpty())
return buildDir + QLatin1String("/") + targetName + QLatin1String(".bar");
return userPackagePath;
}
// ----------------------------------------------------------------------------
BlackBerryDeployInformation::BlackBerryDeployInformation(ProjectExplorer::Target *target)
: QAbstractTableModel(target)
, m_target(target)
@@ -89,9 +109,9 @@ QVariant BlackBerryDeployInformation::data(const QModelIndex &index, int role) c
return di.enabled ? Qt::Checked : Qt::Unchecked;
} else if (role == Qt::DisplayRole || role == Qt::EditRole) {
if (index.column() == AppDescriptorColumn)
return di.appDescriptorPath;
return QDir::toNativeSeparators(di.appDescriptorPath());
else if (index.column() == PackageColumn)
return di.packagePath;
return QDir::toNativeSeparators(di.packagePath());
}
return QVariant();
@@ -126,9 +146,9 @@ bool BlackBerryDeployInformation::setData(const QModelIndex &index, const QVaria
di.enabled = static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked;
} else if (role == Qt::EditRole) {
if (index.column() == AppDescriptorColumn)
di.appDescriptorPath = value.toString();
di.userAppDescriptorPath = value.toString();
else if (index.column() == PackageColumn)
di.packagePath = value.toString();
di.userPackagePath = value.toString();
}
emit dataChanged(index, index);
@@ -173,9 +193,11 @@ QVariantMap BlackBerryDeployInformation::toMap() const
QVariantMap deployInfoMap;
deployInfoMap[QLatin1String(ENABLED_KEY)] = deployInfo.enabled;
deployInfoMap[QLatin1String(APPDESCRIPTOR_KEY)] = deployInfo.appDescriptorPath;
deployInfoMap[QLatin1String(PACKAGE_KEY)] = deployInfo.packagePath;
deployInfoMap[QLatin1String(APPDESCRIPTOR_KEY)] = deployInfo.userAppDescriptorPath;
deployInfoMap[QLatin1String(PACKAGE_KEY)] = deployInfo.userPackagePath;
deployInfoMap[QLatin1String(PROFILE_KEY)] = deployInfo.proFilePath;
deployInfoMap[QLatin1String(TARGET_KEY)] = deployInfo.targetName;
deployInfoMap[QLatin1String(SOURCE_KEY)] = deployInfo.sourceDir;
outerMap[QString::fromLatin1(DEPLOYINFO_KEY).arg(i)] = deployInfoMap;
}
@@ -196,8 +218,13 @@ void BlackBerryDeployInformation::fromMap(const QVariantMap &map)
const QString appDescriptorPath = innerMap.value(QLatin1String(APPDESCRIPTOR_KEY)).toString();
const QString packagePath = innerMap.value(QLatin1String(PACKAGE_KEY)).toString();
const QString proFilePath = innerMap.value(QLatin1String(PROFILE_KEY)).toString();
const QString targetName = innerMap.value(QLatin1String(TARGET_KEY)).toString();
const QString sourceDir = innerMap.value(QLatin1String(SOURCE_KEY)).toString();
m_deployInformation << BarPackageDeployInformation(enabled, appDescriptorPath, packagePath, proFilePath);
BarPackageDeployInformation deployInformation(enabled, proFilePath, sourceDir, m_target->activeBuildConfiguration()->buildDirectory(), targetName);
deployInformation.userAppDescriptorPath = appDescriptorPath;
deployInformation.userPackagePath = packagePath;
m_deployInformation << deployInformation;
}
endResetModel();
@@ -216,8 +243,13 @@ void BlackBerryDeployInformation::updateModel()
foreach (Qt4ProjectManager::Qt4ProFileNode *node, appNodes) {
bool nodeFound = false;
for (int i = 0; i < m_deployInformation.size(); ++i) {
if (m_deployInformation[i].proFilePath == node->path()) {
keep << m_deployInformation[i];
if (m_deployInformation[i].proFilePath == node->path()
&& (!m_deployInformation[i].userAppDescriptorPath.isEmpty()
|| !m_deployInformation[i].userPackagePath.isEmpty())) {
BarPackageDeployInformation deployInformation = m_deployInformation[i];
// In case the user resets the bar package path (or if it is empty already), we need the current build dir
deployInformation.buildDir = m_target->activeBuildConfiguration()->buildDirectory();
keep << deployInformation;
nodeFound = true;
break;
}
@@ -270,9 +302,7 @@ BarPackageDeployInformation BlackBerryDeployInformation::deployInformationFromNo
Qt4ProjectManager::TargetInformation ti = node->targetInformation();
QFileInfo fi(node->path());
const QString appDescriptorPath = QDir::toNativeSeparators(fi.absolutePath() + QLatin1String("/bar-descriptor.xml"));
QString buildDir = m_target->activeBuildConfiguration()->buildDirectory();
QString barPackagePath = QDir::toNativeSeparators(buildDir + QLatin1Char('/') + ti.target + QLatin1String(".bar"));
const QString buildDir = m_target->activeBuildConfiguration()->buildDirectory();
return BarPackageDeployInformation(true, appDescriptorPath, barPackagePath, node->path());
return BarPackageDeployInformation(true, node->path(), fi.absolutePath(), buildDir, ti.target);
}

View File

@@ -47,18 +47,27 @@ namespace Internal {
class BarPackageDeployInformation {
public:
BarPackageDeployInformation(bool enabled, QString appDescriptorPath, QString packagePath, QString proFilePath)
BarPackageDeployInformation(bool enabled, const QString &proFilePath, const QString &sourceDir,
const QString &buildDir, const QString &targetName)
: enabled(enabled)
, appDescriptorPath(appDescriptorPath)
, packagePath(packagePath)
, proFilePath(proFilePath)
, sourceDir(sourceDir)
, buildDir(buildDir)
, targetName(targetName)
{
}
QString appDescriptorPath() const;
QString packagePath() const;
bool enabled;
QString appDescriptorPath;
QString packagePath;
QString proFilePath;
QString sourceDir;
QString buildDir;
QString targetName;
QString userAppDescriptorPath;
QString userPackagePath;
};
class BlackBerryDeployInformation : public QAbstractTableModel

View File

@@ -117,7 +117,7 @@ bool BlackBerryDeployStep::init()
args << QLatin1String("-device") << deviceHost();
if (!password().isEmpty())
args << QLatin1String("-password") << password();
args << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath));
args << QnxUtils::addQuotes(QDir::toNativeSeparators(info.packagePath()));
addCommand(deployCmd, args);
}
@@ -132,8 +132,8 @@ void BlackBerryDeployStep::run(QFutureInterface<bool> &fi)
QList<BarPackageDeployInformation> packagesToDeploy = deployConfig->deploymentInfo()->enabledPackages();
foreach (const BarPackageDeployInformation &info, packagesToDeploy) {
if (!QFileInfo(info.packagePath).exists()) {
raiseError(tr("Package '%1' does not exist. Create the package first.").arg(info.packagePath));
if (!QFileInfo(info.packagePath()).exists()) {
raiseError(tr("Package '%1' does not exist. Create the package first.").arg(info.packagePath()));
fi.reportResult(false);
return;
}

View File

@@ -102,7 +102,7 @@ QString BlackBerryRunConfiguration::barPackage() const
QList<BarPackageDeployInformation> packages = dc->deploymentInfo()->enabledPackages();
foreach (const BarPackageDeployInformation package, packages) {
if (package.proFilePath == proFilePath())
return package.packagePath;
return package.packagePath();
}
return QString();
}