diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 56ab39f..d933c86 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -1592,6 +1592,31 @@ } } + static void fixPathDependency(string pack, ref Dependency dep) { + if (dep.path.length > 0) { + auto mainpack = getBasePackageName(pack); + dep.path = Path("../") ~ mainpack; + } + } + + void fixPathDependencies(ref PackageRecipe recipe, Path base_path) + { + foreach (name, ref dep; recipe.buildSettings.dependencies) + fixPathDependency(name, dep); + + foreach (ref cfg; recipe.configurations) + foreach (name, ref dep; cfg.buildSettings.dependencies) + fixPathDependency(name, dep); + + foreach (ref subp; recipe.subPackages) + if (subp.path.length) { + auto sub_path = base_path ~ Path(subp.path); + auto pack = prj.packageManager.getOrLoadPackage(sub_path); + fixPathDependencies(pack.info, sub_path); + pack.storeInfo(sub_path); + } else fixPathDependencies(subp.recipe, base_path); + } + bool[string] visited; foreach (pack_; prj.getTopologicalPackageList()) { auto pack = pack_.basePackage; @@ -1601,23 +1626,13 @@ logInfo("Copy package '%s' to destination folder...", pack.name); copyFolderRec(pack.path, dst_path); + // adjust all path based dependencies + fixPathDependencies(pack.info, dst_path); + // overwrite package description file with additional version information - pack_.storeInfo(dst_path); + pack.storeInfo(dst_path); } - // adjust all path based dependencies of the root package - void fixPathDependency(string pack, ref Dependency dep) { - if (dep.path.length > 0) - dep.path = Path("../") ~ pack; - } - foreach (name, ref dep; prj.rootPackage.info.buildSettings.dependencies) - fixPathDependency(name, dep); - foreach (ref cfg; prj.rootPackage.info.configurations) - foreach (name, ref dep; cfg.buildSettings.dependencies) - fixPathDependency(name, dep); - prj.rootPackage.storeInfo(path ~ prj.rootPackage.name); - - logInfo("Executing dustmite..."); auto testcmd = appender!string(); testcmd.formattedWrite("%s dustmite --vquiet --test-package=%s --build=%s --config=%s", diff --git a/source/dub/project.d b/source/dub/project.d index b019d23..fb25c07 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -116,6 +116,12 @@ /** Allows iteration of the dependency tree in topological order */ + int delegate(int delegate(ref Package)) getTopologicalPackageList(bool children_first = false, Package root_package = null, string[string] configs = null) + { + // ugly way to avoid code duplication since inout isn't compatible with foreach type inference + return cast(int delegate(int delegate(ref Package)))(cast(const)this).getTopologicalPackageList(children_first, root_package, configs); + } + /// ditto int delegate(int delegate(ref const Package)) getTopologicalPackageList(bool children_first = false, in Package root_package = null, string[string] configs = null) const { const(Package) rootpack = root_package ? root_package : m_rootPackage;