diff options
| author | ruki <[email protected]> | 2023-11-15 16:34:08 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-15 16:34:08 +0800 |
| commit | 6677fd77ee78b53a1f9bd4ce9665ce8b60083d47 (patch) | |
| tree | 0094dfb752ac8e8816973f0db25b328c844d550f /xmake/modules | |
| parent | 4b102cbd2221494395e6e279ed453eee81ba45a4 (diff) | |
| parent | 7c37e9b9b92b53e4384daea5193f826bf8ac9492 (diff) | |
Merge pull request #4373 from xmake-io/xpack
Support `xmake pack`
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/require/impl/utils/filter.lua | 13 | ||||
| -rw-r--r-- | xmake/modules/private/utils/batchcmds.lua | 28 |
2 files changed, 29 insertions, 12 deletions
diff --git a/xmake/modules/private/action/require/impl/utils/filter.lua b/xmake/modules/private/action/require/impl/utils/filter.lua index 75bba1d42..0eee765b2 100644 --- a/xmake/modules/private/action/require/impl/utils/filter.lua +++ b/xmake/modules/private/action/require/impl/utils/filter.lua @@ -28,8 +28,6 @@ import("core.sandbox.sandbox") -- get filter function _filter() - - -- init filter if _g.filter == nil then _g.filter = filter.new() _g.filter:register("common", function (variable) @@ -60,13 +58,9 @@ function _filter() if type(result) == "function" then result = result() end - - -- ok? return result end) end - - -- ok return _g.filter end @@ -75,10 +69,7 @@ function _handler(package, strval) -- @note cannot cache it, because the package instance will be changed return function (variable) - - -- init maps - local maps = - { + local maps = { version = function () if strval then -- set_urls("https://sqlite.org/2018/sqlite-autoconf-$(version)000.tar.gz", @@ -102,8 +93,6 @@ function _handler(package, strval) if type(result) == "function" then result = result() end - - -- ok? return result end end diff --git a/xmake/modules/private/utils/batchcmds.lua b/xmake/modules/private/utils/batchcmds.lua index 6edd1d8f3..fe518cbec 100644 --- a/xmake/modules/private/utils/batchcmds.lua +++ b/xmake/modules/private/utils/batchcmds.lua @@ -144,6 +144,22 @@ function _runcmd_rm(cmd, opt) end end +-- run command: os.tryrm +function _runcmd_tryrm(cmd, opt) + local filepath = cmd.filepath + if not opt.dryrun then + os.tryrm(filepath) + end +end + +-- run command: os.rmdir +function _runcmd_rmdir(cmd, opt) + local dir = cmd.dir + if not opt.dryrun and os.isdir(dir) then + os.tryrm(dir) + end +end + -- run command: os.cp function _runcmd_cp(cmd, opt) if not opt.dryrun then @@ -178,8 +194,10 @@ function _runcmd(cmd, opt) execv = _runcmd_execv, vexecv = _runcmd_vexecv, mkdir = _runcmd_mkdir, + rmdir = _runcmd_rmdir, cd = _runcmd_cd, rm = _runcmd_rm, + tryrm = _runcmd_tryrm, cp = _runcmd_cp, mv = _runcmd_mv, ln = _runcmd_ln @@ -333,11 +351,21 @@ function batchcmds:mkdir(dir) table.insert(self:cmds(), {kind = "mkdir", dir = dir}) end +-- add command: os.rmdir +function batchcmds:rmdir(dir) + table.insert(self:cmds(), {kind = "rmdir", dir = dir}) +end + -- add command: os.rm function batchcmds:rm(filepath) table.insert(self:cmds(), {kind = "rm", filepath = filepath}) end +-- add command: os.tryrm +function batchcmds:tryrm(filepath) + table.insert(self:cmds(), {kind = "tryrm", filepath = filepath}) +end + -- add command: os.cp function batchcmds:cp(srcpath, dstpath, opt) table.insert(self:cmds(), {kind = "cp", srcpath = srcpath, dstpath = dstpath, opt = opt}) |
