Skip to content

Commit

Permalink
Merge pull request #288 from atilaneves/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
atilaneves authored Feb 28, 2024
2 parents 5d8c197 + bad5653 commit 0c24c68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
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

0 comments on commit 0c24c68

Please sign in to comment.