mirror of https://github.com/buggins/dlangide.git
merge
This commit is contained in:
commit
73604e115c
|
@ -39,7 +39,7 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
// open home screen tab
|
// open home screen tab
|
||||||
frame.showHomeScreen();
|
frame.showHomeScreen();
|
||||||
// for testing: load workspace at startup
|
// for testing: load workspace at startup
|
||||||
//frame.loadWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));
|
frame.openFileOrWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews"));
|
||||||
|
|
||||||
// show window
|
// show window
|
||||||
window.show();
|
window.show();
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
module dlangide.builders.builder;
|
module dlangide.builders.builder;
|
||||||
|
|
||||||
|
import dlangui.core.logger;
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
import dlangide.ui.outputpanel;
|
import dlangide.ui.outputpanel;
|
||||||
import dlangide.builders.extprocess;
|
import dlangide.builders.extprocess;
|
||||||
import dlangui.widgets.appframe;
|
import dlangui.widgets.appframe;
|
||||||
import std.algorithm;
|
import std.algorithm;
|
||||||
|
import core.thread;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
|
||||||
|
@ -36,7 +38,8 @@ class Builder : BackgroundOperationWatcher {
|
||||||
/// update background operation status
|
/// update background operation status
|
||||||
override void update() {
|
override void update() {
|
||||||
scope(exit)pollText();
|
scope(exit)pollText();
|
||||||
if (_extprocess.state == ExternalProcessState.None) {
|
ExternalProcessState state = _extprocess.state;
|
||||||
|
if (state == ExternalProcessState.None) {
|
||||||
_box.writeText("Running dub\n"d);
|
_box.writeText("Running dub\n"d);
|
||||||
char[] program = "dub".dup;
|
char[] program = "dub".dup;
|
||||||
char[][] params;
|
char[][] params;
|
||||||
|
@ -44,8 +47,8 @@ class Builder : BackgroundOperationWatcher {
|
||||||
params ~= "build".dup;
|
params ~= "build".dup;
|
||||||
params ~= "-v".dup;
|
params ~= "-v".dup;
|
||||||
params ~= "--force".dup;
|
params ~= "--force".dup;
|
||||||
_extprocess.run(program, params, dir, _box, null);
|
state = _extprocess.run(program, params, dir, _box, null);
|
||||||
if (_extprocess.state != ExternalProcessState.Running) {
|
if (state != ExternalProcessState.Running) {
|
||||||
_box.writeText("Failed to run builder tool\n"d);
|
_box.writeText("Failed to run builder tool\n"d);
|
||||||
_finished = true;
|
_finished = true;
|
||||||
destroy(_extprocess);
|
destroy(_extprocess);
|
||||||
|
@ -53,7 +56,7 @@ class Builder : BackgroundOperationWatcher {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExternalProcessState state = _extprocess.poll();
|
state = _extprocess.poll();
|
||||||
if (state == ExternalProcessState.Stopped) {
|
if (state == ExternalProcessState.Stopped) {
|
||||||
_box.writeText("Builder finished with result "d ~ to!dstring(_extprocess.result) ~ "\n"d);
|
_box.writeText("Builder finished with result "d ~ to!dstring(_extprocess.result) ~ "\n"d);
|
||||||
_finished = true;
|
_finished = true;
|
||||||
|
|
|
@ -3,7 +3,7 @@ module dlangide.builders.extprocess;
|
||||||
import dlangui.core.logger;
|
import dlangui.core.logger;
|
||||||
|
|
||||||
import std.process;
|
import std.process;
|
||||||
import std.file;
|
import std.stdio;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
import std.stdio;
|
import std.stdio;
|
||||||
import core.thread;
|
import core.thread;
|
||||||
|
@ -249,12 +249,12 @@ class ExternalProcess {
|
||||||
params ~= _program;
|
params ~= _program;
|
||||||
params ~= _args;
|
params ~= _args;
|
||||||
if (!_stderr)
|
if (!_stderr)
|
||||||
redirect = Redirect.stdin | Redirect.stderrToStdout;
|
redirect = Redirect.stdout | Redirect.stdin | Redirect.stderrToStdout;
|
||||||
else
|
else
|
||||||
redirect = Redirect.all;
|
redirect = Redirect.all;
|
||||||
Log.i("Trying to run program ", _program, " with args ", _args);
|
Log.i("Trying to run program ", _program, " with args ", _args);
|
||||||
try {
|
try {
|
||||||
_pipes = pipeProcess(params, redirect, _env, Config.none, _workDir);
|
_pipes = pipeProcess(params, redirect, _env, Config.suppressConsole, _workDir);
|
||||||
_state = ExternalProcessState.Running;
|
_state = ExternalProcessState.Running;
|
||||||
// start readers
|
// start readers
|
||||||
_stdoutReader = new BackgroundReader(_pipes.stdout, _stdout);
|
_stdoutReader = new BackgroundReader(_pipes.stdout, _stdout);
|
||||||
|
@ -272,12 +272,25 @@ class ExternalProcess {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void waitForReadingCompletion() {
|
protected void waitForReadingCompletion() {
|
||||||
if (_stdoutReader && !_stdoutReader.finished)
|
try {
|
||||||
_stdoutReader.join(false);
|
_pipes.stdin.close();
|
||||||
if (_stderrReader && !_stderrReader.finished)
|
} catch (Exception e) {
|
||||||
_stderrReader.join(false);
|
Log.e("Cannot close stdin for ", _program, " ", e);
|
||||||
_stdoutReader = null;
|
}
|
||||||
_stderrReader = null;
|
try {
|
||||||
|
if (_stdoutReader && !_stdoutReader.finished)
|
||||||
|
_stdoutReader.join(false);
|
||||||
|
_stdoutReader = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Exception while waiting for stdout reading completion for ", _program, " ", e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (_stderrReader && !_stderrReader.finished)
|
||||||
|
_stderrReader.join(false);
|
||||||
|
_stderrReader = null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Exception while waiting for stderr reading completion for ", _program, " ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// polls all available output from process streams
|
/// polls all available output from process streams
|
||||||
|
|
|
@ -23,4 +23,8 @@ class OutputPanel : DockWindow {
|
||||||
void addLogLines(string category, dstring[] msg...) {
|
void addLogLines(string category, dstring[] msg...) {
|
||||||
_logWidget.appendLines(msg);
|
_logWidget.appendLines(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear(string category = null) {
|
||||||
|
_logWidget.text = ""d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue