summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-02-07 22:30:34 +0800
committerruki <[email protected]>2024-02-07 22:30:34 +0800
commitac5e6c6b2d840d1cbfa0b16d38bfa9c7edc85720 (patch)
tree1ff22671a2449b421f91261e1602910920f35e7c
parent136350b6422b1dee9ae599c44e866bc1b2a18e39 (diff)
improve soname
-rw-r--r--xmake/rules/linker/soname/xmake.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/xmake/rules/linker/soname/xmake.lua b/xmake/rules/linker/soname/xmake.lua
index 2af8d7489..b82b52794 100644
--- a/xmake/rules/linker/soname/xmake.lua
+++ b/xmake/rules/linker/soname/xmake.lua
@@ -34,6 +34,7 @@ rule("linker.soname")
end)
after_link(function (target)
+ import("core.project.depend")
local soname = target:soname()
if target:is_shared() and soname and target:data("soname.enabled") then
local version = target:version()
@@ -45,13 +46,18 @@ rule("linker.soname")
end
local targetfile_with_soname = path.join(target:targetdir(), soname)
local targetfile = target:targetfile()
- if soname ~= filename and soname ~= path.filename(targetfile_with_version) and not os.islink(target:targetfile()) then
- os.cp(target:targetfile(), targetfile_with_version)
- os.rm(target:targetfile())
- local oldir = os.cd(target:targetdir())
- os.ln(path.filename(targetfile_with_version), soname, {force = true})
- os.ln(soname, path.filename(targetfile), {force = true})
- os.cd(oldir)
+ if soname ~= filename and soname ~= path.filename(targetfile_with_version) then
+ depend.on_changed(function ()
+ os.cp(target:targetfile(), targetfile_with_version)
+ os.rm(target:targetfile())
+ local oldir = os.cd(target:targetdir())
+ os.ln(path.filename(targetfile_with_version), soname, {force = true})
+ os.ln(soname, path.filename(targetfile), {force = true})
+ os.cd(oldir)
+ end, {dependfile = target:dependfile(targetfile_with_version),
+ files = {target:targetfile()},
+ values = {soname, version},
+ changed = target:is_rebuilt()})
end
end
end)