diff options
| author | ruki <[email protected]> | 2025-11-28 22:34:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-28 22:34:57 +0800 |
| commit | 9d6daa73dbbc1c46552d5377291339514a1b6153 (patch) | |
| tree | 5e0db830df0d4e7ab8dbbe0f468adbc4f449aa58 | |
| parent | b186dc3e4f917b820df6729d2054d4bc16f40654 (diff) | |
improve nsis
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 74a083a1d..3dc579608 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -96,31 +96,36 @@ function _get_command_strings(package, cmd, opt) 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 + -- 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 + dstdir = path.join(dstdir, path.relative(srcitem, opt.rootdir)) + else + 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 #srcfiles > 1 or path.islastsep(dstfile) then + if #srcitems > 1 or path.islastsep(dstfile) then if opt.rootdir then - dstfile = path.join(dstfile, path.relative(srcfile, opt.rootdir)) + dstfile = path.join(dstfile, path.relative(srcitem, opt.rootdir)) else - dstfile = path.join(dstfile, path.filename(srcfile)) + dstfile = path.join(dstfile, path.filename(srcitem)) end end - srcfile = path.normalize(srcfile) + 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, srcfile)) + table.insert(result, string.format("File \"/oname=%s\" \"%s\"", dstname, srcitem)) end end elseif kind == "rm" then |
