diff --git a/src/dlangide.d b/src/dlangide.d index f9bd162..cf9338d 100644 --- a/src/dlangide.d +++ b/src/dlangide.d @@ -39,7 +39,7 @@ extern (C) int UIAppMain(string[] args) { // open home screen tab frame.showHomeScreen(); // for testing: load workspace at startup - //frame.loadWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews")); + frame.openFileOrWorkspace(appendPath(exePath, "../workspaces/sample1/sample1.dlangidews")); // show window window.show(); diff --git a/src/dlangide/builders/builder.d b/src/dlangide/builders/builder.d index 93ee318..979d023 100644 --- a/src/dlangide/builders/builder.d +++ b/src/dlangide/builders/builder.d @@ -1,10 +1,12 @@ module dlangide.builders.builder; +import dlangui.core.logger; import dlangide.workspace.project; import dlangide.ui.outputpanel; import dlangide.builders.extprocess; import dlangui.widgets.appframe; import std.algorithm; +import core.thread; import std.string; import std.conv; @@ -36,7 +38,8 @@ class Builder : BackgroundOperationWatcher { /// update background operation status override void update() { scope(exit)pollText(); - if (_extprocess.state == ExternalProcessState.None) { + ExternalProcessState state = _extprocess.state; + if (state == ExternalProcessState.None) { _box.writeText("Running dub\n"d); char[] program = "dub".dup; char[][] params; @@ -44,8 +47,8 @@ class Builder : BackgroundOperationWatcher { params ~= "build".dup; params ~= "-v".dup; params ~= "--force".dup; - _extprocess.run(program, params, dir, _box, null); - if (_extprocess.state != ExternalProcessState.Running) { + state = _extprocess.run(program, params, dir, _box, null); + if (state != ExternalProcessState.Running) { _box.writeText("Failed to run builder tool\n"d); _finished = true; destroy(_extprocess); @@ -53,7 +56,7 @@ class Builder : BackgroundOperationWatcher { return; } } - ExternalProcessState state = _extprocess.poll(); + state = _extprocess.poll(); if (state == ExternalProcessState.Stopped) { _box.writeText("Builder finished with result "d ~ to!dstring(_extprocess.result) ~ "\n"d); _finished = true; diff --git a/src/dlangide/builders/extprocess.d b/src/dlangide/builders/extprocess.d index bf3821d..4cccd2d 100644 --- a/src/dlangide/builders/extprocess.d +++ b/src/dlangide/builders/extprocess.d @@ -3,7 +3,7 @@ module dlangide.builders.extprocess; import dlangui.core.logger; import std.process; -import std.file; +import std.stdio; import std.utf; import std.stdio; import core.thread; @@ -249,12 +249,12 @@ class ExternalProcess { params ~= _program; params ~= _args; if (!_stderr) - redirect = Redirect.stdin | Redirect.stderrToStdout; + redirect = Redirect.stdout | Redirect.stdin | Redirect.stderrToStdout; else redirect = Redirect.all; Log.i("Trying to run program ", _program, " with args ", _args); try { - _pipes = pipeProcess(params, redirect, _env, Config.none, _workDir); + _pipes = pipeProcess(params, redirect, _env, Config.suppressConsole, _workDir); _state = ExternalProcessState.Running; // start readers _stdoutReader = new BackgroundReader(_pipes.stdout, _stdout); @@ -272,12 +272,25 @@ class ExternalProcess { } protected void waitForReadingCompletion() { - if (_stdoutReader && !_stdoutReader.finished) - _stdoutReader.join(false); - if (_stderrReader && !_stderrReader.finished) - _stderrReader.join(false); - _stdoutReader = null; - _stderrReader = null; + try { + _pipes.stdin.close(); + } catch (Exception e) { + Log.e("Cannot close stdin for ", _program, " ", e); + } + 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 diff --git a/src/dlangide/ui/outputpanel.d b/src/dlangide/ui/outputpanel.d index 5e99610..b6fb531 100644 --- a/src/dlangide/ui/outputpanel.d +++ b/src/dlangide/ui/outputpanel.d @@ -23,4 +23,8 @@ class OutputPanel : DockWindow { void addLogLines(string category, dstring[] msg...) { _logWidget.appendLines(msg); } + + void clear(string category = null) { + _logWidget.text = ""d; + } }