diff options
| author | ruki <[email protected]> | 2025-11-28 22:31:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-28 22:31:14 +0800 |
| commit | b186dc3e4f917b820df6729d2054d4bc16f40654 (patch) | |
| tree | da149b733bc42f2399b6d77df1083cac382b472c /xmake/plugins/pack | |
| parent | e918f54bb7e5f722ef3ef375809ebcfdaf546ddb (diff) | |
fix cp dir
Diffstat (limited to 'xmake/plugins/pack')
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 41 |
1 files changed, 27 insertions, 14 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) |
