Revision | c141989e152f4874cab63dfab6812920e5c6d0a6 (tree) |
---|---|
Zeit | 2024-04-06 09:21:01 |
Autor | Fs <Fsu0413@vip....> |
Commiter | Fs |
simplify "if not"
@@ -7,10 +7,7 @@ local scriptFile = arg[0] | ||
7 | 7 | local n, n2 |
8 | 8 | repeat |
9 | 9 | n = n2 |
10 | - n2 = string.find(scriptFile, "/", n and (n + 1) or 1) | |
11 | - if not n2 then | |
12 | - n2 = string.find(scriptFile, "\\", n and (n + 1) or 1) | |
13 | - end | |
10 | + n2 = string.find(scriptFile, "/", n and (n + 1) or 1) or string.find(scriptFile, "\\", n and (n + 1) or 1) | |
14 | 11 | until not n2 |
15 | 12 | |
16 | 13 | scriptPath = (n and string.sub(scriptFile, 1, n - 1) or ".") |
@@ -68,10 +68,7 @@ end | ||
68 | 68 | local gccCommon = function(isWin, executableName) |
69 | 69 | local script = "" |
70 | 70 | |
71 | - if not executableName then | |
72 | - executableName = "gcc" | |
73 | - end | |
74 | - | |
71 | + executableName = executableName or "gcc" | |
75 | 72 | script = script .. executableName .. " -dumpfullversion -dumpversion" |
76 | 73 | if isWin then |
77 | 74 | script = script .. "\r\n" |
@@ -982,18 +982,12 @@ gen.generateBuildCommand = function(self, para) | ||
982 | 982 | if para.download and type(para.download) == "table" then |
983 | 983 | for _, url in ipairs(para.download) do |
984 | 984 | local filename, tool = filenameAndToolFromUrl(url) |
985 | - if not paraCopy.DOWNLOADPACKAGE then | |
986 | - paraCopy.DOWNLOADPACKAGE = "" | |
987 | - end | |
985 | + paraCopy.DOWNLOADPACKAGE = paraCopy.DOWNLOADPACKAGE or "" | |
988 | 986 | paraCopy.DOWNLOADPACKAGE = paraCopy.DOWNLOADPACKAGE .. self[para.template].download .. " \"" .. filename .. "\" \"" .. url .. "\"\n" |
989 | - if not paraCopy.UNCOMPRESSPACKAGE then | |
990 | - paraCopy.UNCOMPRESSPACKAGE = "" | |
991 | - end | |
987 | + paraCopy.UNCOMPRESSPACKAGE = paraCopy.UNCOMPRESSPACKAGE or "" | |
992 | 988 | if tool then |
993 | 989 | paraCopy.UNCOMPRESSPACKAGE = paraCopy.UNCOMPRESSPACKAGE .. self[para.template].extract[tool] .. " \"" .. filename .. "\"\n" |
994 | - if not paraCopy.DELETEUNCOMPRESSED then | |
995 | - paraCopy.DELETEUNCOMPRESSED = "" | |
996 | - end | |
990 | + paraCopy.DELETEUNCOMPRESSED = paraCopy.DELETEUNCOMPRESSED or "" | |
997 | 991 | paraCopy.DELETEUNCOMPRESSED = paraCopy.DELETEUNCOMPRESSED .. self[para.template].delete .. " \"" .. filename .. "\"\n" |
998 | 992 | end |
999 | 993 | end |
@@ -1019,18 +1013,14 @@ gen.generateBuildCommand = function(self, para) | ||
1019 | 1013 | end |
1020 | 1014 | |
1021 | 1015 | local ret = string.gsub(template, "%&([%w_]+)%&", function(s) |
1022 | - if paraCopy[s] then | |
1023 | - return paraCopy[s] | |
1024 | - else | |
1025 | - return "" | |
1026 | - end | |
1016 | + return paraCopy[s] or "" | |
1027 | 1017 | end) |
1028 | 1018 | |
1029 | 1019 | return ret |
1030 | 1020 | end |
1031 | 1021 | |
1032 | 1022 | gen.dumpConfTable = function(self, para, indent) |
1033 | - if not indent then indent = 1 end | |
1023 | + indent = indent or 1 | |
1034 | 1024 | |
1035 | 1025 | local returnText = "{\n" |
1036 | 1026 | local keys = {} |
@@ -990,9 +990,7 @@ for name, value in pairs(conf) do | ||
990 | 990 | value.crossCompile = false |
991 | 991 | end |
992 | 992 | |
993 | - if not value.variant then | |
994 | - value.variant = {} | |
995 | - end | |
993 | + value.variant = value.variant or {} | |
996 | 994 | |
997 | 995 | value.binaryPackageUrlunix = "http://10.0.1.6:8080/job/MariaDB/job/" .. name .. "/lastSuccessfulBuild/artifact/buildDir/" .. value.name .. ".tar.xz" |
998 | 996 | value.sourcePackageUrlunix = "http://10.0.1.6/webdav/sources/mariadb-connector-c-" .. value.mariadbVersion .. "-src.tar.gz" |
@@ -1307,9 +1307,7 @@ for name, value in pairs(conf) do | ||
1307 | 1307 | value.crossCompile = false |
1308 | 1308 | end |
1309 | 1309 | |
1310 | - if not value.variant then | |
1311 | - value.variant = {} | |
1312 | - end | |
1310 | + value.variant = value.variant or {} | |
1313 | 1311 | |
1314 | 1312 | value.binaryPackageUrlunix = "http://10.0.1.6:8080/job/OpenSSL/job/" .. name .. "/lastSuccessfulBuild/artifact/buildDir/" .. value.name .. ".tar.xz" |
1315 | 1313 | value.sourcePackageUrlunix = "http://10.0.1.6/webdav/sources/openssl-" .. value.opensslVersion .. ".tar.gz" |
@@ -6775,9 +6775,7 @@ for name, value in pairs(conf) do | ||
6775 | 6775 | value.crossCompile = false |
6776 | 6776 | end |
6777 | 6777 | |
6778 | - if not value.variant then | |
6779 | - value.variant = {} | |
6780 | - end | |
6778 | + value.variant = value.variant or {} | |
6781 | 6779 | |
6782 | 6780 | local qtVersionSplit = split(value.qtVersion, ".") |
6783 | 6781 | local qtSourcePackagePrefix = "qt-everywhere-src-" |