summaryrefslogtreecommitdiff
path: root/src/plugins/remotelinux/remotelinuxdeployconfiguration.cpp
blob: 94bfbfb981f558ebbda4d9fd04a5490e697bfe44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "remotelinuxdeployconfiguration.h"

#include "remotelinux_constants.h"
#include "remotelinuxtr.h"

#include <projectexplorer/devicesupport/filetransferinterface.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>

using namespace ProjectExplorer;

namespace RemoteLinux::Internal {

FileTransferMethod defaultTransferMethod(Kit *kit)
{
    auto runDevice = DeviceKitAspect::device(kit);
    auto buildDevice = BuildDeviceKitAspect::device(kit);

    if (runDevice != buildDevice) {
        // FIXME: That's not the full truth, we need support from the build
        // device, too.
        if (runDevice && runDevice->extraData(Constants::SupportsRSync).toBool())
            return FileTransferMethod::Rsync;
    }

    if (runDevice && runDevice->extraData(Constants::SupportsSftp).toBool())
        return FileTransferMethod::Sftp;

    return FileTransferMethod::GenericCopy;
}

RemoteLinuxDeployConfigurationFactory::RemoteLinuxDeployConfigurationFactory()
{
    setConfigBaseId(RemoteLinux::Constants::DeployToGenericLinux);
    addSupportedTargetDeviceType(RemoteLinux::Constants::GenericLinuxOsType);
    setDefaultDisplayName(Tr::tr("Deploy to Remote Linux Host"));
    setUseDeploymentDataView();

    const auto needsMakeInstall = [](Target *target)
    {
        const Project * const prj = target->project();
        return prj->deploymentKnowledge() == DeploymentKnowledge::Bad
                && prj->hasMakeInstallEquivalent();
    };
    setPostRestore([needsMakeInstall](DeployConfiguration *dc, const QVariantMap &map) {
        // 4.9 -> 4.10. See QTCREATORBUG-22689.
        if (map.value("_checkMakeInstall").toBool() && needsMakeInstall(dc->target())) {
            dc->stepList()->insertStep(0, Constants::MakeInstallStepId);
        }
    });

    addInitialStep(Constants::MakeInstallStepId, needsMakeInstall);
    addInitialStep(Constants::KillAppStepId);

    // Todo: Check: Instead of having three different steps here, have one
    // and shift the logic into the implementation there?
    addInitialStep(Constants::RsyncDeployStepId, [](Target *target) {
        return defaultTransferMethod(target->kit()) == FileTransferMethod::Rsync;
    });
    addInitialStep(Constants::DirectUploadStepId, [](Target *target) {
        return defaultTransferMethod(target->kit()) == FileTransferMethod::Sftp;
    });
    addInitialStep(ProjectExplorer::Constants::COPY_FILE_STEP, [](Target *target) {
        return defaultTransferMethod(target->kit()) == FileTransferMethod::GenericCopy;
    });
}

} // RemoteLinux::Internal