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 (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)
PYTHON_AVAILABLE := $(shell $(PYTHON) --version > /dev/null 2>&1 && echo python)
GIT_AVAILABLE := $(shell git --version > /dev/null 2>&1 && echo git)

View File

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