diff --git a/source/dub/dub.d b/source/dub/dub.d index 544805f..3c5c11c 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -773,6 +773,13 @@ if (existsFile(path ~ ".dub/build")) rmdirRecurse((path ~ ".dub/build").toNativeString()); if (existsFile(path ~ ".dub/obj")) rmdirRecurse((path ~ ".dub/obj").toNativeString()); + + auto p = Package.load(path); + if (p.getBuildSettings().targetType == TargetType.none) { + foreach (sp; p.subPackages.filter!(sp => !sp.path.empty)) { + cleanPackage(path ~ sp.path); + } + } } /// Fetches the package matching the dependency and places it in the specified location. diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 8e0a171..1895e3b 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -47,6 +47,11 @@ { scope (exit) cleanupTemporaries(); + auto root_ti = targets[m_project.rootPackage.name]; + + enforce(!(settings.rdmd && root_ti.buildSettings.targetType == TargetType.none), + "Building package with target type \"none\" with rdmd is not supported yet."); + logInfo("Performing \"%s\" build using %s for %-(%s, %).", settings.buildType, settings.platform.compilerBinary, settings.platform.architecture); @@ -76,13 +81,13 @@ } } NativePath tpath; - if (buildTarget(settings, bs, ti.pack, ti.config, ti.packages, additional_dep_files, tpath)) - any_cached = true; + if (bs.targetType != TargetType.none) + if (buildTarget(settings, bs, ti.pack, ti.config, ti.packages, additional_dep_files, tpath)) + any_cached = true; target_paths[target] = tpath; } // build all targets - auto root_ti = targets[m_project.rootPackage.name]; if (settings.rdmd || root_ti.buildSettings.targetType == TargetType.staticLibrary) { // RDMD always builds everything at once and static libraries don't need their // dependencies to be built diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index ef51351..b526b7b 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -267,7 +267,7 @@ } auto depti = &targets[depname]; const depbs = &depti.buildSettings; - if (depbs.targetType == TargetType.executable) + if (depbs.targetType == TargetType.executable && ti.buildSettings.targetType != TargetType.none) continue; // add to (link) dependencies @@ -282,6 +282,9 @@ if (depbs.targetType == TargetType.staticLibrary) ti.linkDependencies = ti.linkDependencies.filter!(d => !depti.linkDependencies.canFind(d)).array ~ depti.linkDependencies; } + + enforce(!(ti.buildSettings.targetType == TargetType.none && ti.dependencies.empty), + "Package with target type \"none\" must have dependencies to build."); } collectDependencies(rootPackage, targets[rootPackage.name], targets); @@ -422,9 +425,8 @@ settings.compiler.extractBuildOptions(ti.buildSettings); auto tt = ti.buildSettings.targetType; - bool generatesBinary = tt != TargetType.sourceLibrary && tt != TargetType.none; - enforce (generatesBinary || ti.pack !is m_project.rootPackage || (ti.buildSettings.options & BuildOption.syntaxOnly), - format("Main package must have a binary target type, not %s. Cannot build.", tt)); + enforce (tt != TargetType.sourceLibrary || ti.pack !is m_project.rootPackage || (ti.buildSettings.options & BuildOption.syntaxOnly), + format("Main package must not have target type \"%s\". Cannot build.", tt)); } } } diff --git a/test/issue97-targettype-none-nodeps/.fail_build b/test/issue97-targettype-none-nodeps/.fail_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/.fail_build diff --git a/test/issue97-targettype-none-nodeps/.gitignore b/test/issue97-targettype-none-nodeps/.gitignore new file mode 100644 index 0000000..433d266 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/.gitignore @@ -0,0 +1,5 @@ +.dub +docs.json +__dummy.html +*.o +*.obj diff --git a/test/issue97-targettype-none-nodeps/.no_run b/test/issue97-targettype-none-nodeps/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/.no_run diff --git a/test/issue97-targettype-none-nodeps/a/dub.sdl b/test/issue97-targettype-none-nodeps/a/dub.sdl new file mode 100644 index 0000000..0c83ba9 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/a/dub.sdl @@ -0,0 +1,2 @@ +name "a" +targetType "executable" diff --git a/test/issue97-targettype-none-nodeps/a/source/app.d b/test/issue97-targettype-none-nodeps/a/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none-nodeps/a/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none-nodeps/b/dub.sdl b/test/issue97-targettype-none-nodeps/b/dub.sdl new file mode 100644 index 0000000..97d00a8 --- /dev/null +++ b/test/issue97-targettype-none-nodeps/b/dub.sdl @@ -0,0 +1,2 @@ +name "b" +targetType "executable" diff --git a/test/issue97-targettype-none-nodeps/b/source/app.d b/test/issue97-targettype-none-nodeps/b/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none-nodeps/b/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none-nodeps/dub.sdl b/test/issue97-targettype-none-nodeps/dub.sdl new file mode 100644 index 0000000..75bd0bd --- /dev/null +++ b/test/issue97-targettype-none-nodeps/dub.sdl @@ -0,0 +1,4 @@ +name "issue97-targettype-none" +targetType "none" +subPackage "./a/" +subPackage "./b/" diff --git a/test/issue97-targettype-none-onerecipe/.gitignore b/test/issue97-targettype-none-onerecipe/.gitignore new file mode 100644 index 0000000..433d266 --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/.gitignore @@ -0,0 +1,5 @@ +.dub +docs.json +__dummy.html +*.o +*.obj diff --git a/test/issue97-targettype-none-onerecipe/.no_run b/test/issue97-targettype-none-onerecipe/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/.no_run diff --git a/test/issue97-targettype-none-onerecipe/a/source/app.d b/test/issue97-targettype-none-onerecipe/a/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/a/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none-onerecipe/b/source/app.d b/test/issue97-targettype-none-onerecipe/b/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/b/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none-onerecipe/dub.sdl b/test/issue97-targettype-none-onerecipe/dub.sdl new file mode 100644 index 0000000..0914715 --- /dev/null +++ b/test/issue97-targettype-none-onerecipe/dub.sdl @@ -0,0 +1,14 @@ +name "issue97-targettype-none" +targetType "none" +dependency "issue97-targettype-none:a" version="*" +dependency "issue97-targettype-none:b" version="*" +subPackage { + name "a" + targetType "executable" + sourcePaths "a/source" +} +subPackage { + name "b" + targetType "executable" + sourcePaths "b/source" +} diff --git a/test/issue97-targettype-none.sh b/test/issue97-targettype-none.sh new file mode 100755 index 0000000..3ffe303 --- /dev/null +++ b/test/issue97-targettype-none.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +${DUB} build --root ${CURR_DIR}/issue97-targettype-none 2>&1 || true + +# make sure both sub-packages are cleaned +OUTPUT=`${DUB} clean --root ${CURR_DIR}/issue97-targettype-none 2>&1` +echo $OUTPUT | grep -c "Cleaning package at .*/issue97-targettype-none/a/" > /dev/null +echo $OUTPUT | grep -c "Cleaning package at .*/issue97-targettype-none/b/" > /dev/null diff --git a/test/issue97-targettype-none/.no_build b/test/issue97-targettype-none/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue97-targettype-none/.no_build diff --git a/test/issue97-targettype-none/.no_run b/test/issue97-targettype-none/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue97-targettype-none/.no_run diff --git a/test/issue97-targettype-none/a/dub.sdl b/test/issue97-targettype-none/a/dub.sdl new file mode 100644 index 0000000..0c83ba9 --- /dev/null +++ b/test/issue97-targettype-none/a/dub.sdl @@ -0,0 +1,2 @@ +name "a" +targetType "executable" diff --git a/test/issue97-targettype-none/a/source/app.d b/test/issue97-targettype-none/a/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none/a/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none/b/dub.sdl b/test/issue97-targettype-none/b/dub.sdl new file mode 100644 index 0000000..97d00a8 --- /dev/null +++ b/test/issue97-targettype-none/b/dub.sdl @@ -0,0 +1,2 @@ +name "b" +targetType "executable" diff --git a/test/issue97-targettype-none/b/source/app.d b/test/issue97-targettype-none/b/source/app.d new file mode 100644 index 0000000..c3eec7f --- /dev/null +++ b/test/issue97-targettype-none/b/source/app.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("Edit source/app.d to start your project."); +} diff --git a/test/issue97-targettype-none/dub.sdl b/test/issue97-targettype-none/dub.sdl new file mode 100644 index 0000000..1f47423 --- /dev/null +++ b/test/issue97-targettype-none/dub.sdl @@ -0,0 +1,6 @@ +name "issue97-targettype-none" +targetType "none" +dependency "issue97-targettype-none:a" version="*" +dependency "issue97-targettype-none:b" version="*" +subPackage "./a/" +subPackage "./b/"