Skip to content

Commit

Permalink
add dub describe --data=configs,builds
Browse files Browse the repository at this point in the history
supersedes the trivial part of #2204
  • Loading branch information
WebFreak001 committed Sep 4, 2023
1 parent 7d2a2a3 commit 5b68f3d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
18 changes: 13 additions & 5 deletions source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -890,14 +890,14 @@ class Project {
return ret;
}

private string[] listBuildSetting(string attributeName)(ref GeneratorSettings settings,
private string[] listBuildSetting(string attributeName)(in GeneratorSettings settings,
string config, ProjectDescription projectDescription, Compiler compiler, bool disableEscaping)
{
return listBuildSetting!attributeName(settings, getPackageConfigs(settings.platform, config),
projectDescription, compiler, disableEscaping);
}

private string[] listBuildSetting(string attributeName)(ref GeneratorSettings settings,
private string[] listBuildSetting(string attributeName)(in GeneratorSettings settings,
string[string] configs, ProjectDescription projectDescription, Compiler compiler, bool disableEscaping)
{
if (compiler)
Expand All @@ -907,7 +907,7 @@ class Project {
}

// Output a build setting formatted for a compiler
private string[] formatBuildSettingCompiler(string attributeName)(ref GeneratorSettings settings,
private string[] formatBuildSettingCompiler(string attributeName)(in GeneratorSettings settings,
string[string] configs, ProjectDescription projectDescription, Compiler compiler, bool disableEscaping)
{
import std.process : escapeShellFileName;
Expand Down Expand Up @@ -1000,7 +1000,7 @@ class Project {
}

// Output a build setting without formatting for any particular compiler
private string[] formatBuildSettingPlain(string attributeName)(ref GeneratorSettings settings, string[string] configs, ProjectDescription projectDescription)
private string[] formatBuildSettingPlain(string attributeName)(in GeneratorSettings settings, string[string] configs, ProjectDescription projectDescription)
{
import std.path : buildNormalizedPath, dirSeparator;
import std.range : only;
Expand Down Expand Up @@ -1113,7 +1113,7 @@ class Project {

// The "compiler" arg is for choosing which compiler the output should be formatted for,
// or null to imply "list" format.
private string[] listBuildSetting(ref GeneratorSettings settings, string[string] configs,
private string[] listBuildSetting(in GeneratorSettings settings, string[string] configs,
ProjectDescription projectDescription, string requestedData, Compiler compiler, bool disableEscaping)
{
// Certain data cannot be formatter for a compiler
Expand Down Expand Up @@ -1143,6 +1143,10 @@ class Project {
case "post-build-environments":
case "pre-run-environments":
case "post-run-environments":
case "default-config":
case "configs":
case "default-build":
case "builds":
enforce(false, "--data="~requestedData~" can only be used with `--data-list` or `--data-list --data-0`.");
break;

Expand Down Expand Up @@ -1194,6 +1198,10 @@ class Project {
case "post-run-environments": return listBuildSetting!"postRunEnvironments"(args);
case "requirements": return listBuildSetting!"requirements"(args);
case "options": return listBuildSetting!"options"(args);
case "default-config": return [getDefaultConfiguration(settings.platform)];
case "configs": return configurations;
case "default-build": return [builds[0]];
case "builds": return builds;

default:
enforce(false, "--data="~requestedData~
Expand Down
31 changes: 31 additions & 0 deletions test/4-describe-data-1-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ if ! $DUB describe --compiler=$DC --filter-versions \
--data=pre-build-commands \
--data=post-build-commands \
'--data=requirements, options' \
--data=default-config \
--data=configs \
--data=default-build \
--data=builds \
> "$temp_file"; then
die $LINENO 'Printing project data failed!'
fi
Expand Down Expand Up @@ -130,6 +134,33 @@ echo "debugMode" >> "$expected_file"
echo "debugInfo" >> "$expected_file"
echo "stackStomping" >> "$expected_file"
echo "warnings" >> "$expected_file"
echo >> "$expected_file"
# --data=default-config
echo "my-project-config" >> "$expected_file"
echo >> "$expected_file"
# --data=configs
echo "my-project-config" >> "$expected_file"
echo >> "$expected_file"
# --data=default-build
echo "debug" >> "$expected_file"
echo >> "$expected_file"
# --data=builds
echo "debug" >> "$expected_file"
echo "plain" >> "$expected_file"
echo "release" >> "$expected_file"
echo "release-debug" >> "$expected_file"
echo "release-nobounds" >> "$expected_file"
echo "unittest" >> "$expected_file"
echo "profile" >> "$expected_file"
echo "profile-gc" >> "$expected_file"
echo "docs" >> "$expected_file"
echo "ddox" >> "$expected_file"
echo "cov" >> "$expected_file"
echo "cov-ctfe" >> "$expected_file"
echo "unittest-cov" >> "$expected_file"
echo "unittest-cov-ctfe" >> "$expected_file"
echo "syntax" >> "$expected_file"
# echo >> "$expected_file"

if ! diff "$expected_file" "$temp_file"; then
echo "Result:"
Expand Down

0 comments on commit 5b68f3d

Please sign in to comment.