Skip to content

Commit

Permalink
Fix atilaneves#232 - pass on command-line options to dub dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Nov 8, 2023
1 parent a6fdca7 commit 0c782e9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
24 changes: 9 additions & 15 deletions payload/reggae/rules/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct DubPath {

imported!"reggae.build".Target dubDependency(DubPath dubPath)() {
import reggae.config: reggaeOptions = options; // the ones used to run reggae
return DubPathDependency(reggaeOptions.projectPath, dubPath)
return DubPathDependency(reggaeOptions, dubPath)
.target;
}

Expand Down Expand Up @@ -79,7 +79,7 @@ imported!"reggae.build".Target dubDependant(
enum stringImportPaths = oneOptionalOf!(StringImportPaths, A);

auto dubPathDependencies = [DubPaths]
.map!(p => DubPathDependency(reggaeOptions.projectPath, p));
.map!(p => DubPathDependency(reggaeOptions, p));

auto allImportPaths = dubPathDependencies
.save
Expand Down Expand Up @@ -138,27 +138,21 @@ private struct DubPathDependency {
import reggae.options: Options;
import reggae.build: Target;

string projectPath;
Options subOptions; // options for the dub dependency
DubInfo dubInfo;
string projectPath;

this(in string projectPath, in DubPath dubPath) {
this(in Options reggaeOptions, in DubPath dubPath) {
import reggae.dub.interop: dubInfos;
import reggae.options: getOptions;
import std.stdio: stdout;
import std.path: buildPath;

this.projectPath = projectPath;
projectPath = reggaeOptions.projectPath;
const path = buildPath(projectPath, dubPath.value);
subOptions = getOptions(
[
"reggae",
"-C",
path,
"--dub-config=" ~ dubPath.config.value,
path, // not sure why I need this again with -C above...
]
);
subOptions = reggaeOptions.dup;
subOptions.projectPath = path;
subOptions.workingDir = path;
subOptions.dubConfig = dubPath.config.value;
// dubInfos in this case returns an associative array but there's
// only really one key.
dubInfo = dubInfos(stdout, subOptions)[dubPath.config.value];
Expand Down
29 changes: 28 additions & 1 deletion tests/it/runtime/issues.d
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ unittest {
}


@Tags("dub", "ninja")
@("229")
@Tags("dub", "ninja")
unittest {
with(immutable ReggaeSandbox()) {
writeFile(
Expand Down Expand Up @@ -454,3 +454,30 @@ unittest {
runReggae;
}
}

@("232")
@Tags("dub", "ninja")
unittest {
with(immutable ReggaeSandbox()) {
writeFile(
"over/there/dub.sdl",
[
`name "foo"`,
`targetType "executable"`,
]
);
writeFile("over/there/source/app.d", q{void main() {}});
writeFile(
"reggaefile.d",
q{
import reggae;
alias dubDep = dubDependency!(DubPath("over/there"));
mixin build!dubDep;
}
);

runReggae("-b", "ninja", "--dub-objs-dir=" ~ inSandboxPath("dub_objs"));
ninja.shouldExecuteOk;
shouldExist("dub_objs");
}
}

0 comments on commit 0c782e9

Please sign in to comment.