summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/archive.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-18 00:35:53 +0800
committerruki <[email protected]>2023-11-18 00:35:53 +0800
commit76d63abc88586d3e51179773c1112f1eee76a8e8 (patch)
tree0e5ce02c245fadc920d71d02ed4151ff284121e5 /xmake/plugins/pack/archive.lua
parent14f1ed5587ebe19a644f4832c059ff4ec830f6df (diff)
improve installdir for xpack
Diffstat (limited to 'xmake/plugins/pack/archive.lua')
-rw-r--r--xmake/plugins/pack/archive.lua51
1 files changed, 5 insertions, 46 deletions
diff --git a/xmake/plugins/pack/archive.lua b/xmake/plugins/pack/archive.lua
index 2db7a1e3c..5a890ca85 100644
--- a/xmake/plugins/pack/archive.lua
+++ b/xmake/plugins/pack/archive.lua
@@ -23,63 +23,22 @@ import("core.base.option")
import("utils.archive")
import("batchcmds")
--- get archive directory
-function _get_archivedir(package)
- return path.join(package:buildir(), "archive", package:format())
-end
-
--- run command
-function _run_command(package, cmd)
- local opt = cmd.opt or {}
- local kind = cmd.kind
- local archivedir = _get_archivedir(package)
- if kind == "cp" then
- local srcpath = cmd.srcpath
- local dstpath = path.join(archivedir, cmd.dstpath)
- os.vcp(srcpath, dstpath, opt)
- elseif kind == "rm" then
- local filepath = path.join(archivedir, cmd.filepath)
- os.tryrm(filepath, opt)
- elseif kind == "rmdir" then
- local dir = path.join(archivedir, cmd.dir)
- if os.isdir(dir) then
- os.tryrm(dir, opt)
- end
- elseif kind == "mv" then
- local srcpath = cmd.srcpath
- local dstpath = path.join(archivedir, cmd.dstpath)
- os.vmv(srcpath, dstpath, opt)
- elseif kind == "cd" then
- local dir = path.join(archivedir, cmd.dir)
- os.cd(dir)
- elseif kind == "mkdir" then
- local dir = path.join(archivedir, cmd.dir)
- os.mkdir(dir)
- end
-end
-
--- run commands
-function _run_commands(package, cmds)
- for _, cmd in ipairs(cmds) do
- _run_command(package, cmd)
- end
-end
-
-- pack archive package
function _pack_archive(package)
-- do install
- _run_commands(package, batchcmds.get_installcmds(package):cmds())
+ batchcmds.get_installcmds(package):runcmds()
-- archive install files
- local archivedir = _get_archivedir(package)
- local oldir = os.cd(archivedir)
+ local installdir = package:installdir()
+ local oldir = os.cd(installdir)
local archivefiles = os.files("**")
os.cd(oldir)
- archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = archivedir})
+ archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = installdir})
end
function main(package)
cprint("packing %s .. ", package:outputfile())
+ _pack_archive(package)
end