scripts: Improve str_to_version again.

Don't treat hypen and dot as the same thing - it will cause issues with
pacakge revisions.  Cleaned up some Lua code as well.

Also show warnings about potentially uninitialised stuff with GCC 12,
just don't make them fatal errors.
This commit is contained in:
Vas Crabb 2022-05-17 03:16:54 +10:00
parent 1f8af0c190
commit a3ee45c94c
2 changed files with 20 additions and 16 deletions

View File

@ -995,7 +995,7 @@ endif
ifeq ($(OS),windows) ifeq ($(OS),windows)
ifeq (posix,$(SHELLTYPE)) ifeq (posix,$(SHELLTYPE))
GCC_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) -dumpversion 2> /dev/null) GCC_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) -dumpfullversion 2> /dev/null)
CLANG_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) --version 2> /dev/null| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$$/\1/" | head -n 1) CLANG_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) --version 2> /dev/null| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*$$/\1/" | head -n 1)
PYTHON_AVAILABLE := $(shell $(PYTHON) --version > /dev/null 2>&1 && echo python) PYTHON_AVAILABLE := $(shell $(PYTHON) --version > /dev/null 2>&1 && echo python)
GIT_AVAILABLE := $(shell git --version > /dev/null 2>&1 && echo git) GIT_AVAILABLE := $(shell git --version > /dev/null 2>&1 && echo git)

View File

@ -35,33 +35,37 @@ end
function str_to_version(str) function str_to_version(str)
local val = 0 local val = 0
if (str == nil or str == '') then if not str then
return val return val
end end
local cnt = 10000 local scale = 10000
for word in string.gmatch(str, '([^.-]+)') do for word, sep in str:gmatch('([^.-]+)([.-]?)') do
if(tonumber(word) == nil) then local part = tonumber(word)
if not part then
return val
end
val = val + tonumber(word) * scale
scale = scale // 100
if (scale == 0) or (sep ~= '.') then
return val return val
end end
val = val + tonumber(word) * cnt
cnt = cnt / 100
end end
return val return val
end end
function findfunction(x) function findfunction(x)
assert(type(x) == "string") assert(type(x) == "string")
local f=_G local f = _G
for v in x:gmatch("[^%.]+") do for v in x:gmatch("[^%.]+") do
if type(f) ~= "table" then if type(f) ~= "table" then
return nil, "looking for '"..v.."' expected table, not "..type(f) return nil, "looking for '" .. v .. "' expected table, not " .. type(f)
end end
f=f[v] f = f[v]
end end
if type(f) == "function" then if type(f) == "function" then
return f return f
else else
return nil, "expected function, not "..type(f) return nil, "expected function, not " .. type(f)
end end
end end
@ -1098,8 +1102,8 @@ end
end end
if version >= 120000 then if version >= 120000 then
buildoptions { buildoptions {
"-Wno-maybe-uninitialized", "-Wno-error=maybe-uninitialized",
"-Wno-uninitialized", -- netlist "-Wno-error=uninitialized", -- netlist
} }
end end
end end