From ad8a223ce684cd394179aca49fbea9c7b2e0d4c0 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 17 Jul 2024 00:57:22 +0800 Subject: add rpath for xpack --- xmake/modules/private/utils/batchcmds.lua | 51 +++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 12 deletions(-) (limited to 'xmake/modules/private/utils/batchcmds.lua') diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index 6c3742b9f..3ea49ea8d 100644 --- a/xmake/modules/private/utils/batchcmds.lua +++ b/xmake/modules/private/utils/batchcmds.lua @@ -29,6 +29,7 @@ import("core.tool.linker") import("core.tool.compiler") import("core.language.language") import("utils.progress", {alias = "progress_utils"}) +import("utils.binary.rpath", {alias = "rpath_utils"}) -- define module local batchcmds = batchcmds or object { _init = {"_TARGET", "_CMDS", "_DEPINFO", "_tip"}} @@ -173,6 +174,20 @@ function _runcmd_ln(cmd, opt) end end +-- run command: clean rpath +function _runcmd_clean_rpath(cmd, opt) + if not opt.dryrun then + rpath_utils.clean(cmd.filepath, opt.opt) + end +end + +-- run command: insert rpath +function _runcmd_insert_rpath(cmd, opt) + if not opt.dryrun then + rpath_utils.insert(cmd.filepath, cmd.rpath, opt.opt) + end +end + -- run command function _runcmd(cmd, opt) local kind = cmd.kind @@ -180,18 +195,20 @@ function _runcmd(cmd, opt) if not maps then maps = { - show = _runcmd_show, - runv = _runcmd_runv, - vrunv = _runcmd_vrunv, - execv = _runcmd_execv, - vexecv = _runcmd_vexecv, - mkdir = _runcmd_mkdir, - rmdir = _runcmd_rmdir, - cd = _runcmd_cd, - rm = _runcmd_rm, - cp = _runcmd_cp, - mv = _runcmd_mv, - ln = _runcmd_ln + show = _runcmd_show, + runv = _runcmd_runv, + vrunv = _runcmd_vrunv, + execv = _runcmd_execv, + vexecv = _runcmd_vexecv, + mkdir = _runcmd_mkdir, + rmdir = _runcmd_rmdir, + cd = _runcmd_cd, + rm = _runcmd_rm, + cp = _runcmd_cp, + mv = _runcmd_mv, + ln = _runcmd_ln, + clean_rpath = _runcmd_clean_rpath, + insert_rpath = _runcmd_insert_rpath } _g.maps = maps end @@ -389,6 +406,16 @@ function batchcmds:show(format, ...) table.insert(self:cmds(), {kind = "show", showtext = showtext}) end +-- add command: clean rpath +function batchcmds:clean_rpath(filepath, opt) + table.insert(self:cmds(), {kind = "clean_rpath", filepath = filepath, opt = opt}) +end + +-- add command: insert rpath +function batchcmds:insert_rpath(filepath, rpath, opt) + table.insert(self:cmds(), {kind = "insert_rpath", filepath = filepath, rpath = rpath, opt = opt}) +end + -- add raw command for the specific generator or xpack format function batchcmds:rawcmd(kind, rawstr) table.insert(self:cmds(), {kind = kind, rawstr = rawstr}) -- cgit v1.3.1 From 61325d912523d963241467a3dc5a2e20fe63ef42 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 17 Jul 2024 00:57:56 +0800 Subject: improve batchcmds --- xmake/modules/private/utils/batchcmds.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'xmake/modules/private/utils/batchcmds.lua') diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index 3ea49ea8d..97f414c77 100644 --- a/xmake/modules/private/utils/batchcmds.lua +++ b/xmake/modules/private/utils/batchcmds.lua @@ -188,6 +188,20 @@ function _runcmd_insert_rpath(cmd, opt) end end +-- run command: remove rpath +function _runcmd_remove_rpath(cmd, opt) + if not opt.dryrun then + rpath_utils.remove(cmd.filepath, cmd.rpath, opt.opt) + end +end + +-- run command: change rpath +function _runcmd_change_rpath(cmd, opt) + if not opt.dryrun then + rpath_utils.change(cmd.filepath, cmd.rpath_old, cmd.rpath_new, opt.opt) + end +end + -- run command function _runcmd(cmd, opt) local kind = cmd.kind @@ -208,7 +222,9 @@ function _runcmd(cmd, opt) mv = _runcmd_mv, ln = _runcmd_ln, clean_rpath = _runcmd_clean_rpath, - insert_rpath = _runcmd_insert_rpath + insert_rpath = _runcmd_insert_rpath, + remove_rpath = _runcmd_remove_rpath, + change_rpath = _runcmd_change_rpath } _g.maps = maps end @@ -416,6 +432,16 @@ function batchcmds:insert_rpath(filepath, rpath, opt) table.insert(self:cmds(), {kind = "insert_rpath", filepath = filepath, rpath = rpath, opt = opt}) end +-- add command: remove rpath +function batchcmds:remove_rpath(filepath, rpath, opt) + table.insert(self:cmds(), {kind = "remove_rpath", filepath = filepath, rpath = rpath, opt = opt}) +end + +-- add command: change rpath +function batchcmds:change_rpath(filepath, rpath_old, rpath_new, opt) + table.insert(self:cmds(), {kind = "change_rpath", filepath = filepath, rpath_old = rpath_old, rpath_new = rpath_new, opt = opt}) +end + -- add raw command for the specific generator or xpack format function batchcmds:rawcmd(kind, rawstr) table.insert(self:cmds(), {kind = kind, rawstr = rawstr}) -- cgit v1.3.1