diff options
| author | ruki <[email protected]> | 2026-03-29 22:49:37 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-03-29 22:49:41 +0800 |
| commit | 1bccfc273af2b1d579d033324bca481e15c58653 (patch) | |
| tree | 192697793bd61d48b4423da0ac4a1eab804d80dc | |
| parent | f4513cc28aa778e1ad0d050511cc7e295fe81e32 (diff) | |
fix const limit on lua5.5
115 files changed, 207 insertions, 2 deletions
diff --git a/xmake/actions/build/build_files.lua b/xmake/actions/build/build_files.lua index 26b389ba6..a30b85c1d 100644 --- a/xmake/actions/build/build_files.lua +++ b/xmake/actions/build/build_files.lua @@ -44,6 +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) exclude = path.pattern(exclude) table.insert(_excludes, exclude) diff --git a/xmake/actions/build/deprecated/build_files.lua b/xmake/actions/build/deprecated/build_files.lua index db1492bd8..d5b434a09 100644 --- a/xmake/actions/build/deprecated/build_files.lua +++ b/xmake/actions/build/deprecated/build_files.lua @@ -142,6 +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) exclude = path.pattern(exclude) table.insert(_excludes, exclude) diff --git a/xmake/actions/config/configfiles.lua b/xmake/actions/config/configfiles.lua index 78ff3ebec..8f4cb07ff 100644 --- a/xmake/actions/config/configfiles.lua +++ b/xmake/actions/config/configfiles.lua @@ -300,6 +300,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets, preprocessors -- get variables from the target for name, value in pairs(target:get("configvar")) do + local value = value if variables[name] == nil then value = table.unwrap(value) variables[name] = value @@ -319,6 +320,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets, preprocessors -- get the builtin variables from the target for name, value in pairs(_get_builtinvars_target(target)) do + local value = value if type(value) == "function" then value = value() end @@ -329,6 +331,7 @@ function _generate_configfile(srcfile, dstfile, fileinfo, targets, preprocessors end -- get the global builtin variables for name, value in pairs(_get_builtinvars_global()) do + local value = value if type(value) == "function" then value = value() end diff --git a/xmake/actions/config/main.lua b/xmake/actions/config/main.lua index 6908e21c3..83743021a 100644 --- a/xmake/actions/config/main.lua +++ b/xmake/actions/config/main.lua @@ -292,6 +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) 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 diff --git a/xmake/actions/test/main.lua b/xmake/actions/test/main.lua index 7dcf3201c..4ce54f5bc 100644 --- a/xmake/actions/test/main.lua +++ b/xmake/actions/test/main.lua @@ -520,6 +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) file = path.relative(file, os.projectdir()) target_new:add("files", file, {defines = extra.defines, @@ -531,6 +532,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) file = path.relative(file, os.projectdir()) target_new:remove("files", file) @@ -586,6 +588,7 @@ function main() if test_patterns then local tests_new = {} for _, pattern in ipairs(test_patterns) do + local pattern = pattern pattern = "^" .. path.pattern(pattern) .. "$" for name, testinfo in pairs(tests) do if name:match(pattern) then diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua index f325ec3d2..332cbed06 100644 --- a/xmake/core/base/interpreter.lua +++ b/xmake/core/base/interpreter.lua @@ -117,6 +117,7 @@ end -- and we will only use the child values if be override mode function interpreter:_fetch_root_scope(root) for scope_kind_and_name, _ in pairs(root or {}) do + local scope_kind_and_name = scope_kind_and_name -- is scope_kind@@scope_name? scope_kind_and_name = scope_kind_and_name:split("@@", {plain = true}) @@ -340,6 +341,7 @@ function interpreter:_api_register_xxx_script(scope_kind, action, ...) if #patterns > 0 then local scripts = scope[name] or {} for _, pattern in ipairs(patterns) do + local pattern = pattern -- check assert(type(pattern) == "string") @@ -460,6 +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) if type(value) == "string" then results[key] = filter:handle(value) @@ -501,6 +504,7 @@ function interpreter:_handle(scope, deduplicate, enable_filter) -- remove repeat values and unwrap it local results = {} for name, values in pairs(scope) do + local values = values -- filter values -- @@ -1665,6 +1669,7 @@ function interpreter:api_define(apis) local definitions = self._API_DEFINITIONS or {} for apitype, apifuncs in pairs(apis) do for _, apifunc in ipairs(apifuncs) do + local apifunc = apifunc -- is {"apifunc", apiscript}? local apiscript = nil diff --git a/xmake/core/base/linuxos.lua b/xmake/core/base/linuxos.lua index 32af1ccad..dc1fa529f 100644 --- a/xmake/core/base/linuxos.lua +++ b/xmake/core/base/linuxos.lua @@ -145,6 +145,7 @@ function linuxos.version() if os_release then os_release = os_release:trim():lower():split("\n") for _, line in ipairs(os_release) do + local line = line -- ubuntu: VERSION="16.04.7 LTS (Xenial Xerus)" -- fedora: VERSION="32 (Container Image)" -- debian: VERSION="9 (stretch)" diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 6d46bddef..609683c6f 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -726,6 +726,7 @@ function option.show_options(options, taskname) -- transform description local desp_strs = table.new(#description, 0) for _, v in ipairs(description) do + local v = v if type(v) == "function" then v = v() end diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 9ba469505..3ef59775c 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -437,6 +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) exclude = path.pattern(exclude) table.insert(_excludes, exclude) @@ -988,9 +989,9 @@ function os.execv(program, argv, opt) filename = os._get_shell_path(opt) or "sh" argv = table.join(shellfile, argv) else - line = line:sub(3) + local shebang = line:sub(3) local shellargv = {} - local splitinfo = line:split("%s") + local splitinfo = shebang:split("%s") filename = splitinfo[1] if #splitinfo > 1 then shellargv = table.slice(splitinfo, 2) @@ -1013,6 +1014,7 @@ function os.execv(program, argv, opt) local envars = os.getenvs() if setenvs then for k, v in pairs(setenvs) do + local v = v if type(v) == "table" then v = path.joinenv(v) end @@ -1021,6 +1023,7 @@ function os.execv(program, argv, opt) end if addenvs then for k, v in pairs(addenvs) do + local v = v if type(v) == "table" then v = path.joinenv(v) end @@ -1033,6 +1036,7 @@ function os.execv(program, argv, opt) end envs = {} for k, v in pairs(envars) do + local v = v -- we try to fix too long value before running process if type(v) == "string" and #v > 4096 and os.host() == "windows" then v = os._deduplicate_pathenv(v) diff --git a/xmake/core/base/path.lua b/xmake/core/base/path.lua index 0d2dadfba..ee154147f 100644 --- a/xmake/core/base/path.lua +++ b/xmake/core/base/path.lua @@ -388,6 +388,7 @@ function path.splitenv(env_path) -- see https://git.kernel.org/pub/scm/utils/dash/dash.git/tree/src/exec.c?h=v0.5.9.1&id=afe0e0152e4dc12d84be3c02d6d62b0456d68580#n173 -- no escape sequences, so `:` and `%` is invalid in environment variable for _, v in ipairs(env_path:split(path.envsep(), { plain = true })) do + local v = v -- flag for shells, style `<path>%<flag>` local flag = v:find("%", 1, true) if flag then @@ -416,6 +417,7 @@ function path.joinenv(paths, envsep) if xmake._HOST == "windows" then local tab = {} for _, v in ipairs(paths) do + local v = v if v ~= "" then if v:find(envsep, 1, true) then v = '"' .. v .. '"' diff --git a/xmake/core/base/private/match_copyfiles.lua b/xmake/core/base/private/match_copyfiles.lua index 9570a8c4b..594ac6cdf 100644 --- a/xmake/core/base/private/match_copyfiles.lua +++ b/xmake/core/base/private/match_copyfiles.lua @@ -50,6 +50,7 @@ function match_copyfiles(instance, filetype, outputdir, opt) local srcfiles_removed = {} local removed_count = 0 for _, copyfile in ipairs(table.wrap(copyfiles)) do + local copyfile = copyfile -- mark as removed files? local removed = false diff --git a/xmake/core/base/text.lua b/xmake/core/base/text.lua index 9d4294ee6..558b1eb5e 100644 --- a/xmake/core/base/text.lua +++ b/xmake/core/base/text.lua @@ -182,6 +182,7 @@ function text.wordwrap(str, width, opt) -- handle lines for _, v in ipairs(lines) do + local v = v -- remove tailing spaces, include "\r", which will be produced by `("l1\r\nl2"):split(...)` v = v:rtrim() diff --git a/xmake/core/base/thread.lua b/xmake/core/base/thread.lua index 067b92f3f..187f98d53 100644 --- a/xmake/core/base/thread.lua +++ b/xmake/core/base/thread.lua @@ -103,6 +103,7 @@ function _thread:start() -- translate arguments (mutex, ...) local argv = {} for _, arg in ipairs(self._ARGV) do + local arg = arg if type(arg) == "table" then -- try to serialize thread object (mutex, event, semaphore, queue, sharedata) local serialized = thread._serialize_object(arg) @@ -927,6 +928,7 @@ function thread._run_thread(callback_str, callinfo_str) if argv then local newargv = {} for _, arg in ipairs(argv) do + local arg = arg if type(arg) == "table" and arg.caddr then -- try to deserialize thread object local obj = thread._deserialize_object(arg) diff --git a/xmake/core/base/winos.lua b/xmake/core/base/winos.lua index d43f08262..03994175f 100644 --- a/xmake/core/base/winos.lua +++ b/xmake/core/base/winos.lua @@ -178,6 +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) argn = argn + #arg if argn > limit then diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 6b725c404..7b95b3a17 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1156,6 +1156,7 @@ end function _instance:envs() local envs = {} for name, values in pairs(self:_rawenvs()) do + local values = values if self:_pathenvs():has(name) then local newvalues = {} for _, value in ipairs(values) do @@ -1663,6 +1664,7 @@ function _instance:buildhash() -- We cannot directly deserialize the table, so the result may be different each time local configs_order = {} for k, v in pairs(table.wrap(configs)) do + local v = v if type(v) == "table" then v = string.serialize(v, {strip = true, indent = false, orderkeys = true}) end diff --git a/xmake/core/package/scheme.lua b/xmake/core/package/scheme.lua index d03cce0a9..a8cb8ede4 100644 --- a/xmake/core/package/scheme.lua +++ b/xmake/core/package/scheme.lua @@ -172,6 +172,7 @@ function _instance:versions() -- https://github.com/xmake-io/xmake/issues/6953 local versions = {} for version, _ in table.orderpairs(self:_versions_list()) do + local version = version -- remove the url alias prefix if exists local pos = version:find(':', 1, true) if pos then @@ -191,6 +192,7 @@ function _instance:_versions_list() local versionfiles = self:get("versionfiles") if versionfiles then for _, versionfile in ipairs(table.wrap(versionfiles)) do + local versionfile = versionfile if not path.is_absolute(versionfile) then local subpath = versionfile versionfile = path.join(self:scriptdir(), subpath) @@ -337,6 +339,7 @@ function _instance:patches() else -- match semver, e.g add_patches(">=1.0.0", url, sha256) for range, patchinfo in pairs(patchinfos) do + local patchinfo = patchinfo if semver.satisfies(version_str, range) then patches = patches or {} patchinfo = table.wrap(patchinfo) @@ -371,6 +374,7 @@ function _instance:resources() else -- match semver, e.g add_resources(">=1.0.0", name, url, sha256) for range, resourceinfo in pairs(resourceinfos) do + local resourceinfo = resourceinfo if semver.satisfies(version_str, range) then resources = resources or {} resourceinfo = table.wrap(resourceinfo) diff --git a/xmake/core/project/config.lua b/xmake/core/project/config.lua index 451bfe8ae..a2e26d699 100644 --- a/xmake/core/project/config.lua +++ b/xmake/core/project/config.lua @@ -60,6 +60,7 @@ function config._is_value(value, ...) value = tostring(value) for _, v in ipairs(table.pack(...)) do + local v = v -- escape '-' v = tostring(v) if value == v or value:find("^" .. v:gsub("%-", "%%-") .. "$") then diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua index c24e97d70..7546237b0 100644 --- a/xmake/core/project/package.lua +++ b/xmake/core/project/package.lua @@ -351,6 +351,7 @@ function _instance:rules() -- make rule instances rules = {} for rulename, ruleinfo in pairs(ruleinfos) do + local rulename = rulename rulename = "@" .. self:name() .. "/" .. rulename local instance = rule.new(rulename, ruleinfo, {package = self}) if instance:script("load") then diff --git a/xmake/core/project/project.lua b/xmake/core/project/project.lua index f9e199a1b..beab21a22 100644 --- a/xmake/core/project/project.lua +++ b/xmake/core/project/project.lua @@ -172,6 +172,7 @@ end function project._api_add_moduledirs(interp, ...) local scriptdir = project.interpreter():scriptdir() for _, dir in ipairs({...}) do + local dir = dir if not path.is_absolute(dir) then dir = path.absolute(dir, scriptdir) end @@ -184,6 +185,7 @@ function project._api_add_plugindirs(interp, ...) local scriptdir = project.interpreter():scriptdir() local plugindirs = {} for _, dir in ipairs({...}) do + local dir = dir if not path.is_absolute(dir) then dir = path.absolute(dir, scriptdir) end @@ -196,6 +198,7 @@ end function project._api_add_platformdirs(interp, ...) local scriptdir = project.interpreter():scriptdir() for _, dir in ipairs({...}) do + local dir = dir if not path.is_absolute(dir) then dir = path.absolute(dir, scriptdir) end @@ -207,6 +210,7 @@ end function project._api_add_toolchaindirs(interp, ...) local scriptdir = project.interpreter():scriptdir() for _, dir in ipairs({...}) do + local dir = dir if not path.is_absolute(dir) then dir = path.absolute(dir, scriptdir) end diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index c11c6e246..20e802468 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -405,6 +405,7 @@ function rule.new(name, info, opt) -- local deps = {} for _, depname in ipairs(table.wrap(instance:get("deps"))) do + local depname = depname -- @xxx -> @package/xxx if depname:startswith("@") and not depname:find("/", 1, true) then depname = "@" .. opt.package:name() .. "/" .. depname:sub(2) @@ -416,6 +417,7 @@ function rule.new(name, info, opt) instance:set("deps", deps) end for depname, extraconf in pairs(table.wrap(instance:extraconf("deps"))) do + local depname = depname if depname:startswith("@") and not depname:find("/", 1, true) then depname = "@" .. opt.package:name() .. "/" .. depname:sub(2) instance:extraconf_set("deps", depname, extraconf) diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index aa204a054..fc47299c9 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -1410,6 +1410,7 @@ function _instance:pkgenvs() local envs = pkg:envs() if envs then for name, values in table.orderpairs(envs) do + local values = values if type(values) == "table" then values = path.joinenv(values) end @@ -1875,6 +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() key2rules[extension] = key2rules[extension] or {} table.insert(key2rules[extension], r) @@ -1930,6 +1932,7 @@ function _instance:fileconfig(sourcefile, opt) local results = os.match(filepath) if #results > 0 then for _, file in ipairs(results) do + local file = file if path.is_absolute(file) then file = path.relative(file, os.projectdir()) end @@ -2027,6 +2030,7 @@ function _instance:sourcefiles() local removed_count = 0 local targetcache = memcache.cache("core.project.target") for _, file in ipairs(table.wrap(files)) do + local file = file -- mark as removed files? local removed = false @@ -2074,6 +2078,7 @@ function _instance:sourcefiles() -- process source files for _, sourcefile in ipairs(results) do + local sourcefile = sourcefile -- convert to the relative path if path.is_absolute(sourcefile) then diff --git a/xmake/core/sandbox/modules/import/core/sandbox/module.lua b/xmake/core/sandbox/modules/import/core/sandbox/module.lua index dd7dac16e..2090c1f52 100644 --- a/xmake/core/sandbox/modules/import/core/sandbox/module.lua +++ b/xmake/core/sandbox/modules/import/core/sandbox/module.lua @@ -168,6 +168,7 @@ function core_sandbox_module._load_from_scriptdir(module_fullpath, opt) -- save module local scope = module for _, modulename in ipairs(path.split(modulepath)) do + local modulename = modulename local pos = modulename:find(".lua", 1, true) if pos then modulename = modulename:sub(1, pos - 1) 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 ec737785b..516a3e725 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_directory.lua @@ -34,6 +34,7 @@ local xmake = require("base/xmake") function sandbox_lib_detect_find_directory._expand_paths(paths) local results = {} for _, _path in ipairs(table.wrap(paths)) do + local _path = _path if type(_path) == "function" then local ok, result_or_errors = sandbox.load(_path) if ok then @@ -45,6 +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) if #_s_path > 0 then table.insert(results, _s_path) @@ -58,6 +60,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) if #suffix > 0 then table.insert(results, suffix) 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 71e580ba1..b007713b6 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_file.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_file.lua @@ -35,6 +35,7 @@ local xmake = require("base/xmake") function sandbox_lib_detect_find_file._expand_paths(paths) local results = {} for _, _path in ipairs(table.wrap(paths)) do + local _path = _path if type(_path) == "function" then local ok, result_or_errors = sandbox.load(_path) if ok then @@ -50,6 +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) if #_s_path > 0 then table.insert(results, _s_path) @@ -63,6 +65,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) if #suffix > 0 then table.insert(results, suffix) 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 cd7413fb7..23b6e26f7 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_path.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_path.lua @@ -34,6 +34,7 @@ local xmake = require("base/xmake") function sandbox_lib_detect_find_path._expand_paths(paths) local results = {} for _, _path in ipairs(table.wrap(paths)) do + local _path = _path if type(_path) == "function" then local ok, result_or_errors = sandbox.load(_path) if ok then @@ -45,6 +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) if #_s_path > 0 then table.insert(results, _s_path) @@ -58,6 +60,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) if #suffix > 0 then table.insert(results, suffix) 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 288a9089e..a3bb75064 100644 --- a/xmake/core/sandbox/modules/import/lib/detect/find_program.lua +++ b/xmake/core/sandbox/modules/import/lib/detect/find_program.lua @@ -108,6 +108,7 @@ function sandbox_lib_detect_find_program._find_from_paths(name, paths, opt) -- attempt to check it from the given directories if not path.is_absolute(name) then for _, _path in ipairs(table.wrap(paths)) do + local _path = _path -- format path for builtin variables if type(_path) == "function" then @@ -269,6 +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() if #program_path > 0 then local program_path_real = sandbox_lib_detect_find_program._check(program_path, opt) diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua index e6c649580..a72733680 100644 --- a/xmake/core/tool/builder.lua +++ b/xmake/core/tool/builder.lua @@ -165,6 +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) if flag then if extraconf then @@ -390,6 +391,7 @@ function builder:_add_items_from_target(items, name, opt) local result, sources = target:get_from(name, "*") if result then for idx, values in ipairs(result) do + local values = values local source = sources[idx] local extras = target:extraconf_from(name, source) values = table.wrap(values) @@ -691,6 +693,7 @@ function builder:_sort_links_of_items(items, opt) -- re-generate links to items list if sortlinks or makegroups then for _, link in ipairs(links) do + local link = link if link:startswith("framework::") then link = link:sub(12) table.insert(items, {name = "frameworks", values = table.wrap(link), check = false, multival = false, mapper = framework_mapper}) diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 5ca360492..3d9d65fa5 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -241,6 +241,7 @@ function _instance:runenvs() if toolchain_runenvs then runenvs = {} for name, values in pairs(toolchain_runenvs) do + local values = values if type(values) == "table" then values = path.joinenv(values) end @@ -652,6 +653,7 @@ function toolchain.parsename(name) toolchain_name = toolchain_name_raw local splitinfo = configs_str:split(",", {plain = true}) for _, v in ipairs(splitinfo) do + local v = v local parts = v:split("=", {plain = true}) local k = parts[1] v = parts[2] diff --git a/xmake/modules/cli/amalgamate.lua b/xmake/modules/cli/amalgamate.lua index 72c7e8f2f..4f771807c 100644 --- a/xmake/modules/cli/amalgamate.lua +++ b/xmake/modules/cli/amalgamate.lua @@ -89,6 +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())) inputpaths[idx] = inputpath gh:add_edge("__root__", inputpath) diff --git a/xmake/modules/core/tools/armcc/parse_deps.lua b/xmake/modules/core/tools/armcc/parse_deps.lua index 560bca40b..28a4f797c 100644 --- a/xmake/modules/core/tools/armcc/parse_deps.lua +++ b/xmake/modules/core/tools/armcc/parse_deps.lua @@ -59,6 +59,7 @@ function main(depsdata) local plain = {plain = true} line = line:replace("\\ ", space_placeholder, plain) for _, includefile in ipairs(line:split('\n', plain)) do + local includefile = includefile if is_host("windows") and includefile:match("^%w\\:") then includefile = includefile:replace("\\:", ":", plain) end diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index a28d049c3..c945e163b 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -536,6 +536,7 @@ function _preprocess(program, argv, opt) local sourcefile = argv[#argv] local extension = path.extension(sourcefile) for _, flag in ipairs(argv) do + local flag = flag if flag:startswith("-Fo") or flag:startswith("/Fo") then objectfile = flag:sub(4) break @@ -703,6 +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() if #line > 0 then local skip = false @@ -806,6 +808,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() if not parse_include.has_include_note(line) then results = results .. line .. "\r\n" diff --git a/xmake/modules/core/tools/cl/parse_deps_json.lua b/xmake/modules/core/tools/cl/parse_deps_json.lua index 651f795ac..a969fa12e 100644 --- a/xmake/modules/core/tools/cl/parse_deps_json.lua +++ b/xmake/modules/core/tools/cl/parse_deps_json.lua @@ -134,6 +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) if includefile then results:insert(includefile) diff --git a/xmake/modules/core/tools/cl6x/parse_deps.lua b/xmake/modules/core/tools/cl6x/parse_deps.lua index 301d696aa..94a23bd9d 100644 --- a/xmake/modules/core/tools/cl6x/parse_deps.lua +++ b/xmake/modules/core/tools/cl6x/parse_deps.lua @@ -65,6 +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] if includefile and #includefile > 0 then includefile = _normailize_dep(includefile, projectdir) diff --git a/xmake/modules/core/tools/cl_json/parse_deps.lua b/xmake/modules/core/tools/cl_json/parse_deps.lua index 2b84122b3..0dff3cf11 100644 --- a/xmake/modules/core/tools/cl_json/parse_deps.lua +++ b/xmake/modules/core/tools/cl_json/parse_deps.lua @@ -134,6 +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) if includefile then results:insert(includefile) diff --git a/xmake/modules/core/tools/gcc/parse_deps.lua b/xmake/modules/core/tools/gcc/parse_deps.lua index 5adf69b91..b8d55e844 100644 --- a/xmake/modules/core/tools/gcc/parse_deps.lua +++ b/xmake/modules/core/tools/gcc/parse_deps.lua @@ -92,6 +92,7 @@ function main(depsdata, opt) local plain = {plain = true} line = line:replace("\\ ", space_placeholder, plain) for _, includefile in ipairs(line:split(' ', plain)) do -- it will trim all internal spaces without `{strict = true}` + local includefile = includefile -- some gcc toolchains will some invalid paths (e.g. `d\:\xxx`), we need to fix it -- https://github.com/xmake-io/xmake/issues/1196 if is_host("windows") and includefile:match("^%w\\:") then diff --git a/xmake/modules/core/tools/link/has_flags.lua b/xmake/modules/core/tools/link/has_flags.lua index 9d44b7b1c..372118f39 100644 --- a/xmake/modules/core/tools/link/has_flags.lua +++ b/xmake/modules/core/tools/link/has_flags.lua @@ -88,6 +88,7 @@ end function _ignore_flags(flags) local results = {} for _, flag in ipairs(flags) do + local flag = flag flag = flag:lower() if not flag:find("[%-/]def:.+%.def") and not flag:find("[%-/]export:") then table.insert(results, flag) diff --git a/xmake/modules/core/tools/rc/parse_deps.lua b/xmake/modules/core/tools/rc/parse_deps.lua index bd526823f..66f0dcdc2 100644 --- a/xmake/modules/core/tools/rc/parse_deps.lua +++ b/xmake/modules/core/tools/rc/parse_deps.lua @@ -41,6 +41,7 @@ function main(depsdata) local results = hashset.new() local projectdir = os.projectdir() for _, includefile in ipairs(depsdata:split('\n', {plain = true})) do + local includefile = includefile if #includefile > 0 then includefile = _normailize_dep(includefile, projectdir) if includefile then diff --git a/xmake/modules/detect/sdks/find_cross_toolchain.lua b/xmake/modules/detect/sdks/find_cross_toolchain.lua index 9b7076201..7b5a11af3 100644 --- a/xmake/modules/detect/sdks/find_cross_toolchain.lua +++ b/xmake/modules/detect/sdks/find_cross_toolchain.lua @@ -34,6 +34,7 @@ function _find_bindir(sdkdir, opt) -- attempt to find *-[gcc|clang|ld] for _, toolname in ipairs({"gcc", "clang", "ld"}) do + local toolname = toolname if is_host("windows") then toolname = toolname .. ".exe" end diff --git a/xmake/modules/detect/sdks/find_dotnet.lua b/xmake/modules/detect/sdks/find_dotnet.lua index f64acacd3..3afb06138 100644 --- a/xmake/modules/detect/sdks/find_dotnet.lua +++ b/xmake/modules/detect/sdks/find_dotnet.lua @@ -49,6 +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 ver, dir = line:match("^(%S+)%s+%[(.-)%]") if ver and dir then @@ -72,6 +73,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 name, ver = line:match("^(%S+)%s+(%S+)%s+%[") if name and ver then diff --git a/xmake/modules/detect/sdks/find_vstudio.lua b/xmake/modules/detect/sdks/find_vstudio.lua index 8a805aae6..e7699ee0d 100644 --- a/xmake/modules/detect/sdks/find_vstudio.lua +++ b/xmake/modules/detect/sdks/find_vstudio.lua @@ -395,6 +395,7 @@ function _check_vcvarsall_env(vars) if value_org and value_new and #value_org > 0 then local values_new = hashset.from(path.splitenv(value_new)) for _, p in ipairs(value_org) do + local p = p if not values_new:has(p) then if #p > 256 then p = p:sub(1, 256) .. "..." @@ -518,6 +519,7 @@ function _find_vstudio(opt) -- find vs2017 -> vs4.2 local results = {} for _, version in ipairs(order_vsvers) do + local version = version -- find VC install path (and aux build path) using `vswhere` (for version >= 15.0) -- * version > 15.0 eschews registry entries; but `vswhere` (included with version >= 15.2) can be used to find VC install path diff --git a/xmake/modules/lib/detect/check_importfiles.lua b/xmake/modules/lib/detect/check_importfiles.lua index 844939891..d8c12d387 100644 --- a/xmake/modules/lib/detect/check_importfiles.lua +++ b/xmake/modules/lib/detect/check_importfiles.lua @@ -34,6 +34,7 @@ function main(names, opt) verbose = true end for _, name in ipairs(names) do + local name = name local kind local parts = name:split("::") if #parts == 2 then diff --git a/xmake/modules/lib/detect/find_toolname.lua b/xmake/modules/lib/detect/find_toolname.lua index 37f468c73..0b7ad1a9b 100644 --- a/xmake/modules/lib/detect/find_toolname.lua +++ b/xmake/modules/lib/detect/find_toolname.lua @@ -49,6 +49,7 @@ function _find_with_whole_name(program) local partnames = {} local names = path.filename(program):lower():split("%s") for _, name in ipairs(names) do + local name = name -- remove suffix: ".exe", e.g. "zig.exe cc" name = _remove_suffix(name) -- "zig c++" -> zig_cxx diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua index 8ac8e3385..61a44f8c1 100644 --- a/xmake/modules/lib/detect/has_flags.lua +++ b/xmake/modules/lib/detect/has_flags.lua @@ -106,6 +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() if #flag > 0 then if flag:find(" ", 1, true) then diff --git a/xmake/modules/net/proxy.lua b/xmake/modules/net/proxy.lua index 812fdc536..7a45da39d 100644 --- a/xmake/modules/net/proxy.lua +++ b/xmake/modules/net/proxy.lua @@ -157,6 +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() if host == proxy_hosts or host:match(_host_pattern(proxy_host)) then return _global_proxy() diff --git a/xmake/modules/package/manager/apt/find_package.lua b/xmake/modules/package/manager/apt/find_package.lua index f9bec605d..4e9f7b138 100644 --- a/xmake/modules/package/manager/apt/find_package.lua +++ b/xmake/modules/package/manager/apt/find_package.lua @@ -33,6 +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() -- get includedirs diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua index 7192843a9..dba4cae04 100644 --- a/xmake/modules/package/manager/cmake/find_package.lua +++ b/xmake/modules/package/manager/cmake/find_package.lua @@ -203,6 +203,7 @@ function _find_package(cmake, name, opt) io.write(linkdata .. "\n") end for _, line in ipairs(os.argv(linkdata)) do + local line = line local is_ldflags = false local is_library = false for _, suffix in ipairs({".so", ".dylib", ".dylib", ".tbd", ".lib"}) do diff --git a/xmake/modules/package/manager/conan/v1/install_package.lua b/xmake/modules/package/manager/conan/v1/install_package.lua index d96727eb7..9d36400ac 100644 --- a/xmake/modules/package/manager/conan/v1/install_package.lua +++ b/xmake/modules/package/manager/conan/v1/install_package.lua @@ -77,6 +77,7 @@ function _conan_generate_conanfile(name, configs, opt) if #options > 0 then conanfile:print("[options]") for _, item in ipairs(options) do + local item = item if not item:find(":", 1, true) then item = name .. ":" .. item end diff --git a/xmake/modules/package/manager/conan/v2/install_package.lua b/xmake/modules/package/manager/conan/v2/install_package.lua index ff834e1b6..fae6d7ff4 100644 --- a/xmake/modules/package/manager/conan/v2/install_package.lua +++ b/xmake/modules/package/manager/conan/v2/install_package.lua @@ -77,6 +77,7 @@ function _conan_generate_conanfile(name, configs, opt) if #options > 0 then conanfile:print("[options]") for _, item in ipairs(options) do + local item = item if not item:find(":", 1, true) then item = name .. "/*:" .. item end diff --git a/xmake/modules/package/manager/conda/find_package.lua b/xmake/modules/package/manager/conda/find_package.lua index 608d85f3b..b3f447bed 100644 --- a/xmake/modules/package/manager/conda/find_package.lua +++ b/xmake/modules/package/manager/conda/find_package.lua @@ -107,6 +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() -- get includedirs diff --git a/xmake/modules/package/manager/nix/search_package.lua b/xmake/modules/package/manager/nix/search_package.lua index 3ad66610c..60acd3ef3 100644 --- a/xmake/modules/package/manager/nix/search_package.lua +++ b/xmake/modules/package/manager/nix/search_package.lua @@ -75,6 +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() if line ~= "" then local parts = line:split("%s+", {limit = 2}) diff --git a/xmake/modules/package/manager/nuget/find_package.lua b/xmake/modules/package/manager/nuget/find_package.lua index 4a27eed19..c9fa2b712 100644 --- a/xmake/modules/package/manager/nuget/find_package.lua +++ b/xmake/modules/package/manager/nuget/find_package.lua @@ -188,6 +188,7 @@ function _find_package(name, result, opt) local libarch = libarchs[arch] or "x64" local libmode = configs.debug and "Debug" or "Release" for _, file in ipairs(libinfo.files) do + local file = file local filepath = path.join(installdir, file) file = file:trim() diff --git a/xmake/modules/package/manager/pacman/find_package.lua b/xmake/modules/package/manager/pacman/find_package.lua index 3b200db26..cc84b6774 100644 --- a/xmake/modules/package/manager/pacman/find_package.lua +++ b/xmake/modules/package/manager/pacman/find_package.lua @@ -50,6 +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] if line:find("/include/", 1, true) and (line:endswith(".h") or line:endswith(".hpp")) then if not line:startswith("/usr/include/") then @@ -133,6 +134,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] if line:endswith(".dll.a") then -- only for mingw local apath = path.join(pathtomsys, line) @@ -185,6 +187,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] if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then table.insert(pkgconfig_files, line) diff --git a/xmake/modules/package/manager/portage/find_package.lua b/xmake/modules/package/manager/portage/find_package.lua index 4f6ae5d32..7fb560a28 100644 --- a/xmake/modules/package/manager/portage/find_package.lua +++ b/xmake/modules/package/manager/portage/find_package.lua @@ -63,6 +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] if line:find("/pkgconfig/", 1, true) and line:endswith(".pc") then pkgconfig_files[path.basename(line)] = line diff --git a/xmake/modules/package/manager/vcpkg/find_package.lua b/xmake/modules/package/manager/vcpkg/find_package.lua index f3dc740bd..7d0f44e12 100644 --- a/xmake/modules/package/manager/vcpkg/find_package.lua +++ b/xmake/modules/package/manager/vcpkg/find_package.lua @@ -35,6 +35,7 @@ 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() if #feature > 0 then table.insert(features, feature) @@ -42,6 +43,7 @@ function _required_features(name, configs) end end for _, feature in ipairs(table.wrap(configs and configs.features)) do + local feature = feature feature = tostring(feature):trim() if #feature > 0 then table.insert(features, feature) @@ -102,6 +104,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() if plat == "windows" then line = line:lower() diff --git a/xmake/modules/package/manager/zypper/find_package.lua b/xmake/modules/package/manager/zypper/find_package.lua index 2f0d5fc88..e5a05c5ab 100644 --- a/xmake/modules/package/manager/zypper/find_package.lua +++ b/xmake/modules/package/manager/zypper/find_package.lua @@ -38,6 +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() -- get includedirs diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua index c2fc26954..43c7d902b 100644 --- a/xmake/modules/package/tools/autoconf.lua +++ b/xmake/modules/package/tools/autoconf.lua @@ -667,6 +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() if value ~= "" then if type(name) == "number" then @@ -721,6 +722,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() if value ~= "" then if type(name) == "number" then @@ -748,6 +750,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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 1557aebeb..2417a0b8a 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -1307,6 +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() if type(name) == "number" then if value ~= "" then diff --git a/xmake/modules/package/tools/jom.lua b/xmake/modules/package/tools/jom.lua index e712ca8dd..26dbb014e 100644 --- a/xmake/modules/package/tools/jom.lua +++ b/xmake/modules/package/tools/jom.lua @@ -69,6 +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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/make.lua b/xmake/modules/package/tools/make.lua index 485426119..f7f4f2dd7 100644 --- a/xmake/modules/package/tools/make.lua +++ b/xmake/modules/package/tools/make.lua @@ -138,6 +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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/meson.lua b/xmake/modules/package/tools/meson.lua index fbc6bbe77..010e410db 100644 --- a/xmake/modules/package/tools/meson.lua +++ b/xmake/modules/package/tools/meson.lua @@ -566,6 +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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/msbuild.lua b/xmake/modules/package/tools/msbuild.lua index 633ce4e14..6152560a2 100644 --- a/xmake/modules/package/tools/msbuild.lua +++ b/xmake/modules/package/tools/msbuild.lua @@ -95,6 +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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/nmake.lua b/xmake/modules/package/tools/nmake.lua index 85182ac61..fe2b96956 100644 --- a/xmake/modules/package/tools/nmake.lua +++ b/xmake/modules/package/tools/nmake.lua @@ -57,6 +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() if value ~= "" then if type(name) == "number" then diff --git a/xmake/modules/package/tools/xmake.lua b/xmake/modules/package/tools/xmake.lua index 4ff3c6239..3ccd09298 100644 --- a/xmake/modules/package/tools/xmake.lua +++ b/xmake/modules/package/tools/xmake.lua @@ -539,6 +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() if type(name) == "number" then if value ~= "" then diff --git a/xmake/modules/private/action/require/impl/actions/download.lua b/xmake/modules/private/action/require/impl/actions/download.lua index 84c8d85be..f8a5e1584 100644 --- a/xmake/modules/private/action/require/impl/actions/download.lua +++ b/xmake/modules/private/action/require/impl/actions/download.lua @@ -346,6 +346,7 @@ function main(package, opt) local ok = false local urls_failed = {} for idx, url in ipairs(urls) do + local url = url local url_alias = package:url_alias(url) local url_excludes = package:url_excludes(url) local url_includes = package:url_includes(url) diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index 94f8007b3..206c2ae52 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -79,6 +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}) if linkdir ~= "${exec_prefix}/lib" then libs = libs .. " -L" .. linkdir @@ -95,6 +96,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}) if includedir ~= "${prefix}/include" then cflags = cflags .. " -I" .. includedir diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 359f9ac47..613afd5e8 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -152,6 +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) if extpackages_list[idx] then table.insert(confirmed_extpackages, extpackages_list[idx]) diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 4e2d70e5f..53c3d627d 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -70,6 +70,7 @@ function _load_require(require_str, requires_extra, opt) packagename = packagename_raw local splitinfo = configs_str:split(",", {plain = true}) for _, v in ipairs(splitinfo) do + local v = v local parts = v:split("=", {plain = true}) local k = parts[1] v = parts[2] @@ -1216,6 +1217,7 @@ function _get_package_compatkey(dep) if configs then local configs_order = {} for k, v in pairs(configs) do + local v = v if type(v) == "table" then v = string.serialize(v, {strip = true, indent = false, orderkeys = true}) end @@ -1594,6 +1596,7 @@ function get_configs_str(package) local ignored_configs_for_buildhash = hashset.from(requireinfo.ignored_configs_for_buildhash or {}) local configs_overrided = requireinfo.configs_overrided or {} for k, v in pairs(requireinfo.configs) do + local v = v if not ignored_configs_for_buildhash:has(k) then v = configs_overrided[k] or v if type(v) == "boolean" then diff --git a/xmake/modules/private/action/require/impl/utils/requirekey.lua b/xmake/modules/private/action/require/impl/utils/requirekey.lua index 5fd228ecf..f86806490 100644 --- a/xmake/modules/private/action/require/impl/utils/requirekey.lua +++ b/xmake/modules/private/action/require/impl/utils/requirekey.lua @@ -66,6 +66,7 @@ function main(requireinfo, opt) if configs then local configs_order = {} for k, v in pairs(configs) do + local v = v if type(v) == "table" then v = string.serialize(v, {strip = true, indent = false, orderkeys = true}) end diff --git a/xmake/modules/private/action/require/info.lua b/xmake/modules/private/action/require/info.lua index f1be7a01b..84247d456 100644 --- a/xmake/modules/private/action/require/info.lua +++ b/xmake/modules/private/action/require/info.lua @@ -165,6 +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) if git.checkurl(url) then searchnames:insert(instance:name() .. archive.extension(url) .. " ${dim}(git)${clear}") @@ -193,6 +194,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) if type(info) ~= "table" then info = tostring(info) diff --git a/xmake/modules/private/action/run/runenvs.lua b/xmake/modules/private/action/run/runenvs.lua index 43d150e66..32c6141fd 100644 --- a/xmake/modules/private/action/run/runenvs.lua +++ b/xmake/modules/private/action/run/runenvs.lua @@ -98,6 +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 oldenvs = addenvs[name] if oldenvs then diff --git a/xmake/modules/private/async/jobpool.lua b/xmake/modules/private/async/jobpool.lua index 3d9bd7819..91c70cd78 100644 --- a/xmake/modules/private/async/jobpool.lua +++ b/xmake/modules/private/async/jobpool.lua @@ -269,6 +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) if smalltree:size() < 16 or type(item) == "table" then smalltree:insert(item) diff --git a/xmake/modules/private/service/remote_build/filesync.lua b/xmake/modules/private/service/remote_build/filesync.lua index e984d3968..0bea69765 100644 --- a/xmake/modules/private/service/remote_build/filesync.lua +++ b/xmake/modules/private/service/remote_build/filesync.lua @@ -137,6 +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() if #line > 0 and not line:startswith("#") then local filepath = path.join(gitroot, line) diff --git a/xmake/modules/private/utils/package.lua b/xmake/modules/private/utils/package.lua index 6df309f5f..c964c3ad3 100644 --- a/xmake/modules/private/utils/package.lua +++ b/xmake/modules/private/utils/package.lua @@ -22,6 +22,7 @@ function _concat_packages(a, b) local result = table.copy(a) for k, v in pairs(b) do + local v = v local o = result[k] if o ~= nil then v = table.join(o, v) @@ -29,6 +30,7 @@ function _concat_packages(a, b) result[k] = v end for k, v in pairs(result) do + local v = v if k == "links" or k == "syslinks" or k == "frameworks" or k == "ldflags" or k == "shflags" then if type(v) == "table" and #v > 1 then -- we need to ensure link orders when removing repeat values diff --git a/xmake/modules/private/utils/target.lua b/xmake/modules/private/utils/target.lua index 56fb6faeb..501916832 100644 --- a/xmake/modules/private/utils/target.lua +++ b/xmake/modules/private/utils/target.lua @@ -36,6 +36,7 @@ function has_tool(toolname, tools) trim_xx = true end for _, v in ipairs(tools) do + local v = v if trim_xx then v = v:rtrim("xx") end @@ -113,6 +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) if flag then table.insert(result, flag) diff --git a/xmake/modules/private/utils/trim_trailing_spaces.lua b/xmake/modules/private/utils/trim_trailing_spaces.lua index a0279a261..5f879bb22 100644 --- a/xmake/modules/private/utils/trim_trailing_spaces.lua +++ b/xmake/modules/private/utils/trim_trailing_spaces.lua @@ -24,6 +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() table.insert(filedata2, line) end diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua index 2ba6068df..bff00d57a 100644 --- a/xmake/modules/private/xrepo/action/env.lua +++ b/xmake/modules/private/xrepo/action/env.lua @@ -149,6 +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() if envfiles[binditem] then table.insert(files, envfiles[binditem]) diff --git a/xmake/modules/target/action/install/pkgconfig_importfiles.lua b/xmake/modules/target/action/install/pkgconfig_importfiles.lua index 9a9b8ee81..77b6a21ec 100644 --- a/xmake/modules/target/action/install/pkgconfig_importfiles.lua +++ b/xmake/modules/target/action/install/pkgconfig_importfiles.lua @@ -46,6 +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}) if linkdir ~= "${exec_prefix}/lib" then libs = libs .. " -L" .. linkdir @@ -62,6 +63,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}) if includedir ~= "${prefix}/include" then cflags = cflags .. " -I" .. includedir diff --git a/xmake/modules/utils/binary/deplibs.lua b/xmake/modules/utils/binary/deplibs.lua index 1de8056fd..e1a9a776d 100644 --- a/xmake/modules/utils/binary/deplibs.lua +++ b/xmake/modules/utils/binary/deplibs.lua @@ -44,6 +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() if not line:startswith("Dump of file") and line:endswith(".dll") then depends = depends or {} @@ -71,6 +72,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() if not line:endswith(":") then if plat == "windows" or plat == "mingw" then @@ -126,6 +128,7 @@ function _get_depends_by_ldd(binaryfile, opt) local result = try { function () return os.iorunv(ldd.program, {binaryfile}) end } if result then for _, line in ipairs(result:split("\n")) do + local line = line local splitinfo = line:split("=>") line = splitinfo[2] if not line or line:find("not found", 1, true) then @@ -202,6 +205,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() if not line:endswith(":") then local filename = line:match(".-%.dylib") or line:match(".-%.framework") @@ -344,6 +348,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) if dependfile then table.insert(result, dependfile) diff --git a/xmake/modules/utils/binary/rpath.lua b/xmake/modules/utils/binary/rpath.lua index 33cab5a43..6ee17e98d 100644 --- a/xmake/modules/utils/binary/rpath.lua +++ b/xmake/modules/utils/binary/rpath.lua @@ -55,6 +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() 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 diff --git a/xmake/modules/utils/run_script.lua b/xmake/modules/utils/run_script.lua index e6f8469f6..057ea57cd 100644 --- a/xmake/modules/utils/run_script.lua +++ b/xmake/modules/utils/run_script.lua @@ -191,6 +191,7 @@ function main(script, opt) if opt.thread then local argv for _, arg in ipairs(opt.arguments) do + local arg = arg argv = argv or {} if path.instance_of(arg) then arg = tostring(arg) diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 2d0913c20..5320df979 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -63,6 +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) exclude = path.pattern(exclude) table.insert(_excludes, exclude) diff --git a/xmake/plugins/pack/deb/main.lua b/xmake/plugins/pack/deb/main.lua index cfcdb0dfd..930dcb225 100644 --- a/xmake/plugins/pack/deb/main.lua +++ b/xmake/plugins/pack/deb/main.lua @@ -81,6 +81,7 @@ function _get_customcmd(package, installcmds, cmd) elseif cmd.program then local argv = {} for _, arg in ipairs(cmd.argv) do + local arg = arg if path.instance_of(arg) then arg = arg:clone():set(_translate_filepath(package, arg:rawstr())):str() elseif path.is_absolute(arg) then @@ -206,6 +207,7 @@ function _pack_deb(debuild, package) end) end for _, name in ipairs(specvars_names) do + local name = name name = name:trim() if specvars_values[name] == nil then local value = specvars[name] diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 3dc579608..f566296c5 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -99,6 +99,7 @@ function _get_command_strings(package, cmd, opt) -- match files and directories local srcitems = os.filedirs(srcpath) for _, srcitem in ipairs(srcitems) do + local srcitem = srcitem if os.isdir(srcitem) then -- copy directory recursively srcitem = path.normalize(srcitem) @@ -283,6 +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() if specvars_values[name] == nil then local value = specvars[name] diff --git a/xmake/plugins/pack/runself/main.lua b/xmake/plugins/pack/runself/main.lua index 31f88f9dd..32b376684 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -123,6 +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() if specvars_values[name] == nil then local value = specvars[name] diff --git a/xmake/plugins/pack/srpm/main.lua b/xmake/plugins/pack/srpm/main.lua index 5b570844d..dec2dfdfa 100644 --- a/xmake/plugins/pack/srpm/main.lua +++ b/xmake/plugins/pack/srpm/main.lua @@ -102,6 +102,7 @@ function _get_customcmd(package, installcmds, cmd) elseif cmd.program then local argv = {} for _, arg in ipairs(cmd.argv) do + local arg = arg if path.instance_of(arg) then arg = arg:clone():set(_translate_filepath(package, arg:rawstr())):str() elseif path.is_absolute(arg) then @@ -218,6 +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() if specvars_values[name] == nil then local value = specvars[name] diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua index 896ea2339..a3055bc0c 100644 --- a/xmake/plugins/pack/wix/main.lua +++ b/xmake/plugins/pack/wix/main.lua @@ -82,11 +82,13 @@ function _get_cp_kind_table(package, cmds, opt) -- match files and directories local srcitems = os.filedirs(cmd.srcpath) for _, srcitem in ipairs(srcitems) do + local srcitem = srcitem if os.isdir(srcitem) then -- for directory, recursively collect all files in it local rootdir = option.rootdir or srcitem local files = os.files(path.join(srcitem, "**")) for _, srcfile in ipairs(files) do + local srcfile = srcfile -- the destination is directory? append the relative path local dstfile = cmd.dstpath if option.rootdir then @@ -300,6 +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() if specvars_values[name] == nil then local value = specvars[name] diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 909184800..e38c1cef1 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -90,6 +90,7 @@ function _translate_arguments(arguments) local is_include = false local lsp = _get_lsp() for idx, arg in ipairs(arguments) do + local arg = arg -- convert path to string, maybe we need to convert path, but not supported now. arg = tostring(arg) diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 167d4bb5f..d089cf805 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -562,6 +562,7 @@ function _add_target_source_groups(cmakelists, target, outputdir) rootdir = string.format("${CMAKE_CURRENT_SOURCE_DIR}/%s", _get_relative_unix_path(rootdir, outputdir)) end for _, filepattern in ipairs(files) do + local filepattern = filepattern if filepattern:find("**", 1, true) then filepattern = filepattern:gsub("%*%*", "*") table.insert(recurse_sources, _get_relative_unix_path(path.join(rootdir, filepattern), outputdir)) @@ -734,6 +735,7 @@ function _add_target_compile_options(cmakelists, target, outputdir) if #cflags > 0 or #cxflags > 0 or #cxxflags > 0 or #cuflags > 0 then cmakelists:print("target_compile_options(%s PRIVATE", target:name()) for _, flag in ipairs(_translate_flags(cflags, outputdir)) do + local flag = flag local prefix prefix, flag = _split_flag_with_tool_prefix(flag) if prefix == toolname then @@ -745,6 +747,7 @@ function _add_target_compile_options(cmakelists, target, outputdir) end end for _, flag in ipairs(_translate_flags(cxflags, outputdir)) do + local flag = flag local prefix prefix, flag = _split_flag_with_tool_prefix(flag) if prefix == toolname then @@ -757,6 +760,7 @@ function _add_target_compile_options(cmakelists, target, outputdir) end end for _, flag in ipairs(_translate_flags(cxxflags, outputdir)) do + local flag = flag local prefix prefix, flag = _split_flag_with_tool_prefix(flag) if prefix == toolname then @@ -768,6 +772,7 @@ function _add_target_compile_options(cmakelists, target, outputdir) end end for _, flag in ipairs(_translate_flags(cuflags, outputdir)) do + local flag = flag local prefix prefix, flag = _split_flag_with_tool_prefix(flag) if prefix == toolname then @@ -883,6 +888,7 @@ function _add_target_languages(cmakelists, target) local languages = target:get("languages") if languages then for _, lang in ipairs(languages) do + local lang = lang local has_ext = false -- c | c++ | gnu | gnu++ local flag = lang:replace('xx', '++'):replace('latest', ''):gsub('%d', '') @@ -1150,6 +1156,7 @@ function _add_target_link_options(cmakelists, target, outputdir) cmakelists:print("target_link_libraries(%s PRIVATE", target:name()) end for _, flag in ipairs(flags) do + local flag = flag local prefix prefix, flag = _split_flag_with_tool_prefix(flag) if prefix == toolname then diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua index 3128a1c96..d58db7051 100644 --- a/xmake/plugins/project/make/makefile.lua +++ b/xmake/plugins/project/make/makefile.lua @@ -276,6 +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) makefile:print("\t%s", _get_cmd_rm(filedir)) end @@ -554,6 +555,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) table.insert(objectfiles_translated, objectfile) makefile:write(" " .. objectfile) diff --git a/xmake/plugins/project/ninja/build_ninja.lua b/xmake/plugins/project/ninja/build_ninja.lua index e53745a86..f89915e02 100644 --- a/xmake/plugins/project/ninja/build_ninja.lua +++ b/xmake/plugins/project/ninja/build_ninja.lua @@ -78,6 +78,7 @@ function _translate_compflags(compflags, outputdir) local flags = {} local last_flag = nil; for _, flag in ipairs(compflags) do + local flag = flag if flag == "-I" or flag == "-isystem" then last_flag = flag else @@ -103,6 +104,7 @@ end function _translate_linkflags(linkflags, outputdir) local flags = {} for _, flag in ipairs(linkflags) do + local flag = flag for _, pattern in ipairs({"[%-](L)(.*)", "[%-](F)(.*)"}) do flag = flag:gsub(pattern, function (flag, dir) dir = _get_relative_unix_path(dir, outputdir) diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua index 78bee84f8..b1bade847 100644 --- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua @@ -33,6 +33,7 @@ function _make_compflags(sourcefile, target, vcprojdir) -- replace -Idir or /Idir, -Fdsymbol.pdb or /Fdsymbol.pdb local flags = {} for _, flag in ipairs(compflags) do + local flag = flag -- replace -Idir or /Idir flag = flag:gsub("[%-|/]I(.*)", function (dir) @@ -75,6 +76,7 @@ function _make_linkflags(target, vcprojdir) -- replace -libpath:dir or /libpath:dir, -pdb:symbol.pdb or /pdb:symbol.pdb local flags = {} for _, flag in ipairs(linkflags) do + local flag = flag -- replace -libpath:dir or /libpath:dir flag = flag:gsub("[%-|/]libpath:(.*)", function (dir) diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua index 0a1b0955e..4da7a5d2e 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x.lua @@ -93,6 +93,7 @@ function _get_command_string(cmd, vcxprojdir) if cmd.program then local argv = {} for _, v in ipairs(table.join(cmd.program, cmd.argv)) do + local v = v if path.instance_of(v) then v = v:clone():set(_translate_path(v:rawstr(), vcxprojdir)):str() elseif path.is_absolute(v) then @@ -276,6 +277,7 @@ function _make_targetinfo(mode, arch, target, vcxprojdir) end end for k, v in table.orderpairs(setrunenvs) do + local v = v if #v == 1 then v = v[1] if path.is_absolute(v) and v:startswith(project.directory()) then diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua index fd62b0859..78407021e 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua @@ -137,6 +137,7 @@ end function _make_compcmd(compargv, sourcefile, objectfile, vcxprojdir) local argv = {} for i, v in ipairs(compargv) do + local v = v if i == 1 then v = path.filename(v) -- C:\xxx\ml.exe -> ml.exe end @@ -163,6 +164,7 @@ function _make_compflags(sourcefile, targetinfo, vcxprojdir) -- translate path for -Idir or /Idir local flags = {} for _, flag in ipairs(targetinfo.compflags[sourcefile]) do + local flag = flag for _, pattern in ipairs({"[%-/](I)(.*)", "[%-/](external:I)(.*)"}) do -- -Idir or /Idir @@ -186,6 +188,7 @@ function _make_linkflags(targetinfo, vcxprojdir) -- replace -libpath:dir or /libpath:dir local flags = {} for _, flag in ipairs(targetinfo.linkflags) do + local flag = flag -- replace -libpath:dir or /libpath:dir flag = flag:gsub(string.ipattern("[%-/]libpath:(.*)"), function (dir) @@ -932,6 +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}) if cxxlangflags[lang] then cxxstandard = cxxlangflags[lang] diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua index e3d29e946..2ac7aef5d 100644 --- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua +++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua @@ -77,6 +77,7 @@ function _make_filter(filepath, target, vcxprojdir) local rootdir = extraconf.rootdir assert(rootdir, "please set root directory, e.g. add_filegroups(%s, {rootdir = 'xxx'})", filegroup) for _, rootdir in ipairs(table.wrap(rootdir)) do + local rootdir = rootdir if not path.is_absolute(rootdir) then rootdir = path.absolute(rootdir, scriptdir) end @@ -84,6 +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))) if filepath:match(filepattern) then if mode == "plain" then diff --git a/xmake/plugins/project/vstudio/impl/vsutils.lua b/xmake/plugins/project/vstudio/impl/vsutils.lua index 98fbfd39f..984dd609e 100644 --- a/xmake/plugins/project/vstudio/impl/vsutils.lua +++ b/xmake/plugins/project/vstudio/impl/vsutils.lua @@ -79,6 +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) 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 diff --git a/xmake/plugins/project/vsxmake/getinfo.lua b/xmake/plugins/project/vsxmake/getinfo.lua index 585383872..9e943e49c 100644 --- a/xmake/plugins/project/vsxmake/getinfo.lua +++ b/xmake/plugins/project/vsxmake/getinfo.lua @@ -185,6 +185,7 @@ function _make_targetinfo(mode, arch, target) end end for k, v in table.orderpairs(addrunenvs) do + local v = v -- https://github.com/xmake-io/xmake/issues/3391 v = table.unique(v) if k:upper() == "PATH" then @@ -194,6 +195,7 @@ function _make_targetinfo(mode, arch, target) end end for k, v in table.orderpairs(setrunenvs) do + local v = v if #v == 1 then v = v[1] if path.is_absolute(v) and v:startswith(project.directory()) then @@ -342,6 +344,7 @@ function _make_filter(filepath, target, vcxprojdir) local rootdir = extraconf.rootdir assert(rootdir, "please set root directory, e.g. add_filegroups(%s, {rootdir = 'xxx'})", filegroup) for _, rootdir in ipairs(table.wrap(rootdir)) do + local rootdir = rootdir if not path.is_absolute(rootdir) then rootdir = path.absolute(rootdir, scriptdir) end @@ -349,6 +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))) if filepath:match(filepattern) then if mode == "plain" then diff --git a/xmake/plugins/show/info/target.lua b/xmake/plugins/show/info/target.lua index 62d8b6ddd..e63a51ea7 100644 --- a/xmake/plugins/show/info/target.lua +++ b/xmake/plugins/show/info/target.lua @@ -272,6 +272,7 @@ function _collect_target_info(target) end end for _, sourcekind in sourcekinds:keys() do + local sourcekind = sourcekind local compinst = target:compiler(sourcekind) if compinst then info.compilers = info.compilers or {} diff --git a/xmake/plugins/show/lists/apis.lua b/xmake/plugins/show/lists/apis.lua index 5011d39ae..84c2ab441 100644 --- a/xmake/plugins/show/lists/apis.lua +++ b/xmake/plugins/show/lists/apis.lua @@ -92,6 +92,7 @@ function description_package_scope_apis() local result = {} for _, names in pairs(package.apis()) do for _, name in ipairs(names) do + local name = name if type(name) == "table" then name = "package." .. name[1] end @@ -145,6 +146,7 @@ function description_builtin_apis() -- add root project apis for _, names in pairs(project.apis()) do for _, name in ipairs(names) do + local name = name if type(name) == "table" then name = name[1] end @@ -287,6 +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 modulefiles = os.files(path.join(moduledir, "**.lua|**/xmake.lua|private/**.lua|core/tools/**.lua|detect/tools/**.lua")) if modulefiles then diff --git a/xmake/rules/c++/modules/builder.lua b/xmake/rules/c++/modules/builder.lua index 761b2cf6c..6d82cca0b 100644 --- a/xmake/rules/c++/modules/builder.lua +++ b/xmake/rules/c++/modules/builder.lua @@ -91,6 +91,7 @@ function _get_jobdeps(target, module, jobgraph, buildfilejob) local jobdeps = {} local moduletype = support.has_two_phase_compilation_support(target) and "bmi" or "onephase" for dep_name, dep in pairs(module.deps) do + local dep_name = dep_name if dep.headerunit then dep_name = dep_name .. dep.key end @@ -347,6 +348,7 @@ function build_modules_for_batchjobs(target, batchjobs, built_modules, opt) local jobs local moduletype = has_two_phase_compilation_support and "bmi" or "onephase" for _, sourcefile in ipairs(_built_modules) do + local sourcefile = sourcefile jobs = jobs or {} local bmionly = support.is_bmionly(target, sourcefile) local module = mapper.get(target, sourcefile) @@ -354,6 +356,7 @@ function build_modules_for_batchjobs(target, batchjobs, built_modules, opt) local buildfilejob = _get_module_buildfilejob_for(target, sourcefile, moduletype) local deps = {} for dep_name, dep in pairs(module.deps) do + local dep_name = dep_name if dep.headerunit then dep_name = dep_name .. dep.key end @@ -409,6 +412,7 @@ function build_objectfiles_for_batchjobs(target, batchjobs, built_modules, opt) local jobs for _, sourcefile in ipairs(_built_modules) do + local sourcefile = sourcefile if not support.is_bmionly(target, sourcefile) then jobs = jobs or {} local module = mapper.get(target, sourcefile) diff --git a/xmake/rules/c++/modules/clang/builder.lua b/xmake/rules/c++/modules/clang/builder.lua index 60f2186e5..4839733e0 100644 --- a/xmake/rules/c++/modules/clang/builder.lua +++ b/xmake/rules/c++/modules/clang/builder.lua @@ -234,6 +234,7 @@ function _get_requiresflags(target, module) if not requiresflags or requires_changed then requiresflags = {} for required, dep in table.orderpairs(module.deps) do + local required = required if dep.headerunit then required = required .. dep.key end diff --git a/xmake/rules/c++/modules/clang/support.lua b/xmake/rules/c++/modules/clang/support.lua index 4bf5832a6..d0e73b304 100644 --- a/xmake/rules/c++/modules/clang/support.lua +++ b/xmake/rules/c++/modules/clang/support.lua @@ -49,6 +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() if line:startswith("#") and line:find("/vector\"", 1, true) then local includedir = line:match("\"(.+)/vector\"") @@ -164,6 +165,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() if os.isdir(line) then table.insert(includedirs, path.normalize(line)) diff --git a/xmake/rules/c++/modules/gcc/support.lua b/xmake/rules/c++/modules/gcc/support.lua index 4de7d6eab..62cdd37f9 100644 --- a/xmake/rules/c++/modules/gcc/support.lua +++ b/xmake/rules/c++/modules/gcc/support.lua @@ -38,6 +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() if line:startswith("#") and line:find("/vector\"", 1, true) then local includedir = line:match("\"(.+)/vector\"") @@ -114,6 +115,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() if os.isdir(line) then table.insert(includedirs, path.normalize(line)) diff --git a/xmake/rules/c++/modules/msvc/builder.lua b/xmake/rules/c++/modules/msvc/builder.lua index b59115477..46496609c 100644 --- a/xmake/rules/c++/modules/msvc/builder.lua +++ b/xmake/rules/c++/modules/msvc/builder.lua @@ -189,6 +189,7 @@ function _get_requiresflags(target, module) if not requiresflags or requires_changed then local deps_flags = {} for required, dep in pairs(module.deps) do + local required = required if dep.headerunit then required = required .. dep.key end diff --git a/xmake/rules/c++/unity_build/unity_build.lua b/xmake/rules/c++/unity_build/unity_build.lua index d5f5b060c..ce25b02cb 100644 --- a/xmake/rules/c++/unity_build/unity_build.lua +++ b/xmake/rules/c++/unity_build/unity_build.lua @@ -32,6 +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) sourcefile_unity = path.absolute(sourcefile_unity) sourcefile = path.relative(sourcefile, path.directory(sourcefile_unity)) diff --git a/xmake/rules/nim/build/target.lua b/xmake/rules/nim/build/target.lua index 52599b74d..13eb8be5c 100644 --- a/xmake/rules/nim/build/target.lua +++ b/xmake/rules/nim/build/target.lua @@ -53,6 +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() if #line > 0 then table.insert(dependinfo.files, line) diff --git a/xmake/rules/platform/linux/module/driver_modules.lua b/xmake/rules/platform/linux/module/driver_modules.lua index 689e3d0c7..f7d90a781 100644 --- a/xmake/rules/platform/linux/module/driver_modules.lua +++ b/xmake/rules/platform/linux/module/driver_modules.lua @@ -117,10 +117,12 @@ 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() if line:endswith("stub.c") then local include_cflag = false for _, cflag in ipairs(line:split("%s+")) do + local cflag = cflag local has_cflag = false if cflag:startswith("-fplugin=") then -- @see https://github.com/xmake-io/xmake/issues/3279 @@ -172,6 +174,7 @@ module_exit(hello_exit); if ldflags then local ko = ldflags:find("-T ", 1, true) for _, ldflag in ipairs(os.argv(ldflags)) do + local ldflag = ldflag if ldflag:endswith(".lds") then if not path.is_absolute(ldflag) then ldflag = path.absolute(ldflag, builddir or sdkdir) diff --git a/xmake/rules/qt/load.lua b/xmake/rules/qt/load.lua index dff70f52e..6b362e306 100644 --- a/xmake/rules/qt/load.lua +++ b/xmake/rules/qt/load.lua @@ -180,6 +180,7 @@ function _add_qmakeprllibs(target, prlfile, qt) end if envs.QMAKE_PRL_LIBS_FOR_CMAKE then for _, lib in ipairs(envs.QMAKE_PRL_LIBS_FOR_CMAKE:split(';', {plain = true})) do + local lib = lib if lib:startswith("-L") then local libdir = lib:sub(3) target:add("linkdirs", libdir) diff --git a/xmake/rules/qt/moc/xmake.lua b/xmake/rules/qt/moc/xmake.lua index dfd194ffe..509770576 100644 --- a/xmake/rules/qt/moc/xmake.lua +++ b/xmake/rules/qt/moc/xmake.lua @@ -87,6 +87,7 @@ rule("qt.moc") } for _, pathmap in ipairs(pathmaps) do for _, item in ipairs(_get_values_from_target(target, pathmap[1])) do + local item = item local pathitem = path(item, function (p) local item = table.unwrap(compiler.map_flags("cxx", pathmap[2], p)) if item then diff --git a/xmake/rules/swift/xmake.lua b/xmake/rules/swift/xmake.lua index e124865f2..0e8821c63 100644 --- a/xmake/rules/swift/xmake.lua +++ b/xmake/rules/swift/xmake.lua @@ -80,6 +80,7 @@ rule("swift.interop") if cpp_langflags == nil then local languages = target:get("languages") for _, language in ipairs(languages) do + local language = language if language:startswith("c++") or language:startswith("cxx") or language:startswith("gnu++") diff --git a/xmake/rules/utils/symbols/export_all/export_all.lua b/xmake/rules/utils/symbols/export_all/export_all.lua index 851450371..8c3a5b241 100644 --- a/xmake/rules/utils/symbols/export_all/export_all.lua +++ b/xmake/rules/utils/symbols/export_all/export_all.lua @@ -90,6 +90,7 @@ function _get_allsymbols_by_dumpbin(target, dumpbin, opt) _get_sourcefiles_map(target, sourcefiles_map) end for _, objectfile in ipairs(target:objectfiles()) do + local objectfile = objectfile local objectsymbols = try { function () return os.iorunv(dumpbin, {"/symbols", "/nologo", objectfile}) end } if objectsymbols then local sourcefile = sourcefiles_map[objectfile] @@ -125,6 +126,7 @@ function _get_allsymbols_by_objdump(target, objdump, opt) _get_sourcefiles_map(target, sourcefiles_map) end for _, objectfile in ipairs(target:objectfiles()) do + local objectfile = objectfile local objectsymbols = try { function () return os.iorunv(objdump, {"--syms", objectfile}) end } if objectsymbols then local sourcefile = sourcefiles_map[objectfile] diff --git a/xmake/rules/utils/symbols/export_list/xmake.lua b/xmake/rules/utils/symbols/export_list/xmake.lua index 84878fe7b..6759ee3ec 100644 --- a/xmake/rules/utils/symbols/export_list/xmake.lua +++ b/xmake/rules/utils/symbols/export_list/xmake.lua @@ -115,6 +115,7 @@ rule("utils.symbols.export_list") elseif exportkind == "apple" then local file = io.open(exportfile_tmp, 'w') for _, symbol in ipairs(exportsymbols) do + local symbol = symbol if not symbol:startswith("_") then symbol = "_" .. symbol end diff --git a/xmake/rules/verilator/verilator.lua b/xmake/rules/verilator/verilator.lua index 25ee1968f..cfa6bf030 100644 --- a/xmake/rules/verilator/verilator.lua +++ b/xmake/rules/verilator/verilator.lua @@ -40,6 +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) if os.isfile(classfile) then table.insert(global_classes, classfile) @@ -312,6 +313,7 @@ function build_cppfiles(target, jobgraph, sourcebatch, opt) end local sourcefiles = sourcebatch.sourcefiles for _, sourcefile in ipairs(sourcefiles) do + local sourcefile = sourcefile progress.show(opt.progress or 0, "${color.build.object}compiling.verilog %s", sourcefile) -- we need to use slashes to fix it on windows -- @see https://github.com/verilator/verilator/issues/3873 diff --git a/xmake/rules/wdk/load.lua b/xmake/rules/wdk/load.lua index 637ea9f80..9abf7438d 100644 --- a/xmake/rules/wdk/load.lua +++ b/xmake/rules/wdk/load.lua @@ -62,6 +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() if ldflag:find("[/%-]entry:") then entry = true @@ -111,6 +112,7 @@ function _kernel_driver_base(target, default_entrypoint) -- set default driver entry if does not exist local has_entry = false for _, ldflag in ipairs(target:get("ldflags")) do + local ldflag = ldflag if type(ldflag) == "string" then ldflag = ldflag:lower() if ldflag:find("[/%-]entry:") then diff --git a/xmake/rules/winsdk/mfc/mfc.lua b/xmake/rules/winsdk/mfc/mfc.lua index 671d74f2d..5464067cc 100644 --- a/xmake/rules/winsdk/mfc/mfc.lua +++ b/xmake/rules/winsdk/mfc/mfc.lua @@ -107,6 +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() if define:find("^[_]?unicode$") then unicode = true diff --git a/xmake/rules/xcode/application/run.lua b/xmake/rules/xcode/application/run.lua index 249558ffc..7debb8fc4 100644 --- a/xmake/rules/xcode/application/run.lua +++ b/xmake/rules/xcode/application/run.lua @@ -61,6 +61,7 @@ function _run_on_simulator(target, opt) -- find the booted devices local name, deviceid for _, line in ipairs(list:split('\n', {plain = true})) do + local line = line if line:find("(Booted)", 1, true) then line = line:trim() name, deviceid = line:match("(.-)%s+%(([%w%-]+)%)") |
