blob: 045cc6943b78630e0431f2868a1bb75646a98bcb (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "dockersettings.h"
#include <coreplugin/documentmanager.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <QMutex>
namespace Docker::Internal {
class DockerDeviceData
{
public:
bool operator==(const DockerDeviceData &other) const
{
return imageId == other.imageId && repo == other.repo && tag == other.tag
&& useLocalUidGid == other.useLocalUidGid && mounts == other.mounts
&& keepEntryPoint == other.keepEntryPoint && enableLldbFlags == other.enableLldbFlags
&& clangdExecutable == other.clangdExecutable;
}
bool operator!=(const DockerDeviceData &other) const { return !(*this == other); }
// Used for "docker run"
QString repoAndTag() const
{
if (repo == "<none>")
return imageId;
if (tag == "<none>")
return repo;
return repo + ':' + tag;
}
QString repoAndTagEncoded() const { return repoAndTag().replace(':', '.'); }
QString imageId;
QString repo;
QString tag;
QString size;
bool useLocalUidGid = true;
QStringList mounts = {Core::DocumentManager::projectsDirectory().toString()};
bool keepEntryPoint = false;
bool enableLldbFlags = false;
Utils::FilePath clangdExecutable;
};
class DockerDevice : public ProjectExplorer::IDevice
{
public:
using Ptr = QSharedPointer<DockerDevice>;
using ConstPtr = QSharedPointer<const DockerDevice>;
explicit DockerDevice(const DockerDeviceData &data);
~DockerDevice();
void shutdown();
static Ptr create(const DockerDeviceData &data)
{
return Ptr(new DockerDevice(data));
}
ProjectExplorer::IDeviceWidget *createWidget() override;
QList<ProjectExplorer::Task> validate() const override;
Utils::ProcessInterface *createProcessInterface() const override;
bool canCreateProcessModel() const override { return true; }
bool hasDeviceTester() const override { return false; }
ProjectExplorer::DeviceTester *createDeviceTester() const override;
bool usableAsBuildDevice() const override;
Utils::FilePath rootPath() const override;
Utils::FilePath filePath(const QString &pathOnDevice) const override;
bool handlesFile(const Utils::FilePath &filePath) const override;
bool ensureReachable(const Utils::FilePath &other) const override;
Utils::expected_str<Utils::FilePath> localSource(const Utils::FilePath &other) const override;
Utils::Environment systemEnvironment() const override;
const DockerDeviceData data() const;
DockerDeviceData data();
void setData(const DockerDeviceData &data);
bool updateContainerAccess() const;
void setMounts(const QStringList &mounts) const;
bool prepareForBuild(const ProjectExplorer::Target *target) override;
std::optional<Utils::FilePath> clangdExecutable() const override;
protected:
void fromMap(const Utils::Storage &map) final;
Utils::Storage toMap() const final;
private:
void aboutToBeRemoved() const final;
class DockerDevicePrivate *d = nullptr;
friend class DockerDeviceSetupWizard;
friend class DockerDeviceWidget;
};
class DockerDeviceFactory final : public ProjectExplorer::IDeviceFactory
{
public:
DockerDeviceFactory();
void shutdownExistingDevices();
private:
QMutex m_deviceListMutex;
std::vector<QWeakPointer<DockerDevice>> m_existingDevices;
};
} // namespace Docker::Internal
Q_DECLARE_METATYPE(Docker::Internal::DockerDeviceData)
|