From a3ee45c94cb02f1d40b42b70505966a6f51b8357 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 17 May 2022 03:16:54 +1000 Subject: 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. --- makefile | 2 +- scripts/genie.lua | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/makefile b/makefile index f4f3b9bf719..362d1f01db6 100644 --- a/makefile +++ b/makefile @@ -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) diff --git a/scripts/genie.lua b/scripts/genie.lua index f7b48fd3b05..9c02cca4b45 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -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 -- cgit v1.2.3