diff --git a/source/dub/dependency.d b/source/dub/dependency.d index cef6935..8ba99ed 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -42,8 +42,11 @@ } // A Dependency, which matches every valid version. - static @property ANY() { return Dependency(ANY_IDENT); } - static @property INVALID() { Dependency ret; ret.m_versA = Version.HEAD; ret.m_versB = Version.RELEASE; return ret; } + static @property any() { return Dependency(ANY_IDENT); } + static @property invalid() { Dependency ret; ret.m_versA = Version.HEAD; ret.m_versB = Version.RELEASE; return ret; } + + alias ANY = any; + alias INVALID = invalid; this(string ves) { diff --git a/source/dub/dependencyresolver.d b/source/dub/dependencyresolver.d index 7c339bd..f68e7b6 100644 --- a/source/dub/dependencyresolver.d +++ b/source/dub/dependencyresolver.d @@ -62,6 +62,7 @@ auto root_base_pack = rootPackage(root.pack); + // find all possible configurations of each possible dependency size_t[string] package_indices; CONFIG[][] all_configs; bool[TreeNode] visited; @@ -94,6 +95,9 @@ } findConfigsRec(root); + // prepend an invalid configuration to denote an unchosen dependency (for optional dependencies) + foreach (ref cfgs; all_configs) cfgs = CONFIG.invalid ~ cfgs; + logDebug("Configurations used for dependency resolution:"); foreach (n, i; package_indices) logDebug(" %s (%s): %s", n, i, all_configs[i]); @@ -132,7 +136,7 @@ } else { auto config = all_configs[childidx][config_indices[childidx]]; auto chnode = TreeNode(ch.pack, config); - if (!matches(ch.configs, config)) { + if (config == CONFIG.invalid || !matches(ch.configs, config)) { // if we are at the root level, we can safely skip the maxcpi computation and instead choose another childidx config if (parentbase == root_base_pack) { error = format("No match for dependency %s %s of %s", ch.pack, ch.configs, parent.pack); @@ -175,8 +179,10 @@ if (conflict_index < 0) { CONFIG[string] ret; foreach (p, i; package_indices) - if (all_configs[i].length) - ret[p] = all_configs[i][config_indices[i]]; + if (all_configs[i].length) { + auto cfg = all_configs[i][config_indices[i]]; + if (cfg != CONFIG.invalid) ret[p] = cfg; + } return ret; }