Revision | 39457608e52ab2f21b66a184d136fcfcd7acdd93 (tree) |
---|---|
Zeit | 2023-05-21 12:04:46 |
Autor | Fs <Fsu0413@vip....> |
Commiter | Fs |
lua 5.4
@@ -1,13 +1,17 @@ | ||
1 | 1 | |
2 | +if string.sub(_VERSION, -3) ~= "5.4" then | |
3 | + fail = nil | |
4 | +end | |
5 | + | |
2 | 6 | local scriptFile = arg[0] |
3 | 7 | local n, n2 |
4 | 8 | repeat |
5 | 9 | n = n2 |
6 | 10 | n2 = string.find(scriptFile, "/", n and (n + 1) or 1) |
7 | - if n2 == nil then | |
11 | + if not n2 then | |
8 | 12 | n2 = string.find(scriptFile, "\\", n and (n + 1) or 1) |
9 | 13 | end |
10 | -until n2 == nil | |
14 | +until not n2 | |
11 | 15 | |
12 | 16 | scriptPath = (n and string.sub(scriptFile, 1, n - 1) or ".") |
13 | 17 |
@@ -1,4 +1,7 @@ | ||
1 | 1 | |
2 | +-- TODO: find a more sensible name for this module. | |
3 | +-- The version is not for a specific compiler, but rather a version number of a whole toolchain. | |
4 | + | |
2 | 5 | local compilerVer = {} |
3 | 6 | |
4 | 7 | local runCmdScript = function(script) |
@@ -31,7 +34,7 @@ compilerVer.parseVersionNum = function(str) | ||
31 | 34 | if #match > 0 then |
32 | 35 | return setmetatable(match, { __tostring = function(m) return m[1] .. "." .. m[2] .. "." .. m[3] end}) |
33 | 36 | end |
34 | - return nil | |
37 | + return fail | |
35 | 38 | end |
36 | 39 | |
37 | 40 | local runShScript = function(script) |
@@ -130,4 +133,45 @@ compilerVer.emcc = function(isWin, path) | ||
130 | 133 | return compilerVer.parseVersionNum(ret) |
131 | 134 | end |
132 | 135 | |
136 | +--[==[ | |
137 | +-- unused function. NDK version is still provided by Configuration. | |
138 | +compilerVer.ndk = function(_, path) | |
139 | + -- NDK r13+ have a file named "source.properties" in its path. | |
140 | + -- In this file there is an item calls "Pkg.Revision" which indicates the version of NDK itself. | |
141 | + | |
142 | + local file, err = io.open(path .. "/source.properties", "r") | |
143 | + | |
144 | + if not file then | |
145 | + return fail | |
146 | + end | |
147 | + | |
148 | + local major, minor | |
149 | + | |
150 | + for line in file:lines() do | |
151 | + major, minor = string.match(line, "^Pkg%.Revision = (%d+)%.(%d+)%.%d+$") | |
152 | + if major then | |
153 | + break | |
154 | + end | |
155 | + end | |
156 | + | |
157 | + file:close() | |
158 | + | |
159 | + if not major then | |
160 | + return fail | |
161 | + end | |
162 | + | |
163 | + local ndkMinorRevisionTable = { | |
164 | + "", | |
165 | + "b", | |
166 | + "c", | |
167 | + "d", | |
168 | + "e", | |
169 | + "f", -- no NDK versions ever reached this far, so.. | |
170 | + "g", | |
171 | + } | |
172 | + | |
173 | + return major .. ndkMinorRevisionTable[tonumber(minor) + 1] | |
174 | +end | |
175 | +]==] | |
176 | + | |
133 | 177 | return compilerVer |
@@ -972,7 +972,7 @@ local filenameAndToolFromUrl = function(url) | ||
972 | 972 | repeat |
973 | 973 | n = n2 |
974 | 974 | n2 = string.find(url, "/", n and (n + 1) or 1) |
975 | - until n2 == nil | |
975 | + until not n2 | |
976 | 976 | local target = string.sub(url, n + 1) |
977 | 977 | local tool = nil |
978 | 978 |
@@ -0,0 +1,85 @@ | ||
1 | + | |
2 | +local hostOsVer = {} | |
3 | + | |
4 | +hostOsVer.Windows = function() | |
5 | + local file, err = io.popen("cmd /c ver" , "r") | |
6 | + if not file then return fail, err end | |
7 | + | |
8 | + -- the version string is in the second line | |
9 | + file:read() | |
10 | + local line = file:read() | |
11 | + file:close() | |
12 | + | |
13 | + -- currently we are using only Windows 10+ | |
14 | + local major, minor, patch | |
15 | + string.gsub(line, "%[[^%d]+(%d+)%.(%d+)%.(%d+)[^%]]*%]", function(...) | |
16 | + major, minor, patch = ... | |
17 | + end) | |
18 | + | |
19 | + if not major then return fail, "pattern didn't match line " .. line end | |
20 | + | |
21 | + local prefix | |
22 | + | |
23 | + if tonumber(major) < 5 then | |
24 | + -- Windows 9x / ME / NT4.0 / pre-3.2, not supported | |
25 | + if tonumber(major) == 5 then | |
26 | + if tonumber(minor) == 0 then | |
27 | + prefix = "Windows 2000" | |
28 | + elseif tonumber(minor) == 1 or tonumber(minor) == 2 then | |
29 | + prefix = "Windows XP" | |
30 | + end | |
31 | + elseif tonumber(major) == 6 then | |
32 | + if tonumber(minor) == 0 then | |
33 | + prefix = "Windows Vista" | |
34 | + elseif tonumber(minor) == 1 then | |
35 | + prefix = "Windows 7" | |
36 | + elseif tonumber(minor) == 2 then | |
37 | + prefix = "Windows 8" | |
38 | + elseif tonumber(minor) == 3 then | |
39 | + prefix = "Windows 8.1" | |
40 | + elseif tonumber(minor) == 4 then | |
41 | + prefix = "Windows 10" | |
42 | + end | |
43 | + elseif tonumber(major) == 10 then | |
44 | + if tonumber(minor) == 0 then | |
45 | + -- first Windows 11 is build 10.0.22000.1 | |
46 | + if tonumber(patch) < 22000 then | |
47 | + prefix = "Windows 10" | |
48 | + else | |
49 | + prefix = "Windows 11" | |
50 | + end | |
51 | + end | |
52 | + end | |
53 | + | |
54 | + -- known Windows 10 / 11 codename | |
55 | + local codename = { | |
56 | + ["10240"] = "1507", | |
57 | + ["10586"] = "1511", | |
58 | + ["14393"] = "1607", -- or Windows Server 2016 | |
59 | + ["15063"] = "1703", | |
60 | + ["16299"] = "1709", | |
61 | + ["17134"] = "1803", | |
62 | + ["17763"] = "1809", -- or Windows Server 2019 | |
63 | + ["18362"] = "1903", | |
64 | + ["18363"] = "1909", | |
65 | + ["19041"] = "2004", | |
66 | + ["19042"] = "20H2", | |
67 | + ["19043"] = "21H1", | |
68 | + ["19044"] = "21H2", | |
69 | + ["19045"] = "22H2", -- final version of Windows 10 | |
70 | + | |
71 | + ["20348"] = "21H2", -- Windows Server 2022 only | |
72 | + ["20349"] = "22H2", -- Does this really exist? | |
73 | + | |
74 | + ["22000"] = "21H2", -- first version of Windows 11 | |
75 | + ["22621"] = "22H2", | |
76 | + } | |
77 | + | |
78 | + if not prefix then | |
79 | + return fail, "Windows version not supported " .. line | |
80 | + end | |
81 | + | |
82 | + return prefix .. " " .. major .. "." .. minor .. "." .. patch | |
83 | +end | |
84 | + | |
85 | +return hostOsVer |
@@ -527,19 +527,19 @@ conf.m3_3mal = { | ||
527 | 527 | |
528 | 528 | for name, value in pairs(conf) do |
529 | 529 | -- sanity check |
530 | - if value.name == nil then | |
530 | + if not value.name then | |
531 | 531 | io.stderr:write("no name for config " .. name .. "\n") |
532 | 532 | io.stderr:flush() |
533 | 533 | os.exit(1) |
534 | 534 | end |
535 | 535 | |
536 | - if value.mariadbVersion == nil then | |
536 | + if not value.mariadbVersion then | |
537 | 537 | io.stderr:write("no mariadbVersion for config " .. name .. "\n") |
538 | 538 | io.stderr:flush() |
539 | 539 | os.exit(1) |
540 | 540 | end |
541 | 541 | |
542 | - if value.host == nil then | |
542 | + if not value.host then | |
543 | 543 | io.stderr:write("no host for config " .. name .. "\n") |
544 | 544 | io.stderr:flush() |
545 | 545 | os.exit(1) |
@@ -901,19 +901,19 @@ conf.o3_0aaln527 = { | ||
901 | 901 | |
902 | 902 | for name, value in pairs(conf) do |
903 | 903 | -- sanity check |
904 | - if value.name == nil then | |
904 | + if not value.name then | |
905 | 905 | io.stderr:write("no name for config " .. name .. "\n") |
906 | 906 | io.stderr:flush() |
907 | 907 | os.exit(1) |
908 | 908 | end |
909 | 909 | |
910 | - if value.opensslVersion == nil then | |
910 | + if not value.opensslVersion then | |
911 | 911 | io.stderr:write("no opensslVersion for config " .. name .. "\n") |
912 | 912 | io.stderr:flush() |
913 | 913 | os.exit(1) |
914 | 914 | end |
915 | 915 | |
916 | - if value.host == nil then | |
916 | + if not value.host then | |
917 | 917 | io.stderr:write("no host for config " .. name .. "\n") |
918 | 918 | io.stderr:flush() |
919 | 919 | os.exit(1) |
@@ -5285,19 +5285,19 @@ end | ||
5285 | 5285 | |
5286 | 5286 | for name, value in pairs(conf) do |
5287 | 5287 | -- sanity check |
5288 | - if value.name == nil then | |
5288 | + if not value.name then | |
5289 | 5289 | io.stderr:write("no name for config " .. name .. "\n") |
5290 | 5290 | io.stderr:flush() |
5291 | 5291 | os.exit(1) |
5292 | 5292 | end |
5293 | 5293 | |
5294 | - if value.qtVersion == nil then | |
5294 | + if not value.qtVersion then | |
5295 | 5295 | io.stderr:write("no qtVersion for config " .. name .. "\n") |
5296 | 5296 | io.stderr:flush() |
5297 | 5297 | os.exit(1) |
5298 | 5298 | end |
5299 | 5299 | |
5300 | - if value.host == nil then | |
5300 | + if not value.host then | |
5301 | 5301 | io.stderr:write("no host for config " .. name .. "\n") |
5302 | 5302 | io.stderr:flush() |
5303 | 5303 | os.exit(1) |