Merge pull request #806 from Blizzard/add-issemver

Add premake.isSemVer function
This commit is contained in:
Tom van Dijck 2017-06-18 15:11:32 -07:00 committed by GitHub
commit b86a9e4802

View File

@ -147,6 +147,14 @@
return false
end
-- try to parse semver, if it fails, it's not semver compatible and we cannot compare, in which case
-- we're going to ignore the checkVersion entirely, but warn.
if not premake.isSemVer(version) then
p.warn("'" .. version .. "' is not semver compatible, and cannot be compared against '" .. checks .. "'.");
return true
end
-- now compare the semver against the checks.
local function eq(a, b) return a == b end
local function le(a, b) return a <= b end
local function lt(a, b) return a < b end
@ -411,3 +419,13 @@
return string.format("%s(%d)", info.short_src, info.currentline)
end
end
---
-- check if version is semver.
---
function premake.isSemVer(version)
local sMajor, sMinor, sPatch, sPrereleaseAndBuild = version:match("^(%d+)%.?(%d*)%.?(%d*)(.-)$")
return (type(sMajor) == 'string')
end