summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-11-17 23:30:30 +0800
committerruki <[email protected]>2023-11-17 23:30:30 +0800
commit0accb1d4f09cc780bbb16ea510f791f8354ee741 (patch)
tree786529a1229992b92ac59a05f7bf48f4e46e6450
parent42030c6ef77d2cdb5dfd1e809eff448f761d36a7 (diff)
add pack archive stub
-rw-r--r--core/xpack.lua2
-rw-r--r--tests/plugins/pack/xmake.lua2
-rw-r--r--xmake/plugins/pack/archive.lua33
-rw-r--r--xmake/plugins/pack/nsis/main.lua10
-rw-r--r--xmake/plugins/pack/xpack.lua3
-rw-r--r--xmake/plugins/pack/zip/main.lua26
6 files changed, 71 insertions, 5 deletions
diff --git a/core/xpack.lua b/core/xpack.lua
index 280b1365a..eb61f49e4 100644
--- a/core/xpack.lua
+++ b/core/xpack.lua
@@ -1,5 +1,5 @@
xpack("xmake")
- set_formats("nsis")
+ set_formats("nsis", "zip")
set_description("A cross-platform build utility based on Lua. https://xmake.io")
set_licensefile("../LICENSE.md")
add_targets("demo")
diff --git a/tests/plugins/pack/xmake.lua b/tests/plugins/pack/xmake.lua
index fc436f8b7..9142e3aa8 100644
--- a/tests/plugins/pack/xmake.lua
+++ b/tests/plugins/pack/xmake.lua
@@ -19,7 +19,7 @@ target("foo")
add_packages("zlib")
xpack("test")
- set_formats("nsis")
+ set_formats("nsis", "zip")
set_description("hello")
set_licensefile("LICENSE.md")
add_targets("test", "foo")
diff --git a/xmake/plugins/pack/archive.lua b/xmake/plugins/pack/archive.lua
new file mode 100644
index 000000000..c6b30c941
--- /dev/null
+++ b/xmake/plugins/pack/archive.lua
@@ -0,0 +1,33 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file archive.lua
+--
+
+-- imports
+import("core.base.option")
+import("utils.archive")
+
+-- pack archive package
+function _pack_archive(package)
+end
+
+function main(package, format)
+ cprint("packing %s", package:outputfile())
+ _pack_archive(package)
+end
+
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua
index 22d63eb30..bb1da6a7a 100644
--- a/xmake/plugins/pack/nsis/main.lua
+++ b/xmake/plugins/pack/nsis/main.lua
@@ -586,7 +586,7 @@ function _get_specvars(package)
end
-- pack nsis package
-function _pack_nsis(makensis, package, opt)
+function _pack_nsis(makensis, package)
-- install the initial specfile
local specfile = package:specfile()
@@ -618,13 +618,19 @@ function _pack_nsis(makensis, package, opt)
end
function main(package)
+
+ -- only for windows
+ if not is_host("windows") then
+ return
+ end
+
cprint("packing %s", package:outputfile())
-- get makensis
local makensis, oldenvs = _get_makensis()
-- pack nsis package
- _pack_nsis(makensis.program, package, opt)
+ _pack_nsis(makensis.program, package)
-- done
os.setenvs(oldenvs)
diff --git a/xmake/plugins/pack/xpack.lua b/xmake/plugins/pack/xpack.lua
index 745d8f9f7..4d32d6c08 100644
--- a/xmake/plugins/pack/xpack.lua
+++ b/xmake/plugins/pack/xpack.lua
@@ -323,7 +323,8 @@ end
-- get the output filename
function xpack:filename()
local extensions = {
- nsis = ".exe"
+ nsis = ".exe",
+ zip = ".zip"
}
local extension = extensions[self:format()] or ""
return self:basename() .. extension
diff --git a/xmake/plugins/pack/zip/main.lua b/xmake/plugins/pack/zip/main.lua
new file mode 100644
index 000000000..b54e6bf8a
--- /dev/null
+++ b/xmake/plugins/pack/zip/main.lua
@@ -0,0 +1,26 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file main.lua
+--
+
+-- imports
+import(".archive")
+
+function main(package)
+ archive(package, "zip")
+end