diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 1895e3b..0932176 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -34,7 +34,6 @@ private { PackageManager m_packageMan; NativePath[] m_temporaryFiles; - NativePath m_targetExecutablePath; } this(Project project) @@ -108,10 +107,10 @@ auto buildsettings = targets[m_project.rootPackage.name].buildSettings.dup; if (settings.run && !(buildsettings.options & BuildOption.syntaxOnly)) { NativePath exe_file_path; - if (m_targetExecutablePath.empty) + if (m_tempTargetExecutablePath.empty) exe_file_path = getTargetPath(buildsettings, settings); else - exe_file_path = m_targetExecutablePath ~ settings.compiler.getTargetFileName(buildsettings, settings.platform); + exe_file_path = m_tempTargetExecutablePath ~ settings.compiler.getTargetFileName(buildsettings, settings.platform); runTarget(exe_file_path, buildsettings, settings.runArgs, settings); } } @@ -161,7 +160,7 @@ NativePath target_path; if (settings.tempBuild) { string packageName = pack.basePackage is null ? pack.name : pack.basePackage.name; - m_targetExecutablePath = target_path = getTempDir() ~ format(".dub/build/%s-%s/%s/", packageName, pack.version_, build_id); + m_tempTargetExecutablePath = target_path = getTempDir() ~ format(".dub/build/%s-%s/%s/", packageName, pack.version_, build_id); } else target_path = pack.path ~ format(".dub/build/%s/", build_id); diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 34352ba..30abdac 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -74,6 +74,7 @@ protected { Project m_project; + NativePath m_tempTargetExecutablePath; } this(Project project) @@ -109,12 +110,13 @@ if (bs.targetType == TargetType.executable) bs.addSourceFiles(mainfiles); generateTargets(settings, targets); + auto targetPath = (m_tempTargetExecutablePath.empty) ? NativePath(bs.targetPath) : m_tempTargetExecutablePath; foreach (pack; m_project.getTopologicalPackageList(true, null, configs)) { BuildSettings buildsettings; buildsettings.processVars(m_project, pack, pack.getBuildSettings(settings.platform, configs[pack.name]), settings, true); bool generate_binary = !(buildsettings.options & BuildOption.syntaxOnly); - finalizeGeneration(pack, m_project, settings, buildsettings, NativePath(bs.targetPath), generate_binary); + finalizeGeneration(pack, m_project, settings, buildsettings, targetPath, generate_binary); } performPostGenerateActions(settings, targets); diff --git a/test/issue1136-temp-copy-files.sh b/test/issue1136-temp-copy-files.sh new file mode 100755 index 0000000..ab935cb --- /dev/null +++ b/test/issue1136-temp-copy-files.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +. $(dirname "${BASH_SOURCE[0]}")/common.sh +cd ${CURR_DIR}/issue1136-temp-copy-files + +"$DUB" app.d diff --git a/test/issue1136-temp-copy-files/.no_build b/test/issue1136-temp-copy-files/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1136-temp-copy-files/.no_build diff --git a/test/issue1136-temp-copy-files/app.d b/test/issue1136-temp-copy-files/app.d new file mode 100644 index 0000000..3883984 --- /dev/null +++ b/test/issue1136-temp-copy-files/app.d @@ -0,0 +1,15 @@ +/+ dub.sdl: + +name "app" +dependency "mylib" path="./mylib" ++/ + +import std.exception: enforce; +import std.file: exists, thisExePath; +import std.path: dirName, buildPath; + +void main() +{ + string filePath = buildPath(thisExePath.dirName, "helloworld.txt"); + enforce(filePath.exists); +} \ No newline at end of file diff --git a/test/issue1136-temp-copy-files/mylib/dub.sdl b/test/issue1136-temp-copy-files/mylib/dub.sdl new file mode 100644 index 0000000..8276ed1 --- /dev/null +++ b/test/issue1136-temp-copy-files/mylib/dub.sdl @@ -0,0 +1,3 @@ +name "mylib" +copyFiles "./helloworld.txt" +targetType "none" \ No newline at end of file diff --git a/test/issue1136-temp-copy-files/mylib/helloworld.txt b/test/issue1136-temp-copy-files/mylib/helloworld.txt new file mode 100644 index 0000000..bc7774a --- /dev/null +++ b/test/issue1136-temp-copy-files/mylib/helloworld.txt @@ -0,0 +1 @@ +hello world! \ No newline at end of file