diff options
| author | ruki <[email protected]> | 2023-11-24 23:09:46 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-24 23:09:46 +0800 |
| commit | 51efaa718683a9bf18cd6859e60f1d5240c10c5d (patch) | |
| tree | 0ae3485ef5434f8acfc70210b6910356aa5adfc5 /xmake/plugins/pack/xpack.lua | |
| parent | 16f74fe53b4c240c8bee69e1d06dc821067f2817 (diff) | |
| parent | 43ac546cbd551bf06ae37a8211c8a65d9eadbb0b (diff) | |
Merge pull request #4415 from xmake-io/makeself
pack runself
Diffstat (limited to 'xmake/plugins/pack/xpack.lua')
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 82 |
1 files changed, 75 insertions, 7 deletions
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index e5829fd45..64e9d77dc 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -225,6 +225,35 @@ function xpack:format() return self._FORMAT end +-- get the input kind +function xpack:inputkind() + local inputkind = self:get("inputkind") + if inputkind == nil then + local inputkinds = { + nsis = "binary", + zip = "binary", + targz = "binary", + srczip = "source", + srctargz = "source", + runself = "source", + deb = "source", + rpm = "source" + } + inputkind = inputkinds[self:format()] or "binary" + end + return inputkind +end + +-- pack from source files? +function xpack:from_source() + return self:inputkind() == "source" +end + +-- pack from binary files? +function xpack:from_binary() + return self:inputkind() == "binary" +end + -- get the build directory function xpack:buildir() return path.join(config.buildir(), ".xpack", self:name()) @@ -244,6 +273,9 @@ function xpack:basename() local basename = option.get("basename") or self:get("basename") if basename == nil then basename = self:name() + if self:from_source() then + basename = basename .. "-src" + end local version = self:version() if version then basename = basename .. "-" .. version @@ -264,6 +296,8 @@ function xpack:specvars() PACKAGE_TITLE = self:title() or "", PACKAGE_DESCRIPTION = self:description() or "", PACKAGE_FILENAME = self:filename(), + PACKAGE_AUTHOR = self:get("author") or "", + PACKAGE_MAINTAINER = self:get("maintainer") or self:get("author") or "", PACKAGE_HOMEPAGE = self:get("homepage") or "", PACKAGE_COPYRIGHT = self:get("copyright") or "", PACKAGE_COMPANY = self:get("company") or "", @@ -336,9 +370,14 @@ function xpack:extension() local extension = self:get("extension") if extension == nil then local extensions = { - nsis = ".exe", - zip = ".zip", - targz = ".tar.gz" + nsis = ".exe", + zip = ".zip", + targz = ".tar.gz", + srczip = ".zip", + srctargz = ".tar.gz", + runself = ".gz.run", + deb = ".deb", + rpm = ".rpm" } extension = extensions[self:format()] or "" end @@ -465,22 +504,51 @@ function xpack:installfiles() return self:_copiedfiles("installfiles", self:installdir()) end --- get the root directory, this is just a temporary sandbox installation path, +-- get the installed root directory, this is just a temporary sandbox installation path, -- we may replace it with the actual installation path in the specfile -function xpack:rootdir() +function xpack:install_rootdir() return path.join(self:buildir(), "installed", self:format()) end -- get the installed directory function xpack:installdir(...) - local installdir = self:rootdir() - local prefixdir = self:get("prefixdir") + local installdir = self:install_rootdir() + local prefixdir = self:prefixdir() if prefixdir then installdir = path.join(installdir, prefixdir) end return path.normalize(path.join(installdir, ...)) end +-- get the source files +function xpack:sourcefiles() + return self:_copiedfiles("sourcefiles", self:sourcedir()) +end + +-- get the source root directory +function xpack:source_rootdir() + return path.join(self:buildir(), "source", self:format()) +end + +-- get the source directory +function xpack:sourcedir(...) + local sourcedir = self:source_rootdir() + local prefixdir = self:prefixdir() + if prefixdir then + sourcedir = path.join(sourcedir, prefixdir) + end + return path.normalize(path.join(sourcedir, ...)) +end + +-- get the prefixdir +function xpack:prefixdir() + local prefixdir = self:get("prefixdir") + if prefixdir then + return filter.handle(prefixdir, self) + end + return prefixdir +end + -- get the binary directory function xpack:bindir() local bindir = self:get("bindir") |
