mirror of https://github.com/buggins/dlangide.git
build using dub, continue
This commit is contained in:
parent
926ecb0cd8
commit
52040619c9
|
@ -1,11 +1,60 @@
|
||||||
module dlangide.builders.builder;
|
module dlangide.builders.builder;
|
||||||
|
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
|
import dlangide.ui.outputpanel;
|
||||||
|
import dlangide.builders.extprocess;
|
||||||
|
import dlangui.widgets.appframe;
|
||||||
|
import std.algorithm;
|
||||||
|
import std.string;
|
||||||
|
import std.conv;
|
||||||
|
|
||||||
class Builder {
|
class Builder : BackgroundOperationWatcher, ProcessOutputTarget {
|
||||||
protected Project _project;
|
protected Project _project;
|
||||||
|
protected ExternalProcess _extprocess;
|
||||||
|
protected OutputPanel _log;
|
||||||
|
|
||||||
@property Project project() { return _project; }
|
@property Project project() { return _project; }
|
||||||
@property void project(Project p) { _project = p; }
|
@property void project(Project p) { _project = p; }
|
||||||
|
|
||||||
|
this(AppFrame frame, Project project, OutputPanel log) {
|
||||||
|
super(frame);
|
||||||
|
_project = project;
|
||||||
|
_log = log;
|
||||||
|
_extprocess = new ExternalProcess();
|
||||||
|
}
|
||||||
|
/// log lines
|
||||||
|
override void onText(dstring text) {
|
||||||
|
dstring[] lines = text.split('\n');
|
||||||
|
_log.addLogLines(null, lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// returns icon of background operation to show in status line
|
||||||
|
override @property string icon() { return "folder"; }
|
||||||
|
/// update background operation status
|
||||||
|
override void update() {
|
||||||
|
if (_extprocess.state == ExternalProcessState.None) {
|
||||||
|
onText("Running dub\n"d);
|
||||||
|
_extprocess.run(cast(char[])"dub", cast(char[][])["build"], cast(char[])_project.dir, this, null);
|
||||||
|
if (_extprocess.state != ExternalProcessState.Running) {
|
||||||
|
onText("Failed to run builder tool");
|
||||||
|
_finished = true;
|
||||||
|
destroy(_extprocess);
|
||||||
|
_extprocess = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExternalProcessState state = _extprocess.poll();
|
||||||
|
if (state == ExternalProcessState.Stopped) {
|
||||||
|
onText("Builder finished with result "d ~ to!dstring(_extprocess.result) ~ "\n"d);
|
||||||
|
_finished = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_cancelRequested) {
|
||||||
|
_extprocess.kill();
|
||||||
|
_extprocess.wait();
|
||||||
|
_finished = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,8 +235,9 @@ class ExternalProcess {
|
||||||
ExternalProcessState kill() {
|
ExternalProcessState kill() {
|
||||||
if (_state == ExternalProcessState.Error || _state == ExternalProcessState.None || _state == ExternalProcessState.Stopped)
|
if (_state == ExternalProcessState.Error || _state == ExternalProcessState.None || _state == ExternalProcessState.Stopped)
|
||||||
return _state;
|
return _state;
|
||||||
if (_state == ExternalProcessState.Stopping) {
|
if (_state == ExternalProcessState.Running) {
|
||||||
std.process.kill(_pipes.pid);
|
std.process.kill(_pipes.pid);
|
||||||
|
_state = ExternalProcessState.Stopping;
|
||||||
}
|
}
|
||||||
return _state;
|
return _state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import dlangide.ui.dsourceedit;
|
||||||
import dlangide.ui.homescreen;
|
import dlangide.ui.homescreen;
|
||||||
import dlangide.workspace.workspace;
|
import dlangide.workspace.workspace;
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
|
import dlangide.builders.builder;
|
||||||
|
|
||||||
import std.conv;
|
import std.conv;
|
||||||
import std.utf;
|
import std.utf;
|
||||||
|
@ -146,6 +147,7 @@ class IDEFrame : AppFrame {
|
||||||
TabItem tab = _tabs.tab(index);
|
TabItem tab = _tabs.tab(index);
|
||||||
ProjectSourceFile file = cast(ProjectSourceFile)tab.objectParam;
|
ProjectSourceFile file = cast(ProjectSourceFile)tab.objectParam;
|
||||||
if (file) {
|
if (file) {
|
||||||
|
setCurrentProject(file.project);
|
||||||
// tab is source file editor
|
// tab is source file editor
|
||||||
_wsPanel.selectItem(file);
|
_wsPanel.selectItem(file);
|
||||||
focusEditor(file.filename);
|
focusEditor(file.filename);
|
||||||
|
@ -378,7 +380,8 @@ class IDEFrame : AppFrame {
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.BuildProject:
|
case IDEActions.BuildProject:
|
||||||
case IDEActions.BuildWorkspace:
|
case IDEActions.BuildWorkspace:
|
||||||
setBackgroundOperation(new BackgroundOperationWatcherTest(this));
|
buildProject();
|
||||||
|
//setBackgroundOperation(new BackgroundOperationWatcherTest(this));
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.WindowCloseAllDocuments:
|
case IDEActions.WindowCloseAllDocuments:
|
||||||
askForUnsavedEdits(delegate() {
|
askForUnsavedEdits(delegate() {
|
||||||
|
@ -470,6 +473,18 @@ class IDEFrame : AppFrame {
|
||||||
currentWorkspace = ws;
|
currentWorkspace = ws;
|
||||||
_wsPanel.workspace = ws;
|
_wsPanel.workspace = ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Project currentProject;
|
||||||
|
void setCurrentProject(Project project) {
|
||||||
|
currentProject = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
void buildProject() {
|
||||||
|
if (!currentProject)
|
||||||
|
return;
|
||||||
|
Builder op = new Builder(this, currentProject, _logPanel);
|
||||||
|
setBackgroundOperation(op);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget createAboutWidget()
|
Widget createAboutWidget()
|
||||||
|
|
|
@ -157,6 +157,11 @@ class WorkspaceItem {
|
||||||
return _filename;
|
return _filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// workspace item directory
|
||||||
|
@property string dir() {
|
||||||
|
return _dir;
|
||||||
|
}
|
||||||
|
|
||||||
/// file name of workspace item
|
/// file name of workspace item
|
||||||
@property void filename(string fname) {
|
@property void filename(string fname) {
|
||||||
if (fname.length > 0) {
|
if (fname.length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue