This commit is contained in:
SirLynix
2022-12-06 20:10:10 +01:00
committed by Jérôme Leclercq
parent b379518479
commit 292ca60592
34 changed files with 1995 additions and 60 deletions

View File

@@ -0,0 +1,64 @@
add_rules("mode.debug", "mode.release")
option("enable_tools")
set_default(false)
set_showmenu(true)
target("bz2")
set_kind("$(kind)")
set_languages("c89")
add_headerfiles("bzlib.h")
add_files("blocksort.c")
add_files("bzlib.c")
add_files("compress.c")
add_files("crctable.c")
add_files("decompress.c")
add_files("huffman.c")
add_files("randtable.c")
if is_plat("windows") and is_kind("shared") then
set_filename("libbz2.dll")
add_files("libbz2.def")
end
if is_plat("wasm") then
add_defines("BZ_STRICT_ANSI")
end
if has_config("enable_tools") then
target("bzip2")
set_kind("binary")
add_deps("bz2")
add_files("bzip2.c")
after_install(function (target)
-- copy/link additional executables/scripts (behavior is altered by checking the program name)
if target:is_plat("windows", "mingw") then
local binarydir = path.join(target:installdir(), "bin")
os.vcp(path.join(binarydir, "bzip2.exe"), path.join(binarydir, "bzcat.exe"))
os.vcp(path.join(binarydir, "bzip2.exe"), path.join(binarydir, "bunzip2.exe"))
else
local binarydir = path.join(target:installdir(), "bin")
os.ln(path.join(binarydir, "bzip2"), path.join(binarydir, "bzcat"))
os.ln(path.join(binarydir, "bzip2"), path.join(binarydir, "bunzip2"))
-- copy shell scripts
os.vcp("bzdiff", binarydir)
os.vcp("bzgrep", binarydir)
os.vcp("bzmore", binarydir)
-- and renamed copies
os.ln(path.join(binarydir, "bzdiff"), path.join(binarydir, "bzcmp"))
os.ln(path.join(binarydir, "bzgrep"), path.join(binarydir, "bzegrep"))
os.ln(path.join(binarydir, "bzgrep"), path.join(binarydir, "bzfgrep"))
os.ln(path.join(binarydir, "bzmore"), path.join(binarydir, "bzless"))
end
end)
target("bzip2recover")
set_kind("binary")
add_deps("bz2")
add_files("bzip2recover.c")
end

View File

@@ -0,0 +1,36 @@
package("bzip2")
set_homepage("https://sourceware.org/bzip2/")
set_description("Freely available, patent free, high-quality data compressor.")
add_urls("https://sourceware.org/pub/bzip2/bzip2-$(version).tar.gz")
add_versions("1.0.8", "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269")
if is_plat("mingw") and is_subhost("msys") then
add_extsources("pacman::bzip2")
elseif is_plat("linux") then
add_extsources("pacman::bzip2", "apt::libbz2-dev")
elseif is_plat("macosx") then
add_extsources("brew::bzip2")
end
on_install("linux", "macosx", "windows", "android", "iphoneos", "cross", "bsd", "mingw", "wasm", function (package)
local configs = {}
if not package:is_plat("cross", "iphoneos", "android", "wasm") then
configs.enable_tools = true
package:addenv("PATH", "bin")
end
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
if not package:is_plat("cross", "iphoneos", "android", "wasm") then
os.vrun("bunzip2 --help")
os.vrun("bzcat --help")
os.vrun("bzip2 --help")
end
assert(package:has_cfuncs("BZ2_bzCompressInit", {includes = "bzlib.h"}))
end)