summaryrefslogtreecommitdiff
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
parentd151aaa50441d159a2980ceefc55f1db45f4d9b0 (diff)
improve batchcmds
-rw-r--r--xmake/modules/target/action/install/main.lua12
-rw-r--r--xmake/plugins/pack/batchcmds.lua18
2 files changed, 22 insertions, 8 deletions
diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua
index 5a0bec7ab..b78c8bb54 100644
--- a/xmake/modules/target/action/install/main.lua
+++ b/xmake/modules/target/action/install/main.lua
@@ -49,16 +49,16 @@ function _get_target_package_libfiles(target, opt)
end
-- copy file with symlinks
-function _copyfile_with_symlinks(srcfile, outputdir)
+function _copy_file_with_symlinks(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
- _copyfile_with_symlinks(srcfile_symlink, outputdir)
- os.vcp(srcfile, outputdir, {symlink = true, force = true})
+ _copy_file_with_symlinks(srcfile_symlink, outputdir)
+ os.vcp(srcfile, path.join(outputdir, path.filename(srcfile)), {symlink = true, force = true})
else
- os.vcp(srcfile, outputdir)
+ os.vcp(srcfile, path.join(outputdir, path.filename(srcfile)))
end
end
@@ -121,7 +121,7 @@ function _install_shared_libraries(target, opt)
if os.isfile(filepath) and hash.sha256(filepath) ~= hash.sha256(libfile) then
wprint("'%s' already exists in install dir, we are copying '%s' to overwrite it.", filepath, libfile)
end
- _copyfile_with_symlinks(libfile, bindir)
+ _copy_file_with_symlinks(libfile, bindir)
end
end
@@ -152,7 +152,7 @@ function _install_shared(target, opt)
end
else
-- install target with soname and symlink
- _copyfile_with_symlinks(targetfile, bindir)
+ _copy_file_with_symlinks(targetfile, bindir)
end
os.trycp(target:symbolfile(), path.join(bindir, path.filename(target:symbolfile())))
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