diff options
| author | ruki <[email protected]> | 2026-04-01 21:02:03 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-04-01 21:02:03 +0800 |
| commit | 39fd35ea9d5d14079e4669b85423d488c9097cd4 (patch) | |
| tree | 7d4452174422931fe8a56f49b2d349b4b7cc90b3 /xmake/plugins | |
| parent | 75b084fa57f2fe00f369d9cac3878c03da43a68a (diff) | |
| parent | c63ac2d50545f2f58872c5be9a46d8fb5b3e8016 (diff) | |
Merge pull request #7437 from xmake-io/lua55
update to lua5.5
Diffstat (limited to 'xmake/plugins')
| -rw-r--r-- | xmake/plugins/format/main.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/deb/main.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/pack/runself/main.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/srpm/main.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/pack/wix/main.lua | 4 | ||||
| -rw-r--r-- | xmake/plugins/project/clang/compile_commands.lua | 1 | ||||
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 7 | ||||
| -rw-r--r-- | xmake/plugins/project/make/makefile.lua | 4 | ||||
| -rw-r--r-- | xmake/plugins/project/ninja/build_ninja.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua | 5 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua | 3 | ||||
| -rw-r--r-- | xmake/plugins/project/vstudio/impl/vsutils.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/project/vsxmake/getinfo.lua | 5 | ||||
| -rw-r--r-- | xmake/plugins/show/info/target.lua | 1 | ||||
| -rw-r--r-- | xmake/plugins/show/lists/apis.lua | 4 |
18 files changed, 42 insertions, 13 deletions
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua index 2d0913c20..fe05d86c6 100644 --- a/xmake/plugins/format/main.lua +++ b/xmake/plugins/format/main.lua @@ -63,7 +63,7 @@ function _get_file_patterns(sourcefiles) if excludes then local _excludes = {} for _, exclude in ipairs(excludes) do - 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 cfcdb0dfd..3f7fa4e82 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,7 +207,7 @@ function _pack_deb(debuild, package) end) end for _, name in ipairs(specvars_names) do - 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 3dc579608..420a1458c 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,7 +284,7 @@ function _pack_nsis(makensis, package) table.insert(specvars_names, name) end, {encoding = "ansi"}) for _, name in ipairs(specvars_names) do - 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 31f88f9dd..42eb8bc67 100644 --- a/xmake/plugins/pack/runself/main.lua +++ b/xmake/plugins/pack/runself/main.lua @@ -123,7 +123,7 @@ function _pack_runself(makeself, package) table.insert(specvars_names, name) end) for _, name in ipairs(specvars_names) do - 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 5b570844d..49e27fca3 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,7 +219,7 @@ function _pack_srpm(rpmbuild, package) table.insert(specvars_names, name) end) for _, name in ipairs(specvars_names) do - 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 896ea2339..e12461883 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,7 +302,7 @@ function _pack_wix(wix, package) table.insert(specvars_names, name) end) for _, name in ipairs(specvars_names) do - 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/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..ed179e177 100644 --- a/xmake/plugins/project/make/makefile.lua +++ b/xmake/plugins/project/make/makefile.lua @@ -276,7 +276,7 @@ end -- remove the given files or directories function _add_remove_files(makefile, filedirs, outputdir) for _, filedir in ipairs(filedirs) do - 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 @@ -554,7 +554,7 @@ function _add_build_target(makefile, target, targetflags, outputdir) local objectfiles = target:objectfiles() local objectfiles_translated = {} for _, objectfile in ipairs(objectfiles) do - 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/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..f1f44c3a8 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,7 +935,7 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo) local cstandard local cxxstandard for _, lang in pairs(targetinfo.languages) do - 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 e3d29e946..ed9002662 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,7 +85,7 @@ function _make_filter(filepath, target, vcxprojdir) local files = extraconf.files or "**" local mode = extraconf.mode for _, filepattern in ipairs(files) do - 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 98fbfd39f..30832ae3f 100644 --- a/xmake/plugins/project/vstudio/impl/vsutils.lua +++ b/xmake/plugins/project/vstudio/impl/vsutils.lua @@ -79,7 +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 - 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 585383872..9395657fd 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,7 +352,7 @@ function _make_filter(filepath, target, vcxprojdir) local files = extraconf.files or "**" local mode = extraconf.mode for _, filepattern in ipairs(files) do - 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/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..475535a1e 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,7 +289,7 @@ function script_extension_module_apis() local result = {} local moduledirs = module.directories() for _, moduledir in ipairs(moduledirs) do - 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 |
