diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 9ab99e7..cb2eadb 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -120,7 +120,10 @@ buildsettings.processVars(m_project, pack, pack.getBuildSettings(settings.platform, configs[pack.name]), settings, true); bool generate_binary = !(buildsettings.options & BuildOption.syntaxOnly); auto bs = &targets[m_project.rootPackage.name].buildSettings; - auto targetPath = (m_tempTargetExecutablePath.empty) ? NativePath(bs.targetPath) : m_tempTargetExecutablePath; + auto targetPath = !m_tempTargetExecutablePath.empty ? m_tempTargetExecutablePath : + !bs.targetPath.empty ? NativePath(bs.targetPath) : + NativePath(buildsettings.targetPath); + finalizeGeneration(pack, m_project, settings, buildsettings, targetPath, generate_binary); } diff --git a/test/issue2086-copyfiles-subpackage-targetpath.sh b/test/issue2086-copyfiles-subpackage-targetpath.sh new file mode 100755 index 0000000..9502f8c --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +. $(dirname "${BASH_SOURCE[0]}")/common.sh +cd "${CURR_DIR}/issue2086-copyfiles-subpackage-targetpath" || die "Could not cd." + +rm -f "sub/to_be_deployed.txt" + +"$DUB" build +./sub/sub diff --git a/test/issue2086-copyfiles-subpackage-targetpath/.no_run b/test/issue2086-copyfiles-subpackage-targetpath/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/.no_run diff --git a/test/issue2086-copyfiles-subpackage-targetpath/dub.json b/test/issue2086-copyfiles-subpackage-targetpath/dub.json new file mode 100644 index 0000000..70862f5 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/dub.json @@ -0,0 +1,10 @@ +{ + "name": "root", + "targetType": "none", + "dependencies": { + "root:sub": "*" + }, + "subPackages": [ + "sub" + ] +} diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json b/test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json new file mode 100644 index 0000000..76bfce6 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json @@ -0,0 +1,8 @@ +{ + "name": "sub", + "targetType": "executable", + "targetName": "sub", + "copyFiles": [ + "files/*" + ] +} diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/files/to_be_deployed.txt b/test/issue2086-copyfiles-subpackage-targetpath/sub/files/to_be_deployed.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/sub/files/to_be_deployed.txt diff --git a/test/issue2086-copyfiles-subpackage-targetpath/sub/source/app.d b/test/issue2086-copyfiles-subpackage-targetpath/sub/source/app.d new file mode 100644 index 0000000..9dc16f9 --- /dev/null +++ b/test/issue2086-copyfiles-subpackage-targetpath/sub/source/app.d @@ -0,0 +1,9 @@ +import std.exception: enforce; +import std.file: exists, thisExePath; +import std.path: dirName, buildPath; + +void main() +{ + string filePath = buildPath(thisExePath.dirName, "to_be_deployed.txt"); + enforce(filePath.exists); +}