summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-03-29 22:55:28 +0800
committerruki <[email protected]>2026-03-29 22:55:28 +0800
commit8841ed9f7b427896f042abcfb3537dd731f6a923 (patch)
treed2cb01d00f1873851e86199deef19dda20c43702
parent1bccfc273af2b1d579d033324bca481e15c58653 (diff)
improve const limit codes
-rw-r--r--xmake/actions/build/build_files.lua3
-rw-r--r--xmake/actions/build/deprecated/build_files.lua3
-rw-r--r--xmake/actions/config/main.lua3
-rw-r--r--xmake/actions/test/main.lua9
-rw-r--r--xmake/core/base/interpreter.lua3
-rw-r--r--xmake/core/base/os.lua3
-rw-r--r--xmake/core/base/winos.lua3
-rw-r--r--xmake/core/project/package.lua3
-rw-r--r--xmake/core/project/target.lua3
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_directory.lua6
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_file.lua6
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_path.lua6
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_program.lua3
-rw-r--r--xmake/core/tool/builder.lua3
-rw-r--r--xmake/modules/cli/amalgamate.lua3
-rw-r--r--xmake/modules/core/tools/cl.lua6
-rw-r--r--xmake/modules/core/tools/cl/parse_deps_json.lua3
-rw-r--r--xmake/modules/core/tools/cl6x/parse_deps.lua3
-rw-r--r--xmake/modules/core/tools/cl_json/parse_deps.lua3
-rw-r--r--xmake/modules/core/tools/link/has_flags.lua3
-rw-r--r--xmake/modules/detect/sdks/find_dotnet.lua6
-rw-r--r--xmake/modules/lib/detect/has_flags.lua3
-rw-r--r--xmake/modules/net/proxy.lua3
-rw-r--r--xmake/modules/package/manager/apt/find_package.lua3
-rw-r--r--xmake/modules/package/manager/conda/find_package.lua3
-rw-r--r--xmake/modules/package/manager/nix/search_package.lua3
-rw-r--r--xmake/modules/package/manager/pacman/find_package.lua9
-rw-r--r--xmake/modules/package/manager/portage/find_package.lua3
-rw-r--r--xmake/modules/package/manager/vcpkg/find_package.lua9
-rw-r--r--xmake/modules/package/manager/zypper/find_package.lua3
-rw-r--r--xmake/modules/package/tools/autoconf.lua9
-rw-r--r--xmake/modules/package/tools/cmake.lua3
-rw-r--r--xmake/modules/package/tools/jom.lua3
-rw-r--r--xmake/modules/package/tools/make.lua3
-rw-r--r--xmake/modules/package/tools/meson.lua3
-rw-r--r--xmake/modules/package/tools/msbuild.lua3
-rw-r--r--xmake/modules/package/tools/nmake.lua3
-rw-r--r--xmake/modules/package/tools/xmake.lua3
-rw-r--r--xmake/modules/private/action/require/impl/actions/install.lua6
-rw-r--r--xmake/modules/private/action/require/impl/install_packages.lua3
-rw-r--r--xmake/modules/private/action/require/info.lua6
-rw-r--r--xmake/modules/private/action/run/runenvs.lua3
-rw-r--r--xmake/modules/private/async/jobpool.lua3
-rw-r--r--xmake/modules/private/service/remote_build/filesync.lua3
-rw-r--r--xmake/modules/private/utils/target.lua3
-rw-r--r--xmake/modules/private/utils/trim_trailing_spaces.lua3
-rw-r--r--xmake/modules/private/xrepo/action/env.lua3
-rw-r--r--xmake/modules/target/action/install/pkgconfig_importfiles.lua6
-rw-r--r--xmake/modules/utils/binary/deplibs.lua12
-rw-r--r--xmake/modules/utils/binary/rpath.lua3
-rw-r--r--xmake/plugins/format/main.lua3
-rw-r--r--xmake/plugins/pack/deb/main.lua3
-rw-r--r--xmake/plugins/pack/nsis/main.lua3
-rw-r--r--xmake/plugins/pack/runself/main.lua3
-rw-r--r--xmake/plugins/pack/srpm/main.lua3
-rw-r--r--xmake/plugins/pack/wix/main.lua3
-rw-r--r--xmake/plugins/project/make/makefile.lua6
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua3
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua3
-rw-r--r--xmake/plugins/project/vstudio/impl/vsutils.lua3
-rw-r--r--xmake/plugins/project/vsxmake/getinfo.lua3
-rw-r--r--xmake/plugins/show/lists/apis.lua3
-rw-r--r--xmake/rules/c++/modules/clang/support.lua6
-rw-r--r--xmake/rules/c++/modules/gcc/support.lua6
-rw-r--r--xmake/rules/c++/unity_build/unity_build.lua3
-rw-r--r--xmake/rules/nim/build/target.lua3
-rw-r--r--xmake/rules/platform/linux/module/driver_modules.lua3
-rw-r--r--xmake/rules/verilator/verilator.lua3
-rw-r--r--xmake/rules/wdk/load.lua3
-rw-r--r--xmake/rules/winsdk/mfc/mfc.lua3
70 files changed, 92 insertions, 184 deletions
diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua
index a30b85c1d..2b353fbe1 100644
--- a/xmake/actions/build/build_files.lua
+++ b/xmake/actions/build/build_files.lua
@@ -44,8 +44,7 @@ function _get_file_patterns(sourcefiles)
if excludes then
local _excludes = {}
for _, exclude in ipairs(excludes) do
- local exclude = exclude
- exclude = path.translate(exclude)
+ local exclude = path.translate(exclude)
exclude = path.pattern(exclude)
table.insert(_excludes, exclude)
end
diff --git a/xmake/actions/build/deprecated/build_files.lua b/xmake/actions/build/deprecated/build_files.lua
index d5b434a09..247dbdced 100644
--- a/xmake/actions/build/deprecated/build_files.lua
+++ b/xmake/actions/build/deprecated/build_files.lua
@@ -142,8 +142,7 @@ function _get_file_patterns(sourcefiles)
if excludes then
local _excludes = {}
for _, exclude in ipairs(excludes) do
- local exclude = exclude
- exclude = path.translate(exclude)
+ local exclude = path.translate(exclude)
exclude = path.pattern(exclude)
table.insert(_excludes, exclude)
end
diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua
index 83743021a..99019757b 100644
--- a/xmake/actions/config/main.lua
+++ b/xmake/actions/config/main.lua
@@ -292,8 +292,7 @@ force to build in current directory via run `xmake -P .`]], os.projectdir())
-- merge the project options after default options
for name, value in pairs(project.get("config")) do
- local value = value
- value = table.unwrap(value)
+ local value = table.unwrap(value)
assert(type(value) == "string" or type(value) == "boolean" or type(value) == "number", "set_config(%s): unsupported value type(%s)", name, type(value))
if not config.readonly(name) then
config.set(name, value)
diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua
index 4ce54f5bc..0a00b76f1 100644
--- a/xmake/actions/test/main.lua
+++ b/xmake/actions/test/main.lua
@@ -520,8 +520,7 @@ function get_tests()
local scriptdir = target:scriptdir()
target_new:name_set(target:name() .. "_" .. name)
for _, file in ipairs(extra.files) do
- local file = file
- file = path.absolute(file, scriptdir)
+ local file = path.absolute(file, scriptdir)
file = path.relative(file, os.projectdir())
target_new:add("files", file, {defines = extra.defines,
cflags = extra.cflags,
@@ -532,8 +531,7 @@ function get_tests()
project.target_add(target_new)
end
for _, file in ipairs(extra.remove_files) do
- local file = file
- file = path.absolute(file, scriptdir)
+ local file = path.absolute(file, scriptdir)
file = path.relative(file, os.projectdir())
target_new:remove("files", file)
end
@@ -588,8 +586,7 @@ function main()
if test_patterns then
local tests_new = {}
for _, pattern in ipairs(test_patterns) do
- local pattern = pattern
- pattern = "^" .. path.pattern(pattern) .. "$"
+ local pattern = "^" .. path.pattern(pattern) .. "$"
for name, testinfo in pairs(tests) do
if name:match(pattern) then
tests_new[name] = testinfo
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 332cbed06..bcf446309 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -462,8 +462,7 @@ function interpreter:_filter(values, level)
if table.is_dictionary(values) then
local results = {}
for key, value in pairs(values) do
- local key = key
- key = (type(key) == "string" and filter:handle(key) or key)
+ local key = (type(key) == "string" and filter:handle(key) or key)
if type(value) == "string" then
results[key] = filter:handle(value)
elseif type(value) == "table" and level < 1 then
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua
index 3ef59775c..005f18a70 100644
--- a/xmake/core/base/os.lua
+++ b/xmake/core/base/os.lua
@@ -437,8 +437,7 @@ function os.match(pattern, mode, opt)
if excludes then
local _excludes = {}
for _, exclude in ipairs(excludes) do
- local exclude = exclude
- exclude = path.translate(exclude)
+ local exclude = path.translate(exclude)
exclude = path.pattern(exclude)
table.insert(_excludes, exclude)
end
diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua
index 03994175f..17b0e5d6a 100644
--- a/xmake/core/base/winos.lua
+++ b/xmake/core/base/winos.lua
@@ -178,8 +178,7 @@ function winos.cmdargv(argv, opt)
local limit = 4096
local argn = 0
for _, arg in ipairs(argv) do
- local arg = arg
- arg = tostring(arg)
+ local arg = tostring(arg)
argn = argn + #arg
if argn > limit then
break
diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua
index 7546237b0..b990c11e3 100644
--- a/xmake/core/project/package.lua
+++ b/xmake/core/project/package.lua
@@ -351,8 +351,7 @@ function _instance:rules()
-- make rule instances
rules = {}
for rulename, ruleinfo in pairs(ruleinfos) do
- local rulename = rulename
- rulename = "@" .. self:name() .. "/" .. rulename
+ local rulename = "@" .. self:name() .. "/" .. rulename
local instance = rule.new(rulename, ruleinfo, {package = self})
if instance:script("load") then
utils.warning("we cannot add `on_load()` in package rule(%s), please use `on_config()` instead of it!", rulename)
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index fc47299c9..74b4bc034 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1876,8 +1876,7 @@ function _instance:filerules(sourcefile)
-- we can also get extensions from add_rules("xxx", {extensions = ".cpp"})
local rule_extensions = self:extraconf("rules", r:name(), "extensions") or r:get("extensions")
for _, extension in ipairs(table.wrap(rule_extensions)) do
- local extension = extension
- extension = extension:lower()
+ local extension = extension:lower()
key2rules[extension] = key2rules[extension] or {}
table.insert(key2rules[extension], r)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua b/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua
index 516a3e725..63392a751 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua
@@ -46,8 +46,7 @@ function sandbox_lib_detect_find_directory._expand_paths(paths)
_path = vformat(_path)
end
for _, _s_path in ipairs(table.wrap(_path)) do
- local _s_path = _s_path
- _s_path = tostring(_s_path)
+ local _s_path = tostring(_s_path)
if #_s_path > 0 then
table.insert(results, _s_path)
end
@@ -60,8 +59,7 @@ end
function sandbox_lib_detect_find_directory._normalize_suffixes(suffixes)
local results = {}
for _, suffix in ipairs(table.wrap(suffixes)) do
- local suffix = suffix
- suffix = tostring(suffix)
+ local suffix = tostring(suffix)
if #suffix > 0 then
table.insert(results, suffix)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
index b007713b6..e642f45b7 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua
@@ -51,8 +51,7 @@ function sandbox_lib_detect_find_file._expand_paths(paths)
end
end
for _, _s_path in ipairs(table.wrap(_path)) do
- local _s_path = _s_path
- _s_path = tostring(_s_path)
+ local _s_path = tostring(_s_path)
if #_s_path > 0 then
table.insert(results, _s_path)
end
@@ -65,8 +64,7 @@ end
function sandbox_lib_detect_find_file._normalize_suffixes(suffixes)
local results = {}
for _, suffix in ipairs(table.wrap(suffixes)) do
- local suffix = suffix
- suffix = tostring(suffix)
+ local suffix = tostring(suffix)
if #suffix > 0 then
table.insert(results, suffix)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua
index 23b6e26f7..159d7dbdc 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua
@@ -46,8 +46,7 @@ function sandbox_lib_detect_find_path._expand_paths(paths)
_path = vformat(_path)
end
for _, _s_path in ipairs(table.wrap(_path)) do
- local _s_path = _s_path
- _s_path = tostring(_s_path)
+ local _s_path = tostring(_s_path)
if #_s_path > 0 then
table.insert(results, _s_path)
end
@@ -60,8 +59,7 @@ end
function sandbox_lib_detect_find_path._normalize_suffixes(suffixes)
local results = {}
for _, suffix in ipairs(table.wrap(suffixes)) do
- local suffix = suffix
- suffix = tostring(suffix)
+ local suffix = tostring(suffix)
if #suffix > 0 then
table.insert(results, suffix)
end
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
index a3bb75064..0ca3f8d19 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua
@@ -270,8 +270,7 @@ function sandbox_lib_detect_find_program._find(name, paths, opt)
local ok, wherepaths = os.iorunv("where.exe", {program_name})
if ok and wherepaths then
for _, program_path in ipairs(wherepaths:split("\n")) do
- local program_path = program_path
- program_path = program_path:trim()
+ local program_path = program_path:trim()
if #program_path > 0 then
local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt)
if program_path_real then
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index a72733680..bfcc08874 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -165,8 +165,7 @@ function builder:_add_flags_from_flagkind(flags, target, flagkind, opt)
local targetflags = target:get(flagkind, opt)
local extraconf = target:extraconf(flagkind)
for _, flag in ipairs(table.wrap(targetflags)) do
- local flag = flag
- flag = target_utils.flag_belong_to_tool(flag, self, extraconf)
+ local flag = target_utils.flag_belong_to_tool(flag, self, extraconf)
if flag then
if extraconf then
local flagconf = extraconf[flag]
diff --git a/xmake/modules/cli/amalgamate.lua b/xmake/modules/cli/amalgamate.lua
index 4f771807c..b76f60b6e 100644
--- a/xmake/modules/cli/amalgamate.lua
+++ b/xmake/modules/cli/amalgamate.lua
@@ -89,8 +89,7 @@ function _generate_file(target, inputpaths, outputpath, uniqueid)
-- generate include graph
local gh = graph.new(true)
for idx, inputpath in ipairs(inputpaths) do
- local inputpath = inputpath
- inputpath = path.normalize(path.absolute(inputpath, os.projectdir()))
+ local inputpath = path.normalize(path.absolute(inputpath, os.projectdir()))
inputpaths[idx] = inputpath
gh:add_edge("__root__", inputpath)
end
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index c945e163b..02a562e06 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -704,8 +704,7 @@ function _show_warnings(self, output, sourcefile)
local has_warnings = false
local has_source_dependencies = _has_source_dependencies(self)
for _, line in ipairs(output:split("\n", {plain = true})) do
- local line = line
- line = line:rtrim()
+ local line = line:rtrim()
if #line > 0 then
local skip = false
@@ -808,8 +807,7 @@ function compile(self, sourcefile, objectfile, dependinfo, flags, opt)
else
-- filter includes notes: "Note: including file: xxx.h", @note maybe not english language
for _, line in ipairs(tostring(errors):split("\n", {plain = true})) do
- local line = line
- line = line:rtrim()
+ local line = line:rtrim()
if not parse_include.has_include_note(line) then
results = results .. line .. "\r\n"
end
diff --git a/xmake/modules/core/tools/cl/parse_deps_json.lua b/xmake/modules/core/tools/cl/parse_deps_json.lua
index a969fa12e..890868dcb 100644
--- a/xmake/modules/core/tools/cl/parse_deps_json.lua
+++ b/xmake/modules/core/tools/cl/parse_deps_json.lua
@@ -134,8 +134,7 @@ function main(depsdata)
local results = hashset.new()
local projectdir = os.projectdir():lower() -- we need to generate lower string, because json values are all lower
for _, includefile in ipairs(includes) do
- local includefile = includefile
- includefile = _normailize_dep(includefile, projectdir)
+ local includefile = _normailize_dep(includefile, projectdir)
if includefile then
results:insert(includefile)
end
diff --git a/xmake/modules/core/tools/cl6x/parse_deps.lua b/xmake/modules/core/tools/cl6x/parse_deps.lua
index 94a23bd9d..ef1b79860 100644
--- a/xmake/modules/core/tools/cl6x/parse_deps.lua
+++ b/xmake/modules/core/tools/cl6x/parse_deps.lua
@@ -65,8 +65,7 @@ function main(depsdata, opt)
local line = depsdata:rtrim() -- maybe there will be an empty newline at the end. so we trim it first
local plain = {plain = true}
for _, includefile in ipairs(line:split('\n', plain)) do -- it will trim all internal spaces without `{strict = true}`
- local includefile = includefile
- includefile = includefile:split(": ", plain)[2]
+ local includefile = includefile:split(": ", plain)[2]
if includefile and #includefile > 0 then
includefile = _normailize_dep(includefile, projectdir)
if includefile then
diff --git a/xmake/modules/core/tools/cl_json/parse_deps.lua b/xmake/modules/core/tools/cl_json/parse_deps.lua
index 0dff3cf11..29dc2c5eb 100644
--- a/xmake/modules/core/tools/cl_json/parse_deps.lua
+++ b/xmake/modules/core/tools/cl_json/parse_deps.lua
@@ -134,8 +134,7 @@ function main(depsdata)
local results = hashset.new()
local projectdir = os.projectdir():lower() -- we need to generate lower string, because json values are all lower
for _, includefile in ipairs(includes) do
- local includefile = includefile
- includefile = _normailize_dep(includefile, projectdir)
+ local includefile = _normailize_dep(includefile, projectdir)
if includefile then
results:insert(includefile)
end
diff --git a/xmake/modules/core/tools/link/has_flags.lua b/xmake/modules/core/tools/link/has_flags.lua
index 372118f39..80e7e2417 100644
--- a/xmake/modules/core/tools/link/has_flags.lua
+++ b/xmake/modules/core/tools/link/has_flags.lua
@@ -88,8 +88,7 @@ end
function _ignore_flags(flags)
local results = {}
for _, flag in ipairs(flags) do
- local flag = flag
- flag = flag:lower()
+ local flag = flag:lower()
if not flag:find("[%-/]def:.+%.def") and not flag:find("[%-/]export:") then
table.insert(results, flag)
end
diff --git a/xmake/modules/detect/sdks/find_dotnet.lua b/xmake/modules/detect/sdks/find_dotnet.lua
index 3afb06138..af17f1d65 100644
--- a/xmake/modules/detect/sdks/find_dotnet.lua
+++ b/xmake/modules/detect/sdks/find_dotnet.lua
@@ -49,8 +49,7 @@ function _find_dotnet_cli(sdkdir)
if sdklist then
local sdks = {}
for _, line in ipairs(sdklist:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
local ver, dir = line:match("^(%S+)%s+%[(.-)%]")
if ver and dir then
table.insert(sdks, {version = ver, directory = path.join(dir, ver)})
@@ -73,8 +72,7 @@ function _find_dotnet_cli(sdkdir)
if runtimelist then
local runtimes = {}
for _, line in ipairs(runtimelist:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
local name, ver = line:match("^(%S+)%s+(%S+)%s+%[")
if name and ver then
table.insert(runtimes, {name = name, version = ver})
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 61a44f8c1..a28b3e41a 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -106,8 +106,7 @@ function main(name, flags, opt)
-- split flag group, e.g. "-I /xxx" => {"-I", "/xxx"}
local results = {}
for _, flag in ipairs(checkflags) do
- local flag = flag
- flag = flag:trim()
+ local flag = flag:trim()
if #flag > 0 then
if flag:find(" ", 1, true) then
table.join2(results, os.argv(flag))
diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua
index 7a45da39d..a1e35977f 100644
--- a/xmake/modules/net/proxy.lua
+++ b/xmake/modules/net/proxy.lua
@@ -157,8 +157,7 @@ function config(url)
if host and proxy_hosts then
host = host:lower()
for _, proxy_host in ipairs(proxy_hosts) do
- local proxy_host = proxy_host
- proxy_host = proxy_host:lower()
+ local proxy_host = proxy_host:lower()
if host == proxy_hosts or host:match(_host_pattern(proxy_host)) then
return _global_proxy()
end
diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua
index 4e9f7b138..9f3941980 100644
--- a/xmake/modules/package/manager/apt/find_package.lua
+++ b/xmake/modules/package/manager/apt/find_package.lua
@@ -33,8 +33,7 @@ function _find_package(dpkg, name, opt)
local listinfo = try {function () return os.iorunv(dpkg.program, {"--listfiles", name}) end}
if listinfo then
for _, line in ipairs(listinfo:split('\n', {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
-- get includedirs
local pos = line:find("include/", 1, true)
diff --git a/xmake/modules/package/manager/conda/find_package.lua b/xmake/modules/package/manager/conda/find_package.lua
index b3f447bed..87ecd817b 100644
--- a/xmake/modules/package/manager/conda/find_package.lua
+++ b/xmake/modules/package/manager/conda/find_package.lua
@@ -107,8 +107,7 @@ function main(name, opt)
local result = nil
local packagedir = metainfo.extracted_package_dir
for _, line in ipairs(metainfo.files) do
- local line = line
- line = line:trim()
+ local line = line:trim()
-- get includedirs
local pos = line:find("include/", 1, true)
diff --git a/xmake/modules/package/manager/nix/search_package.lua b/xmake/modules/package/manager/nix/search_package.lua
index 60acd3ef3..e5e40aa8c 100644
--- a/xmake/modules/package/manager/nix/search_package.lua
+++ b/xmake/modules/package/manager/nix/search_package.lua
@@ -75,8 +75,7 @@ function _search_with_env(name)
-- nixpkgs.cmakeWithGui cmake-3.27.7
for _, line in ipairs(searchdata:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if line ~= "" then
local parts = line:split("%s+", {limit = 2})
if #parts >= 2 then
diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua
index cc84b6774..2a609505b 100644
--- a/xmake/modules/package/manager/pacman/find_package.lua
+++ b/xmake/modules/package/manager/pacman/find_package.lua
@@ -50,8 +50,7 @@ function _find_package_from_list(list, name, pacman, opt)
-- iterate over each file path inside the pacman package
local result = {}
for _, line in ipairs(list:split('\n', {plain = true})) do -- on msys cygpath should be used to convert local path to windows path
- local line = line
- line = line:trim():split('%s+')[2]
+ local line = line:trim():split('%s+')[2]
if line:find("/include/", 1, true) and (line:endswith(".h") or line:endswith(".hpp")) then
if not line:startswith("/usr/include/") then
if not (msystem and line:startswith("/" .. msystem .. "/include/")) then
@@ -134,8 +133,7 @@ function _find_libfiles_from_list(list, name, pacman, opt)
-- iterate over each file path inside the pacman package
local libfiles
for _, line in ipairs(list:split('\n', {plain = true})) do -- on msys cygpath should be used to convert local path to windows path
- local line = line
- line = line:trim():split('%s+')[2]
+ local line = line:trim():split('%s+')[2]
if line:endswith(".dll.a") then -- only for mingw
local apath = path.join(pathtomsys, line)
apath = apath:trim()
@@ -187,8 +185,7 @@ function main(name, opt)
local linkdirs = {}
local pkgconfig_files = {}
for _, line in ipairs(list:split('\n', {plain = true})) do
- local line = line
- line = line:trim():split('%s+')[2]
+ local line = line:trim():split('%s+')[2]
if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then
table.insert(pkgconfig_files, line)
end
diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua
index 7fb560a28..6f4feef48 100644
--- a/xmake/modules/package/manager/portage/find_package.lua
+++ b/xmake/modules/package/manager/portage/find_package.lua
@@ -63,8 +63,7 @@ function main(name, opt)
local has_includes = false
local pkgconfig_files = {}
for _, line in ipairs(list) do
- local line = line
- line = line:trim():split('%s+')[1]
+ local line = line:trim():split('%s+')[1]
if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then
pkgconfig_files[path.basename(line)] = line
end
diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua
index 7d0f44e12..d14092854 100644
--- a/xmake/modules/package/manager/vcpkg/find_package.lua
+++ b/xmake/modules/package/manager/vcpkg/find_package.lua
@@ -35,16 +35,14 @@ function _required_features(name, configs)
local features_str = name:match("%[(.-)%]")
if features_str then
for _, feature in ipairs(features_str:split(",", {plain = true})) do
- local feature = feature
- feature = feature:trim()
+ local feature = feature:trim()
if #feature > 0 then
table.insert(features, feature)
end
end
end
for _, feature in ipairs(table.wrap(configs and configs.features)) do
- local feature = feature
- feature = tostring(feature):trim()
+ local feature = tostring(feature):trim()
if #feature > 0 then
table.insert(features, feature)
end
@@ -104,8 +102,7 @@ function _get_package_info(name, triplet, infodirs, arch, plat, mode)
local info = io.readfile(infofile)
if info then
for _, line in ipairs(info:split('\n')) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if plat == "windows" then
line = line:lower()
end
diff --git a/xmake/modules/package/manager/zypper/find_package.lua b/xmake/modules/package/manager/zypper/find_package.lua
index e5a05c5ab..e44a70a9d 100644
--- a/xmake/modules/package/manager/zypper/find_package.lua
+++ b/xmake/modules/package/manager/zypper/find_package.lua
@@ -38,8 +38,7 @@ function _find_package(rpm, name, opt)
end }
if listinfo then
for _, line in ipairs(listinfo:split('\n', { plain = true })) do
- local line = line
- line = line:trim()
+ local line = line:trim()
-- get includedirs
local pos = line:find("include/", 1, true)
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 43c7d902b..181fc8295 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -667,8 +667,7 @@ function configure(package, configs, opt)
-- pass configurations
local argv = {}
for name, value in pairs(_get_configs(package, configs)) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
@@ -722,8 +721,7 @@ function build(package, configs, opt)
end
if opt.makeconfigs then
for name, value in pairs(opt.makeconfigs) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
@@ -750,8 +748,7 @@ function install(package, configs, opt)
end
if opt.makeconfigs then
for name, value in pairs(opt.makeconfigs) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 2417a0b8a..360a0f700 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -1307,8 +1307,7 @@ function configure(package, configs, opt)
-- pass configurations
local argv = {}
for name, value in pairs(_get_configs(package, configs, opt)) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if type(name) == "number" then
if value ~= "" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/jom.lua b/xmake/modules/package/tools/jom.lua
index 26dbb014e..470502300 100644
--- a/xmake/modules/package/tools/jom.lua
+++ b/xmake/modules/package/tools/jom.lua
@@ -69,8 +69,7 @@ function build(package, configs, opt)
end
configs = table.join(jom_argv, configs)
for name, value in pairs(configs) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua
index f7f4f2dd7..13869a236 100644
--- a/xmake/modules/package/tools/make.lua
+++ b/xmake/modules/package/tools/make.lua
@@ -138,8 +138,7 @@ function build(package, configs, opt)
table.insert(argv, "V=1")
end
for name, value in pairs(configs) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua
index 010e410db..14492cde7 100644
--- a/xmake/modules/package/tools/meson.lua
+++ b/xmake/modules/package/tools/meson.lua
@@ -566,8 +566,7 @@ function generate(package, configs, opt)
-- TODO: support more backends https://mesonbuild.com/Commands.html#setup
local argv = {"setup"}
for name, value in pairs(_get_configs(package, configs, opt)) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/msbuild.lua b/xmake/modules/package/tools/msbuild.lua
index 6152560a2..d36be1b6a 100644
--- a/xmake/modules/package/tools/msbuild.lua
+++ b/xmake/modules/package/tools/msbuild.lua
@@ -95,8 +95,7 @@ function build(package, configs, opt)
-- pass configurations
local argv = {}
for name, value in pairs(_get_configs(package, configs, opt)) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua
index fe2b96956..78ff8d9bb 100644
--- a/xmake/modules/package/tools/nmake.lua
+++ b/xmake/modules/package/tools/nmake.lua
@@ -57,8 +57,7 @@ function build(package, configs, opt)
table.insert(argv, "VERBOSE=1")
end
for name, value in pairs(configs) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if value ~= "" then
if type(name) == "number" then
table.insert(argv, value)
diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua
index 3ccd09298..133de5f39 100644
--- a/xmake/modules/package/tools/xmake.lua
+++ b/xmake/modules/package/tools/xmake.lua
@@ -539,8 +539,7 @@ function install(package, configs, opt)
table.insert(argv, "-y")
table.insert(argv, "-c")
for name, value in pairs(_get_configs(package, configs, opt)) do
- local value = value
- value = tostring(value):trim()
+ local value = tostring(value):trim()
if type(name) == "number" then
if value ~= "" then
table.insert(argv, value)
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua
index 206c2ae52..a987ff8e9 100644
--- a/xmake/modules/private/action/require/impl/actions/install.lua
+++ b/xmake/modules/private/action/require/impl/actions/install.lua
@@ -79,8 +79,7 @@ function _patch_pkgconfig(package)
-- get libs
local libs = ""
for _, linkdir in ipairs(fetchinfo.linkdirs) do
- local linkdir = linkdir
- linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true})
+ local linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true})
if linkdir ~= "${exec_prefix}/lib" then
libs = libs .. " -L" .. linkdir
end
@@ -96,8 +95,7 @@ function _patch_pkgconfig(package)
-- cflags
local cflags = ""
for _, includedir in ipairs(fetchinfo.includedirs or fetchinfo.sysincludedirs) do
- local includedir = includedir
- includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true})
+ local includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true})
if includedir ~= "${prefix}/include" then
cflags = cflags .. " -I" .. includedir
end
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua
index 613afd5e8..6d6a66d03 100644
--- a/xmake/modules/private/action/require/impl/install_packages.lua
+++ b/xmake/modules/private/action/require/impl/install_packages.lua
@@ -152,8 +152,7 @@ function _get_confirm_from_3rd(packages)
local confirmed_extpackages = {}
if result and result ~= "n" then
for _, idx in ipairs(result:split(',')) do
- local idx = idx
- idx = tonumber(idx)
+ local idx = tonumber(idx)
if extpackages_list[idx] then
table.insert(confirmed_extpackages, extpackages_list[idx])
end
diff --git a/xmake/modules/private/action/require/info.lua b/xmake/modules/private/action/require/info.lua
index 84247d456..4ef702a2c 100644
--- a/xmake/modules/private/action/require/info.lua
+++ b/xmake/modules/private/action/require/info.lua
@@ -165,8 +165,7 @@ function main(requires_raw)
cprint(" -> ${color.dump.string_quote}searchdirs${clear}: %s", table.concat(table.wrap(core_package.searchdirs()), path.envsep()))
local searchnames = hashset.new()
for _, url in ipairs(urls) do
- local url = url
- url = filter.handle(url, instance)
+ local url = filter.handle(url, instance)
if git.checkurl(url) then
searchnames:insert(instance:name() .. archive.extension(url) .. " ${dim}(git)${clear}")
searchnames:insert(path.basename(url_filename(url)) .. " ${dim}(git)${clear}")
@@ -194,8 +193,7 @@ function main(requires_raw)
local fetchinfo = instance:fetch()
if fetchinfo then
for name, info in pairs(fetchinfo) do
- local info = info
- info = table.unwrap(info)
+ local info = table.unwrap(info)
if type(info) ~= "table" then
info = tostring(info)
end
diff --git a/xmake/modules/private/action/run/runenvs.lua b/xmake/modules/private/action/run/runenvs.lua
index 32c6141fd..dfcd181b7 100644
--- a/xmake/modules/private/action/run/runenvs.lua
+++ b/xmake/modules/private/action/run/runenvs.lua
@@ -98,8 +98,7 @@ function _add_target_pkgenvs(addenvs, target, targets_added)
local pkgenvs = target:pkgenvs()
if pkgenvs then
for name, values in pairs(pkgenvs) do
- local values = values
- values = path.splitenv(values)
+ local values = path.splitenv(values)
local oldenvs = addenvs[name]
if oldenvs then
table.join2(oldenvs, values)
diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua
index 91c70cd78..b3ee5893b 100644
--- a/xmake/modules/private/async/jobpool.lua
+++ b/xmake/modules/private/async/jobpool.lua
@@ -269,8 +269,7 @@ function jobpool:_gentree(job, refs)
-- strip tree
local smalltree = hashset.new()
for _, item in ipairs(tree) do
- local item = item
- item = table.unwrap(item)
+ local item = table.unwrap(item)
if smalltree:size() < 16 or type(item) == "table" then
smalltree:insert(item)
else
diff --git a/xmake/modules/private/service/remote_build/filesync.lua b/xmake/modules/private/service/remote_build/filesync.lua
index 0bea69765..fa9ba1fde 100644
--- a/xmake/modules/private/service/remote_build/filesync.lua
+++ b/xmake/modules/private/service/remote_build/filesync.lua
@@ -137,8 +137,7 @@ function filesync:_ignorefiles_load(ignorefiles)
local gitroot = path.directory(gitignore_file)
local gitignore = io.open(gitignore_file, "r")
for line in gitignore:lines() do
- local line = line
- line = line:trim()
+ local line = line:trim()
if #line > 0 and not line:startswith("#") then
local filepath = path.join(gitroot, line)
local pattern = path.relative(filepath, rootdir)
diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua
index 501916832..8c9d8153e 100644
--- a/xmake/modules/private/utils/target.lua
+++ b/xmake/modules/private/utils/target.lua
@@ -114,8 +114,7 @@ function translate_flags_in_tool(target, flagkind, flags)
--
local result = {}
for _, flag in ipairs(flags) do
- local flag = flag
- flag = flag_belong_to_tool(flag, toolinst, extraconf)
+ local flag = flag_belong_to_tool(flag, toolinst, extraconf)
if flag then
table.insert(result, flag)
end
diff --git a/xmake/modules/private/utils/trim_trailing_spaces.lua b/xmake/modules/private/utils/trim_trailing_spaces.lua
index 5f879bb22..155c36c92 100644
--- a/xmake/modules/private/utils/trim_trailing_spaces.lua
+++ b/xmake/modules/private/utils/trim_trailing_spaces.lua
@@ -24,8 +24,7 @@ function main(pattern)
if filedata then
local filedata2 = {}
for _, line in ipairs(filedata:split('\n', {strict = true})) do
- local line = line
- line = line:rtrim()
+ local line = line:rtrim()
table.insert(filedata2, line)
end
io.writefile(filepath, table.concat(filedata2, "\n"))
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua
index bff00d57a..f42d079b6 100644
--- a/xmake/modules/private/xrepo/action/env.lua
+++ b/xmake/modules/private/xrepo/action/env.lua
@@ -149,8 +149,7 @@ function _get_boundenvs(opt)
if bind then
local envfiles = _get_envfiles()
for _, binditem in ipairs(bind:split(',', {plain = true})) do
- local binditem = binditem
- binditem = binditem:trim()
+ local binditem = binditem:trim()
if envfiles[binditem] then
table.insert(files, envfiles[binditem])
else
diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
index 77b6a21ec..74e0c523c 100644
--- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua
+++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua
@@ -46,8 +46,7 @@ function main(target, opt)
-- get libs
local libs = ""
for _, linkdir in ipairs(linkdirs) do
- local linkdir = linkdir
- linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true})
+ local linkdir = path.unix(path.normalize(linkdir)):replace(installdir, "${exec_prefix}", {plain = true})
if linkdir ~= "${exec_prefix}/lib" then
libs = libs .. " -L" .. linkdir
end
@@ -63,8 +62,7 @@ function main(target, opt)
-- get cflags
local cflags = ""
for _, includedir in ipairs(includedirs) do
- local includedir = includedir
- includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true})
+ local includedir = path.unix(path.normalize(includedir)):replace(installdir, "${prefix}", {plain = true})
if includedir ~= "${prefix}/include" then
cflags = cflags .. " -I" .. includedir
end
diff --git a/xmake/modules/utils/binary/deplibs.lua b/xmake/modules/utils/binary/deplibs.lua
index e1a9a776d..56029ef20 100644
--- a/xmake/modules/utils/binary/deplibs.lua
+++ b/xmake/modules/utils/binary/deplibs.lua
@@ -44,8 +44,7 @@ function _get_depends_by_dumpbin(binaryfile, opt)
local result = try { function () return os.iorunv(dumpbin.program, {"/dependents", "/nologo", binaryfile}) end }
if result then
for _, line in ipairs(result:split("\n")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if not line:startswith("Dump of file") and line:endswith(".dll") then
depends = depends or {}
table.insert(depends, line)
@@ -72,8 +71,7 @@ function _get_depends_by_objdump(binaryfile, opt)
local result = try { function () return os.iorunv(objdump.program, argv) end }
if result then
for _, line in ipairs(result:split("\n")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if not line:endswith(":") then
if plat == "windows" or plat == "mingw" then
if line:startswith("DLL Name:") then
@@ -205,8 +203,7 @@ function _get_depends_by_otool(binaryfile, opt)
local result = try { function () return os.iorunv(otool.program, {"-L", binaryfile}) end }
if result then
for _, line in ipairs(result:split("\n")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if not line:endswith(":") then
local filename = line:match(".-%.dylib") or line:match(".-%.framework")
if filename then
@@ -348,8 +345,7 @@ function _get_plain_depends(binaryfile, opt)
if depends and opt.resolve_path then
local result = {}
for _, dependfile in ipairs(depends) do
- local dependfile = dependfile
- dependfile = _resolve_filepath(binaryfile, dependfile, opt)
+ local dependfile = _resolve_filepath(binaryfile, dependfile, opt)
if dependfile then
table.insert(result, dependfile)
end
diff --git a/xmake/modules/utils/binary/rpath.lua b/xmake/modules/utils/binary/rpath.lua
index 6ee17e98d..2e74443ad 100644
--- a/xmake/modules/utils/binary/rpath.lua
+++ b/xmake/modules/utils/binary/rpath.lua
@@ -55,8 +55,7 @@ function _get_rpath_list_by_objdump(binaryfile, opt)
if result then
local cmd = false
for _, line in ipairs(result:split("\n")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if plat == "macosx" or plat == "iphoneos" or plat == "appletvos" or plat == "watchos" then
if not cmd and line:find("cmd LC_RPATH", 1, true) then
cmd = true
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 5320df979..fe05d86c6 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -63,8 +63,7 @@ function _get_file_patterns(sourcefiles)
if excludes then
local _excludes = {}
for _, exclude in ipairs(excludes) do
- local exclude = exclude
- exclude = path.translate(exclude)
+ local exclude = path.translate(exclude)
exclude = path.pattern(exclude)
table.insert(_excludes, exclude)
end
diff --git a/xmake/plugins/pack/deb/main.lua b/xmake/plugins/pack/deb/main.lua
index 930dcb225..3f7fa4e82 100644
--- a/xmake/plugins/pack/deb/main.lua
+++ b/xmake/plugins/pack/deb/main.lua
@@ -207,8 +207,7 @@ function _pack_deb(debuild, package)
end)
end
for _, name in ipairs(specvars_names) do
- local name = name
- name = name:trim()
+ local name = name:trim()
if specvars_values[name] == nil then
local value = specvars[name]
if type(value) == "function" then
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index f566296c5..420a1458c 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -284,8 +284,7 @@ function _pack_nsis(makensis, package)
table.insert(specvars_names, name)
end, {encoding = "ansi"})
for _, name in ipairs(specvars_names) do
- local name = name
- name = name:trim()
+ local name = name:trim()
if specvars_values[name] == nil then
local value = specvars[name]
if type(value) == "function" then
diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua
index 32b376684..42eb8bc67 100644
--- a/xmake/plugins/pack/runself/main.lua
+++ b/xmake/plugins/pack/runself/main.lua
@@ -123,8 +123,7 @@ function _pack_runself(makeself, package)
table.insert(specvars_names, name)
end)
for _, name in ipairs(specvars_names) do
- local name = name
- name = name:trim()
+ local name = name:trim()
if specvars_values[name] == nil then
local value = specvars[name]
if type(value) == "function" then
diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua
index dec2dfdfa..49e27fca3 100644
--- a/xmake/plugins/pack/srpm/main.lua
+++ b/xmake/plugins/pack/srpm/main.lua
@@ -219,8 +219,7 @@ function _pack_srpm(rpmbuild, package)
table.insert(specvars_names, name)
end)
for _, name in ipairs(specvars_names) do
- local name = name
- name = name:trim()
+ local name = name:trim()
if specvars_values[name] == nil then
local value = specvars[name]
if type(value) == "function" then
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index a3055bc0c..e12461883 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -302,8 +302,7 @@ function _pack_wix(wix, package)
table.insert(specvars_names, name)
end)
for _, name in ipairs(specvars_names) do
- local name = name
- name = name:trim()
+ local name = name:trim()
if specvars_values[name] == nil then
local value = specvars[name]
if type(value) == "function" then
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua
index d58db7051..ed179e177 100644
--- a/xmake/plugins/project/make/makefile.lua
+++ b/xmake/plugins/project/make/makefile.lua
@@ -276,8 +276,7 @@ end
-- remove the given files or directories
function _add_remove_files(makefile, filedirs, outputdir)
for _, filedir in ipairs(filedirs) do
- local filedir = filedir
- filedir = _get_relative_unix_path(filedir, outputdir)
+ local filedir = _get_relative_unix_path(filedir, outputdir)
makefile:print("\t%s", _get_cmd_rm(filedir))
end
end
@@ -555,8 +554,7 @@ function _add_build_target(makefile, target, targetflags, outputdir)
local objectfiles = target:objectfiles()
local objectfiles_translated = {}
for _, objectfile in ipairs(objectfiles) do
- local objectfile = objectfile
- objectfile = _get_relative_unix_path(objectfile, outputdir)
+ local objectfile = _get_relative_unix_path(objectfile, outputdir)
table.insert(objectfiles_translated, objectfile)
makefile:write(" " .. objectfile)
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index 78407021e..f1f44c3a8 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -935,8 +935,7 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo)
local cstandard
local cxxstandard
for _, lang in pairs(targetinfo.languages) do
- local lang = lang
- lang = lang:replace("c++", "cxx", {plain = true})
+ local lang = lang:replace("c++", "cxx", {plain = true})
if cxxlangflags[lang] then
cxxstandard = cxxlangflags[lang]
elseif clangflags[lang] then
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
index 2ac7aef5d..ed9002662 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
@@ -85,8 +85,7 @@ function _make_filter(filepath, target, vcxprojdir)
local files = extraconf.files or "**"
local mode = extraconf.mode
for _, filepattern in ipairs(files) do
- local filepattern = filepattern
- filepattern = path.pattern(path.absolute(path.join(rootdir, filepattern)))
+ local filepattern = path.pattern(path.absolute(path.join(rootdir, filepattern)))
if filepath:match(filepattern) then
if mode == "plain" then
filter = path.normalize(filegroup)
diff --git a/xmake/plugins/project/vstudio/impl/vsutils.lua b/xmake/plugins/project/vstudio/impl/vsutils.lua
index 984dd609e..30832ae3f 100644
--- a/xmake/plugins/project/vstudio/impl/vsutils.lua
+++ b/xmake/plugins/project/vstudio/impl/vsutils.lua
@@ -79,8 +79,7 @@ function reset_config_and_caches(mode, arch)
end
-- merge the project options after default options
for name, value in pairs(project.get("config")) do
- local value = value
- value = table.unwrap(value)
+ local value = table.unwrap(value)
assert(type(value) == "string" or type(value) == "boolean" or type(value) == "number", "set_config(%s): unsupported value type(%s)", name, type(value))
if not config.readonly(name) then
config.set(name, value)
diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua
index 9e943e49c..9395657fd 100644
--- a/xmake/plugins/project/vsxmake/getinfo.lua
+++ b/xmake/plugins/project/vsxmake/getinfo.lua
@@ -352,8 +352,7 @@ function _make_filter(filepath, target, vcxprojdir)
local files = extraconf.files or "**"
local mode = extraconf.mode
for _, filepattern in ipairs(files) do
- local filepattern = filepattern
- filepattern = path.pattern(path.absolute(path.join(rootdir, filepattern)))
+ local filepattern = path.pattern(path.absolute(path.join(rootdir, filepattern)))
if filepath:match(filepattern) then
if mode == "plain" then
filter = path.normalize(filegroup)
diff --git a/xmake/plugins/show/lists/apis.lua b/xmake/plugins/show/lists/apis.lua
index 84c2ab441..475535a1e 100644
--- a/xmake/plugins/show/lists/apis.lua
+++ b/xmake/plugins/show/lists/apis.lua
@@ -289,8 +289,7 @@ function script_extension_module_apis()
local result = {}
local moduledirs = module.directories()
for _, moduledir in ipairs(moduledirs) do
- local moduledir = moduledir
- moduledir = path.absolute(moduledir)
+ local moduledir = path.absolute(moduledir)
local modulefiles = os.files(path.join(moduledir, "**.lua|**/xmake.lua|private/**.lua|core/tools/**.lua|detect/tools/**.lua"))
if modulefiles then
for _, modulefile in ipairs(modulefiles) do
diff --git a/xmake/rules/c++/modules/clang/support.lua b/xmake/rules/c++/modules/clang/support.lua
index d0e73b304..b1699d21a 100644
--- a/xmake/rules/c++/modules/clang/support.lua
+++ b/xmake/rules/c++/modules/clang/support.lua
@@ -49,8 +49,7 @@ function _get_toolchain_includedirs_for_stlheaders(target, includedirs, clang)
local result = try {function () return os.iorunv(clang, argv, {envs = compinst:runenvs()}) end}
if result then
for _, line in ipairs(result:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if line:startswith("#") and line:find("/vector\"", 1, true) then
local includedir = line:match("\"(.+)/vector\"")
if includedir and os.isdir(includedir) then
@@ -165,8 +164,7 @@ function toolchain_includedirs(target)
local _, result = try {function () return os.iorunv(clang, table.join({"-E", "-Wp,-v", "-xc++", os.nuldev()}, runtime_flag or {})) end}
if result then
for _, line in ipairs(result:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if os.isdir(line) then
table.insert(includedirs, path.normalize(line))
elseif line:startswith("End") then
diff --git a/xmake/rules/c++/modules/gcc/support.lua b/xmake/rules/c++/modules/gcc/support.lua
index 62cdd37f9..1204d207d 100644
--- a/xmake/rules/c++/modules/gcc/support.lua
+++ b/xmake/rules/c++/modules/gcc/support.lua
@@ -38,8 +38,7 @@ function _get_toolchain_includedirs_for_stlheaders(includedirs, gcc)
local result = try {function () return os.iorunv(gcc, {"-E", "-x", "c++", tmpfile}) end}
if result then
for _, line in ipairs(result:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if line:startswith("#") and line:find("/vector\"", 1, true) then
local includedir = line:match("\"(.+)/vector\"")
if includedir and os.isdir(includedir) then
@@ -115,8 +114,7 @@ function toolchain_includedirs(target)
local _, result = try {function () return os.iorunv(gcc, {"-E", "-Wp,-v", "-xc", os.nuldev()}) end}
if result then
for _, line in ipairs(result:split("\n", {plain = true})) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if os.isdir(line) then
table.insert(includedirs, path.normalize(line))
elseif line:startswith("End") then
diff --git a/xmake/rules/c++/unity_build/unity_build.lua b/xmake/rules/c++/unity_build/unity_build.lua
index ce25b02cb..bf5ee55b3 100644
--- a/xmake/rules/c++/unity_build/unity_build.lua
+++ b/xmake/rules/c++/unity_build/unity_build.lua
@@ -32,8 +32,7 @@ function _merge_unityfile(target, sourcefile_unity, sourcefiles, opt)
local uniqueid = target:data("unity_build.uniqueid")
local unityfile = io.open(sourcefile_unity, "w")
for _, sourcefile in ipairs(sourcefiles) do
- local sourcefile = sourcefile
- sourcefile = path.absolute(sourcefile)
+ local sourcefile = path.absolute(sourcefile)
sourcefile_unity = path.absolute(sourcefile_unity)
sourcefile = path.relative(sourcefile, path.directory(sourcefile_unity))
if uniqueid then
diff --git a/xmake/rules/nim/build/target.lua b/xmake/rules/nim/build/target.lua
index 13eb8be5c..6fe58be80 100644
--- a/xmake/rules/nim/build/target.lua
+++ b/xmake/rules/nim/build/target.lua
@@ -53,8 +53,7 @@ function _generate_dependinfo(compinst, compflags, sourcefiles, dependinfo)
local depsdata = io.readfile(depsfile)
if depsdata then
for _, line in ipairs(depsdata:split("\n")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if #line > 0 then
table.insert(dependinfo.files, line)
end
diff --git a/xmake/rules/platform/linux/module/driver_modules.lua b/xmake/rules/platform/linux/module/driver_modules.lua
index f7d90a781..e7a0dda49 100644
--- a/xmake/rules/platform/linux/module/driver_modules.lua
+++ b/xmake/rules/platform/linux/module/driver_modules.lua
@@ -117,8 +117,7 @@ module_exit(hello_exit);
if result then
-- we can also split ';' for the muliple commands
for _, line in ipairs(result:split("[\n;]")) do
- local line = line
- line = line:trim()
+ local line = line:trim()
if line:endswith("stub.c") then
local include_cflag = false
for _, cflag in ipairs(line:split("%s+")) do
diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua
index cfa6bf030..e1535ecd8 100644
--- a/xmake/rules/verilator/verilator.lua
+++ b/xmake/rules/verilator/verilator.lua
@@ -40,8 +40,7 @@ function _get_sourcefiles_from_cmake(target, cmakefile)
-- get global class source files
-- set(hello_GLOBAL "${VERILATOR_ROOT}/include/verilated.cpp" "${VERILATOR_ROOT}/include/verilated_threads.cpp")
for classfile in values:gmatch("\"(.-)\"") do
- local classfile = classfile
- classfile = classfile:gsub("%${VERILATOR_ROOT}", verilator_root)
+ local classfile = classfile:gsub("%${VERILATOR_ROOT}", verilator_root)
if os.isfile(classfile) then
table.insert(global_classes, classfile)
end
diff --git a/xmake/rules/wdk/load.lua b/xmake/rules/wdk/load.lua
index 9abf7438d..4943340d7 100644
--- a/xmake/rules/wdk/load.lua
+++ b/xmake/rules/wdk/load.lua
@@ -62,8 +62,7 @@ function driver_umdf(target)
-- set default driver entry if does not exist
local entry = false
for _, ldflag in ipairs(target:get("shflags")) do
- local ldflag = ldflag
- ldflag = ldflag:lower()
+ local ldflag = ldflag:lower()
if ldflag:find("[/%-]entry:") then
entry = true
break
diff --git a/xmake/rules/winsdk/mfc/mfc.lua b/xmake/rules/winsdk/mfc/mfc.lua
index 5464067cc..5bcd41072 100644
--- a/xmake/rules/winsdk/mfc/mfc.lua
+++ b/xmake/rules/winsdk/mfc/mfc.lua
@@ -107,8 +107,7 @@ function application(target, mfc_kind)
-- set startup entry
local unicode = false
for _, define in ipairs(target:get("defines")) do
- local define = define
- define = define:lower():trim()
+ local define = define:lower():trim()
if define:find("^[_]?unicode$") then
unicode = true
break