diff --git a/source/dub/description.d b/source/dub/description.d index 22ec530..e958501 100644 --- a/source/dub/description.d +++ b/source/dub/description.d @@ -28,7 +28,13 @@ string[] platform; PackageDescription[] packages; /// All packages in the dependency tree TargetDescription[] targets; /// Build targets - @ignore TargetDescription[string] targetLookup; /// Targets by name + @ignore size_t[string] targetLookup; /// Target index by name + + /// Targets by name + ref inout(TargetDescription) lookupTarget(string name) inout + { + return targets[ targetLookup[name] ]; + } } diff --git a/source/dub/generators/targetdescription.d b/source/dub/generators/targetdescription.d index ad54a29..bd208ef 100644 --- a/source/dub/generators/targetdescription.d +++ b/source/dub/generators/targetdescription.d @@ -13,7 +13,7 @@ class TargetDescriptionGenerator : ProjectGenerator { TargetDescription[] targetDescriptions; - TargetDescription[string] targetDescriptionLookup; + size_t[string] targetDescriptionLookup; this(Project project) { @@ -34,7 +34,7 @@ d.dependencies = t.dependencies.dup; d.linkDependencies = t.linkDependencies.dup; - targetDescriptionLookup[d.rootPackage] = d; + targetDescriptionLookup[d.rootPackage] = i; targetDescriptions[i++] = d; } } diff --git a/source/dub/project.d b/source/dub/project.d index a1d07de..22a7faa 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -645,7 +645,7 @@ assert(compiler); - auto targetDescription = projectDescription.targetLookup[projectDescription.rootPackage]; + auto targetDescription = projectDescription.lookupTarget(projectDescription.rootPackage); auto buildSettings = targetDescription.buildSettings; string[] values; @@ -731,7 +731,7 @@ string[] list; - auto targetDescription = projectDescription.targetLookup[projectDescription.rootPackage]; + auto targetDescription = projectDescription.lookupTarget(projectDescription.rootPackage); auto buildSettings = targetDescription.buildSettings; // Return any BuildSetting member attributeName as a range of strings. Don't attempt to fixup values. @@ -889,10 +889,10 @@ auto configs = getPackageConfigs(platform, config); // Include link dependencies - auto target = projectDescription.targetLookup[projectDescription.rootPackage]; + auto target = projectDescription.lookupTarget(projectDescription.rootPackage); auto bs = target.buildSettings; foreach (ldep; target.linkDependencies) { - auto dbs = projectDescription.targetLookup[ldep].buildSettings; + auto dbs = projectDescription.lookupTarget(ldep).buildSettings; if (bs.targetType != TargetType.staticLibrary) { bs.addLibFiles((Path(dbs.targetPath) ~ getTargetFileName(dbs, platform)).toNativeString()); } @@ -900,13 +900,13 @@ target.buildSettings = bs; // Update projectDescription.targets - projectDescription.targetLookup[projectDescription.rootPackage] = target; - foreach (ref t; projectDescription.targets) { + projectDescription.lookupTarget(projectDescription.rootPackage) = target; + /+foreach (ref t; projectDescription.targets) { if(t.rootPackage == target.rootPackage) { t = target; break; } - } + }+/ // Genrate results if (formattingCompiler)