summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-15 22:55:08 +0800
committerruki <[email protected]>2024-07-15 12:21:42 +0800
commit729a9c2602a64f4d2fa5151355e8c63ff1a326ab (patch)
tree3893248b1514e0228ebbb96fa41844d675d149d7 /xmake/plugins/pack/batchcmds.lua
parentd151aaa50441d159a2980ceefc55f1db45f4d9b0 (diff)
improve batchcmds
Diffstat (limited to 'xmake/plugins/pack/batchcmds.lua')
-rw-r--r--xmake/plugins/pack/batchcmds.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index ff20729eb..320afaf72 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -86,6 +86,20 @@ function _get_target_package_libfiles(target, opt)
return libfiles
end
+-- copy file with symlinks
+function _copy_file_with_symlinks(batchcmds_, srcfile, outputdir)
+ if os.islink(srcfile) then
+ local srcfile_symlink = os.readlink(srcfile)
+ if not path.is_absolute(srcfile_symlink) then
+ srcfile_symlink = path.join(path.directory(srcfile), srcfile_symlink)
+ end
+ _copy_file_with_symlinks(batchcmds_, srcfile_symlink, outputdir)
+ batchcmds_:cp(srcfile, path.join(outputdir, path.filename(srcfile)), {symlink = true, force = true})
+ else
+ batchcmds_:cp(srcfile, path.join(outputdir, path.filename(srcfile)))
+ end
+end
+
-- install headers
function _install_target_headers(target, batchcmds_, opt)
local package = opt.package
@@ -139,7 +153,7 @@ function _install_target_shared_libraries(target, batchcmds_, opt)
-- do install
for _, libfile in ipairs(libfiles) do
local filename = path.filename(libfile)
- batchcmds_:cp(libfile, path.join(bindir, filename))
+ _copy_file_with_symlinks(batchcmds_, libfile, bindir)
end
end
@@ -203,7 +217,7 @@ function _on_target_installcmd_shared(target, batchcmds_, opt)
local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target)
local libdir = _get_target_libdir(package, target)
- batchcmds_:cp(target:targetfile(), path.join(bindir, target:filename()))
+ _copy_file_with_symlinks(batchcmds_, target:targetfile(), bindir)
if os.isfile(target:symbolfile()) then
batchcmds_:cp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile())))
end