diff --git a/payload/reggae/rules/dub.d b/payload/reggae/rules/dub.d index c71faa33..664b8a00 100644 --- a/payload/reggae/rules/dub.d +++ b/payload/reggae/rules/dub.d @@ -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; } @@ -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 @@ -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]; diff --git a/tests/it/runtime/issues.d b/tests/it/runtime/issues.d index f4cd463f..229b649f 100644 --- a/tests/it/runtime/issues.d +++ b/tests/it/runtime/issues.d @@ -425,8 +425,8 @@ unittest { } -@Tags("dub", "ninja") @("229") +@Tags("dub", "ninja") unittest { with(immutable ReggaeSandbox()) { writeFile( @@ -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"); + } +}