diff options
| author | ruki <[email protected]> | 2024-07-23 23:44:08 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-23 23:44:08 +0800 |
| commit | 694c0ac091263a7bfeeda55cfc5a6a816c516a95 (patch) | |
| tree | 90d1be01bbf3d9eb047f7d3e5d61ec8ff0e188de /xmake/plugins/pack/nsis/main.lua | |
| parent | 9e1643aee954cdadea3eba96f3242b0a55ab6898 (diff) | |
fix pack io.gsub
Diffstat (limited to 'xmake/plugins/pack/nsis/main.lua')
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 2dc304b7b..ac6d008b7 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -260,22 +260,34 @@ function _pack_nsis(makensis, package) os.cp(specfile_template, specfile) end - -- replace variables in specfile + -- replace variables in specfile, + -- and we need to avoid `attempt to yield across a C-call boundary` in io.gsub local specvars = _get_specvars(package) local pattern = package:extraconf("specfile", "pattern") or "%${([^\n]-)}" + local specvars_names = {} + local specvars_values = {} io.gsub(specfile, "(" .. pattern .. ")", function(_, name) + table.insert(specvars_names, name) + end) + for _, name in ipairs(specvars_names) do name = name:trim() - local value = specvars[name] - if type(value) == "function" then - value = value() - end - if value ~= nil then - dprint(" > replace %s -> %s", name, value) - end - if type(value) == "table" then - dprint("invalid variable value", value) + if specvars_values[name] == nil then + local value = specvars[name] + if type(value) == "function" then + value = value() + end + if value ~= nil then + dprint(" > replace %s -> %s", name, value) + end + if type(value) == "table" then + dprint("invalid variable value", value) + end + specvars_values[name] = value end - return value + end + io.gsub(specfile, "(" .. pattern .. ")", function(_, name) + name = name:trim() + return specvars_values[name] end) -- make package |
