diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 67d07d3..aef3aa0 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -412,7 +412,10 @@ Package pack; if (!package_name.empty) { // load package in root_path to enable searching for sub packages - loadCwdPackage(dub, null, false); + if (loadCwdPackage(dub, null, false)) { + if (package_name.startsWith(":")) + package_name = dub.projectName ~ package_name; + } pack = dub.packageManager.getFirstPackage(package_name); enforce(pack, "Failed to find a package named '"~package_name~"'."); logInfo("Building package %s in %s", pack.name, pack.path.toNativeString()); diff --git a/source/dub/package_.d b/source/dub/package_.d index 10db3e1..22044bd 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -486,7 +486,7 @@ case "buildTypes": foreach (string name, settings; value) { BuildSettingsTemplate bs; - bs.parseJson(settings); + bs.parseJson(settings, null); buildTypes[name] = bs; } break; @@ -494,8 +494,10 @@ } } + enforce(this.name.length > 0, "The package \"name\" field is missing or empty."); + // parse build settings - this.buildSettings.parseJson(json); + this.buildSettings.parseJson(json, this.name); if (auto pv = "configurations" in json) { TargetType deftargettp = TargetType.library; @@ -504,12 +506,10 @@ foreach (settings; *pv) { ConfigurationInfo ci; - ci.parseJson(settings, deftargettp); + ci.parseJson(settings, this.name, deftargettp); this.configurations ~= ci; } } - - enforce(this.name.length > 0, "The package \"name\" field is missing or empty."); } Json toJson() @@ -555,7 +555,7 @@ this.buildSettings = build_settings; } - void parseJson(Json json, TargetType default_target_type = TargetType.library) + void parseJson(Json json, string package_name, TargetType default_target_type = TargetType.library) { this.buildSettings.targetType = default_target_type; @@ -573,7 +573,7 @@ enforce(!this.name.empty, "Configuration is missing a name."); BuildSettingsTemplate bs; - this.buildSettings.parseJson(json); + this.buildSettings.parseJson(json, package_name); } Json toJson() @@ -623,7 +623,7 @@ BuildRequirements[string] buildRequirements; BuildOptions[string] buildOptions; - void parseJson(Json json) + void parseJson(Json json, string package_name) { foreach(string name, value; json) { @@ -634,7 +634,8 @@ switch(basename){ default: break; case "dependencies": - foreach( string pkg, verspec; value ) { + foreach (string pkg, verspec; value) { + if (pkg.startsWith(":")) pkg = package_name ~ pkg; enforce(pkg !in this.dependencies, "The dependency '"~pkg~"' is specified more than once." ); this.dependencies[pkg] = deserializeJson!Dependency(verspec); }