forked from qt-creator/qt-creator
CMake: Fix pipe name on windows
Fix the name of the pipe used to talk to cmake-server on windows. The name needs to follow a very specific pattern there. Change-Id: I2789be43b374d008e2bf784563ab362efd891e59 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -32,9 +32,11 @@
|
|||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QCryptographicHash>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
@@ -58,6 +60,10 @@ const char END_MAGIC[] = "\n]== \"CMake Server\" ==]\n";
|
|||||||
|
|
||||||
QString socketName(const Utils::FileName &buildDirectory)
|
QString socketName(const Utils::FileName &buildDirectory)
|
||||||
{
|
{
|
||||||
|
if (HostOsInfo::isWindowsHost()) {
|
||||||
|
QUuid uuid = QUuid::createUuid();
|
||||||
|
return "\\\\.\\pipe\\" + uuid.toString();
|
||||||
|
}
|
||||||
return buildDirectory.toString() + "/socket";
|
return buildDirectory.toString() + "/socket";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +96,8 @@ ServerMode::ServerMode(const Environment &env,
|
|||||||
|
|
||||||
m_cmakeProcess->setEnvironment(env);
|
m_cmakeProcess->setEnvironment(env);
|
||||||
m_cmakeProcess->setWorkingDirectory(buildDirectory.toString());
|
m_cmakeProcess->setWorkingDirectory(buildDirectory.toString());
|
||||||
const QStringList args = QStringList({ "-E", "server", "--pipe=" + socketName(buildDirectory) });
|
m_socketName = socketName(buildDirectory);
|
||||||
|
const QStringList args = QStringList({ "-E", "server", "--pipe=" + m_socketName });
|
||||||
|
|
||||||
connect(m_cmakeProcess.get(), &QtcProcess::started, this, [this]() { m_connectionTimer.start(); });
|
connect(m_cmakeProcess.get(), &QtcProcess::started, this, [this]() { m_connectionTimer.start(); });
|
||||||
connect(m_cmakeProcess.get(),
|
connect(m_cmakeProcess.get(),
|
||||||
@@ -159,8 +166,6 @@ void ServerMode::connectToServer()
|
|||||||
if (m_cmakeSocket)
|
if (m_cmakeSocket)
|
||||||
return; // We connected in the meantime...
|
return; // We connected in the meantime...
|
||||||
|
|
||||||
const QString socketString = socketName(m_buildDirectory);
|
|
||||||
|
|
||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
++counter;
|
++counter;
|
||||||
|
|
||||||
@@ -169,7 +174,7 @@ void ServerMode::connectToServer()
|
|||||||
m_cmakeProcess->disconnect();
|
m_cmakeProcess->disconnect();
|
||||||
reportError(tr("Running \"%1\" failed: Timeout waiting for pipe \"%2\".")
|
reportError(tr("Running \"%1\" failed: Timeout waiting for pipe \"%2\".")
|
||||||
.arg(m_cmakeExecutable.toUserOutput())
|
.arg(m_cmakeExecutable.toUserOutput())
|
||||||
.arg(socketString));
|
.arg(m_socketName));
|
||||||
|
|
||||||
Core::Reaper::reap(m_cmakeProcess.release());
|
Core::Reaper::reap(m_cmakeProcess.release());
|
||||||
emit disconnected();
|
emit disconnected();
|
||||||
@@ -194,7 +199,7 @@ void ServerMode::connectToServer()
|
|||||||
socket->deleteLater();
|
socket->deleteLater();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket->connectToServer(socketString);
|
socket->connectToServer(m_socketName);
|
||||||
m_connectionTimer.start();
|
m_connectionTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +223,8 @@ void ServerMode::handleCMakeFinished(int code, QProcess::ExitStatus status)
|
|||||||
m_cmakeSocket = nullptr;
|
m_cmakeSocket = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile::remove(socketName(m_buildDirectory));
|
if (!HostOsInfo::isWindowsHost())
|
||||||
|
QFile::remove(m_socketName);
|
||||||
|
|
||||||
emit disconnected();
|
emit disconnected();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ private:
|
|||||||
const QString m_extraGenerator;
|
const QString m_extraGenerator;
|
||||||
const QString m_platform;
|
const QString m_platform;
|
||||||
const QString m_toolset;
|
const QString m_toolset;
|
||||||
|
QString m_socketName;
|
||||||
const bool m_useExperimental;
|
const bool m_useExperimental;
|
||||||
bool m_gotHello = false;
|
bool m_gotHello = false;
|
||||||
bool m_isConnected = false;
|
bool m_isConnected = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user