diff --git a/source/dub/description.d b/source/dub/description.d index cc7a9b7..2bb6b97 100644 --- a/source/dub/description.d +++ b/source/dub/description.d @@ -33,8 +33,22 @@ /// Targets by name ref inout(TargetDescription) lookupTarget(string name) inout { - return targets[ targetLookup[name] ]; + auto pti = name in targetLookup; + enforce(pti !is null, "Target '"~name~"' doesn't exist. Is the target type set to \"none\" in the package recipe?"); + return targets[*pti]; } + + /// Projects by name + ref inout(PackageDescription) lookupPackage(string name) inout + { + foreach (ref p; packages) + if (p.name == name) + return p; + throw new Exception("Package '"~name~"' not found in dependency tree."); + } + + /// Root package + ref inout(PackageDescription) lookupRootPackage() inout { return lookupPackage(rootPackage); } } diff --git a/source/dub/project.d b/source/dub/project.d index fa902e7..72f67e5 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -742,6 +742,9 @@ import std.range : only; string[] list; + + enforce(projectDescription.lookupRootPackage().targetType != TargetType.none, + "Target type is 'none'. Cannot list build settings."); auto targetDescription = projectDescription.lookupTarget(projectDescription.rootPackage); auto buildSettings = targetDescription.buildSettings;