summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-08-23 00:55:41 +0800
committerruki <[email protected]>2022-08-23 00:55:41 +0800
commit1a870edea963e755c2e0b6983f0c0c1395ad06e7 (patch)
tree999a9a32834f1b0a5d5a10683b7260a19fdbd4b1
parent22097d49e8a8ff60a8535005c3c3e5b713b2bd42 (diff)
improve rpath for framework
-rw-r--r--xmake/modules/core/tools/gcc.lua5
-rw-r--r--xmake/rules/xcode/framework/xmake.lua6
2 files changed, 9 insertions, 2 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 4122c8ae8..7dfaab07f 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -350,13 +350,14 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
-- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib
local flags_extra = {}
- if targetkind == "shared" and is_plat("macosx", "iphoneos", "watchos") then
+ local plat = self:plat()
+ if targetkind == "shared" and (plat == "macosx" or plat == "iphoneos" or plat == "watchos") then
table.insert(flags_extra, "-install_name")
table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
end
-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
- if targetkind == "shared" and is_plat("mingw") then
+ if targetkind == "shared" and plat == "mingw" then
table.insert(flags_extra, "-Wl,--out-implib," .. path.join(path.directory(targetfile), path.basename(targetfile) .. ".dll.a"))
end
diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua
index de7d7c93c..438cbe00d 100644
--- a/xmake/rules/xcode/framework/xmake.lua
+++ b/xmake/rules/xcode/framework/xmake.lua
@@ -105,6 +105,12 @@ rule("xcode.framework")
end
os.vcp(target:targetfile(), contentsdir)
+ -- change rpath
+ local filename = path.filename(target:targetfile())
+ local targetfile = path.join(contentsdir, filename)
+ local rpath = path.relative(contentsdir, path.directory(bundledir))
+ os.vrunv("install_name_tool", {"-id", path.join("@rpath", rpath), targetfile})
+
-- move header files
os.tryrm(headersdir)
os.mv(path.join(contentsdir, "Headers.tmp", target:basename()), headersdir)