DUB additional params; LDMD toolchain setting - close #80

This commit is contained in:
Vadim Lopatin 2016-01-15 10:49:22 +03:00
parent 8da7d8d36a
commit f74e757e00
5 changed files with 75 additions and 11 deletions

View File

@ -22,7 +22,8 @@ class Builder : BackgroundOperationWatcher {
protected ProjectConfiguration _projectConfig;
protected BuildConfiguration _buildConfig;
protected BuildOperation _buildOp;
protected bool _verbose;
protected string _dubExecutable;
protected string _dubAdditionalParams;
protected BuildResultListener _listener;
protected int _exitCode = int.min;
protected string _toolchain;
@ -32,7 +33,9 @@ class Builder : BackgroundOperationWatcher {
@property void project(Project p) { _project = p; }
this(AppFrame frame, Project project, OutputPanel log, ProjectConfiguration projectConfig, BuildConfiguration buildConfig,
BuildOperation buildOp, bool verbose,
BuildOperation buildOp,
string dubExecutable,
string dubAdditionalParams,
string toolchain = null,
string arch = null,
BuildResultListener listener = null) {
@ -41,7 +44,8 @@ class Builder : BackgroundOperationWatcher {
_projectConfig = projectConfig;
_buildConfig = buildConfig;
_buildOp = buildOp;
_verbose = verbose;
_dubExecutable = dubExecutable.empty ? "dub" : dubExecutable;
_dubAdditionalParams = dubAdditionalParams;
_project = project;
_log = log;
_toolchain = toolchain;
@ -66,7 +70,7 @@ class Builder : BackgroundOperationWatcher {
ExternalProcessState state = _extprocess.state;
if (state == ExternalProcessState.None) {
_log.clear();
char[] program = "dub".dup;
char[] program = _dubExecutable.dup;
char[][] params;
char[] dir = _project.dir.dup;
@ -114,15 +118,14 @@ class Builder : BackgroundOperationWatcher {
params ~= "--build=unittest".dup;
break;
}
if (!_dubAdditionalParams.empty)
params ~= _dubAdditionalParams.dup;
}
if(_projectConfig.name != ProjectConfiguration.DEFAULT_NAME) {
params ~= "--config=".dup ~ _projectConfig.name;
}
if (_verbose)
params ~= "-v".dup;
auto text = "Running (in " ~ dir ~ "): " ~ program ~ " " ~ params.join(' ') ~ "\n";
_box.writeText(to!dstring(text));
state = _extprocess.run(program, params, dir, _box, null);

View File

@ -1277,9 +1277,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
ProjectSettings projectSettings = project.settings;
string toolchain = projectSettings.getToolchain(_settings);
string arch = projectSettings.getArch(_settings);
bool verbose = projectSettings.buildVerbose;
string dubExecutable = _settings.dubExecutable;
string dubAdditionalParams = projectSettings.getDubAdditionalParams(_settings);
Builder op = new Builder(this, project, _logPanel, currentWorkspace.projectConfiguration, currentWorkspace.buildConfiguration, buildOp,
verbose,
dubExecutable, dubAdditionalParams,
toolchain,
arch,
listener);

View File

@ -33,10 +33,16 @@ SettingsPage createSettingsPages() {
SettingsPage toolchains = dlang.addChild("dlang/toolchains", UIString("Toolchains"d));
SettingsPage dmdtoolchain = toolchains.addChild("dlang/toolchains/dmd", UIString("DMD"d));
dmdtoolchain.addExecutableFileNameEdit("dlang/toolchains/dmd/executable", UIString("DMD executable"d), "dmd");
dmdtoolchain.addStringEdit("dlang/toolchains/dmd/dub_additional_params", UIString("DUB additional params"d), "");
SettingsPage ldctoolchain = toolchains.addChild("dlang/toolchains/ldc", UIString("LDC"d));
ldctoolchain.addExecutableFileNameEdit("dlang/toolchains/ldc/executable", UIString("LDC2 executable"d), "ldc2");
ldctoolchain.addStringEdit("dlang/toolchains/ldc/dub_additional_params", UIString("DUB additional params"d), "");
SettingsPage ldmdtoolchain = toolchains.addChild("dlang/toolchains/ldmd", UIString("LDMD"d));
ldmdtoolchain.addExecutableFileNameEdit("dlang/toolchains/ldmd/executable", UIString("LDMD2 executable"d), "ldmd2");
ldmdtoolchain.addStringEdit("dlang/toolchains/ldmd/dub_additional_params", UIString("DUB additional params"d), "");
SettingsPage gdctoolchain = toolchains.addChild("dlang/toolchains/gdc", UIString("GDC"d));
gdctoolchain.addExecutableFileNameEdit("dlang/toolchains/gdc/executable", UIString("GDC executable"d), "gdc");
gdctoolchain.addStringEdit("dlang/toolchains/gdc/dub_additional_params", UIString("DUB additional params"d), "");
SettingsPage ui = res.addChild("interface", UIString("Interface"d));
ui.addStringComboBox("interface/theme", UIString("Theme"d), [
@ -90,12 +96,14 @@ SettingsPage createProjectSettingsPages() {
StringListValue("default", "Default"d),
StringListValue("dmd", "DMD"d),
StringListValue("ldc", "LDC"d),
StringListValue("ldmd", "LDMD"d),
StringListValue("gdc", "GDC"d)]);
build.addStringComboBox("build/arch", UIString("Architecture"d), [
StringListValue("default", "Default"d),
StringListValue("x86", "x86"d),
StringListValue("x86_64", "x86_64"d)]);
build.addCheckbox("build/verbose", UIString("Verbose"d), true);
build.addStringEdit("build/dub_additional_params", UIString("DUB additional params"d), "");
SettingsPage dbg = res.addChild("debug", UIString("Run and Debug"d));
dbg.addStringEdit("debug/run_args", UIString("Command line args"d), "");

View File

@ -30,8 +30,13 @@ class IDESettings : SettingsFile {
dubSettings.setStringDef("executable", "dub");
dubSettings.setStringDef("additional_params", "");
dmdToolchainSettings.setStringDef("executable", "dmd");
dmdToolchainSettings.setStringDef("dub_additional_params", "");
ldcToolchainSettings.setStringDef("executable", "ldc2");
ldcToolchainSettings.setStringDef("dub_additional_params", "");
ldmdToolchainSettings.setStringDef("executable", "ldmd2");
ldmdToolchainSettings.setStringDef("dub_additional_params", "");
gdcToolchainSettings.setStringDef("executable", "gdc");
gdcToolchainSettings.setStringDef("dub_additional_params", "");
}
/// override to do something after loading - e.g. set defaults
@ -73,6 +78,11 @@ class IDESettings : SettingsFile {
return res;
}
@property Setting ldmdToolchainSettings() {
Setting res = _setting.objectByPath("dlang/toolchains/ldmd", true);
return res;
}
@property Setting gdcToolchainSettings() {
Setting res = _setting.objectByPath("dlang/toolchains/gdc", true);
return res;
@ -165,13 +175,27 @@ class IDESettings : SettingsFile {
return dubSettings.getString("additional_params", "");
}
string getToolchainSettings(string toolchainName) {
string getToolchainCompilerExecutable(string toolchainName) {
if (toolchainName.equal("dmd"))
return dmdToolchainSettings.getString("executable", "dmd");
if (toolchainName.equal("gdc"))
return gdcToolchainSettings.getString("executable", "gdc");
if (toolchainName.equal("ldc"))
return ldcToolchainSettings.getString("executable", "ldc2");
if (toolchainName.equal("ldmd"))
return ldmdToolchainSettings.getString("executable", "ldmd2");
return null;
}
string getToolchainAdditionalDubParams(string toolchainName) {
if (toolchainName.equal("dmd"))
return dmdToolchainSettings.getString("dub_additional_params", "");
if (toolchainName.equal("gdc"))
return gdcToolchainSettings.getString("dub_additional_params", "");
if (toolchainName.equal("ldc"))
return ldcToolchainSettings.getString("dub_additional_params", "");
if (toolchainName.equal("ldmd"))
return ldmdToolchainSettings.getString("dub_additional_params", "");
return null;
}

View File

@ -5,6 +5,9 @@ import dlangui.core.i18n;
import dlangide.workspace.idesettings;
import std.string;
import std.array;
const AVAILABLE_TOOLCHAINS = ["default", "dmd", "ldc", "gdc"];
const AVAILABLE_ARCH = ["default", "x86", "x86_64"];
@ -24,6 +27,7 @@ class ProjectSettings : SettingsFile {
build.setStringDef("toolchain", "default");
build.setStringDef("arch", "default");
build.setBooleanDef("verbose", false);
build.setStringDef("dub_additional_params", "");
Setting dbg = debugSettings();
dbg.setBooleanDef("external_console", true);
}
@ -44,7 +48,16 @@ class ProjectSettings : SettingsFile {
string getToolchain(IDESettings idesettings) {
string cfg = buildSettings.getString("toolchain");
return idesettings.getToolchainSettings(cfg);
return idesettings.getToolchainCompilerExecutable(cfg);
}
string getDubAdditionalParams(IDESettings idesettings) {
string cfg = buildSettings.getString("toolchain");
string globalparams = idesettings.dubAdditionalParams;
string globaltoolchainparams = idesettings.getToolchainAdditionalDubParams(cfg);
string projectparams = buildSettings.getString("dub_additional_params", "");
string verbosity = buildVerbose ? "-v" : null;
return joinParams(globalparams, globaltoolchainparams, projectparams, verbosity);
}
string getArch(IDESettings idesettings) {
@ -55,3 +68,18 @@ class ProjectSettings : SettingsFile {
}
}
/// join parameter lists separating with space
string joinParams(string[] params...) {
char[] res;
foreach(param; params) {
string s = param.strip;
if (!s.empty) {
if (!res.empty)
res ~= " ";
res ~= s;
}
}
if (res.empty)
return null;
return res.dup;
}