summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/archive.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-17 21:53:04 +0800
committerGitHub <[email protected]>2023-11-17 21:53:04 +0800
commit4ec6682dea22ec5a2e4b818700288e625f761d52 (patch)
tree40e3e618ca22ae4e838319d458285698ce7528ee /xmake/plugins/pack/archive.lua
parent14f1ed5587ebe19a644f4832c059ff4ec830f6df (diff)
parent151b4ba88313652627da6f6747ed11bca6edc86c (diff)
Merge pull request #4396 from xmake-io/xpack
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