summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-07-25 22:48:40 +0800
committerruki <[email protected]>2023-07-25 22:48:40 +0800
commit03989ea64f8d591310cb388c432d0311884ad472 (patch)
tree739d9d20de970fe50d6d02ba6296433cfe603bdd
parent0a246a6718da31872cdedf48b3f430c8c6eb9caa (diff)
fix link files
-rw-r--r--xmake/rules/linker/soname/xmake.lua24
1 files changed, 24 insertions, 0 deletions
diff --git a/xmake/rules/linker/soname/xmake.lua b/xmake/rules/linker/soname/xmake.lua
index cd4d20221..3bacb721d 100644
--- a/xmake/rules/linker/soname/xmake.lua
+++ b/xmake/rules/linker/soname/xmake.lua
@@ -28,6 +28,30 @@ rule("linker.soname")
else
target:add("shflags", "-Wl,-soname," .. soname, {force = true})
end
+ target:data_set("soname.enabled", true)
+ end
+ end
+ end)
+ after_link(function (target)
+ local soname = target:soname()
+ if target:is_shared() and soname and target:data("soname.enabled") then
+ local version = target:version()
+ local filename = target:filename()
+ local extension = path.extension(filename)
+ local targetfile_with_version = path.join(target:targetdir(), filename .. "." .. version)
+ if extension == ".dylib" then
+ targetfile_with_version = path.join(target:targetdir(), path.basename(filename) .. "." .. version .. extension)
+ end
+ local targetfile_with_soname = path.join(target:targetdir(), soname)
+ local targetfile = target:targetfile()
+ if soname ~= filename and soname ~= path.filename(targetfile_with_version) then
+ os.cp(target:targetfile(), targetfile_with_version)
+ os.rm(target:targetfile())
+ os.rm(targetfile_with_soname)
+ local oldir = os.cd(target:targetdir())
+ os.ln(path.filename(targetfile_with_version), soname)
+ os.ln(soname, path.filename(targetfile))
+ os.cd(oldir)
end
end
end)