diff options
| author | ruki <[email protected]> | 2023-11-18 00:42:27 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-18 00:42:27 +0800 |
| commit | 8a593a2d3ad47e57064516643fd8cb8442cbb52d (patch) | |
| tree | ad565098d347bcc293f0f635cf6e6816a9d7054d | |
| parent | 4ec6682dea22ec5a2e4b818700288e625f761d52 (diff) | |
add set_prefixdir
| -rw-r--r-- | core/xpack.lua | 4 | ||||
| -rw-r--r-- | xmake/includes/xpack/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/archive.lua | 6 | ||||
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 2 | ||||
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 14 |
5 files changed, 22 insertions, 6 deletions
diff --git a/core/xpack.lua b/core/xpack.lua index 86c87fc83..a84c839d5 100644 --- a/core/xpack.lua +++ b/core/xpack.lua @@ -19,6 +19,10 @@ xpack("xmake") end end package:set("basename", "xmake-v$(version)." .. arch) + local format = package:format() + if format == "zip" then + package:set("prefixdir", "xmake") + end end) before_package(function (package) diff --git a/xmake/includes/xpack/xmake.lua b/xmake/includes/xpack/xmake.lua index 901cb160b..cbfedc600 100644 --- a/xmake/includes/xpack/xmake.lua +++ b/xmake/includes/xpack/xmake.lua @@ -50,6 +50,8 @@ local apis = { "xpack.set_libdir", -- set installed include directory, e.g. include "xpack.set_includedir", + -- set prefix directory, e.g. prefixdir/bin, prefixdir/lib .. + "xpack.set_prefixdir", -- set nsis display name "xpack.set_nsis_displayname", -- set nsis display icon diff --git a/xmake/plugins/pack/archive.lua b/xmake/plugins/pack/archive.lua index 5a890ca85..d66f5e094 100644 --- a/xmake/plugins/pack/archive.lua +++ b/xmake/plugins/pack/archive.lua @@ -30,11 +30,11 @@ function _pack_archive(package) batchcmds.get_installcmds(package):runcmds() -- archive install files - local installdir = package:installdir() - local oldir = os.cd(installdir) + local rootdir = package:rootdir() + local oldir = os.cd(rootdir) local archivefiles = os.files("**") os.cd(oldir) - archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = installdir}) + archive.archive(path.absolute(package:outputfile()), archivefiles, {curdir = rootdir}) end function main(package) diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 660192b02..f85ad271d 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -61,7 +61,7 @@ end -- translate the file path function _translate_filepath(package, filepath) - return filepath:replace(package:installdir(), "$InstDir", {plain = true}) + return filepath:replace(package:rootdir(), "$InstDir", {plain = true}) end -- get command string diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 71fd3ac08..d0dc56697 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -446,10 +446,20 @@ function xpack:installfiles() return self:_copiedfiles("installfiles", self:installdir()) end --- get the install directory, this is just a temporary sandbox installation path, +-- get the 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() + return path.join(self:buildir(), "installed", self:format()) +end + +-- get the installed directory function xpack:installdir(...) - return path.normalize(path.join(self:buildir(), "installed", self:format(), ...)) + local installdir = self:rootdir() + local prefixdir = self:get("prefixdir") + if prefixdir then + installdir = path.join(installdir, prefixdir) + end + return path.normalize(path.join(installdir, ...)) end -- get the binary directory |
