summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-28 22:31:14 +0800
committerruki <[email protected]>2025-11-28 22:31:14 +0800
commitb186dc3e4f917b820df6729d2054d4bc16f40654 (patch)
treeda149b733bc42f2399b6d77df1083cac382b472c
parente918f54bb7e5f722ef3ef375809ebcfdaf546ddb (diff)
fix cp dir
-rw-r--r--xmake/plugins/pack/nsis/main.lua41
-rw-r--r--xmake/rules/qt/installcmd.lua17
2 files changed, 35 insertions, 23 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 793bed1cf..74a083a1d 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -93,22 +93,35 @@ 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
- if opt.rootdir then
- dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir))
- else
- dstfile = path.join(dstfile, path.filename(srcfile))
+ local srcpath = cmd.srcpath
+ local dstpath = _translate_filepath(package, cmd.dstpath)
+
+ -- check if source is a directory
+ if os.isdir(srcpath) then
+ -- use File /r to recursively copy directory
+ srcpath = path.normalize(srcpath)
+ local dstdir = path.normalize(dstpath)
+ table.insert(result, string.format("SetOutPath \"%s\"", dstdir))
+ table.insert(result, string.format("File /r \"%s\\*\"", srcpath))
+ else
+ -- copy files
+ local srcfiles = os.files(srcpath)
+ for _, srcfile in ipairs(srcfiles) do
+ -- the destination is directory? append the filename
+ local dstfile = dstpath
+ if #srcfiles > 1 or path.islastsep(dstfile) then
+ if opt.rootdir then
+ dstfile = path.join(dstfile, path.relative(srcfile, opt.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))
+ table.insert(result, string.format("SetOutPath \"%s\"", dstdir))
+ table.insert(result, string.format("File \"/oname=%s\" \"%s\"", dstname, srcfile))
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/rules/qt/installcmd.lua b/xmake/rules/qt/installcmd.lua
index f9aa87058..705ca9843 100644
--- a/xmake/rules/qt/installcmd.lua
+++ b/xmake/rules/qt/installcmd.lua
@@ -24,7 +24,7 @@ import("rules.qt.install.windeployqt", {rootdir = os.programdir()})
-- install application for xpack
function main(target, batchcmds, opt)
local package = opt.package
-
+
-- only for xpack (package exists)
if not package then
return
@@ -48,15 +48,15 @@ function main(target, batchcmds, opt)
elseif target:is_plat("windows", "mingw") then
-- Windows/Mingw: need to run windeployqt to deploy Qt dependencies
-- First, prepare files in a temporary directory, then copy to package bindir via batchcmds
-
+
-- prepare deployment in a temporary directory
local deploydir = path.join(target:autogendir(), "qt", "deploy", target:name())
os.mkdir(deploydir)
-
+
-- copy target binary to deploydir first
local targetfile = path.join(deploydir, target:filename())
os.cp(target:targetfile(), targetfile)
-
+
-- copy qt.shared deps
local installfiles = {targetfile}
for _, dep in ipairs(target:orderdeps()) do
@@ -69,11 +69,10 @@ function main(target, batchcmds, opt)
-- run windeployqt to deploy Qt dependencies to deploydir
windeployqt.run_deploy(target, deploydir, installfiles)
-
- -- copy all deployed files from deploydir to package bindir via batchcmds
- local package_bindir = package:installdir("bin")
- batchcmds:mkdir(package_bindir)
- batchcmds:cp(path.join(deploydir, "*"), package_bindir, {rootdir = deploydir})
+
+ -- copy all deployed files and directories from deploydir to root install directory via batchcmds
+ local installdir = package:installdir()
+ batchcmds:cp(path.join(deploydir, "*"), installdir, {rootdir = deploydir})
else
-- Linux: copy all files from bindir (plugins, translations, etc. should be handled separately)
local bindir = target:bindir()