summaryrefslogtreecommitdiff
path: root/xmake/plugins/pack/xpack.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-10 22:55:10 +0800
committerruki <[email protected]>2023-11-10 22:55:10 +0800
commitff33f52afebb41b4d281e9b4f7c9c6711a1e422c (patch)
treed7e9c6c2a5b36bf27c28944932b5f47465409e8b /xmake/plugins/pack/xpack.lua
parent28197467e651b9a92d7076a56783eb00b3dfaeb2 (diff)
get specfile
Diffstat (limited to 'xmake/plugins/pack/xpack.lua')
-rw-r--r--xmake/plugins/pack/xpack.lua56
1 files changed, 54 insertions, 2 deletions
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index 680b75d6d..2ffe725be 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -171,7 +171,7 @@ function xpack:formats()
end
-- has the given format?
-function xpack:has_format(...)
+function xpack:format_has(...)
local formats = self:formats()
for _, v in ipairs(table.pack(...)) do
if v and formats:has(v) then
@@ -180,6 +180,58 @@ function xpack:has_format(...)
end
end
+-- set the current format
+function xpack:format_set(format)
+ self._FORMAT = format
+end
+
+-- get the current format
+function xpack:format()
+ return self._FORMAT
+end
+
+-- get the build directory
+function xpack:buildir()
+ return path.join(config.buildir(), ".xpack", self:name(), self:format())
+end
+
+-- get the output directory
+function xpack:outputdir()
+ local outputdir = option.get("outputdir")
+ if outputdir == nil then
+ outputdir = path.join(config.buildir(), "xpack", self:name(), self:format())
+ end
+ return outputdir
+end
+
+-- get the basename
+function xpack:basename()
+ return self:get("basename") or self:name()
+end
+
+-- get the specfile path
+function xpack:specfile()
+ local extensions = {
+ nsis = ".nsi"
+ }
+ local extension = extensions[self:format()] or ".spec"
+ return self:get("specfile") or path.join(self:buildir(), self:basename() .. extension)
+end
+
+-- get the output filename
+function xpack:filename()
+ local extensions = {
+ nsis = ".exe"
+ }
+ local extension = extensions[self:format()] or ""
+ return self:basename() .. extension
+end
+
+-- get the output file
+function xpack:outputfile()
+ return path.join(self:outputdir(), self:filename())
+end
+
-- new a xpack
function _new(name, info)
return xpack {name, info}
@@ -213,7 +265,7 @@ function packages()
end
if need then
local instance = _new(name, scope)
- if not formats_need or instance:has_format(table.unpack(formats_need)) then
+ if not formats_need or instance:format_has(table.unpack(formats_need)) then
packages[name] = instance
end
end