diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 56edc9dccd..620093e3ce 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -2513,7 +2513,7 @@ class DustmiteCommand : PackageBuildCommand { if (subp.path.length) { auto sub_path = base_path ~ NativePath(subp.path); auto pack = prj.packageManager.getOrLoadPackage(sub_path); - fixPathDependencies(pack.recipe, sub_path); + fixPathDependencies(pack.rawRecipe, sub_path); pack.storeInfo(sub_path); } else fixPathDependencies(subp.recipe, base_path); } @@ -2528,7 +2528,7 @@ class DustmiteCommand : PackageBuildCommand { copyFolderRec(pack.path, dst_path); // adjust all path based dependencies - fixPathDependencies(pack.recipe, dst_path); + fixPathDependencies(pack.rawRecipe, dst_path); // overwrite package description file with additional version information pack.storeInfo(dst_path); diff --git a/source/dub/dub.d b/source/dub/dub.d index 87a78bc9ff..1edec4f379 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -1241,8 +1241,10 @@ class Dub { GeneratorSettings settings = this.makeAppSettings(); settings.runArgs = runArgs; + // used for compiler commands and for the CWD of the tool itself, or as + // base for relative paths. + settings.overrideToolWorkingDirectory = path; - initSubPackage.recipe.buildSettings.workingDirectory = path.toNativeString(); template_dub.generateProject("build", settings); } @@ -1293,7 +1295,7 @@ class Dub { if (m_dryRun) return; // allow to choose a custom ddox tool - auto tool = m_project.rootPackage.recipe.ddoxTool; + string tool = m_project.rootPackage.recipe.ddoxTool; if (tool.empty) tool = "ddox"; auto tool_pack = m_packageManager.getBestPackage(tool); diff --git a/source/dub/package_.d b/source/dub/package_.d index 27f696d3fc..41009dcb1f 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -85,6 +85,7 @@ class Package { PackageRecipe m_info; PackageRecipe m_rawRecipe; Package m_parentPackage; + ConfigurationInfo m_testConfiguration; } /** Constructs a `Package` using an in-memory package recipe. @@ -219,14 +220,15 @@ class Package { /// ditto @property void version_(Version value) { assert(m_parentPackage is null); m_info.version_ = value.toString(); } - /** Accesses the recipe contents of this package. + /** Accesses the recipe contents of this package. (only loaded once or after + reloading) The recipe contains any default values and configurations added by DUB. - To access the raw user recipe, use the `rawRecipe` property. + To access or modify the raw user recipe, use the `rawRecipe` property. See_Also: `rawRecipe` */ - @property ref inout(PackageRecipe) recipe() inout { return m_info; } + @property ref const(PackageRecipe) recipe() const { return m_info; } /** Accesses the original package recipe. @@ -236,7 +238,7 @@ class Package { See_Also: `recipe` */ - @property ref const(PackageRecipe) rawRecipe() const { return m_rawRecipe; } + @property ref inout(PackageRecipe) rawRecipe() inout { return m_rawRecipe; } /** Returns the path to the package recipe file. @@ -305,7 +307,7 @@ class Package { void storeInfo(NativePath path) const { auto filename = path ~ defaultPackageFilename; - writeJsonFile(filename, m_info.toJson()); + writeJsonFile(filename, m_rawRecipe.toJson()); } /** Returns the package recipe of a non-path-based sub package. @@ -448,6 +450,14 @@ class Package { } } + void addTestConfiguration(ConfigurationInfo config) + { + assert(m_testConfiguration is ConfigurationInfo.init, + "can't call addTestConfiguration twice!"); + m_info.configurations ~= config; + m_testConfiguration = config; + } + /** Returns the selected configuration for a certain dependency. If no configuration is specified in the package recipe, null will be diff --git a/source/dub/project.d b/source/dub/project.d index f68155a384..4f8f9a08e2 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -344,7 +344,7 @@ class Project { writeFile(mainfile, content); } - rootPackage.recipe.configurations ~= ConfigurationInfo(config, tcinfo); + rootPackage.addTestConfiguration(ConfigurationInfo(config, tcinfo)); return config; }