Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make package recipe const #2667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions source/dub/commandline.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions source/dub/dub.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
20 changes: 15 additions & 5 deletions source/dub/package_.d
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/dub/project.d
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class Project {
writeFile(mainfile, content);
}

rootPackage.recipe.configurations ~= ConfigurationInfo(config, tcinfo);
rootPackage.addTestConfiguration(ConfigurationInfo(config, tcinfo));

return config;
}
Expand Down