summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-16 23:58:04 +0800
committerruki <[email protected]>2023-11-16 23:58:04 +0800
commita986e4a3a2ead1ed96973529de357ab7dcc90095 (patch)
tree66eefb51191441f04d5d554b124aec147cfc0a5c
parentd0f5f984219c480112a941d9de520254a844757a (diff)
prepare package for xmake/nsis
-rw-r--r--core/xpack.lua26
-rw-r--r--xmake/plugins/pack/main.lua6
-rw-r--r--xmake/plugins/pack/nsis/main.lua4
3 files changed, 31 insertions, 5 deletions
diff --git a/core/xpack.lua b/core/xpack.lua
index c41220dc2..5cbff58e8 100644
--- a/core/xpack.lua
+++ b/core/xpack.lua
@@ -21,13 +21,37 @@ xpack("xmake")
before_package(function (package)
import("net.http")
import("utils.archive")
+ import("core.base.global")
local format = package:format()
if package:is_plat("windows") and (format == "nsis" or format == "zip") then
local winenv = path.join(os.programdir(), "winenv")
if os.isdir(winenv) then
package:add("installfiles", path.join(winenv, "**"), {rootdir = path.directory(winenv)})
else
- -- TODO download
+ local arch = package:arch()
+ local url_7z = "https://github.com/xmake-mirror/7zip/releases/download/19.00/7z19.00-" .. arch .. ".zip"
+ local url_curl = "https://curl.se/windows/dl-8.2.1_11/curl-8.2.1_11-win32-mingw.zip"
+ local archive_7z = path.join(package:buildir(), "7z.zip")
+ local archive_curl = path.join(package:buildir(), "curl.zip")
+ local tmpdir_7z = path.join(package:buildir(), "7z")
+ local tmpdir_curl = path.join(package:buildir(), "curl")
+ local winenv_bindir = path.join(package:buildir(), "winenv", "bin")
+ os.mkdir(winenv_bindir)
+ http.download(url_7z, archive_7z, {insecure = global.get("insecure-ssl")})
+ if archive.extract(archive_7z, tmpdir_7z) then
+ os.cp(path.join(tmpdir_7z, "*"), winenv_bindir)
+ else
+ raise("extract 7z.zip failed!")
+ end
+ http.download(url_curl, archive_curl, {insecure = global.get("insecure-ssl")})
+ if archive.extract(archive_curl, tmpdir_curl) then
+ os.cp(path.join(tmpdir_curl, "*", "bin", "*.exe"), winenv_bindir)
+ os.cp(path.join(tmpdir_curl, "*", "bin", "*.crt"), winenv_bindir)
+ else
+ raise("extract curl.zip failed!")
+ end
+ winenv = path.directory(winenv_bindir)
+ package:add("installfiles", path.join(winenv, "**"), {rootdir = path.directory(winenv)})
end
end
end)
diff --git a/xmake/plugins/pack/main.lua b/xmake/plugins/pack/main.lua
index a0c94f998..7a4ab0fbf 100644
--- a/xmake/plugins/pack/main.lua
+++ b/xmake/plugins/pack/main.lua
@@ -39,6 +39,12 @@ function _on_package(package)
end
function _pack_package(package)
+
+ -- ensure build and output directories
+ os.tryrm(package:buildir())
+ os.mkdir(package:outputdir())
+
+ -- do pack
assert(package:formats(), "xpack(%s): formats not found, please use `set_formats()` to set it.", package:name())
local scripts = {
package:script("package_before"),
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 23749962a..02d31ac48 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -606,11 +606,7 @@ function main(package)
-- get makensis
local makensis, oldenvs = _get_makensis()
- -- clean the build directory first
- os.tryrm(package:buildir())
-
-- pack nsis package
- os.mkdir(package:outputdir())
_pack_nsis(makensis.program, package, opt)
-- done