Skip to content

Commit

Permalink
Fix issue #2086: Copy files of sub packages to the target path.
Browse files Browse the repository at this point in the history
  • Loading branch information
veelo committed Jan 23, 2021
1 parent f65e2bd commit e96f614
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ class ProjectGenerator
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);
}

Expand Down
9 changes: 9 additions & 0 deletions test/issue2086-copyfiles-subpackage-targetpath.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions test/issue2086-copyfiles-subpackage-targetpath/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "root",
"targetType": "none",
"dependencies": {
"root:sub": "*"
},
"subPackages": [
"sub"
]
}
8 changes: 8 additions & 0 deletions test/issue2086-copyfiles-subpackage-targetpath/sub/dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "sub",
"targetType": "executable",
"targetName": "sub",
"copyFiles": [
"files/*"
]
}
Empty file.
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit e96f614

Please sign in to comment.