summaryrefslogtreecommitdiff
path: root/xmake/modules/target
diff options
context:
space:
mode:
authorruki <[email protected]>2024-07-17 22:55:38 +0800
committerruki <[email protected]>2024-07-17 22:55:38 +0800
commite1590a09bb6fb17bc25b35d871e9eaec8f894050 (patch)
tree802e14aeae436ebac53d2e595a2f70ef969f7c75 /xmake/modules/target
parent5f5164528ab628cbd688782b9057e898f9a27cfe (diff)
fix rpath
Diffstat (limited to 'xmake/modules/target')
-rw-r--r--xmake/modules/target/action/install/main.lua16
1 files changed, 12 insertions, 4 deletions
diff --git a/xmake/modules/target/action/install/main.lua b/xmake/modules/target/action/install/main.lua
index 0b5ac126e..9e5e0c54c 100644
--- a/xmake/modules/target/action/install/main.lua
+++ b/xmake/modules/target/action/install/main.lua
@@ -29,12 +29,13 @@ function _get_target_package_libfiles(target, opt)
return {}
end
local libfiles = {}
+ local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir()
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, libfile)
+ table.insert(libfiles, path.joinenv({libfile, bindir}))
end
end
end
@@ -47,7 +48,10 @@ function _get_target_package_libfiles(target, opt)
for _, libfile in ipairs(depend_libraries) do
depends:insert(path.filename(libfile))
end
- table.remove_if(libfiles, function (_, libfile) return not depends:has(path.filename(libfile)) end)
+ table.remove_if(libfiles, function (_, libfile)
+ libfile = path.splitenv(libfile)[1]
+ return not depends:has(path.filename(libfile))
+ end)
end
return libfiles
end
@@ -104,15 +108,15 @@ end
-- install shared libraries
function _install_shared_libraries(target, opt)
- local bindir = target:is_plat("windows", "mingw") and target:bindir() or target:libdir()
-- get all dependent shared libraries
local libfiles = {}
for _, dep in ipairs(target:orderdeps()) do
+ local bindir = dep:is_plat("windows", "mingw") and dep:bindir() or dep:libdir()
if dep:kind() == "shared" then
local depfile = dep:targetfile()
if os.isfile(depfile) then
- table.insert(libfiles, depfile)
+ table.insert(libfiles, path.joinenv({depfile, bindir}))
end
end
table.join2(libfiles, _get_target_package_libfiles(dep, {interface = true}))
@@ -124,6 +128,10 @@ function _install_shared_libraries(target, opt)
-- 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)
local filepath = path.join(bindir, filename)
if os.isfile(filepath) and hash.sha256(filepath) ~= hash.sha256(libfile) then