diff options
| author | ruki <[email protected]> | 2024-07-16 23:57:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-07-16 23:57:00 +0800 |
| commit | 4c983a4dc236397c6bee9cf6e06f089d12a9f259 (patch) | |
| tree | effbe21bda41931d313550dbc0723d4b8d8fc174 /xmake/modules/utils/binary | |
| parent | 142e3da88a41ef9519e2482b9c198d8bfeeaec6e (diff) | |
change rpath for macho
Diffstat (limited to 'xmake/modules/utils/binary')
| -rw-r--r-- | xmake/modules/utils/binary/rpath.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/xmake/modules/utils/binary/rpath.lua b/xmake/modules/utils/binary/rpath.lua index 510b5efb5..ad42970ca 100644 --- a/xmake/modules/utils/binary/rpath.lua +++ b/xmake/modules/utils/binary/rpath.lua @@ -165,6 +165,20 @@ function _insert_rpath_by_install_name_tool(binaryfile, rpath, opt) return ok end +-- install_name_tool -rpath <rpath_old> <rpath_new> binaryfile +function _change_rpath_by_install_name_tool(binaryfile, rpath_old, rpath_new, opt) + local plat = opt.plat or os.host() + local arch = opt.arch or os.arch() + if plat ~= "macosx" and plat ~= "iphoneos" and plat ~= "appletvos" and plat ~= "watchos" then + return false + end + local ok = try { function () + os.vrunv("install_name_tool", {"-rpath", rpath_old, rpath_new, binaryfile}) + return true + end } + return ok +end + -- install_name_tool -delete_rpath <rpath> binaryfile function _remove_rpath_by_install_name_tool(binaryfile, rpath, opt) local plat = opt.plat or os.host() @@ -211,6 +225,20 @@ function insert(binaryfile, rpath, opt) end end +-- change rpath +function change(binaryfile, rpath_old, rpath_new, opt) + opt = opt or {} + local ops = {} + if is_host("macosx") then + table.insert(ops, 1, _change_rpath_by_install_name_tool) + end + for _, op in ipairs(ops) do + if op(binaryfile, rpath_old, rpath_new, opt) then + break + end + end +end + -- remove rpath function remove(binaryfile, rpath, opt) opt = opt or {} |
