forked from qt-creator/qt-creator
Docker: Add clangd path to sdktool
This patch also allows the user/installer to supply a path without the device root, to make it easier for the installer. Fixes: QTCREATORBUG-29694 Change-Id: I641b06dd2f4a9d94079fb26f2ed949c5246c1c1e Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -232,13 +232,28 @@ DockerDeviceSettings::DockerDeviceSettings()
|
||||
&StringSelectionAspect::refill);
|
||||
|
||||
clangdExecutable.setValidationFunction(
|
||||
[](const QString &newValue) -> FancyLineEdit::AsyncValidationFuture {
|
||||
return asyncRun([newValue]() -> expected_str<QString> {
|
||||
[this](const QString &newValue) -> FancyLineEdit::AsyncValidationFuture {
|
||||
const FilePath rootPath = FilePath::fromParts(Constants::DOCKER_DEVICE_SCHEME,
|
||||
repoAndTagEncoded(),
|
||||
u"/");
|
||||
return asyncRun([rootPath, newValue]() -> expected_str<QString> {
|
||||
QString changedValue = newValue;
|
||||
FilePath path = FilePath::fromUserInput(newValue);
|
||||
if (!path.needsDevice()) {
|
||||
const FilePath onDevicePath = rootPath.withNewMappedPath(path);
|
||||
if (onDevicePath.exists()) {
|
||||
changedValue = onDevicePath.toUserOutput();
|
||||
path = onDevicePath;
|
||||
} else {
|
||||
return make_unexpected(
|
||||
Tr::tr("Path \"%1\" does not exist.").arg(onDevicePath.toUserOutput()));
|
||||
}
|
||||
}
|
||||
QString error;
|
||||
bool result = checkClangdVersion(FilePath::fromUserInput(newValue), &error);
|
||||
bool result = checkClangdVersion(path, &error);
|
||||
if (!result)
|
||||
return make_unexpected(error);
|
||||
return newValue;
|
||||
return changedValue;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -320,6 +335,8 @@ public:
|
||||
{
|
||||
if (deviceSettings->clangdExecutable().isEmpty())
|
||||
return std::nullopt;
|
||||
if (!deviceSettings->clangdExecutable().needsDevice())
|
||||
return deviceSettings->rootPath().withNewMappedPath(deviceSettings->clangdExecutable());
|
||||
return deviceSettings->clangdExecutable();
|
||||
}
|
||||
|
||||
|
@@ -58,6 +58,7 @@ QString AddDeviceOperation::argumentsHelpText() const
|
||||
" --dockerRepo <STRING> Docker image repo.\n"
|
||||
" --dockerTag <STRING> Docker image tag.\n"
|
||||
" --dockerMappedPaths <STRING> Docker mapped paths (semi-colon separated).\n"
|
||||
" --dockerClangdExecutable <STRING> Path to clangd inside the docker "
|
||||
" <KEY> <TYPE:VALUE> extra key value pairs\n");
|
||||
}
|
||||
|
||||
@@ -219,6 +220,14 @@ bool AddDeviceOperation::setArguments(const QStringList &args)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current == QLatin1String("--dockerClangdExecutable")) {
|
||||
if (next.isNull())
|
||||
return false;
|
||||
++i; // skip next;
|
||||
m_clangdExecutable = next;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (current == QLatin1String("--dockerRepo")) {
|
||||
if (next.isNull())
|
||||
return false;
|
||||
@@ -292,14 +301,14 @@ void AddDeviceOperation::unittest()
|
||||
devData.m_dockerMappedPaths = QStringList{"/opt", "/data"};
|
||||
devData.m_dockerRepo = "repo";
|
||||
devData.m_dockerTag = "tag";
|
||||
|
||||
devData.m_clangdExecutable = "clangdexe";
|
||||
|
||||
QVariantMap result = devData.addDevice(map);
|
||||
QVariantMap data = result.value(QLatin1String(DEVICEMANAGER_ID)).toMap();
|
||||
QVariantList devList = data.value(QLatin1String(DEVICE_LIST_ID)).toList();
|
||||
QCOMPARE(devList.count(), 1);
|
||||
QVariantMap dev = devList.at(0).toMap();
|
||||
QCOMPARE(dev.count(), 20);
|
||||
QCOMPARE(dev.count(), 21);
|
||||
QCOMPARE(dev.value(QLatin1String("Authentication")).toInt(), 2);
|
||||
QCOMPARE(dev.value(QLatin1String("DebugServerKey")).toString(), QLatin1String("debugServer"));
|
||||
QCOMPARE(dev.value(QLatin1String("FreePortsSpec")).toString(), QLatin1String("ports"));
|
||||
@@ -317,6 +326,7 @@ void AddDeviceOperation::unittest()
|
||||
QCOMPARE(dev.value(QLatin1String("Version")).toInt(), 6);
|
||||
QCOMPARE(dev.value(QLatin1String("DockerDeviceDataRepo")).toString(), "repo");
|
||||
QCOMPARE(dev.value(QLatin1String("DockerDeviceDataTag")).toString(), "tag");
|
||||
QCOMPARE(dev.value(QLatin1String("DockerDeviceClangDExecutable")).toString(), "clangdexe");
|
||||
|
||||
const QStringList paths = dev.value(QLatin1String("DockerDeviceMappedPaths")).toStringList();
|
||||
QCOMPARE(paths, QStringList({"/opt", "/data"}));
|
||||
@@ -353,6 +363,7 @@ QVariantMap AddDeviceData::addDevice(const QVariantMap &map) const
|
||||
dev.append(KeyValuePair(QLatin1String("Uname"), QVariant(m_uname)));
|
||||
dev.append(KeyValuePair(QLatin1String("Version"), QVariant(m_version)));
|
||||
dev.append(KeyValuePair(QLatin1String("DockerDeviceMappedPaths"), QVariant(m_dockerMappedPaths)));
|
||||
dev.append(KeyValuePair(QLatin1String("DockerDeviceClangDExecutable"), QVariant(m_clangdExecutable)));
|
||||
dev.append(KeyValuePair(QLatin1String("DockerDeviceDataRepo"), QVariant(m_dockerRepo)));
|
||||
dev.append(KeyValuePair(QLatin1String("DockerDeviceDataTag"), QVariant(m_dockerTag)));
|
||||
dev.append(m_extra);
|
||||
|
@@ -43,6 +43,7 @@ public:
|
||||
QStringList m_dockerMappedPaths;
|
||||
QString m_dockerRepo;
|
||||
QString m_dockerTag;
|
||||
QString m_clangdExecutable;
|
||||
KeyValuePairList m_extra;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user