diff options
| author | ruki <[email protected]> | 2022-08-23 09:36:29 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-23 09:36:29 +0800 |
| commit | 006390def621247c8d3857495afaa4e7038a32fa (patch) | |
| tree | aa0bb46561ded824fd53999d0d6884fa803ba942 /xmake/rules/xcode/application | |
| parent | 5a9631ba93e7a677a8c1e9769b17e392cdbb61af (diff) | |
| parent | 2019daea91cb6ad5eda1a38fab3b515e261ea698 (diff) | |
Merge pull request #2707 from xmake-io/framework
improve frameworks
Diffstat (limited to 'xmake/rules/xcode/application')
| -rw-r--r-- | xmake/rules/xcode/application/build.lua | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/xmake/rules/xcode/application/build.lua b/xmake/rules/xcode/application/build.lua index a4862ae86..b39c3546e 100644 --- a/xmake/rules/xcode/application/build.lua +++ b/xmake/rules/xcode/application/build.lua @@ -25,6 +25,25 @@ import("core.project.depend") import("private.tools.codesign") import("utils.progress") +-- copy frameworks with symlink +-- +-- TODO we should improve os.cp to support for copying directory with symlink +-- 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, frameworkdir_dst) + else + local dstpath = path.join(frameworkdir_dst, path.filename(filepath)) + os.tryrm(dstpath) + os.cp(filepath, dstpath, {symlink = true}) + end + end +end + -- main entry function main (target, opt) @@ -32,6 +51,7 @@ function main (target, opt) local bundledir = path.absolute(target:data("xcode.bundle.rootdir")) local contentsdir = path.absolute(target:data("xcode.bundle.contentsdir")) local resourcesdir = path.absolute(target:data("xcode.bundle.resourcesdir")) + local frameworksdir = path.join(contentsdir, "Frameworks") -- do build if changed depend.on_changed(function () @@ -46,10 +66,21 @@ function main (target, opt) end os.vcp(target:targetfile(), path.join(binarydir, path.filename(target:targetfile()))) - -- copy dependent dynamic libraries, TODO copy frameworks + -- 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 - os.vcp(dep:targetfile(), binarydir) + local frameworkdir = dep:data("xcode.bundle.rootdir") + if dep:rule("xcode.framework") and frameworkdir then + _copy_frameworks(frameworkdir, frameworksdir, {symlink = true}) + else + os.vcp(dep:targetfile(), binarydir) + end end end |
