Reputation: 392
People keep trying to build my project with old versions of Dmd and Dub (0.9.2 instead of 1.0.0) and it does not work. Can I specify in the dub.json file the min required dub version?
Upvotes: 4
Views: 112
Reputation: 2168
These days dub allows you to specify toolchain requirements. See https://dub.pm/package-format-json.html#toolchain-requirements
In dub.json
you could do:
{
"name": "my-package",
"toolchainRequirements": {
"dub": ">=1.14.0",
"frontend": ">=2.069",
"gdc": "no"
}
}
Upvotes: 0
Reputation: 1127
Unfortunately you can't. See this issue for more details. Please make noise there ;-)
Two ideas how to workaround around this for now.
int main()
{
static if (__VERSION__ < 2069)
{
pragma(msg, "Your DMD version is outdated. Please update");
return 1;
}
...
}
2) Use preGenerateCommands = ['rdmd checkversions.d']
int main()
{
import std.process : execute;
import std.stdio : writeln;
auto ver = execute(["dub", "--version"]);
if (ver.status != 0)
{
writeln("Error: no dub installation found.");
}
else
{
import std.conv : to;
import std.regex : ctRegex, matchFirst;
auto ctr = ctRegex!`version ([0-9]+)[.]([0-9]+)[.]([0-9]+)`;
auto r = ver.output.matchFirst(ctr);
assert(r.length == 4, "version not found");
int major = r[1].to!int, minor = r[2].to!int, patch = r[3].to!int;
if (major < 2)
{
writeln(minor);
return 1;
}
}
}
Upvotes: 3