diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 129943b..a3a6444 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -402,11 +402,6 @@ bool m_forceRemove = false; } - this() - { - m_compilerName = defaultCompiler(); - } - override void prepare(scope CommandArgs args) { args.getopt("b|build", &m_buildType, [ @@ -420,8 +415,7 @@ args.getopt("compiler", &m_compilerName, [ "Specifies the compiler binary to use (can be a path).", "Arbitrary pre- and suffixes to the identifiers below are recognized (e.g. ldc2 or dmd-2.063) and matched to the proper compiler type:", - " "~["dmd", "gdc", "ldc", "gdmd", "ldmd"].join(", "), - "Default value: "~m_compilerName, + " "~["dmd", "gdc", "ldc", "gdmd", "ldmd"].join(", ") ]); args.getopt("a|arch", &m_arch, [ "Force a different architecture (e.g. x86 or x86_64)" @@ -443,6 +437,7 @@ protected void setupPackage(Dub dub, string package_name) { + if (!m_compilerName.length) m_compilerName = dub.defaultCompiler; m_compiler = getCompiler(m_compilerName); m_buildPlatform = m_compiler.determinePlatform(m_buildSettings, m_compilerName, m_arch); m_buildSettings.addDebugVersions(m_debugVersions); diff --git a/source/dub/dub.d b/source/dub/dub.d index 222a7a5..6992d4d 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -165,6 +165,20 @@ @property inout(Project) project() inout { return m_project; } + /// Returns the default compiler binary to use for building D code. + @property string defaultCompiler() + const { + if (auto pv = "defaultCompiler" in m_userConfig) + if (pv.type == Json.Type.string) + return pv.get!string; + + if (auto pv = "defaultCompiler" in m_systemConfig) + if (pv.type == Json.Type.string) + return pv.get!string; + + return .defaultCompiler(); + } + /// Loads the package from the current working directory as the main /// project package. void loadPackageFromCwd() @@ -693,7 +707,7 @@ ddox_dub.loadPackage(ddox_pack.path); ddox_dub.upgrade(UpgradeOptions.select); - auto compiler_binary = "dmd"; + auto compiler_binary = this.defaultCompiler; GeneratorSettings settings; settings.config = "application";