diff options
| author | ruki <[email protected]> | 2023-11-10 22:57:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-10 22:57:56 +0800 |
| commit | 41b31a8fdb0a9e4e7dd2a6868694c12f95c8a4c6 (patch) | |
| tree | 8c7a3c1e5897efc1dfae25329201d575d650c007 | |
| parent | ff33f52afebb41b4d281e9b4f7c9c6711a1e422c (diff) | |
call makensis
| -rw-r--r-- | tests/plugins/pack/xmake.lua | 1 | ||||
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 25 | ||||
| -rw-r--r-- | xmake/plugins/pack/xpack.lua | 23 |
3 files changed, 45 insertions, 4 deletions
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua index 5d45181c0..7ae6a6cfc 100644 --- a/tests/plugins/pack/xmake.lua +++ b/tests/plugins/pack/xmake.lua @@ -1,3 +1,4 @@ +set_version("1.0.0") add_rules("mode.debug", "mode.release") includes("@builtin/xpack") diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 24bd371f7..876ada157 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -20,6 +20,7 @@ -- imports import("core.base.option") +import("core.base.semver") import("lib.detect.find_tool") import("private.action.require.impl.packagenv") import("private.action.require.impl.install_packages") @@ -61,15 +62,31 @@ function _pack_nsis(makensis, package, opt) os.cp(specfile_template, specfile) end + -- get version + local version, version_build = package:version() + assert(version, "xpack(%s): version not found!", package:name()) + version = semver.new(version) + -- generate specfile print("xpack(%s)", package:name()) print(" description: %s", package:description()) print(" installcmd: ", package:script("installcmd")) - -- ./nsis/makensis.exe /DMAJOR=$($version.ProductMajorPart) - -- /DMINOR=$($version.ProductMinorPart) - -- /DALTER=$($version.ProductBuildPart) /DBUILD=$($($version.ProductVersion - -- -split '\+')[1]) /D${{ matrix.arch }} .\scripts\installer.nsi + local argv = {} + if version:major() then + table.insert(argv, "/DMAJOR=" .. version:major()) + end + if version:minor() then + table.insert(argv, "/DMINOR=" .. version:minor()) + end + if version:patch() then + table.insert(argv, "/DALTER=" .. version:patch()) + end + if version_build then + table.insert(argv, "/DBUILD=" .. version_build) + end + table.insert(argv, specfile) + os.vrunv(makensis, argv) end function main(package, opt) diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua index 2ffe725be..cbc2b9045 100644 --- a/xmake/plugins/pack/xpack.lua +++ b/xmake/plugins/pack/xpack.lua @@ -232,6 +232,29 @@ function xpack:outputfile() return path.join(self:outputdir(), self:filename()) end +-- get the package version +function xpack:version() + local version = self:get("version") + local version_build + if version == nil then + for _, target in ipairs(self:targets()) do + version, version_build = target:version() + if version then + break + end + end + if version == nil then + version, version_build = project.version() + end + else + version_build = self:extraconf("version", version, "build") + if type(version_build) == "string" then + version_build = os.date(version_build, os.time()) + end + end + return version, version_build +end + -- new a xpack function _new(name, info) return xpack {name, info} |
