AppMan: Cleanup variables in TargetInformation and Manifest

Remove all variables we don't need and convert them to FilePaths where
it makes sense.

Change-Id: I4842bcf23f81db8c86f7e305113c24034b361d80
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Dominik Holland
2024-01-23 12:21:36 +01:00
parent 3ce58e0465
commit cdb44ea680
6 changed files with 22 additions and 40 deletions

View File

@@ -12,6 +12,7 @@
#include <projectexplorer/buildstep.h>
#include <projectexplorer/deployconfiguration.h>
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
@@ -52,10 +53,10 @@ public:
const TargetInformation targetInformation(target());
packageFilePath.setValue(targetInformation.packageFile.absoluteFilePath());
packageFilePath.setValue(targetInformation.packageFilePath);
packageFilePath.setDefaultValue(packageFilePath.value());
targetDirectory.setValue(targetInformation.runDirectory.absolutePath());
targetDirectory.setValue(targetInformation.runDirectory);
targetDirectory.setDefaultValue(targetDirectory.value());
setEnabled(!targetInformation.isBuiltin);
@@ -80,14 +81,13 @@ private:
GroupItem runRecipe() final
{
const auto onSetup = [this](FileStreamer &streamer) {
const TargetInformation targetInformation(target());
const FilePath source = packageFilePath().isEmpty() ?
FilePath::fromString(packageFilePath.defaultValue()) :
packageFilePath();
const FilePath targetDir = targetDirectory().isEmpty() ?
FilePath::fromString(targetDirectory.defaultValue()) :
targetDirectory();
const FilePath target = targetInformation.device->filePath(targetDir.path())
const FilePath target = DeviceKitAspect::device(kit())->filePath(targetDir.path())
.pathAppended(source.fileName());
streamer.setSource(source);
streamer.setDestination(target);

View File

@@ -67,7 +67,7 @@ AppManagerInstallPackageStep::AppManagerInstallPackageStep(BuildStepList *bsl, I
const TargetInformation targetInformation(target());
packageFile.setDefaultValue(targetInformation.packageFile.absoluteFilePath());
packageFile.setDefaultValue(targetInformation.packageFilePath.toUserOutput());
setEnabled(!targetInformation.isBuiltin);
};

View File

@@ -74,10 +74,10 @@ AppManagerRemoteInstallPackageStep::AppManagerRemoteInstallPackageStep(BuildStep
const TargetInformation targetInformation(target());
const QString packageFilePath =
targetInformation.runDirectory.absoluteFilePath(targetInformation.packageFile.fileName());
const Utils::FilePath packageFilePath =
targetInformation.runDirectory.pathAppended(targetInformation.packageFilePath.fileName());
packageFile.setDefaultValue(packageFilePath);
packageFile.setDefaultValue(packageFilePath.toUserOutput());
setEnabled(!targetInformation.isBuiltin);
};

View File

@@ -11,9 +11,10 @@
#include "appmanagertr.h"
#include "appmanagerutilities.h"
#include <projectexplorer/environmentaspect.h>
#include <projectexplorer/kitaspects.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <projectexplorer/environmentaspect.h>
#include <remotelinux/remotelinux_constants.h>
@@ -39,8 +40,8 @@ public:
return;
const TargetInformation targetInformation = tis.at(0);
controller.setValue(FilePath::fromString(getToolFilePath(Constants::APPMAN_CONTROLLER, target->kit(),
targetInformation.device)));
controller.setValue(FilePath::fromString(getToolFilePath(Constants::APPMAN_CONTROLLER, kit(),
DeviceKitAspect::device(kit()))));
appId.setValue(targetInformation.manifest.id);
appId.setReadOnly(true);
@@ -117,10 +118,10 @@ public:
rci.displayName = decoratedTargetName(ti.displayName, target);
rci.displayNameUniquifier = ti.displayNameUniquifier;
rci.creationMode = RunConfigurationCreationInfo::AlwaysCreate;
rci.projectFilePath = Utils::FilePath::fromString(ti.manifest.fileName);
rci.projectFilePath = ti.manifest.filePath;
rci.useTerminal = false;
if (!m_fileSystemWatcher.files().contains(ti.manifest.fileName)) {
m_fileSystemWatcher.addFile(ti.manifest.fileName, FileSystemWatcher::WatchAllChanges);
if (!m_fileSystemWatcher.files().contains(ti.manifest.filePath.toFSPathString())) {
m_fileSystemWatcher.addFile(ti.manifest.filePath, FileSystemWatcher::WatchAllChanges);
}
return rci;
});

View File

@@ -62,13 +62,13 @@ QList<TargetInformation> TargetInformation::readFromProject(const Target *target
ati.displayNameUniquifier = id + " [App]";
ati.displayName = id + " [App]";
ati.buildKey = id;
ati.manifest.fileName = manifestFilePath.path();
ati.manifest.filePath = manifestFilePath;
ati.manifest.id = id;
ati.manifest.runtime = runtime;
ati.manifest.code = code;
ati.isBuiltin = isBuiltinPackage;
ati.cmakeBuildTarget = cmakeTarget;
ati.packageFile = QFileInfo(packageFilePath.path());
ati.packageFilePath = packageFilePath;
// qCritical() << "CREATE CONFIG: BUILTIN:" << isBuiltinPackage << id << "TARGET:" << cmakeTarget;
@@ -126,20 +126,12 @@ TargetInformation::TargetInformation(const Target *target)
*this = targetInfoList.first();
device = DeviceKitAspect::device(target->kit());
remote = device && device->type() != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE;
runDirectory = remote ? QDir(Constants::REMOTE_DEFAULT_TMP_PATH) : buildDirectory;
runDirectory = Constants::REMOTE_DEFAULT_TMP_PATH;
}
bool TargetInformation::isValid() const
{
static const QFileInfo INVALID_FILE_INFO = QFileInfo();
return !manifest.fileName.isEmpty() && packageFile != INVALID_FILE_INFO;
}
FilePath TargetInformation::workingDirectory() const
{
return FilePath::fromString(runDirectory.absolutePath());
return !manifest.filePath.isEmpty() && packageFilePath.isFile();
}
} // namespace Internal

View File

@@ -16,14 +16,9 @@ namespace Internal {
class Manifest
{
public:
QString installPathSuffix;
QString fileName;
int formatVersion = 0;
QString formatType;
Utils::FilePath filePath;
QString id;
QString icon;
QString code;
QString runtime;
@@ -39,21 +34,15 @@ class TargetInformation final
{
public:
Manifest manifest;
QDir buildDirectory;
QDir packageSourcesDirectory;
QDir runDirectory;
QFileInfo packageFile;
QFileInfo projectFile;
QSharedPointer<const ProjectExplorer::IDevice> device;
Utils::FilePath runDirectory;
Utils::FilePath packageFilePath;
QString buildKey;
QString displayName;
QString displayNameUniquifier;
QString cmakeBuildTarget;
bool isBuiltin = false;
bool remote = false;
bool isValid() const;
Utils::FilePath workingDirectory() const;
TargetInformation() = default;
TargetInformation(const TargetInformation &other) = default;