summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/wix/main.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-23 23:44:08 +0800
committerruki <[email protected]>2024-07-23 23:44:08 +0800
commit694c0ac091263a7bfeeda55cfc5a6a816c516a95 (patch)
tree90d1be01bbf3d9eb047f7d3e5d61ec8ff0e188de /xmake/plugins/pack/wix/main.lua
parent9e1643aee954cdadea3eba96f3242b0a55ab6898 (diff)
fix pack io.gsub
Diffstat (limited to 'xmake/plugins/pack/wix/main.lua')
-rw-r--r--xmake/plugins/pack/wix/main.lua32
1 files changed, 22 insertions, 10 deletions
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index a99ecdb6e..a99070def 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -265,21 +265,33 @@ function _pack_wix(wix, package)
end
-- 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)
local argv = {"build", specfile}