libs-imp-lz4.lmt /size: 1603 b    last modification: 2021-10-28 13:51
1if not modules then modules = { } end modules ['libs-imp-lz4'] = {
2    version   = 1.001,
3    comment   = "companion to luat-lib.mkxl",
4    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5    copyright = "PRAGMA ADE / ConTeXt Development Team",
6    license   = "see context related readme files"
7}
8
9-- https://packages.msys2.org/package/mingw-w64-x86_64-lz4?repo=mingw64
10
11-- Instead of linking in libs like this we now do them optional. After all, once
12-- we start adding more and more stuff statically we en dup with a mess.
13
14local libname = "lz4"
15local libfile = "liblz4"
16
17local lz4lib = resolvers.libraries.validoptional(libname)
18
19if not lz4lib then return end
20
21local lz4_compress        = lz4lib.compress
22----- lz4_decompress      = lz4lib.decompress
23local lz4_decompresssize  = lz4lib.decompresssize
24local lz4_framecompress   = lz4lib.framecompress
25local lz4_framedecompress = lz4lib.framedecompress
26
27local function okay()
28    if resolvers.libraries.optionalloaded(libname,libfile) then
29        okay = function() return true end
30    else
31        okay = function() return false end
32    end
33    return okay()
34end
35
36local lz4 = {
37    compress        = function (...) return okay() and lz4_compress       (...) end,
38 -- decompress      = function (...) return okay() and lz4_decompress     (...) end,
39    decompresssize  = function (...) return okay() and lz4_decompresssize (...) end,
40    framecompress   = function (...) return okay() and lz4_framecompress  (...) end,
41    framedecompress = function (...) return okay() and lz4_framedecompress(...) end,
42}
43
44package.loaded[libname] = lz4
45
46return lz4
47