diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 63f8d11..ce51f79 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -495,7 +495,7 @@ auto ver = dub.getLatestVersion(depname); auto dep = ver.isBranch ? Dependency(ver) : Dependency("~>" ~ ver.toString()); p.buildSettings.dependencies[depname] = dep; - logInfo("Added dependency %s %s", depname, dep.versionString); + logInfo("Added dependency %s %s", depname, dep.versionSpec); } catch (Exception e) { logError("Could not find package '%s'.", depname); logDebug("Full error: %s", e.toString().sanitize); @@ -1363,7 +1363,7 @@ { logInfo("Packages present in the system and known to dub:"); foreach (p; dub.packageManager.getPackageIterator()) - logInfo(" %s %s: %s", p.name, p.ver, p.path.toNativeString()); + logInfo(" %s %s: %s", p.name, p.version_, p.path.toNativeString()); logInfo(""); return 0; } diff --git a/source/dub/dependency.d b/source/dub/dependency.d index 8591f35..f63ebcb 100644 --- a/source/dub/dependency.d +++ b/source/dub/dependency.d @@ -49,7 +49,7 @@ static @property any() { return Dependency(ANY_IDENT); } /// An invalid dependency (with no possible version matches). - static @property invalid() { Dependency ret; ret.m_versA = Version.HEAD; ret.m_versB = Version.RELEASE; return ret; } + static @property invalid() { Dependency ret; ret.m_versA = Version.maxRelease; ret.m_versB = Version.minRelease; return ret; } deprecated("Use .any instead") alias ANY = any; @@ -105,7 +105,7 @@ /// Returns the exact version matched by the version range. @property Version version_() const { - enforce(m_versA == m_versB, "Dependency "~versionString~" is no exact version."); + enforce(m_versA == m_versB, "Dependency "~this.versionSpec~" is no exact version."); return m_versA; } @@ -150,7 +150,7 @@ ves = ves[2..$]; m_versA = Version(expandVersion(ves)); m_versB = Version(bumpVersion(ves)); - } else if (ves[0] == Version.BRANCH_IDENT) { + } else if (ves[0] == Version.branchPrefix) { m_inclusiveA = true; m_inclusiveB = true; m_versA = m_versB = Version(ves); @@ -163,14 +163,14 @@ size_t idx2 = std.string.indexOf(ves, " "); if (idx2 == -1) { if (cmpa == "<=" || cmpa == "<") { - m_versA = Version.RELEASE; + m_versA = Version.minRelease; m_inclusiveA = true; m_versB = Version(ves); m_inclusiveB = cmpa == "<="; } else if (cmpa == ">=" || cmpa == ">") { m_versA = Version(ves); m_inclusiveA = cmpa == ">="; - m_versB = Version.HEAD; + m_versB = Version.maxRelease; m_inclusiveB = true; } else { // Converts "==" to ">=a&&<=a", which makes merging easier @@ -202,7 +202,7 @@ if (m_versA == m_versB && m_inclusiveA && m_inclusiveB) { // Special "==" case - if (m_versA == Version.MASTER ) return "~master"; + if (m_versA == Version.masterBranch) return "~master"; else return m_versA.toString(); } @@ -223,9 +223,9 @@ } } - if (m_versA != Version.RELEASE) r = (m_inclusiveA ? ">=" : ">") ~ m_versA.toString(); - if (m_versB != Version.HEAD) r ~= (r.length==0 ? "" : " ") ~ (m_inclusiveB ? "<=" : "<") ~ m_versB.toString(); - if (m_versA == Version.RELEASE && m_versB == Version.HEAD) r = ">=0.0.0"; + if (m_versA != Version.minRelease) r = (m_inclusiveA ? ">=" : ">") ~ m_versA.toString(); + if (m_versB != Version.maxRelease) r ~= (r.length==0 ? "" : " ") ~ (m_inclusiveB ? "<=" : "<") ~ m_versB.toString(); + if (m_versA == Version.minRelease && m_versB == Version.maxRelease) r = ">=0.0.0"; return r; } @@ -250,7 +250,7 @@ */ string toString()() const { - auto ret = versionString; + auto ret = versionSpec; if (optional) ret ~= " (optional)"; if (!path.empty) ret ~= " @"~path.toNativeString(); return ret; @@ -266,10 +266,10 @@ Json toJson() const { Json json; if( path.empty && !optional ){ - json = Json(this.versionString); + json = Json(this.versionSpec); } else { json = Json.emptyObject; - json["version"] = this.versionString; + json["version"] = this.versionSpec; if (!path.empty) json["path"] = path.toString(); if (optional) json["optional"] = true; if (default_) json["default"] = true; @@ -296,7 +296,7 @@ if (auto pv = "version" in verspec) logDiagnostic("Ignoring version specification (%s) for path based dependency %s", pv.get!string, pp.get!string); - dep = Dependency.ANY; + dep = Dependency.any; dep.path = Path(verspec.path.get!string); } else { enforce("version" in verspec, "No version field specified!"); @@ -324,7 +324,7 @@ "path": "path/to/package" } `)); - Dependency d = Dependency.ANY; // supposed to ignore the version spec + Dependency d = Dependency.any; // supposed to ignore the version spec d.optional = true; d.default_ = true; d.path = Path("path/to/package"); @@ -420,11 +420,11 @@ const { if (this.matchesAny) return o; if (o.matchesAny) return this; - if (!this.valid || !o.valid) return INVALID; - if (m_versA.isBranch != o.m_versA.isBranch) return INVALID; - if (m_versB.isBranch != o.m_versB.isBranch) return INVALID; - if (m_versA.isBranch) return m_versA == o.m_versA ? this : INVALID; - if (this.path != o.path) return INVALID; + if (!this.valid || !o.valid) return invalid; + if (m_versA.isBranch != o.m_versA.isBranch) return invalid; + if (m_versB.isBranch != o.m_versB.isBranch) return invalid; + if (m_versA.isBranch) return m_versA == o.m_versA ? this : invalid; + if (this.path != o.path) return invalid; Version a = m_versA > o.m_versA ? m_versA : o.m_versA; Version b = m_versB < o.m_versB ? m_versB : o.m_versB; @@ -435,7 +435,7 @@ d.m_inclusiveB = !m_inclusiveB && m_versB <= o.m_versB ? false : o.m_inclusiveB; d.m_versB = b; d.m_optional = m_optional && o.m_optional; - if (!d.valid) return INVALID; + if (!d.valid) return invalid; return d; } @@ -443,7 +443,7 @@ private static bool isDigit(char ch) { return ch >= '0' && ch <= '9'; } private static string skipComp(ref string c) { size_t idx = 0; - while (idx < c.length && !isDigit(c[idx]) && c[idx] != Version.BRANCH_IDENT) idx++; + while (idx < c.length && !isDigit(c[idx]) && c[idx] != Version.branchPrefix) idx++; enforce(idx < c.length, "Expected version number in version spec: "~c); string cmp = idx==c.length-1||idx==0? ">=" : c[0..idx]; c = c[idx..$]; @@ -462,19 +462,19 @@ unittest { Dependency a = Dependency(">=1.1.0"), b = Dependency(">=1.3.0"); - assert (a.merge(b).valid() && a.merge(b).versionString == ">=1.3.0", a.merge(b).toString()); + assert (a.merge(b).valid() && a.merge(b).versionSpec == ">=1.3.0", a.merge(b).toString()); assertThrown(Dependency("<=2.0.0 >=1.0.0")); assertThrown(Dependency(">=2.0.0 <=1.0.0")); a = Dependency(">=1.0.0 <=5.0.0"); b = Dependency(">=2.0.0"); - assert (a.merge(b).valid() && a.merge(b).versionString == ">=2.0.0 <=5.0.0", a.merge(b).toString()); + assert (a.merge(b).valid() && a.merge(b).versionSpec == ">=2.0.0 <=5.0.0", a.merge(b).toString()); assertThrown(a = Dependency(">1.0.0 ==5.0.0"), "Construction is invalid"); a = Dependency(">1.0.0"); b = Dependency("<2.0.0"); assert (a.merge(b).valid(), a.merge(b).toString()); - assert (a.merge(b).versionString == ">1.0.0 <2.0.0", a.merge(b).toString()); + assert (a.merge(b).versionSpec == ">1.0.0 <2.0.0", a.merge(b).toString()); a = Dependency(">2.0.0"); b = Dependency("<1.0.0"); assert (!(a.merge(b)).valid(), a.merge(b).toString()); @@ -497,18 +497,18 @@ // branches / head revisions - a = Dependency(Version.MASTER_STRING); + a = Dependency(Version.masterBranch); assert(a.valid()); - assert(a.matches(Version.MASTER)); - b = Dependency(Version.MASTER_STRING); + assert(a.matches(Version.masterBranch)); + b = Dependency(Version.masterBranch); m = a.merge(b); - assert(m.matches(Version.MASTER)); + assert(m.matches(Version.masterBranch)); //assertThrown(a = Dependency(Version.MASTER_STRING ~ " <=1.0.0"), "Construction invalid"); - assertThrown(a = Dependency(">=1.0.0 " ~ Version.MASTER_STRING), "Construction invalid"); + assertThrown(a = Dependency(">=1.0.0 " ~ Version.masterBranch.toString()), "Construction invalid"); - immutable string branch1 = Version.BRANCH_IDENT ~ "Branch1"; - immutable string branch2 = Version.BRANCH_IDENT ~ "Branch2"; + immutable string branch1 = Version.branchPrefix ~ "Branch1"; + immutable string branch2 = Version.branchPrefix ~ "Branch2"; //assertThrown(a = Dependency(branch1 ~ " " ~ branch2), "Error: '" ~ branch1 ~ " " ~ branch2 ~ "' succeeded"); //assertThrown(a = Dependency(Version.MASTER_STRING ~ " " ~ branch1), "Error: '" ~ Version.MASTER_STRING ~ " " ~ branch1 ~ "' succeeded"); @@ -523,7 +523,7 @@ a = Dependency(branch1); assert(a.matches(branch1), "Dependency(branch1) does not match 'branch1'"); assert(a.matches(Version(branch1)), "Dependency(branch1) does not match Version('branch1')"); - assert(!a.matches(Version.MASTER), "Dependency(branch1) matches Version.MASTER"); + assert(!a.matches(Version.masterBranch), "Dependency(branch1) matches Version.masterBranch"); assert(!a.matches(branch2), "Dependency(branch1) matches 'branch2'"); assert(!a.matches(Version("1.0.0")), "Dependency(branch1) matches '1.0.0'"); a = Dependency(">=1.0.0"); @@ -583,28 +583,28 @@ assert(a.valid); assert(a.version_ == Version("~d2test")); - a = Dependency.ANY; + a = Dependency.any; assert(!a.optional); assert(a.valid); assertThrown(a.version_); - assert(a.matches(Version.MASTER)); + assert(a.matches(Version.masterBranch)); assert(a.matches(Version("1.0.0"))); assert(a.matches(Version("0.0.1-pre"))); b = Dependency(">=1.0.1"); assert(b == a.merge(b)); assert(b == b.merge(a)); - b = Dependency(Version.MASTER); + b = Dependency(Version.masterBranch); assert(a.merge(b) == b); assert(b.merge(a) == b); a.optional = true; - assert(a.matches(Version.MASTER)); + assert(a.matches(Version.masterBranch)); assert(a.matches(Version("1.0.0"))); assert(a.matches(Version("0.0.1-pre"))); b = Dependency(">=1.0.1"); assert(b == a.merge(b)); assert(b == b.merge(a)); - b = Dependency(Version.MASTER); + b = Dependency(Version.masterBranch); assert(a.merge(b) == b); assert(b.merge(a) == b); @@ -612,10 +612,10 @@ } unittest { - assert(Dependency("~>1.0.4").versionString == "~>1.0.4"); - assert(Dependency("~>1.4").versionString == "~>1.4"); - assert(Dependency("~>2").versionString == "~>2"); - assert(Dependency("~>1.0.4+1.2.3").versionString == "~>1.0.4"); + assert(Dependency("~>1.0.4").versionSpec == "~>1.0.4"); + assert(Dependency("~>1.4").versionSpec == "~>1.4"); + assert(Dependency("~>2").versionSpec == "~>2"); + assert(Dependency("~>1.0.4+1.2.3").versionSpec == "~>1.0.4"); } @@ -630,13 +630,15 @@ private { enum MAX_VERS = "99999.0.0"; enum UNKNOWN_VERS = "unknown"; + enum branchPrefix = '~'; + enum masterString = "~master"; string m_version; } static @property minRelease() { return Version("0.0.0"); } static @property maxRelease() { return Version(MAX_VERS); } - static @property masterBranch() { return Version(MASTER_STRING); } - static @property unknownVersion() { return Version(UNKNOWN_VERS); } + static @property masterBranch() { return Version(masterString); } + static @property unknown() { return Version(UNKNOWN_VERS); } deprecated("Use minRelease instead") static @property RELEASE() { return Version("0.0.0"); } @@ -644,19 +646,19 @@ static @property HEAD() { return Version(MAX_VERS); } deprecated("Use masterBranch instead") static @property MASTER() { return Version(MASTER_STRING); } - deprecated("Use unknownVersion instead") + deprecated("Use unknown instead") static @property UNKNOWN() { return Version(UNKNOWN_VERS); } deprecated("Use masterBranch.toString() instead") - static @property MASTER_STRING() { return "~master"; } + static @property MASTER_STRING() { return masterString; } deprecated - static @property BRANCH_IDENT() { return '~'; } + static @property BRANCH_IDENT() { return branchPrefix; } /** Constructs a new `Version` from its string representation. */ this(string vers) { enforce(vers.length > 1, "Version strings must not be empty."); - if (vers[0] != BRANCH_IDENT && vers != UNKNOWN_VERS) + if (vers[0] != branchPrefix && vers != UNKNOWN_VERS) enforce(vers.isValidVersion(), "Invalid SemVer format: " ~ vers); m_version = vers; } @@ -672,10 +674,10 @@ } /// Tests if this represents a branch instead of a version. - @property bool isBranch() const { return !m_version.empty && m_version[0] == BRANCH_IDENT; } + @property bool isBranch() const { return !m_version.empty && m_version[0] == branchPrefix; } /// Tests if this represents the master branch "~master". - @property bool isMaster() const { return m_version == MASTER_STRING; } + @property bool isMaster() const { return m_version == masterString; } /** Tests if this represents a pre-release version. @@ -726,10 +728,10 @@ assert(!a.isBranch, "Error: '1.0.0' treated as branch"); assert(a == a, "a == a failed"); - assertNotThrown(a = Version(Version.MASTER_STRING), "Constructing Version("~Version.MASTER_STRING~"') failed"); - assert(a.isBranch, "Error: '"~Version.MASTER_STRING~"' treated as branch"); + assertNotThrown(a = Version(Version.masterString), "Constructing Version("~Version.masterString~"') failed"); + assert(a.isBranch, "Error: '"~Version.masterString~"' treated as branch"); assert(a.isMaster); - assert(a == Version.MASTER, "Constructed master version != default master version."); + assert(a == Version.masterBranch, "Constructed master version != default master version."); assertNotThrown(a = Version("~BRANCH"), "Construction of branch Version failed."); assert(a.isBranch, "Error: '~BRANCH' not treated as branch'"); @@ -742,7 +744,7 @@ assert(a == b, "a == b with a:'1.0.0', b:'1.0.0' failed"); b = Version("2.0.0"); assert(a != b, "a != b with a:'1.0.0', b:'2.0.0' failed"); - a = Version(Version.MASTER_STRING); + a = Version.masterBranch; b = Version("~BRANCH"); assert(a != b, "a != b with a:MASTER, b:'~branch' failed"); assert(a > b); @@ -772,12 +774,12 @@ for(int j=i-1; j>=0; --j) assert(versions[j] < versions[i], "Failed: " ~ versions[j].toString() ~ "<" ~ versions[i].toString()); - a = Version.UNKNOWN; - b = Version.RELEASE; + a = Version.unknown; + b = Version.minRelease; assertThrown(a == b, "Failed: compared " ~ a.toString() ~ " with " ~ b.toString() ~ ""); - a = Version.UNKNOWN; - b = Version.UNKNOWN; + a = Version.unknown; + b = Version.unknown; assertThrown(a == b, "Failed: UNKNOWN == UNKNOWN"); assert(Version("1.0.0+a") == Version("1.0.0+b")); diff --git a/source/dub/dub.d b/source/dub/dub.d index 9e022dc..b43d98d 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -383,7 +383,7 @@ } else { logInfo(`Generating test runner configuration '%s' for '%s' (%s).`, test_config, config, lbuildsettings.targetType); - BuildSettingsTemplate tcinfo = m_project.rootPackage.info.getConfiguration(config).buildSettings; + BuildSettingsTemplate tcinfo = m_project.rootPackage.recipe.getConfiguration(config).buildSettings; tcinfo.targetType = TargetType.executable; tcinfo.targetName = test_config; tcinfo.versions[""] ~= "VibeCustomMain"; // HACK for vibe.d's legacy main() behavior @@ -438,7 +438,7 @@ }); } } - m_project.rootPackage.info.configurations ~= ConfigurationInfo(test_config, tcinfo); + m_project.rootPackage.recipe.configurations ~= ConfigurationInfo(test_config, tcinfo); m_project = new Project(m_packageManager, m_project.rootPackage); settings.config = test_config; @@ -544,9 +544,9 @@ } if (options & FetchOptions.printOnly) { - if (existing && existing.vers != ver) + if (existing && existing.version_ != Version(ver)) logInfo("A new version for %s is available (%s -> %s). Run \"dub upgrade %s\" to switch.", - packageId, existing.vers, ver, packageId); + packageId, existing.version_, ver, packageId); return null; } @@ -633,7 +633,7 @@ // Retrieve packages to be removed. foreach(pack; m_packageManager.getPackageIterator(package_id)) - if ((wildcardOrEmpty || pack.vers == version_) && m_packageManager.isManagedPackage(pack)) + if ((wildcardOrEmpty || pack.version_ == Version(version_)) && m_packageManager.isManagedPackage(pack)) packages ~= pack; // Check validity of packages to be removed. @@ -647,7 +647,7 @@ ~ "'" ~ to!string(location_) ~ "'."); logError("Available versions:"); foreach(pack; packages) - logError(" %s", pack.vers); + logError(" %s", pack.version_); throw new Exception("Please specify a individual version using --version=... or use the" ~ " wildcard --version=" ~ RemoveVersionWildcard ~ " to remove all versions."); } @@ -656,9 +656,9 @@ foreach(pack; packages) { try { remove(pack, force_remove); - logInfo("Removed %s, version %s.", package_id, pack.vers); + logInfo("Removed %s, version %s.", package_id, pack.version_); } catch (Exception e) { - logError("Failed to remove %s %s: %s", package_id, pack.vers, e.msg); + logError("Failed to remove %s %s: %s", package_id, pack.version_, e.msg); logInfo("Continuing with other packages (if any)."); } } @@ -782,14 +782,14 @@ import std.path : extension; import dub.recipe.io : writePackageRecipe; - auto srcfile = m_project.rootPackage.packageInfoFilename; + auto srcfile = m_project.rootPackage.recipePath; auto srcext = srcfile[$-1].toString().extension; if (srcext == "."~destination_file_ext) { logInfo("Package format is already %s.", destination_file_ext); return; } - writePackageRecipe(srcfile[0 .. $-1] ~ ("dub."~destination_file_ext), m_project.rootPackage.info); + writePackageRecipe(srcfile[0 .. $-1] ~ ("dub."~destination_file_ext), m_project.rootPackage.recipe); removeFile(srcfile); } @@ -798,7 +798,7 @@ if (m_dryRun) return; // allow to choose a custom ddox tool - auto tool = m_project.rootPackage.info.ddoxTool; + auto tool = m_project.rootPackage.recipe.ddoxTool; if (tool.empty) tool = "ddox"; auto tool_pack = m_packageManager.getBestPackage(tool, ">=0.0.0"); @@ -821,7 +821,7 @@ settings.buildType = "debug"; settings.run = true; - auto filterargs = m_project.rootPackage.info.ddoxFilterArgs.dup; + auto filterargs = m_project.rootPackage.recipe.ddoxFilterArgs.dup; if (filterargs.empty) filterargs = ["--min-protection=Protected", "--only-documented"]; settings.runArgs = "filter" ~ filterargs ~ "docs.json"; @@ -1005,7 +1005,7 @@ { m_rootPackage = root; m_selectedVersions = selected_versions; - return super.resolve(TreeNode(root.name, Dependency(root.ver)), (m_options & UpgradeOptions.printUpgradesOnly) == 0); + return super.resolve(TreeNode(root.name, Dependency(root.version_)), (m_options & UpgradeOptions.printUpgradesOnly) == 0); } protected override Dependency[] getAllConfigs(string pack) @@ -1023,7 +1023,7 @@ logDiagnostic("Search for versions of %s (%s package suppliers)", pack, m_dub.m_packageSuppliers.length); Version[] versions; foreach (p; m_dub.packageManager.getPackageIterator(pack)) - versions ~= p.ver; + versions ~= p.version_; foreach (ps; m_dub.m_packageSuppliers) { try { @@ -1160,7 +1160,7 @@ if (!dep.path.empty) { try { auto ret = m_dub.packageManager.getOrLoadPackage(dep.path); - if (dep.matches(ret.ver)) return ret; + if (dep.matches(ret.version_)) return ret; } catch (Exception e) { logDiagnostic("Failed to load path based dependency %s: %s", name, e.msg); logDebug("Full error: %s", e.toString().sanitize); diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index cdcde08..dcdcced 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -148,7 +148,7 @@ auto target_path = pack.path ~ format(".dub/build/%s/", build_id); if (!settings.force && isUpToDate(target_path, buildsettings, settings.platform, pack, packages, additional_dep_files)) { - logInfo("%s %s: target for configuration \"%s\" is up to date.", pack.name, pack.vers, config); + logInfo("%s %s: target for configuration \"%s\" is up to date.", pack.name, pack.version_, config); logDiagnostic("Using existing build in %s.", target_path.toNativeString()); copyTargetFile(target_path, buildsettings, settings.platform); return true; @@ -164,7 +164,7 @@ // determine basic build properties auto generate_binary = !(buildsettings.options & BuildOption.syntaxOnly); - logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.vers, config); + logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.version_, config); if( buildsettings.preBuildCommands.length ){ logInfo("Running pre-build commands..."); @@ -232,7 +232,7 @@ runCommands(buildsettings.preBuildCommands); } - logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.vers, config); + logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.version_, config); logInfo("Running rdmd..."); logDiagnostic("rdmd %s", join(flags, " ")); @@ -261,7 +261,7 @@ f = fp.toNativeString(); } - logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.vers, config); + logInfo("%s %s: building configuration \"%s\"...", pack.name, pack.version_, config); // make all target/import paths relative string makeRelative(string path) { @@ -359,7 +359,7 @@ allfiles ~= buildsettings.stringImportFiles; // TODO: add library files foreach (p; packages) - allfiles ~= (p.packageInfoFilename != Path.init ? p : p.basePackage).packageInfoFilename.toNativeString(); + allfiles ~= (p.recipePath != Path.init ? p : p.basePackage).recipePath.toNativeString(); foreach (f; additional_dep_files) allfiles ~= f.toNativeString(); if (main_pack is m_project.rootPackage) allfiles ~= (main_pack.path ~ SelectedVersions.defaultFile).toNativeString(); diff --git a/source/dub/generators/visuald.d b/source/dub/generators/visuald.d index d9e324b..d1b87b4 100644 --- a/source/dub/generators/visuald.d +++ b/source/dub/generators/visuald.d @@ -188,8 +188,8 @@ } foreach (p; targets[packname].packages) - if (!p.packageInfoFilename.empty) - addFile(p.packageInfoFilename.toNativeString(), false); + if (!p.recipePath.empty) + addFile(p.recipePath.toNativeString(), false); if (files.targetType == TargetType.staticLibrary) foreach(s; files.sourceFiles.filter!(s => !isLinkerFile(s))) addFile(s, true); diff --git a/source/dub/package_.d b/source/dub/package_.d index 2ac1787..4f5b5f8 100644 --- a/source/dub/package_.d +++ b/source/dub/package_.d @@ -130,8 +130,8 @@ if (recipe.version_.length == 0) { logDiagnostic("Note: Failed to determine version of package %s at %s. Assuming ~master.", recipe.name, this.path.toNativeString()); // TODO: Assume unknown version here? - // recipe.version_ = Version.UNKNOWN.toString(); - recipe.version_ = Version.MASTER.toString(); + // recipe.version_ = Version.unknown.toString(); + recipe.version_ = Version.masterBranch.toString(); } else logDiagnostic("Determined package version using GIT: %s %s", recipe.name, recipe.version_); } @@ -280,7 +280,7 @@ /// ditto void storeInfo(Path path) const { - enforce(!ver.isUnknown, "Trying to store a package with an 'unknown' version, this is not supported."); + enforce(!version_.isUnknown, "Trying to store a package with an 'unknown' version, this is not supported."); auto filename = path ~ defaultPackageFilename; auto dstFile = openFile(filename.toNativeString(), FileMode.createTrunc); scope(exit) dstFile.close(); @@ -554,7 +554,7 @@ ret.configuration = config; ret.path = m_path.toNativeString(); ret.name = this.name; - ret.version_ = this.ver; + ret.version_ = this.version_; ret.description = m_info.description; ret.homepage = m_info.homepage; ret.authors = m_info.authors.dup; @@ -607,7 +607,7 @@ foreach (f; sourceFileTypes.byKey.array.sort()) { SourceFileDescription sf; sf.path = f; - sf.type = sourceFileTypes[f]; + sf.role = sourceFileTypes[f]; ret.files ~= sf; } @@ -689,7 +689,7 @@ private void simpleLint() const { if (m_parentPackage) { if (m_parentPackage.path != path) { - if (info.license.length && info.license != m_parentPackage.info.license) + if (this.recipe.license.length && this.recipe.license != m_parentPackage.recipe.license) logWarn("License in subpackage %s is different than it's parent package, this is discouraged.", name); } } diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 75bb95a..c92eece 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -107,7 +107,7 @@ } foreach (p; getPackageIterator(name)) - if (p.ver == ver) + if (p.version_ == ver) return p; return null; @@ -123,7 +123,7 @@ Package getPackage(string name, Version ver, Path path) { auto ret = getPackage(name, path); - if (!ret || ret.ver != ver) return null; + if (!ret || ret.version_ != ver) return null; return ret; } @@ -170,11 +170,11 @@ { Package ret; foreach (p; getPackageIterator(name)) - if (version_spec.matches(p.ver) && (!ret || p.ver > ret.ver)) + if (version_spec.matches(p.version_) && (!ret || p.version_ > ret.version_)) ret = p; if (enable_overrides && ret) { - if (auto ovr = getPackage(name, ret.ver)) + if (auto ovr = getPackage(name, ret.version_)) return ovr; } return ret; @@ -365,9 +365,9 @@ // overwrite dub.json (this one includes a version field) auto pack = new Package(destination, Path.init, null, package_info["version"].get!string); - if (pack.packageInfoFilename.head != defaultPackageFilename) + if (pack.recipePath.head != defaultPackageFilename) // Storeinfo saved a default file, this could be different to the file from the zip. - removeFile(pack.packageInfoFilename); + removeFile(pack.recipePath); pack.storeInfo(); addPackages(m_packages, pack); return pack; @@ -376,7 +376,7 @@ /// Removes the given the package. void remove(in Package pack, bool force_remove) { - logDebug("Remove %s, version %s, path '%s'", pack.name, pack.vers, pack.path); + logDebug("Remove %s, version %s, path '%s'", pack.name, pack.version_, pack.path); enforce(!pack.path.empty, "Cannot remove package "~pack.name~" without a path."); // remove package from repositories' list @@ -410,14 +410,14 @@ auto pack = new Package(path); enforce(pack.name.length, "The package has no name, defined in: " ~ path.toString()); if (verName.length) - pack.ver = Version(verName); + pack.version_ = Version(verName); // don't double-add packages Package[]* packs = &m_repositories[type].localPackages; foreach (p; *packs) { if (p.path == path) { - enforce(p.ver == pack.ver, "Adding the same local package twice with differing versions is not allowed."); - logInfo("Package is already registered: %s (version: %s)", p.name, p.ver); + enforce(p.version_ == pack.version_, "Adding the same local package twice with differing versions is not allowed."); + logInfo("Package is already registered: %s (version: %s)", p.name, p.version_); return p; } } @@ -426,7 +426,7 @@ writeLocalPackageList(type); - logInfo("Registered package: %s (version: %s)", pack.name, pack.ver); + logInfo("Registered package: %s (version: %s)", pack.name, pack.version_); return pack; } @@ -443,7 +443,7 @@ string[Version] removed; foreach_reverse( i; to_remove ) { - removed[(*packs)[i].ver] = (*packs)[i].name; + removed[(*packs)[i].version_] = (*packs)[i].name; *packs = (*packs)[0 .. i] ~ (*packs)[i+1 .. $]; } @@ -516,7 +516,7 @@ if (pp.name != name) logWarn("Local package at %s has different name than %s (%s)", path.toNativeString(), name, pp.name); - pp.ver = ver; + pp.version_ = ver; addPackages(packs, pp); } @@ -644,7 +644,7 @@ if (p.parentPackage) continue; // do not store sub packages auto entry = Json.emptyObject; entry["name"] = p.name; - entry["version"] = p.ver.toString(); + entry["version"] = p.version_.toString(); entry["path"] = p.path.toNativeString(); newlist ~= entry; } @@ -660,7 +660,7 @@ foreach (ovr; m_repositories[type].overrides) { auto jovr = Json.emptyObject; jovr.name = ovr.package_; - jovr["version"] = ovr.version_.versionString; + jovr["version"] = ovr.version_.versionSpec; if (!ovr.targetPath.empty) jovr.targetPath = ovr.targetPath.toNativeString(); else jovr.targetVersion = ovr.targetVersion.toString(); newlist ~= jovr; diff --git a/source/dub/project.d b/source/dub/project.d index f01da00..6e7383b 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -98,7 +98,7 @@ @property string[string] cachedPackagesIDs() const { string[string] pkgs; foreach(p; m_dependencies) - pkgs[p.name] = p.vers; + pkgs[p.name] = p.version_.toString(); return pkgs; } @@ -185,9 +185,9 @@ m_rootPackage.warnOnSpecialCompilerFlags(); string nameSuggestion() { string ret; - ret ~= `Please modify the "name" field in %s accordingly.`.format(m_rootPackage.packageInfoFilename.toNativeString()); - if (!m_rootPackage.info.buildSettings.targetName.length) { - if (m_rootPackage.packageInfoFilename.head.toString().endsWith(".sdl")) { + ret ~= `Please modify the "name" field in %s accordingly.`.format(m_rootPackage.recipePath.toNativeString()); + if (!m_rootPackage.recipe.buildSettings.targetName.length) { + if (m_rootPackage.recipePath.head.toString().endsWith(".sdl")) { ret ~= ` You can then add 'targetName "%s"' to keep the current executable name.`.format(m_rootPackage.name); } else { ret ~= ` You can then add '"targetName": "%s"' to keep the current executable name.`.format(m_rootPackage.name); @@ -197,7 +197,7 @@ } if (m_rootPackage.name != m_rootPackage.name.toLower()) { logWarn(`WARNING: DUB package names should always be lower case. %s`, nameSuggestion()); - } else if (!m_rootPackage.info.name.all!(ch => ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '_')) { + } else if (!m_rootPackage.recipe.name.all!(ch => ch >= 'a' && ch <= 'z' || ch >= '0' && ch <= '9' || ch == '-' || ch == '_')) { logWarn(`WARNING: DUB package names may only contain alphanumeric characters, ` ~ `as well as '-' and '_'. %s`, nameSuggestion()); } @@ -252,10 +252,10 @@ auto basename = getBasePackageName(name); if (name == m_rootPackage.basePackage.name) { - vspec = Dependency(m_rootPackage.ver); + vspec = Dependency(m_rootPackage.version_); p = m_rootPackage.basePackage; } else if (basename == m_rootPackage.basePackage.name) { - vspec = Dependency(m_rootPackage.ver); + vspec = Dependency(m_rootPackage.version_); try p = m_packageManager.getSubPackage(m_rootPackage.basePackage, getSubPackageName(name), false); catch (Exception e) { logDiagnostic("%sError getting sub package %s: %s", indent, name, e.msg); @@ -564,9 +564,9 @@ } /// Determines if the given dependency is already indirectly referenced by other dependencies of pack. - bool isRedundantDependency(in Package pack, in Package dependency) + deprecated bool isRedundantDependency(in Package pack, in Package dependency) const { - foreach (dep; pack.dependencies.byKey) { + foreach (dep; pack.recipe.dependencies.byKey) { auto dp = getDependency(dep, true); if (!dp) continue; if (dp is dependency) continue; @@ -1060,7 +1060,7 @@ const Package pack; const Dependency[string] issuer; - static Action get(string pkg, PlacementLocation location, in Dependency dep, Dependency[string] context, Version old_version = Version.UNKNOWN) + static Action get(string pkg, PlacementLocation location, in Dependency dep, Dependency[string] context, Version old_version = Version.unknown) { return Action(Type.fetch, pkg, location, dep, context, old_version); } @@ -1080,7 +1080,7 @@ return Action(Type.failure, pkg, PlacementLocation.user, dep, context); } - private this(Type id, string pkg, PlacementLocation location, in Dependency d, Dependency[string] issue, Version existing_version = Version.UNKNOWN) + private this(Type id, string pkg, PlacementLocation location, in Dependency d, Dependency[string] issue, Version existing_version = Version.unknown) { this.type = id; this.packageId = pkg; @@ -1095,7 +1095,7 @@ pack = pkg; type = id; packageId = pkg.name; - vers = cast(immutable)Dependency(pkg.ver); + vers = cast(immutable)Dependency(pkg.version_); issuer = issue; } diff --git a/source/dub/recipe/sdl.d b/source/dub/recipe/sdl.d index c282ac1..0b4f05b 100644 --- a/source/dub/recipe/sdl.d +++ b/source/dub/recipe/sdl.d @@ -168,7 +168,7 @@ auto pkg = expandPackageName(t.values[0].get!string, package_name, t); enforceSDL(pkg !in bs.dependencies, "The dependency '"~pkg~"' is specified more than once.", t); - Dependency dep = Dependency.ANY; + Dependency dep = Dependency.any; auto attrs = t.attributes; auto pv = "version" in attrs; @@ -231,7 +231,7 @@ foreach (pack, d; bs.dependencies) { Attribute[] attribs; if (d.path.length) attribs ~= new Attribute(null, "path", Value(d.path.toString())); - else attribs ~= new Attribute(null, "version", Value(d.versionString)); + else attribs ~= new Attribute(null, "version", Value(d.versionSpec)); if (d.optional) attribs ~= new Attribute(null, "optional", Value(true)); ret ~= new Tag(null, "dependency", [Value(pack)], attribs); } @@ -441,7 +441,7 @@ assert(rec.buildSettings.dependencies.length == 2); assert(rec.buildSettings.dependencies["projectname:subpackage1"].optional == false); assert(rec.buildSettings.dependencies["projectname:subpackage1"].path == Path(".")); - assert(rec.buildSettings.dependencies["somedep"].versionString == "1.0.0"); + assert(rec.buildSettings.dependencies["somedep"].versionSpec == "1.0.0"); assert(rec.buildSettings.dependencies["somedep"].optional == true); assert(rec.buildSettings.dependencies["somedep"].path.empty); assert(rec.buildSettings.systemDependencies == "system dependencies");