Skip to content

Commit

Permalink
Merge pull request #1811 from andre2007/fix_issue_1809
Browse files Browse the repository at this point in the history
Fix unnecessary rebuild of single file package
  • Loading branch information
PetarKirov authored Dec 16, 2019
2 parents f54b853 + 26d8cc3 commit a36c285
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ class GenerateCommand : PackageBuildCommand {
gensettings.rdmd = m_rdmd;
gensettings.tempBuild = m_tempBuild;
gensettings.parallelBuild = m_parallel;
gensettings.single = m_single;

logDiagnostic("Generating using %s", m_generator);
dub.generateProject(m_generator, gensettings);
Expand Down
3 changes: 2 additions & 1 deletion source/dub/generators/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,8 @@ class BuildGenerator : ProjectGenerator {
foreach (p; packages)
allfiles ~= (p.recipePath != NativePath.init ? p : p.basePackage).recipePath.toNativeString();
foreach (f; additional_dep_files) allfiles ~= f.toNativeString();
if (main_pack is m_project.rootPackage && m_project.rootPackage.getAllDependencies().length > 0)
bool checkSelectedVersions = !settings.single;
if (checkSelectedVersions && main_pack is m_project.rootPackage && m_project.rootPackage.getAllDependencies().length > 0)
allfiles ~= (main_pack.path ~ SelectedVersions.defaultFile).toNativeString();

foreach (file; allfiles.data) {
Expand Down
4 changes: 4 additions & 0 deletions source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,10 @@ struct GeneratorSettings {

// only used for generator "build"
bool run, force, direct, rdmd, tempBuild, parallelBuild;

/// single file dub package
bool single;

string[] runArgs;
void delegate(int status, string output) compileCallback;
void delegate(int status, string output) linkCallback;
Expand Down
5 changes: 5 additions & 0 deletions test/issue103-single-file-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ if [ -f single-file-test ]; then
die $LINENO 'Shebang invocation produced binary in current directory'
fi

if ! { ${DUB} run --single issue103-single-file-package-w-dep.d --temp-build 2>&1 || true; } | grep -cF "To force a rebuild"; then
echo "Invocation triggered unnecessary rebuild."
exit 1
fi

if ${DUB} "issue103-single-file-package-error.d" 2> /dev/null; then
echo "Invalid package comment syntax did not trigger an error."
exit 1
Expand Down

0 comments on commit a36c285

Please sign in to comment.