summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-28 12:05:12 +0800
committerGitHub <[email protected]>2025-11-28 12:05:12 +0800
commitec0c0d458a14c6a9aff1a01d5e1cf264c8dcfeb2 (patch)
tree648c6e438c1ee829c4f61f8f83c6fef20057ebbb /xmake/plugins
parent4be95ee920757c2c813b84af5f07653c191c0215 (diff)
parent2766d4d1065f8daee0b7b5c95f9fd85b03144eb5 (diff)
Merge pull request #7071 from xmake-io/qt
Add Qt pack support
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/pack/nsis/main.lua42
-rw-r--r--xmake/plugins/pack/wix/main.lua62
2 files changed, 74 insertions, 30 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 793bed1cf..3dc579608 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -93,22 +93,40 @@ function _get_command_strings(package, cmd, opt)
local kind = cmd.kind
if kind == "cp" then
-- https://nsis.sourceforge.io/Reference/File
- local srcfiles = os.files(cmd.srcpath)
- for _, srcfile in ipairs(srcfiles) do
- -- the destination is directory? append the filename
- local dstfile = _translate_filepath(package, cmd.dstpath)
- if #srcfiles > 1 or path.islastsep(dstfile) then
+ local srcpath = cmd.srcpath
+ local dstpath = _translate_filepath(package, cmd.dstpath)
+
+ -- match files and directories
+ local srcitems = os.filedirs(srcpath)
+ for _, srcitem in ipairs(srcitems) do
+ if os.isdir(srcitem) then
+ -- copy directory recursively
+ srcitem = path.normalize(srcitem)
+ local dstdir = dstpath
if opt.rootdir then
- dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir))
+ dstdir = path.join(dstdir, path.relative(srcitem, opt.rootdir))
else
- dstfile = path.join(dstfile, path.filename(srcfile))
+ dstdir = path.join(dstdir, path.filename(srcitem))
+ end
+ dstdir = path.normalize(dstdir)
+ table.insert(result, string.format("SetOutPath \"%s\"", dstdir))
+ table.insert(result, string.format("File /r \"%s\\*\"", srcitem))
+ else
+ -- copy file
+ local dstfile = dstpath
+ if #srcitems > 1 or path.islastsep(dstfile) then
+ if opt.rootdir then
+ dstfile = path.join(dstfile, path.relative(srcitem, opt.rootdir))
+ else
+ dstfile = path.join(dstfile, path.filename(srcitem))
+ end
end
+ srcitem = path.normalize(srcitem)
+ local dstname = path.filename(dstfile)
+ local dstdir = path.normalize(path.directory(dstfile))
+ table.insert(result, string.format("SetOutPath \"%s\"", dstdir))
+ table.insert(result, string.format("File \"/oname=%s\" \"%s\"", dstname, srcitem))
end
- srcfile = path.normalize(srcfile)
- local dstname = path.filename(dstfile)
- local dstdir = path.normalize(path.directory(dstfile))
- table.insert(result, string.format("SetOutPath \"%s\"", dstdir))
- table.insert(result, string.format("File \"/oname=%s\" \"%s\"", dstname, srcfile))
end
elseif kind == "rm" then
local filepath = _translate_filepath(package, cmd.filepath)
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index 080d4e66d..896ea2339 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -79,26 +79,52 @@ function _get_cp_kind_table(package, cmds, opt)
end
local option = table.join(cmd.opt or {}, opt)
- local srcfiles = os.files(cmd.srcpath)
- for _, srcfile in ipairs(srcfiles) do
- -- the destination is directory? append the filename
- local dstfile = cmd.dstpath
- if #srcfiles > 1 or path.islastsep(dstfile) then
- if option.rootdir then
- dstfile = path.join(dstfile, path.relative(srcfile, option.rootdir))
- else
- dstfile = path.join(dstfile, path.filename(srcfile))
- end
- end
- srcfile = path.normalize(srcfile)
- local dstname = path.filename(dstfile)
- local dstdir = path.normalize(path.directory(dstfile))
- dstdir = _translate_filepath(package, dstdir)
+ -- match files and directories
+ local srcitems = os.filedirs(cmd.srcpath)
+ for _, srcitem in ipairs(srcitems) do
+ 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
+ -- the destination is directory? append the relative path
+ local dstfile = cmd.dstpath
+ if option.rootdir then
+ dstfile = path.join(dstfile, path.relative(srcfile, option.rootdir))
+ else
+ dstfile = path.join(dstfile, path.relative(srcfile, rootdir))
+ end
+ srcfile = path.normalize(srcfile)
+ local dstname = path.filename(dstfile)
+ local dstdir = path.normalize(path.directory(dstfile))
+ dstdir = _translate_filepath(package, dstdir)
- if result[dstdir] then
- table.insert(result[dstdir], {srcfile, dstname})
+ if result[dstdir] then
+ table.insert(result[dstdir], {srcfile, dstname})
+ else
+ result[dstdir] = {{srcfile, dstname}}
+ end
+ end
else
- result[dstdir] = {{srcfile, dstname}}
+ -- for file, use the original logic
+ local dstfile = cmd.dstpath
+ if #srcitems > 1 or path.islastsep(dstfile) then
+ if option.rootdir then
+ dstfile = path.join(dstfile, path.relative(srcitem, option.rootdir))
+ else
+ dstfile = path.join(dstfile, path.filename(srcitem))
+ end
+ end
+ srcitem = path.normalize(srcitem)
+ local dstname = path.filename(dstfile)
+ local dstdir = path.normalize(path.directory(dstfile))
+ dstdir = _translate_filepath(package, dstdir)
+
+ if result[dstdir] then
+ table.insert(result[dstdir], {srcitem, dstname})
+ else
+ result[dstdir] = {{srcitem, dstname}}
+ end
end
end
::continue::