Skip to content

Commit

Permalink
fix submodule url && emake server shutdown (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
fundies authored Sep 19, 2021
1 parent 0aaf068 commit 8ba94b6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "Submodules/enigma-dev"]
path = Submodules/enigma-dev
url = https://github.com/enigma-dev/enigma-dev.git
branch = gmxProtoButt
url = ../enigma-dev.git
branch = master
35 changes: 23 additions & 12 deletions Plugins/ServerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ void CompilerClient::SyntaxCheck() {
callData->start();
}

void CompilerClient::TearDown() {
auto* callData = ScheduleTask<AsyncResponseReadWorker<Empty>>();

auto worker = dynamic_cast<AsyncResponseReadWorker<Empty>*>(callData);
worker->stream = stub->PrepareAsyncTeardown(&worker->context, ::buffers::Empty(), &cq);
callData->start();
}

template <typename T>
T* CompilerClient::ScheduleTask() {
auto callData = new T();
Expand All @@ -243,7 +251,7 @@ void CompilerClient::UpdateLoop(void* got_tag, bool ok) {
ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
// create a new child process for us to launch an emake server
process = new QProcess(this);

connect(process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) {
qDebug() << "QProcess error: " << error << endl;
});
Expand All @@ -253,7 +261,7 @@ ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
connect(process, &QProcess::readyReadStandardError, [&]() {
emit LogOutput(process->readAllStandardError());
});

#ifdef _WIN32
//TODO: Make all this stuff configurable in IDE
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
Expand All @@ -271,11 +279,11 @@ ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {

// look for an executable file that looks like emake in some common directories
#ifndef RGM_DEBUG
QString emakeName = "emake";
QString emakeName = "emake";
#else
QString emakeName = "emake-debug";
QString emakeName = "emake-debug";
#endif

QFileInfo emakeFileInfo;
foreach (auto path, MainWindow::EnigmaSearchPaths) {
const QDir dir(path);
Expand All @@ -286,12 +294,12 @@ ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
break;
}
}

if (emakeFileInfo.filePath().isEmpty()) {
qDebug() << "Error: Failed to locate emake. Compiling and syntax check will not work.\n" << "Search Paths:\n" << MainWindow::EnigmaSearchPaths;
return;
}

if (MainWindow::EnigmaRoot.filePath().isEmpty()) {
qDebug() << "Error: Failed to locate ENIGMA sources. Compiling and syntax check will not work.\n" << "Search Paths:\n" << MainWindow::EnigmaSearchPaths;
return;
Expand All @@ -308,9 +316,9 @@ ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
<< "Paths"
<< "-r"
<< "--quiet"
<< "--enigma-root"
<< "--enigma-root"
<< MainWindow::EnigmaRoot.absolutePath();

qDebug() << "Running: " << program << " " << arguments;

process->start(program, arguments);
Expand All @@ -330,11 +338,14 @@ ServerPlugin::ServerPlugin(MainWindow& mainWindow) : RGMPlugin(mainWindow) {
compilerClient->GetSystems();
}

ServerPlugin::~ServerPlugin() { process->close(); }
ServerPlugin::~ServerPlugin() {
compilerClient->TearDown();
process->waitForFinished();
}

void ServerPlugin::Run() { compilerClient->CompileBuffer(mainWindow.Game(), CompileRequest::RUN); };
void ServerPlugin::Run() { compilerClient->CompileBuffer(mainWindow.Game(), CompileRequest::RUN); }

void ServerPlugin::Debug() { compilerClient->CompileBuffer(mainWindow.Game(), CompileRequest::DEBUG); };
void ServerPlugin::Debug() { compilerClient->CompileBuffer(mainWindow.Game(), CompileRequest::DEBUG); }

void ServerPlugin::CreateExecutable() {
const QString& fileName =
Expand Down
1 change: 1 addition & 0 deletions Plugins/ServerPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class CompilerClient : public QObject {
void SetDefinitions(std::string code, std::string yaml);
void SetCurrentConfig(const resources::Settings& settings);
void SyntaxCheck();
void TearDown();

signals:
void CompileStatusChanged(bool finished = false);
Expand Down
2 changes: 1 addition & 1 deletion Submodules/enigma-dev

0 comments on commit 8ba94b6

Please sign in to comment.