diff --git a/source/dub/commandline.d b/source/dub/commandline.d index c6e4736..6d0bc45 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -950,7 +950,7 @@ args.getopt("b|build", &m_buildType, [ "Specifies the type of build to perform. Note that setting the DFLAGS environment variable will override the build type with custom flags.", "Possible names:", - " debug (default), plain, release, release-debug, release-nobounds, unittest, profile, profile-gc, docs, ddox, cov, unittest-cov, syntax and custom types" + " "~builtinBuildTypes.join(", ")~" and custom types" ]); args.getopt("c|config", &m_buildConfig, [ "Builds the specified configuration. Configurations can be defined in dub.json" @@ -1148,10 +1148,10 @@ setupVersionPackage(dub, str_package_info, "debug"); - if (m_printBuilds) { // FIXME: use actual package data + if (m_printBuilds) { logInfo("Available build types:"); - foreach (tp; ["debug", "release", "unittest", "profile"]) - logInfo(" %s", tp); + foreach (i, tp; dub.project.builds) + logInfo(" %s%s", tp, i == 0 ? " [default]" : null); logInfo(""); } diff --git a/source/dub/package_.d b/source/dub/package_.d index 896633b..cf49f92 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -55,6 +55,23 @@ /// Returns the default package recile file name. @property string defaultPackageFilename() { return packageInfoFiles[0].filename; } +/// All built-in build type names except for the special `$DFLAGS` build type. +/// Has the default build type (`debug`) as first index. +static immutable string[] builtinBuildTypes = [ + "debug", + "plain", + "release", + "release-debug", + "release-nobounds", + "unittest", + "profile", + "profile-gc", + "docs", + "ddox", + "cov", + "unittest-cov", + "syntax" +]; /** Represents a package, including its sub packages. */ @@ -256,6 +273,18 @@ return ret.data; } + /** Returns the list of all custom build type names. + + Build type contents can be accessed using `this.recipe.buildTypes`. + */ + @property string[] customBuildTypes() + const { + auto ret = appender!(string[])(); + foreach (name; m_info.buildTypes.byKey) + ret.put(name); + return ret.data; + } + /** Writes the current recipe contents to a recipe file. The parameter-less overload writes to `this.path`, which must not be diff --git a/source/dub/project.d b/source/dub/project.d index 242dcd7..03f6901 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -427,6 +427,10 @@ /// Returns the names of all configurations of the root package. @property string[] configurations() const { return m_rootPackage.configurations; } + /// Returns the names of all built-in and custom build types of the root package. + /// The default built-in build type is the first item in the list. + @property string[] builds() const { return builtinBuildTypes ~ m_rootPackage.customBuildTypes; } + /// Returns a map with the configuration for all packages in the dependency tree. string[string] getPackageConfigs(in BuildPlatform platform, string config, bool allow_non_library = true) const {