summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-14 00:57:41 +0800
committerruki <[email protected]>2023-11-14 00:57:41 +0800
commit6a3e7b08da3e333b0a63b4230f5dbf79df684728 (patch)
tree1c55128db8a0106c657cacad9fa7868aed19f2fb
parented01c2796c2485eb5a9ee6935605985bea6ad5aa (diff)
fix unknown vars
-rw-r--r--tests/plugins/pack/assets/file1.txt0
-rw-r--r--tests/plugins/pack/assets/file2.txt0
-rw-r--r--tests/plugins/pack/assets/img1.png0
-rw-r--r--tests/plugins/pack/assets/img2.png0
-rw-r--r--tests/plugins/pack/xmake.lua11
-rw-r--r--xmake/plugins/pack/nsis/main.lua59
-rw-r--r--xmake/plugins/pack/xpack.lua8
-rw-r--r--xmake/scripts/xpack/nsis/makensis.nsi13
8 files changed, 77 insertions, 14 deletions
diff --git a/tests/plugins/pack/assets/file1.txt b/tests/plugins/pack/assets/file1.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/plugins/pack/assets/file1.txt
diff --git a/tests/plugins/pack/assets/file2.txt b/tests/plugins/pack/assets/file2.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/plugins/pack/assets/file2.txt
diff --git a/tests/plugins/pack/assets/img1.png b/tests/plugins/pack/assets/img1.png
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/plugins/pack/assets/img1.png
diff --git a/tests/plugins/pack/assets/img2.png b/tests/plugins/pack/assets/img2.png
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/plugins/pack/assets/img2.png
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua
index 7ae6a6cfc..a19dcd021 100644
--- a/tests/plugins/pack/xmake.lua
+++ b/tests/plugins/pack/xmake.lua
@@ -11,7 +11,14 @@ xpack("test")
set_formats("nsis")
set_description("hello")
add_targets("test")
-
- on_installcmd(function (package)
+ add_installfiles("assets/*.png")
+ set_installdir("assets")
+ on_installcmd(function (package, batchcmds)
+ batchcmds:cp("assets/*.txt", "assets")
+ batchcmds:mkdir("stub")
+ end)
+ on_uninstallcmd(function (package, batchcmds)
+ batchcmds:rm("assets")
+ batchcmds:rm("stub")
end)
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 8058d747c..19b2a208d 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("core.base.semver")
import("lib.detect.find_tool")
+import("private.utils.batchcmds")
import("private.action.require.impl.packagenv")
import("private.action.require.impl.install_packages")
@@ -52,14 +53,68 @@ function _get_makensis()
return makensis, oldenvs
end
+-- get command string
+function _get_command_string(package, cmd)
+ local kind = cmd.kind
+ local opt = cmd.opt
+ if kind == "cp" then
+ -- TODO
+ elseif kind == "rm" then
+ -- TODO
+ elseif kind == "mv" then
+ -- TODO
+ elseif kind == "cd" then
+ -- TODO
+ elseif kind == "mkdir" then
+ -- TODO
+ elseif kind == "show" then
+ -- TODO
+ end
+ return ""
+end
+
+-- get commands string
+function _get_commands_string(package, cmds)
+ local cmdstrs = {}
+ for _, cmd in ipairs(cmds) do
+ local cmdstr = _get_command_string(package, cmd)
+ if cmdstr then
+ table.insert(cmdstrs, cmdstr)
+ end
+ end
+ return table.concat(cmdstrs, "\n ")
+end
+
-- get install commands
function _get_installcmds(package)
- return ""
+ local cmds = batchcmds.new()
+
+ -- TODO
+
+ -- get custom install commands
+ local script = package:script("installcmd")
+ if script then
+ script(package, cmds)
+ end
+
+ -- generate command string
+ return _get_command_string(package, cmds)
end
-- get uninstall commands
function _get_uninstallcmds(package)
- return ""
+ local cmds = batchcmds.new()
+
+ -- TODO
+
+ -- get custom uninstall commands
+ local script = package:script("uninstallcmd")
+ if script then
+ script(package, cmds)
+ end
+
+ -- generate command string
+ return _get_command_string(package, cmds)
end
-- get specvars
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index 13bf924bb..cc377276e 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.object")
import("core.base.option")
+import("core.base.semver")
import("core.base.hashset")
import("core.project.config")
import("core.project.project")
@@ -220,6 +221,7 @@ function xpack:specvars()
PACKAGE_NAME = self:name(),
PACKAGE_DESCRIPTION = self:description() or "",
PACKAGE_FILENAME = self:filename(),
+ PACKAGE_HOMEPAGE = self:get("homepage") or "",
PACKAGE_COPYRIGHT = self:get("copyright") or "",
PACKAGE_COMPANY = self:get("company") or ""
}
@@ -227,7 +229,7 @@ function xpack:specvars()
-- get version
local version, version_build = self:version()
if version then
- specvars.VERSION = version or "0.0.0"
+ specvars.PACKAGE_VERSION = version or "0.0.0"
try {function ()
local v = semver.new(version)
if v then
@@ -236,9 +238,7 @@ function xpack:specvars()
specvars.PACKAGE_VERSION_ALTER = v:patch() or "0"
end
end}
- if version_build then
- specvars.PACKAGE_VERSION_BUILD = version_build or ""
- end
+ specvars.PACKAGE_VERSION_BUILD = version_build or ""
end
-- get git information
diff --git a/xmake/scripts/xpack/nsis/makensis.nsi b/xmake/scripts/xpack/nsis/makensis.nsi
index 358eee744..856ebffd1 100644
--- a/xmake/scripts/xpack/nsis/makensis.nsi
+++ b/xmake/scripts/xpack/nsis/makensis.nsi
@@ -10,8 +10,12 @@
!include "UAC.nsh"
; the version information
-!define VERSION ${PACKAGE_VERSION}
-!define VERSION_FULL ${PACKAGE_VERSION}+${PACKAGE_VERSION_BUILD}
+!define VERSION "${PACKAGE_VERSION}"
+!if "${PACKAGE_VERSION_BUILD}" != ""
+!define VERSION_FULL "${PACKAGE_VERSION}+${PACKAGE_VERSION_BUILD}"
+!else
+!define VERSION_FULL "${PACKAGE_VERSION}"
+!endif
; set the package name
Name "${PACKAGE_NAME} - v${VERSION}"
@@ -194,7 +198,7 @@ Section "${PACKAGE_NAME} (required)" InstallExeutable
; Write the uninstall keys for Windows
!macro AddReg RootKey
WriteRegStr ${RootKey} ${RegUninstall} "NoAdmin" "$NOADMIN"
- WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "${PACKAGE_NAME} (${PACAKGE_ARCH})"
+ WriteRegStr ${RootKey} ${RegUninstall} "DisplayName" "${PACKAGE_NAME} (${PACKAGE_ARCH})"
WriteRegStr ${RootKey} ${RegUninstall} "DisplayIcon" '"$InstDir\${PACKAGE_FILENAME}"'
WriteRegStr ${RootKey} ${RegUninstall} "Comments" "${PACKAGE_DESCRIPTION}"
WriteRegStr ${RootKey} ${RegUninstall} "Publisher" "${PACKAGE_COPYRIGHT}"
@@ -281,9 +285,6 @@ Section "Uninstall"
; add uninstall commands
${PACKAGE_UNINSTALLCMDS}
- ; remove directories used
- RMDir /r "$InstDir"
-
; clean regs
${If} $NOADMIN == "false"
DeleteRegKey ${HKLM} ${RegUninstall}