mirror of https://github.com/buggins/dlangide.git
rewrite rdmd execution
This commit is contained in:
parent
f8fe92aa77
commit
3f3b3d2fc0
|
@ -16,7 +16,6 @@ alias BuildResultListener = void delegate(int);
|
|||
|
||||
class Builder : BackgroundOperationWatcher {
|
||||
protected Project _project;
|
||||
protected string _filename; // for rdmd
|
||||
protected ExternalProcess _extprocess;
|
||||
protected OutputPanel _log;
|
||||
protected ProtectedTextStorage _box;
|
||||
|
@ -55,23 +54,6 @@ class Builder : BackgroundOperationWatcher {
|
|||
_box = new ProtectedTextStorage();
|
||||
}
|
||||
|
||||
this(AppFrame frame, string filename, OutputPanel log, BuildConfiguration buildConfig,
|
||||
BuildOperation buildOp,
|
||||
string rdmdExecutable,
|
||||
string rdmdAdditionalParams,
|
||||
BuildResultListener listener = null) {
|
||||
super(frame);
|
||||
_listener = listener;
|
||||
_buildOp = buildOp;
|
||||
_filename = filename;
|
||||
_buildConfig = buildConfig;
|
||||
_executable = rdmdExecutable.empty ? "rdmd" : rdmdExecutable;
|
||||
_additionalParams = rdmdAdditionalParams;
|
||||
_log = log;
|
||||
_extprocess = new ExternalProcess();
|
||||
_box = new ProtectedTextStorage();
|
||||
}
|
||||
|
||||
/// log lines
|
||||
void pollText() {
|
||||
dstring text = _box.readText();
|
||||
|
@ -90,31 +72,10 @@ class Builder : BackgroundOperationWatcher {
|
|||
_log.clear();
|
||||
char[] program = _executable.dup;
|
||||
char[][] params;
|
||||
char[] dir;
|
||||
char[] dir = _project.dir.dup;
|
||||
|
||||
if(_buildOp == BuildOperation.RunWithRdmd) {
|
||||
dir = std.path.dirName(_filename).dup;
|
||||
|
||||
if (!_additionalParams.empty)
|
||||
params ~= _additionalParams.dup;
|
||||
|
||||
switch (_buildConfig) {
|
||||
default:
|
||||
case BuildConfiguration.Debug:
|
||||
params ~= "-debug".dup;
|
||||
break;
|
||||
case BuildConfiguration.Release:
|
||||
params ~= "-release".dup;
|
||||
break;
|
||||
case BuildConfiguration.Unittest:
|
||||
params ~= "-unittest".dup;
|
||||
break;
|
||||
}
|
||||
params ~= std.path.baseName(_filename).dup;
|
||||
|
||||
} else {
|
||||
{
|
||||
// dub
|
||||
dir = _project.dir.dup;
|
||||
if (_buildOp == BuildOperation.Build || _buildOp == BuildOperation.Rebuild) {
|
||||
params ~= "build".dup;
|
||||
if (_buildOp == BuildOperation.Rebuild) {
|
||||
|
|
|
@ -245,7 +245,7 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
|||
window.showMessageBox(UIString("Cannot run project"d), UIString("Cannot find executable file"d));
|
||||
return;
|
||||
}
|
||||
ProgramExecutionNoDebug program = new ProgramExecutionNoDebug();
|
||||
auto program = new ProgramExecutionNoDebug;
|
||||
setExecutableParameters(program, project, executableFileName);
|
||||
program.setProgramExecutionStatusListener(this);
|
||||
_execution = program;
|
||||
|
@ -273,6 +273,48 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
|||
return true;
|
||||
}
|
||||
|
||||
void runWithRdmd(string filename) {
|
||||
stopExecution();
|
||||
|
||||
string rdmdExecutable = _settings.rdmdExecutable;
|
||||
|
||||
auto program = new ProgramExecutionNoDebug;
|
||||
string sourceFileName = baseName(filename);
|
||||
string workingDirectory = dirName(filename);
|
||||
string[] args;
|
||||
{
|
||||
string rdmdAdditionalParams = _settings.rdmdAdditionalParams;
|
||||
if (!rdmdAdditionalParams.empty)
|
||||
args ~= rdmdAdditionalParams.split();
|
||||
|
||||
auto buildConfig = currentWorkspace ? currentWorkspace.buildConfiguration : BuildConfiguration.Debug;
|
||||
switch (buildConfig) {
|
||||
default:
|
||||
case BuildConfiguration.Debug:
|
||||
args ~= "-debug";
|
||||
break;
|
||||
case BuildConfiguration.Release:
|
||||
args ~= "-release";
|
||||
break;
|
||||
case BuildConfiguration.Unittest:
|
||||
args ~= "-unittest";
|
||||
break;
|
||||
}
|
||||
args ~= sourceFileName;
|
||||
}
|
||||
version(Windows) {
|
||||
} else {
|
||||
string externalConsoleExecutable = _settings.terminalExecutable;
|
||||
}
|
||||
_logPanel.logLine("Starting " ~ sourceFileName ~ " with rdmd");
|
||||
_statusLine.setBackgroundOperationStatus("run-rdmd", "running..."d);
|
||||
program.setExecutableParams(rdmdExecutable, args, workingDirectory, null);
|
||||
program.setTerminalExecutable(externalConsoleExecutable);
|
||||
program.setProgramExecutionStatusListener(this);
|
||||
_execution = program;
|
||||
program.run();
|
||||
}
|
||||
|
||||
override protected void initialize() {
|
||||
_appName = "dlangide";
|
||||
//_editorTool = new DEditorTool(this);
|
||||
|
@ -1343,16 +1385,6 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
|||
setBackgroundOperation(op);
|
||||
}
|
||||
|
||||
void runWithRdmd(string filename, BuildResultListener listener = null) {
|
||||
string rdmdExecutable = _settings.rdmdExecutable;
|
||||
string rdmdAdditionalParams = _settings.rdmdAdditionalParams;
|
||||
Builder op = new Builder(this, filename, _logPanel, currentWorkspace ? currentWorkspace.buildConfiguration : BuildConfiguration.Debug,
|
||||
BuildOperation.RunWithRdmd,
|
||||
rdmdExecutable, rdmdAdditionalParams,
|
||||
listener);
|
||||
setBackgroundOperation(op);
|
||||
}
|
||||
|
||||
/// updates list of available configurations
|
||||
void setProjectConfigurations(dstring[] items) {
|
||||
projectConfigurationCombo.items = items;
|
||||
|
|
|
@ -19,8 +19,7 @@ enum BuildOperation {
|
|||
Clean,
|
||||
Rebuild,
|
||||
Run,
|
||||
Upgrade,
|
||||
RunWithRdmd
|
||||
Upgrade
|
||||
}
|
||||
|
||||
enum BuildConfiguration {
|
||||
|
|
Loading…
Reference in New Issue