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)); } } }