summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-08-21 23:36:25 +0800
committerruki <[email protected]>2024-08-21 23:36:25 +0800
commitde0ade770bc66add05cd3b654acf50bc8b17fe35 (patch)
treee088183992b580da9a23ac741a50b62d23432080
parent7f4a28767f1a2e9a9139a58e176c5032d157f032 (diff)
add xmz archive
-rw-r--r--xmake/modules/utils/archive/archive.lua10
-rw-r--r--xmake/modules/utils/archive/archive_xmz.lua32
-rw-r--r--xmake/modules/utils/archive/extension.lua6
-rw-r--r--xmake/modules/utils/archive/extract.lua11
-rw-r--r--xmake/modules/utils/archive/extract_xmz.lua32
5 files changed, 88 insertions, 3 deletions
diff --git a/xmake/modules/utils/archive/archive.lua b/xmake/modules/utils/archive/archive.lua
index f91aa9d7f..804229638 100644
--- a/xmake/modules/utils/archive/archive.lua
+++ b/xmake/modules/utils/archive/archive.lua
@@ -22,8 +22,15 @@
import("core.base.option")
import("lib.detect.find_file")
import("lib.detect.find_tool")
+import("archive_xmz")
import("extension", {alias = "get_archive_extension"})
+-- archive archivefile using xmake compress module
+function _archive_using_xmz(archivefile, inputfiles, extension, opt)
+ archive_xmz(archivefile, inputfiles, opt)
+ return true
+end
+
-- archive archivefile using zip
function _archive_using_zip(archivefile, inputfiles, extension, opt)
@@ -312,7 +319,7 @@ function _archive_tarfile(archivefile, tarfile, opt)
return _archive(archivefile, tarfile, extension, archivers[extension], opt)
end
--- archive archive file
+-- archive file
--
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
-- @param inputfiles the input file or directory or list
@@ -334,6 +341,7 @@ function main(archivefile, inputfiles, opt)
, [".tar"] = {_archive_using_tar}
, [".tar.gz"] = {_archive_using_tar, _archive_using_gzip}
, [".tar.xz"] = {_archive_using_tar, _archive_using_xz}
+ , [".xmz"] = {_archive_using_xmz}
}
-- get extension
diff --git a/xmake/modules/utils/archive/archive_xmz.lua b/xmake/modules/utils/archive/archive_xmz.lua
new file mode 100644
index 000000000..77e110054
--- /dev/null
+++ b/xmake/modules/utils/archive/archive_xmz.lua
@@ -0,0 +1,32 @@
+--!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_xmz.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- archive archive file
+--
+-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
+-- @param inputfiles the input file or directory or list
+-- @param options the options, e.g.. {curdir = "/tmp", recurse = true, compress = "fastest|faster|default|better|best", excludes = {"*/dir/*", "dir/*"}}
+--
+function main(archivefile, inputfiles, opt)
+ opt = opt or {}
+end
diff --git a/xmake/modules/utils/archive/extension.lua b/xmake/modules/utils/archive/extension.lua
index 188631164..bee957f65 100644
--- a/xmake/modules/utils/archive/extension.lua
+++ b/xmake/modules/utils/archive/extension.lua
@@ -25,7 +25,11 @@ import("core.base.hashset")
function main(archivefile)
local extension = ""
local filename = path.filename(archivefile)
- local extensionset = hashset.from({".zip", ".7z", ".gz", ".xz", ".tgz", ".bz2", ".tar", ".tar.gz", ".tar.xz", ".tar.bz2", ".tar.Z"})
+ local extensionset = hashset.from({
+ ".xmz", -- xmake compression format
+ ".zip", ".7z", ".gz", ".xz", ".tgz",
+ ".bz2", ".tar", ".tar.gz", ".tar.xz",
+ ".tar.bz2", ".tar.Z"})
local i = filename:lastof(".", true)
if i then
local p = filename:sub(1, i - 1):lastof(".", true)
diff --git a/xmake/modules/utils/archive/extract.lua b/xmake/modules/utils/archive/extract.lua
index 604899300..3bb69ee1a 100644
--- a/xmake/modules/utils/archive/extract.lua
+++ b/xmake/modules/utils/archive/extract.lua
@@ -27,8 +27,15 @@ import("detect.tools.find_tar")
import("detect.tools.find_gzip")
import("detect.tools.find_unzip")
import("detect.tools.find_bzip2")
+import("extract_xmz")
import("extension", {alias = "get_archive_extension"})
+-- extract archivefile using xmake decompress module
+function _extract_using_xmz(archivefile, outputdir, extension, opt)
+ extract_xmz(archivefile, outputdir, opt)
+ return true
+end
+
-- extract archivefile using tar
function _extract_using_tar(archivefile, outputdir, extension, opt)
@@ -394,7 +401,7 @@ function _extract(archivefile, outputdir, extension, extractors, opt)
raise("cannot extract %s, %s!", path.filename(archivefile), errors or "extractors not found!")
end
--- extract archive file
+-- extract file
--
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
-- @param outputdir the output directory
@@ -423,6 +430,7 @@ function main(archivefile, outputdir, opt)
, [".tar.bz2"] = {_extract_using_7z, _extract_using_bzip2}
, [".tar.lz"] = {_extract_using_7z}
, [".tar.Z"] = {_extract_using_7z}
+ , [".xmz"] = {_extract_using_xmz}
}
else
extractors =
@@ -440,6 +448,7 @@ function main(archivefile, outputdir, opt)
, [".tar.bz2"] = {_extract_using_tar, _extract_using_7z, _extract_using_bzip2}
, [".tar.lz"] = {_extract_using_tar, _extract_using_7z}
, [".tar.Z"] = {_extract_using_tar, _extract_using_7z}
+ , [".xmz"] = {_extract_using_xmz}
}
end
diff --git a/xmake/modules/utils/archive/extract_xmz.lua b/xmake/modules/utils/archive/extract_xmz.lua
new file mode 100644
index 000000000..6dd645a52
--- /dev/null
+++ b/xmake/modules/utils/archive/extract_xmz.lua
@@ -0,0 +1,32 @@
+--!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 extract_xmz.lua
+--
+
+-- imports
+import("core.base.option")
+
+-- extract file
+--
+-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
+-- @param outputdir the output directory
+-- @param options the options, e.g.. {excludes = {"*/dir/*", "dir/*"}}
+--
+function main(archivefile, outputdir, opt)
+ opt = opt or {}
+end