From 1a870edea963e755c2e0b6983f0c0c1395ad06e7 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 23 Aug 2022 00:55:41 +0800 Subject: improve rpath for framework --- xmake/rules/xcode/framework/xmake.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'xmake/rules/xcode/framework/xmake.lua') 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) -- cgit v1.3.1 From 910b11a87f0e6a3719609d8be0f77b6e8bd7e06b Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 23 Aug 2022 00:55:57 +0800 Subject: improve rpath for framework --- xmake/rules/xcode/framework/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/rules/xcode/framework/xmake.lua') diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua index 438cbe00d..1dde3eec6 100644 --- a/xmake/rules/xcode/framework/xmake.lua +++ b/xmake/rules/xcode/framework/xmake.lua @@ -109,7 +109,7 @@ rule("xcode.framework") 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}) + os.vrunv("install_name_tool", {"-id", path.join("@rpath", rpath, filename), targetfile}) -- move header files os.tryrm(headersdir) -- cgit v1.3.1 From cc0dfe3d9eca8e11bb6c555c36edf3117d80559a Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 23 Aug 2022 22:33:47 +0800 Subject: fix load framework --- xmake/rules/xcode/application/build.lua | 12 ++++++++++-- xmake/rules/xcode/framework/xmake.lua | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'xmake/rules/xcode/framework/xmake.lua') diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index bb4ca080b..b39c3546e 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -31,11 +31,13 @@ import("utils.progress") -- os.vcp(frameworkdir, frameworksdir, {symlink = true}) function _copy_frameworks(frameworkdir, frameworksdir) os.mkdir(frameworksdir) + local frameworkdir_dst = path.join(frameworksdir, path.filename(frameworkdir)) + os.tryrm(frameworkdir_dst) for _, filepath in ipairs(os.filedirs(path.join(frameworkdir, "*"))) do if path.filename(filepath) == "Versions" then - _copy_frameworks(filepath, path.join(frameworksdir, "Versions")) + _copy_frameworks(filepath, frameworkdir_dst) else - local dstpath = path.join(frameworksdir, path.filename(filepath)) + local dstpath = path.join(frameworkdir_dst, path.filename(filepath)) os.tryrm(dstpath) os.cp(filepath, dstpath, {symlink = true}) end @@ -64,6 +66,12 @@ function main (target, opt) end os.vcp(target:targetfile(), path.join(binarydir, path.filename(target:targetfile()))) + -- change rpath + -- @see https://github.com/xmake-io/xmake/issues/2679#issuecomment-1221839215 + local targetfile = path.join(binarydir, path.filename(target:targetfile())) + os.vrunv("install_name_tool", {"-delete_rpath", "@loader_path", targetfile}) + os.vrunv("install_name_tool", {"-add_rpath", "@executable_path/../Frameworks", targetfile}) + -- copy dependent dynamic libraries and frameworks for _, dep in ipairs(target:orderdeps()) do if dep:kind() == "shared" then diff --git a/xmake/rules/xcode/framework/xmake.lua b/xmake/rules/xcode/framework/xmake.lua index 1dde3eec6..520ccf1b8 100644 --- a/xmake/rules/xcode/framework/xmake.lua +++ b/xmake/rules/xcode/framework/xmake.lua @@ -106,6 +106,7 @@ rule("xcode.framework") os.vcp(target:targetfile(), contentsdir) -- change rpath + -- @see https://github.com/xmake-io/xmake/issues/2679#issuecomment-1221839215 local filename = path.filename(target:targetfile()) local targetfile = path.join(contentsdir, filename) local rpath = path.relative(contentsdir, path.directory(bundledir)) -- cgit v1.3.1