Skip to content

Commit de0ade7

Browse files
committedAug 21, 2024
add xmz archive
1 parent 7f4a287 commit de0ade7

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed
 

‎xmake/modules/utils/archive/archive.lua

+9-1
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,15 @@
2222
import("core.base.option")
2323
import("lib.detect.find_file")
2424
import("lib.detect.find_tool")
25+
import("archive_xmz")
2526
import("extension", {alias = "get_archive_extension"})
2627

28+
-- archive archivefile using xmake compress module
29+
function _archive_using_xmz(archivefile, inputfiles, extension, opt)
30+
archive_xmz(archivefile, inputfiles, opt)
31+
return true
32+
end
33+
2734
-- archive archivefile using zip
2835
function _archive_using_zip(archivefile, inputfiles, extension, opt)
2936

@@ -312,7 +319,7 @@ function _archive_tarfile(archivefile, tarfile, opt)
312319
return _archive(archivefile, tarfile, extension, archivers[extension], opt)
313320
end
314321

315-
-- archive archive file
322+
-- archive file
316323
--
317324
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
318325
-- @param inputfiles the input file or directory or list
@@ -334,6 +341,7 @@ function main(archivefile, inputfiles, opt)
334341
, [".tar"] = {_archive_using_tar}
335342
, [".tar.gz"] = {_archive_using_tar, _archive_using_gzip}
336343
, [".tar.xz"] = {_archive_using_tar, _archive_using_xz}
344+
, [".xmz"] = {_archive_using_xmz}
337345
}
338346

339347
-- get extension
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--!A cross-platform build utility based on Lua
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
--
15+
-- Copyright (C) 2015-present, TBOOX Open Source Group.
16+
--
17+
-- @author ruki
18+
-- @file archive_xmz.lua
19+
--
20+
21+
-- imports
22+
import("core.base.option")
23+
24+
-- archive archive file
25+
--
26+
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
27+
-- @param inputfiles the input file or directory or list
28+
-- @param options the options, e.g.. {curdir = "/tmp", recurse = true, compress = "fastest|faster|default|better|best", excludes = {"*/dir/*", "dir/*"}}
29+
--
30+
function main(archivefile, inputfiles, opt)
31+
opt = opt or {}
32+
end

‎xmake/modules/utils/archive/extension.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import("core.base.hashset")
2525
function main(archivefile)
2626
local extension = ""
2727
local filename = path.filename(archivefile)
28-
local extensionset = hashset.from({".zip", ".7z", ".gz", ".xz", ".tgz", ".bz2", ".tar", ".tar.gz", ".tar.xz", ".tar.bz2", ".tar.Z"})
28+
local extensionset = hashset.from({
29+
".xmz", -- xmake compression format
30+
".zip", ".7z", ".gz", ".xz", ".tgz",
31+
".bz2", ".tar", ".tar.gz", ".tar.xz",
32+
".tar.bz2", ".tar.Z"})
2933
local i = filename:lastof(".", true)
3034
if i then
3135
local p = filename:sub(1, i - 1):lastof(".", true)

‎xmake/modules/utils/archive/extract.lua

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ import("detect.tools.find_tar")
2727
import("detect.tools.find_gzip")
2828
import("detect.tools.find_unzip")
2929
import("detect.tools.find_bzip2")
30+
import("extract_xmz")
3031
import("extension", {alias = "get_archive_extension"})
3132

33+
-- extract archivefile using xmake decompress module
34+
function _extract_using_xmz(archivefile, outputdir, extension, opt)
35+
extract_xmz(archivefile, outputdir, opt)
36+
return true
37+
end
38+
3239
-- extract archivefile using tar
3340
function _extract_using_tar(archivefile, outputdir, extension, opt)
3441

@@ -394,7 +401,7 @@ function _extract(archivefile, outputdir, extension, extractors, opt)
394401
raise("cannot extract %s, %s!", path.filename(archivefile), errors or "extractors not found!")
395402
end
396403

397-
-- extract archive file
404+
-- extract file
398405
--
399406
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
400407
-- @param outputdir the output directory
@@ -423,6 +430,7 @@ function main(archivefile, outputdir, opt)
423430
, [".tar.bz2"] = {_extract_using_7z, _extract_using_bzip2}
424431
, [".tar.lz"] = {_extract_using_7z}
425432
, [".tar.Z"] = {_extract_using_7z}
433+
, [".xmz"] = {_extract_using_xmz}
426434
}
427435
else
428436
extractors =
@@ -440,6 +448,7 @@ function main(archivefile, outputdir, opt)
440448
, [".tar.bz2"] = {_extract_using_tar, _extract_using_7z, _extract_using_bzip2}
441449
, [".tar.lz"] = {_extract_using_tar, _extract_using_7z}
442450
, [".tar.Z"] = {_extract_using_tar, _extract_using_7z}
451+
, [".xmz"] = {_extract_using_xmz}
443452
}
444453
end
445454

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--!A cross-platform build utility based on Lua
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
--
15+
-- Copyright (C) 2015-present, TBOOX Open Source Group.
16+
--
17+
-- @author ruki
18+
-- @file extract_xmz.lua
19+
--
20+
21+
-- imports
22+
import("core.base.option")
23+
24+
-- extract file
25+
--
26+
-- @param archivefile the archive file. e.g. *.tar.gz, *.zip, *.7z, *.tar.bz2, ..
27+
-- @param outputdir the output directory
28+
-- @param options the options, e.g.. {excludes = {"*/dir/*", "dir/*"}}
29+
--
30+
function main(archivefile, outputdir, opt)
31+
opt = opt or {}
32+
end

0 commit comments

Comments
 (0)
Please sign in to comment.