Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unnecessary rebuild of single file package #1811

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 2 additions & 1 deletion source/dub/generators/build.d
Original file line number Diff line number Diff line change
@@ -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) {
4 changes: 4 additions & 0 deletions source/dub/generators/generator.d
Original file line number Diff line number Diff line change
@@ -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;
5 changes: 5 additions & 0 deletions test/issue103-single-file-package.sh
Original file line number Diff line number Diff line change
@@ -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