mirror of https://github.com/buggins/dlangide.git
Run Project improvements
This commit is contained in:
parent
02d7d13379
commit
f2db9a74fc
|
|
@ -11,6 +11,8 @@ import core.thread;
|
||||||
import std.string;
|
import std.string;
|
||||||
import std.conv;
|
import std.conv;
|
||||||
|
|
||||||
|
alias BuildResultListener = void delegate(int);
|
||||||
|
|
||||||
class Builder : BackgroundOperationWatcher {
|
class Builder : BackgroundOperationWatcher {
|
||||||
protected Project _project;
|
protected Project _project;
|
||||||
protected ExternalProcess _extprocess;
|
protected ExternalProcess _extprocess;
|
||||||
|
|
@ -20,12 +22,15 @@ class Builder : BackgroundOperationWatcher {
|
||||||
protected BuildConfiguration _buildConfig;
|
protected BuildConfiguration _buildConfig;
|
||||||
protected BuildOperation _buildOp;
|
protected BuildOperation _buildOp;
|
||||||
protected bool _verbose;
|
protected bool _verbose;
|
||||||
|
protected BuildResultListener _listener;
|
||||||
|
protected int _exitCode = int.min;
|
||||||
|
|
||||||
@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, ProjectConfiguration projectConfig, BuildConfiguration buildConfig, BuildOperation buildOp, bool verbose) {
|
this(AppFrame frame, Project project, OutputPanel log, ProjectConfiguration projectConfig, BuildConfiguration buildConfig, BuildOperation buildOp, bool verbose, BuildResultListener listener = null) {
|
||||||
super(frame);
|
super(frame);
|
||||||
|
_listener = listener;
|
||||||
_projectConfig = projectConfig;
|
_projectConfig = projectConfig;
|
||||||
_buildConfig = buildConfig;
|
_buildConfig = buildConfig;
|
||||||
_buildOp = buildOp;
|
_buildOp = buildOp;
|
||||||
|
|
@ -35,6 +40,7 @@ class Builder : BackgroundOperationWatcher {
|
||||||
_extprocess = new ExternalProcess();
|
_extprocess = new ExternalProcess();
|
||||||
_box = new ProtectedTextStorage();
|
_box = new ProtectedTextStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// log lines
|
/// log lines
|
||||||
void pollText() {
|
void pollText() {
|
||||||
dstring text = _box.readText();
|
dstring text = _box.readText();
|
||||||
|
|
@ -107,6 +113,7 @@ class Builder : BackgroundOperationWatcher {
|
||||||
}
|
}
|
||||||
state = _extprocess.poll();
|
state = _extprocess.poll();
|
||||||
if (state == ExternalProcessState.Stopped) {
|
if (state == ExternalProcessState.Stopped) {
|
||||||
|
_exitCode = _extprocess.result;
|
||||||
_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;
|
||||||
return;
|
return;
|
||||||
|
|
@ -119,4 +126,9 @@ class Builder : BackgroundOperationWatcher {
|
||||||
}
|
}
|
||||||
super.update();
|
super.update();
|
||||||
}
|
}
|
||||||
|
override void removing() {
|
||||||
|
super.removing();
|
||||||
|
if (_exitCode != int.min && _listener)
|
||||||
|
_listener(_exitCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,22 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
||||||
_logPanel.logLine("Program " ~ process.executableFile ~ " is finished");
|
_logPanel.logLine("Program " ~ process.executableFile ~ " is finished");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
_statusLine.setBackgroundOperationStatus(null, null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buildAndRunProject() {
|
||||||
|
if (!currentWorkspace)
|
||||||
|
return;
|
||||||
|
Project project = currentWorkspace.startupProject;
|
||||||
|
if (!project) {
|
||||||
|
window.showMessageBox(UIString("Cannot run project"d), UIString("Startup project is not specified"d));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buildProject(BuildOperation.Build, delegate(int result) {
|
||||||
|
if (!result) {
|
||||||
|
runProject();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,13 +154,19 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
string[] args;
|
string[] args;
|
||||||
string externalConsoleExecutable = null; // TODO
|
string externalConsoleExecutable = null;
|
||||||
string workingDirectory = null; // TODO
|
string workingDirectory = project.workingDirectory;
|
||||||
|
if (project.runInExternalConsole) {
|
||||||
|
version(Windows) {
|
||||||
|
} else {
|
||||||
|
externalConsoleExecutable = "xterm";
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: provide thread safe listener
|
// TODO: provide thread safe listener
|
||||||
_logPanel.logLine("Starting " ~ executableFileName);
|
_logPanel.logLine("Starting " ~ executableFileName);
|
||||||
|
_statusLine.setBackgroundOperationStatus("debug-run", "running..."d);
|
||||||
_execution = new ProgramExecutionNoDebug(executableFileName, args, workingDirectory, externalConsoleExecutable, this);
|
_execution = new ProgramExecutionNoDebug(executableFileName, args, workingDirectory, externalConsoleExecutable, this);
|
||||||
_execution.run();
|
_execution.run();
|
||||||
// TODO: update status
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected void init() {
|
override protected void init() {
|
||||||
|
|
@ -649,8 +671,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
||||||
case IDEActions.DebugStart:
|
case IDEActions.DebugStart:
|
||||||
case IDEActions.DebugStartNoDebug:
|
case IDEActions.DebugStartNoDebug:
|
||||||
case IDEActions.DebugContinue:
|
case IDEActions.DebugContinue:
|
||||||
runProject();
|
buildAndRunProject();
|
||||||
//buildProject(BuildOperation.Run);
|
|
||||||
return true;
|
return true;
|
||||||
case IDEActions.UpdateProjectDependencies:
|
case IDEActions.UpdateProjectDependencies:
|
||||||
buildProject(BuildOperation.Upgrade);
|
buildProject(BuildOperation.Upgrade);
|
||||||
|
|
@ -1010,12 +1031,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void buildProject(BuildOperation buildOp) {
|
void buildProject(BuildOperation buildOp, BuildResultListener listener = null) {
|
||||||
if (!currentWorkspace || !currentWorkspace.startupProject) {
|
if (!currentWorkspace || !currentWorkspace.startupProject) {
|
||||||
_logPanel.logLine("No project is opened");
|
_logPanel.logLine("No project is opened");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Builder op = new Builder(this, currentWorkspace.startupProject, _logPanel, currentWorkspace.projectConfiguration, currentWorkspace.buildConfiguration, buildOp, false);
|
Builder op = new Builder(this, currentWorkspace.startupProject, _logPanel, currentWorkspace.projectConfiguration, currentWorkspace.buildConfiguration, buildOp, false, listener);
|
||||||
setBackgroundOperation(op);
|
setBackgroundOperation(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -457,6 +457,23 @@ class Project : WorkspaceItem {
|
||||||
return exePath;
|
return exePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// working directory for running and debugging project
|
||||||
|
@property string workingDirectory() {
|
||||||
|
// TODO: get from settings
|
||||||
|
return _filename.dirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// commandline parameters for running and debugging project
|
||||||
|
@property string runArgs() {
|
||||||
|
// TODO: get from settings
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@property bool runInExternalConsole() {
|
||||||
|
// TODO
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ProjectFolder findItems(string[] srcPaths) {
|
ProjectFolder findItems(string[] srcPaths) {
|
||||||
ProjectFolder folder = new ProjectFolder(_filename);
|
ProjectFolder folder = new ProjectFolder(_filename);
|
||||||
folder.project = this;
|
folder.project = this;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue