Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #288

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions payload/reggae/dub/interop/configurations.d

This file was deleted.

25 changes: 16 additions & 9 deletions payload/reggae/dub/interop/dublib.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,21 @@ static this() nothrow {
}
}

private struct DubConfigurations {
string[] configurations;
string default_;
string test; // special `dub test` config

bool haveTestConfig() @safe @nogc pure nothrow scope const {
return test != "";
}

bool isTestConfig(in string config) @safe @nogc pure nothrow scope const {
return haveTestConfig && config == test;
}
}

package struct Dub {
import reggae.dub.interop.configurations: DubConfigurations;
import reggae.dub.info: DubInfo;
import reggae.options: Options;
import dub.dub: DubClass = Dub;
Expand Down Expand Up @@ -79,14 +91,12 @@ package struct Dub {
DubInfo[string] ret;

const configs = dubConfigurations(output);
const haveTestConfig = configs.test != "";
bool atLeastOneConfigOk;
Exception dubInfoFailure;

foreach(config; configs.configurations) {
const isTestConfig = haveTestConfig && config == configs.test;
try {
ret[config] = configToDubInfo(output, config, isTestConfig);
ret[config] = configToDubInfo(output, config, configs.isTestConfig(config));
atLeastOneConfigOk = true;
} catch(Exception ex) {
output.log("ERROR: Could not get info for configuration ", config, ": ", ex.msg);
Expand All @@ -105,7 +115,7 @@ package struct Dub {
// (additionally) expose the special `dub test` config as
// `unittest` config in the DSL (`configToDubInfo`) (for
// `dubTest!()`, `dubBuild!(Configuration("unittest"))` etc.)
if(haveTestConfig && configs.test != "unittest" && configs.test in ret)
if(configs.haveTestConfig && configs.test != "unittest" && configs.test in ret)
ret["unittest"] = ret[configs.test];

return ret;
Expand All @@ -130,10 +140,7 @@ package struct Dub {
return ret;
}

imported!"reggae.dub.interop.configurations".DubConfigurations
dubConfigurations(O)(ref O output)
{
import reggae.dub.interop.configurations: DubConfigurations;
DubConfigurations dubConfigurations(O)(ref O output) {
import reggae.io: log;

output.log("Getting dub configurations");
Expand Down
Loading