Skip to content

Commit 2cc1e07

Browse files
committed
[break API to make it slightly less ugly]
1 parent 8aec744 commit 2cc1e07

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

source/dub/commandline.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ class Command {
887887
dub.mainRecipePath = options.recipeFile;
888888
// make the CWD package available so that for example sub packages can reference their
889889
// parent package.
890-
try dub.packageManager.getOrLoadPackage(NativePath(options.root_path), NativePath(options.recipeFile), false, StrictMode.Warn);
890+
try dub.packageManager.getOrLoadPackage(NativePath(options.root_path), NativePath(options.recipeFile), PackageName.init, StrictMode.Warn);
891891
catch (Exception e) {
892892
// by default we ignore CWD package load fails in prepareDUB, since
893893
// they will fail again later when they are actually requested. This

source/dub/dub.d

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class Dub {
515515
void loadPackage(NativePath path)
516516
{
517517
auto pack = this.m_packageManager.getOrLoadPackage(
518-
path, NativePath.init, false, StrictMode.Warn);
518+
path, NativePath.init, PackageName.init, StrictMode.Warn);
519519
this.loadPackage(pack);
520520
}
521521

@@ -1956,8 +1956,7 @@ private class DependencyVersionResolver : DependencyResolver!(Dependency, Depend
19561956
if (!dep.path.empty) {
19571957
try {
19581958
// note: would handle sub-packages directly
1959-
return m_dub.packageManager.getOrLoadPackage(dep.path, NativePath.init, false,
1960-
StrictMode.Ignore, name);
1959+
return m_dub.packageManager.getOrLoadPackage(dep.path, NativePath.init, name);
19611960
} catch (Exception e) {
19621961
logDiagnostic("Failed to load path based dependency %s: %s", name, e.msg);
19631962
logDebug("Full error: %s", e.toString().sanitize);

source/dub/packagemanager.d

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ class PackageManager {
271271
foreach (ovr; repo.overrides)
272272
if (ovr.package_ == name.toString() && ovr.source.matches(ver)) {
273273
Package pack = ovr.target.match!(
274-
(NativePath path) => getOrLoadPackage(path, NativePath.init, false,
275-
StrictMode.Ignore, name),
274+
(NativePath path) => getOrLoadPackage(path, NativePath.init, name),
276275
(Version vers) => getPackage(name, vers, false),
277276
);
278277
if (pack) return pack;
@@ -378,17 +377,14 @@ class PackageManager {
378377
Params:
379378
path = NativePath to the root directory of the package
380379
recipe_path = Optional path to the recipe file of the package
381-
allow_sub_packages = Also return an already-loaded sub package if it resides in the given folder.
382-
Ignored when specifying `name`, as a matching already-loaded sub package is always returned in that case.
380+
name = Optional (sub-)package name if known in advance. Required if a sub-package is to be returned.
383381
mode = Whether to issue errors, warning, or ignore unknown keys in dub.json
384-
name = Optional (sub-)package name if known in advance
385382
386383
Returns: The packages loaded from the given path
387384
Throws: Throws an exception if no package can be loaded
388385
*/
389386
Package getOrLoadPackage(NativePath path, NativePath recipe_path = NativePath.init,
390-
bool allow_sub_packages = false, StrictMode mode = StrictMode.Ignore,
391-
PackageName name = PackageName.init)
387+
PackageName name = PackageName.init, StrictMode mode = StrictMode.Ignore)
392388
{
393389
path.endsWithSlash = true;
394390
const nameString = name.toString();
@@ -398,7 +394,7 @@ class PackageManager {
398394
if (p.name == nameString && (p.path == path || p.basePackage.path == path))
399395
return p;
400396
} else {
401-
if (p.path == path && (!p.parentPackage || (allow_sub_packages && p.parentPackage.path != p.path)))
397+
if (p.path == path && !p.parentPackage)
402398
return p;
403399
}
404400
}

source/dub/project.d

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Project {
6767
logWarn("There was no package description found for the application in '%s'.", project_path.toNativeString());
6868
pack = new Package(PackageRecipe.init, project_path);
6969
} else {
70-
pack = package_manager.getOrLoadPackage(project_path, packageFile, false, StrictMode.Warn);
70+
pack = package_manager.getOrLoadPackage(project_path, packageFile, PackageName.init, StrictMode.Warn);
7171
}
7272

7373
this(package_manager, pack);
@@ -553,8 +553,7 @@ class Project {
553553
p = vspec.visit!(
554554
(NativePath path_) {
555555
auto path = path_.absolute ? path_ : m_rootPackage.path ~ path_;
556-
return m_packageManager.getOrLoadPackage(path, NativePath.init, false,
557-
StrictMode.Ignore, dep.name);
556+
return m_packageManager.getOrLoadPackage(path, NativePath.init, dep.name);
558557
},
559558
(Repository repo) {
560559
return m_packageManager.loadSCMPackage(dep.name, repo);
@@ -587,8 +586,7 @@ class Project {
587586
NativePath path = vspec.path;
588587
if (!path.absolute) path = pack.path ~ path;
589588
logDiagnostic("%sAdding local %s in %s", indent, dep.name, path);
590-
p = m_packageManager.getOrLoadPackage(path, NativePath.init, false,
591-
StrictMode.Ignore, dep.name);
589+
p = m_packageManager.getOrLoadPackage(path, NativePath.init, dep.name);
592590
path.endsWithSlash = true;
593591
if (path != p.basePackage.path) {
594592
logWarn("%sSub package %s must be referenced using the path to it's parent package.", indent, dep.name);

0 commit comments

Comments
 (0)