summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/batchcmds.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-17 23:51:28 +0800
committerruki <[email protected]>2024-07-17 23:51:28 +0800
commit9310167ec7254b065e687cba9740902939c005fd (patch)
treeb95a8deacadbc24500cda037a73c4106e50eb9fe /xmake/plugins/pack/batchcmds.lua
parent95c8f8615eb91de863c1eebeb27bb5c1c5e409a7 (diff)
revert bindir
Diffstat (limited to 'xmake/plugins/pack/batchcmds.lua')
-rw-r--r--xmake/plugins/pack/batchcmds.lua32
1 files changed, 9 insertions, 23 deletions
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index f810b934c..c41efb89d 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -61,15 +61,14 @@ function _get_target_installdir(package, target)
return path.normalize(installdir)
end
-function _get_target_package_libfiles(package, target, opt)
+function _get_target_package_libfiles(target, opt)
local libfiles = {}
- local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target)
for _, pkg in ipairs(target:orderpkgs(opt)) do
if pkg:enabled() and pkg:get("libfiles") then
for _, libfile in ipairs(table.wrap(pkg:get("libfiles"))) do
local filename = path.filename(libfile)
if filename:endswith(".dll") or filename:endswith(".so") or filename:find("%.so%.%d+$") or filename:endswith(".dylib") then
- table.insert(libfiles, path.joinenv({libfile, bindir}))
+ table.insert(libfiles, libfile)
end
end
end
@@ -82,10 +81,7 @@ function _get_target_package_libfiles(package, target, opt)
for _, libfile in ipairs(depend_libraries) do
depends:insert(path.filename(libfile))
end
- table.remove_if(libfiles, function (_, libfile)
- libfile = path.splitenv(libfile)[1]
- return not depends:has(path.filename(libfile))
- end)
+ table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
end
return libfiles
end
@@ -174,31 +170,26 @@ end
-- install target shared libraries
function _install_target_shared_libraries(target, batchcmds_, opt)
local package = opt.package
+ local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target)
-- get all dependent shared libraries
local libfiles = {}
for _, dep in ipairs(target:orderdeps()) do
- local bindir = dep:is_plat("windows", "mingw") and _get_target_bindir(package, dep) or _get_target_libdir(package, dep)
if dep:kind() == "shared" then
local depfile = dep:targetfile()
if os.isfile(depfile) then
- table.insert(libfiles, path.joinenv({depfile, bindir}))
+ table.insert(libfiles, depfile)
end
end
- table.join2(libfiles, _get_target_package_libfiles(package, dep, {interface = true}))
+ table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true}))
end
- table.join2(libfiles, _get_target_package_libfiles(package, target))
+ table.join2(libfiles, _get_target_package_libfiles(target))
-- deduplicate libfiles, prevent packages using the same libfiles from overwriting each other
libfiles = table.unique(libfiles)
-- do install
for _, libfile in ipairs(libfiles) do
- local splitinfo = path.splitenv(libfile)
- libfile = splitinfo[1]
- local bindir = splitinfo[2]
- assert(libfile and bindir)
-
local filename = path.filename(libfile)
_copy_file_with_symlinks(batchcmds_, libfile, bindir)
end
@@ -237,15 +228,15 @@ end
-- uninstall target shared libraries
function _uninstall_target_shared_libraries(target, batchcmds_, opt)
local package = opt.package
+ local bindir = target:is_plat("windows", "mingw") and _get_target_bindir(package, target) or _get_target_libdir(package, target)
-- get all dependent shared libraries
local libfiles = {}
for _, dep in ipairs(target:orderdeps()) do
- local bindir = dep:is_plat("windows", "mingw") and _get_target_bindir(package, dep) or _get_target_libdir(package, dep)
if dep:kind() == "shared" then
local depfile = dep:targetfile()
if os.isfile(depfile) then
- table.insert(libfiles, path.joinenv({depfile, bindir}))
+ table.insert(libfiles, depfile)
end
end
table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true}))
@@ -257,11 +248,6 @@ function _uninstall_target_shared_libraries(target, batchcmds_, opt)
-- do uninstall
for _, libfile in ipairs(libfiles) do
- local splitinfo = path.splitenv(libfile)
- libfile = splitinfo[1]
- local bindir = splitinfo[2]
- assert(libfile and bindir)
-
local filename = path.filename(libfile)
batchcmds_:rm(libfile, path.join(bindir, filename), {emptydirs = true})
end